Package org.milyn.container

Examples of org.milyn.container.ExecutionContext


        test_config_file(testName, smooks);
    }

    private void test_config_file(String testName, Smooks smooks) throws IOException {
        ExecutionContext context = smooks.createExecutionContext();
        String result = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("/test/" + testName + "/input-message.jsn"), smooks);

        if(logger.isDebugEnabled()) {
          logger.debug("Result: " + result);
        }
View Full Code Here


*/
public class FilterSettingsTest extends TestCase {

  public void test_01() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("filterSettings-01.xml"));   
    ExecutionContext execContext = smooks.createExecutionContext();
   
    assertEquals("DOM", ParameterAccessor.getStringParameter(Filter.STREAM_FILTER_TYPE, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.CLOSE_RESULT, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.CLOSE_SOURCE, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.DEFAULT_SERIALIZATION_ON, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.READER_POOL_SIZE, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.ENTITIES_REWRITE, execContext.getDeliveryConfig()));
    assertEquals(null, ParameterAccessor.getStringParameter(Filter.TERMINATE_ON_VISITOR_EXCEPTION, execContext.getDeliveryConfig()));
  }
View Full Code Here

    assertEquals(null, ParameterAccessor.getStringParameter(Filter.TERMINATE_ON_VISITOR_EXCEPTION, execContext.getDeliveryConfig()));
  }

  public void test_02() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("filterSettings-02.xml"));   
    ExecutionContext execContext = smooks.createExecutionContext();
   
    assertEquals("SAX", ParameterAccessor.getStringParameter(Filter.STREAM_FILTER_TYPE, execContext.getDeliveryConfig()));
    assertEquals("true", ParameterAccessor.getStringParameter(Filter.CLOSE_RESULT, execContext.getDeliveryConfig()));
    assertEquals("true", ParameterAccessor.getStringParameter(Filter.CLOSE_SOURCE, execContext.getDeliveryConfig()));
    assertEquals("true", ParameterAccessor.getStringParameter(Filter.DEFAULT_SERIALIZATION_ON, execContext.getDeliveryConfig()));
    assertEquals("3", ParameterAccessor.getStringParameter(Filter.READER_POOL_SIZE, execContext.getDeliveryConfig()));
    assertEquals("true", ParameterAccessor.getStringParameter(Filter.ENTITIES_REWRITE, execContext.getDeliveryConfig()));
    assertEquals("true", ParameterAccessor.getStringParameter(Filter.TERMINATE_ON_VISITOR_EXCEPTION, execContext.getDeliveryConfig()));
  }
View Full Code Here

        config = new SmooksResourceConfiguration("org.xml.sax.driver", "type:Order-List AND from:Acme", JSONReader.class.getName());
    SmooksUtil.registerResource(config, smooks);
    SmooksUtil.registerProfileSet(DefaultProfileSet.create("Order-List-Acme-AcmePartner1", new String[] {"type:Order-List", "from:Acme", "to:AcmePartner1"}), smooks);

    ExecutionContext context = smooks.createExecutionContext("Order-List-Acme-AcmePartner1");
    String result = SmooksUtil.filterAndSerialize(context,  getClass().getResourceAsStream("/test/"+ testNumber +"/input-message.jsn"), smooks);

        if(logger.isDebugEnabled()) {
          logger.debug("Result: " + result);
        }
View Full Code Here

  }

    private void test_config_file(String testNumber) throws Exception {
        Smooks smooks = new Smooks("/test/" + testNumber + "/smooks-config.xml");

        ExecutionContext context = smooks.createExecutionContext();
        String result = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("/test/" + testNumber + "/input-message.jsn"), smooks);

        if(logger.isDebugEnabled()) {
          logger.debug("Result: " + result);
        }
View Full Code Here

 
    public void testProcess() {
        Smooks smooks = null;
        try {
            smooks = new PreconfiguredSmooks();
            ExecutionContext context = smooks.createExecutionContext("msie6");
            String response = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("html_2.html"), smooks);
            log.debug(response);
            Document doc = DomUtil.parse(response);

            assertNull(XmlUtil.getNode(doc, "html/body/xxx"));
View Full Code Here

        resourceConfig.setParameter("new-name", "zzz");
        SmooksUtil.registerResource(resourceConfig, smooks);

        // Transform the same message for each useragent...
        String message = "<aaa><bbb>888</bbb><ccc>999</ccc></aaa>";
        ExecutionContext context = smooks.createExecutionContext("message-target1");
        String result = SmooksUtil.filterAndSerialize(context, new ByteArrayInputStream(message.getBytes()), smooks);
        log.debug(result);
        assertEquals("Unexpected transformation result", "<zzz><bbb>888</bbb><xxx>999</xxx></zzz>", result);
        context = smooks.createExecutionContext("message-target2");
        result = SmooksUtil.filterAndSerialize(context, new ByteArrayInputStream(message.getBytes()), smooks);
View Full Code Here

        SmooksUtil.registerResource(resourceConfig, smooks);

        // Transform the same message for each useragent...
        String message = "<aaa><bbb>888</bbb><ccc>999</ccc></aaa>";

        ExecutionContext context = smooks.createExecutionContext("message-target1");
        CharArrayWriter writer = new CharArrayWriter();
        smooks.filterSource(context, new StreamSource(new ByteArrayInputStream(message.getBytes())), new StreamResult(writer));

        assertEquals("Unexpected transformation result", "<zzz><bbb>888</bbb><xxx>999</xxx></zzz>", writer.toString());
    }
View Full Code Here

  private static final String NL = System.getProperty("line.separator");

  public void test() {

    ExecutionContext context = new MockExecutionContext();

    JavaResult dummyResult = new JavaResult(true);

    FilterResult.setResults(context, dummyResult);

    context.getBeanContext().addBean("string", "blaat", null);
    context.getBeanContext().addBean("emptyMap", Collections.emptyMap(), null);
    context.getBeanContext().addBean("emptyList", Collections.emptyList(), null);
    context.getBeanContext().addBean("emptyArray", new String[0], null);

    Map<String, String> stringMap = new HashMap<String, String>();
    stringMap.put("v1", "some text");
    stringMap.put("v2", "other text");
    stringMap.put("v3", null);

    context.getBeanContext().addBean("stringMap", stringMap, null);

    List<Integer> integerList = new ArrayList<Integer>();
    integerList.add(1);
    integerList.add(2);
    integerList.add(null);

    context.getBeanContext().addBean("integerList", integerList, null);

    context.getBeanContext().addBean("stringArray", new String[] {"a1", "a2", "a3", null}, null);

    Map<String, Object> objectMap = new LinkedHashMap<String, Object>();
    objectMap.put("self", objectMap);

    Map<String, Object> object2Map = new LinkedHashMap<String, Object>();
    object2Map.put("parent", objectMap);

    objectMap.put("map", object2Map);

    List<Object> list = new ArrayList<Object>();

    list.add(list);
    list.add(objectMap);

    object2Map.put("list", list);

    context.getBeanContext().addBean("objectMap", objectMap, null);

    context.getAttributes().put("multiline", "hello\nworld");

    String actual = MultiLineToStringBuilder.toString(context);

    System.out.println(actual);
View Full Code Here

        Smooks smooks = new Smooks(getClass().getResourceAsStream("config-05.xml"));
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);

        ExecutionContext execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("injectedVal", "something");

        smooks.filterSource(execContext, new StringSource("<a/>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a xxx=\"something\" />"), new StringReader(result.getResult()));
View Full Code Here

TOP

Related Classes of org.milyn.container.ExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.