Examples of JavaResult


Examples of org.milyn.payload.JavaResult

  public void test_factory() throws Exception {
    String packagePath = ClassUtil.toFilePath(getClass().getPackage());
        Smooks smooks = new Smooks(packagePath + "/factory-01-config.xml");
        ExecutionContext executionContext = smooks.createExecutionContext();
        JavaResult result = new JavaResult(true);

        smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("factory-01.xml")), result);

        assertNotNull(result.getBean("arrayList"));
        assertNotNull(result.getBean("arrayList") instanceof ArrayList<?>);

        assertNotNull(result.getBean("linkedList"));
        assertNotNull(result.getBean("linkedList") instanceof LinkedList<?>);
  }
View Full Code Here

Examples of org.milyn.payload.JavaResult

      test_children_only(FilterSettings.DEFAULT_DOM);
    }
    private void test_children_only(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01-ext.xml"));
        StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);
        smooks.filterSource(source, result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("children-only.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

      test_all(FilterSettings.DEFAULT_DOM);
    }
    private void test_all(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-02-ext.xml"));
        StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);
        smooks.filterSource(source, result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    }

    public List bind(Reader fixedLengthStream) {
        AssertArgument.isNotNull(fixedLengthStream, "fixedLengthStream");

        JavaResult javaResult = new JavaResult();

        smooks.filterSource(new StreamSource(fixedLengthStream), javaResult);

        return (List) javaResult.getBean(beanId);
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

      test_children_only(FilterSettings.DEFAULT_DOM);
    }
    private void test_children_only(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
        StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);
        smooks.filterSource(source, result);

        XMLUnit.setIgnoreWhitespace( true );
        InputStream stream = getClass().getResourceAsStream("children-only.xml");
        Object bean = result.getBean("soapBody");
        XMLAssert.assertXMLEqual(new InputStreamReader(stream), new StringReader(bean.toString().trim()));
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

      test_all(FilterSettings.DEFAULT_DOM);
    }
    private void test_all(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-02.xml"));
        StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);
        smooks.filterSource(source, result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    }

    public Map bind(Reader fixedLengthStream) {
        AssertArgument.isNotNull(fixedLengthStream, "fixedLengthStream");

        JavaResult javaResult = new JavaResult();

        smooks.filterSource(new StreamSource(fixedLengthStream), javaResult);

        return (Map) javaResult.getBean(beanId);
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

        AssertArgument.isNotNull(inputSource, "inputSource");
        AssertArgument.isNotNull(toType, "toType");

        assertInitialized();

        JavaResult javaResult = new JavaResult();
        ExecutionContext executionContext = smooks.createExecutionContext();

        if (reportPath != null) {
            executionContext.setEventListener(new HtmlReportGenerator(reportPath));
        }

        smooks.filterSource(executionContext, inputSource, javaResult);

        return javaResult.getBean(toType);
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    public <T> Model<T> readModel(Reader message, Class<T> modelRoot) throws SAXException, IOException {
        AssertArgument.isNotNull(message, "message");
        AssertArgument.isNotNull(modelRoot, "modelRoot");

    JavaResult result = new JavaResult();
    ExecutionContext executionContext = descriptor.getSmooks().createExecutionContext();
        Map<Class<?>, Map<String, BeanWriter>> beanWriters = descriptor.getBeanWriters();
    BeanTracker beanTracker = new BeanTracker(beanWriters);

        if(reportPath != null) {
            executionContext.setEventListener(new HtmlReportGenerator(reportPath));           
        }

    executionContext.getBeanContext().addObserver(beanTracker);
   
    if(validate && descriptor.getSchema() != null) {
      // Validate the message against the schemas...
      Document messageDoc = toDocument(message);

          // Validate the document and then filter it through smooks...
          descriptor.getSchema().newValidator().validate(new DOMSource(messageDoc));
      descriptor.getSmooks().filterSource(executionContext, new DOMSource(messageDoc), result);
    } else {
      descriptor.getSmooks().filterSource(executionContext, new StreamSource(message), result);
    }

        Model<T> model;

        if(modelRoot == JavaResult.class) {
            model = new Model<T>(modelRoot.cast(result), beanTracker.beans, beanWriters, NamespaceReaper.getNamespacePrefixMappings(executionContext));
        } else {
            model = new Model<T>(modelRoot.cast(result.getBean(modelRoot)), beanTracker.beans, beanWriters, NamespaceReaper.getNamespacePrefixMappings(executionContext));
        }

        return model;
  }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    smooks.setFilterSettings(filterSettings);
    test(smooks);
  }

  private void test(Smooks smooks) {
    JavaResult result = new JavaResult();
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("message.xml")), result);
   
    Map theBean = (Map) result.getBean("theBean");
    assertEquals("xxx", theBean.get("attr1"));
    assertEquals(null, theBean.get("attr2"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.