Package org.milyn.payload

Examples of org.milyn.payload.JavaResult


    Smooks smooks = new Smooks();

    smooks.addVisitor(new Value("customerNumber1", "customer/@number", Integer.class));
    smooks.addVisitor(new Value("customerNumber2", "customer/@number").setType(Integer.class));

    JavaResult result = new JavaResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("../order-01.xml")), result);

    assertEquals(123123, result.getBean("customerNumber1"));
    assertEquals(123123, result.getBean("customerNumber2"));
  }
View Full Code Here


        if(REPORT_EXECUTION) {
          executionContext.setEventListener(new HtmlReportGenerator("target/report/" + dataFile + "-" + configFile + "/index.html"));
        }
       
      String resource = StreamUtils.readStream(new InputStreamReader(getClass().getResourceAsStream(dataFile)));
      JavaResult result = new JavaResult();

        smooks.filterSource(executionContext, new StreamSource(new StringReader(resource)), result);

        @SuppressWarnings("unchecked")
        ArrayList<A> as = (ArrayList<A>) result.getBean("root");

        assertNotNull(as);
        assertEquals(2, as.size());

    A a1 = as.get(0);
View Full Code Here

    String packagePath = ClassUtil.toFilePath(PerformanceMeasurement.class.getPackage());
    Smooks smooks = new Smooks(packagePath + configFile);

    ExecutionContext executionContext = smooks.createExecutionContext();

    JavaResult result = new JavaResult();

    File warmupFile = new File(warmupFilename);
    File inFile  = new File(inFilename);
    Long endTime = System.currentTimeMillis();
View Full Code Here

        if(REPORT_EXECUTION) {
          executionContext.setEventListener(new HtmlReportGenerator("target/report/" + dataFile + "-" + configFile + "/index.html"));
        }
       
      String resource = StreamUtils.readStream(new InputStreamReader(getClass().getResourceAsStream(dataFile)));
      JavaResult result = new JavaResult();

        smooks.filterSource(executionContext, new StreamSource(new StringReader(resource)), result);

        @SuppressWarnings("unchecked")
        A[] as = (A[]) result.getBean("root");

        assertNotNull(as);
        assertEquals(2, as.length);

    A a1 = as[0];
View Full Code Here

  private final Log logger = LogFactory.getLog(ExpressionBindingTest.class);

    public void test() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("01_binding.xml"));

        JavaResult result = new JavaResult();

        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("01_message.xml")), result);

        Message message1 = (Message) result.getBean("message1");
        assertEquals(946143900000L, message1.getDate().getTime());
        assertEquals(977766300000L, message1.getDatePlus1Year().getTime());

        assertDateValue(result, "message2");
        assertDateValue(result, "message3");
        assertDateValue(result, "message4");

        Map<?, ?> message2 = (Map<?, ?>) result.getBean("message2");
        Date messageDate = (Date) message2.get("datePlus1Year");
        logger.debug("Date plus 1 year: " + messageDate);
        assertEquals(977766300000L, messageDate.getTime());

        assertTrue(message2 == message1.getMessage2());

        Map<?, ?> message5 = (Map<?, ?>) result.getBean("message5");

        assertEquals(10, message5.get("number"));
        assertEquals(15, message5.get("numberAddition"));
    }
View Full Code Here

    }

    public void test_data_variable() throws Exception {
      Smooks smooks = new Smooks(getClass().getResourceAsStream("02_binding.xml"));

      JavaResult result = new JavaResult();

      ExecutionContext context = smooks.createExecutionContext();
      //context.setEventListener(new HtmlReportGenerator("target/expression_data_variable.html"));

      smooks.filterSource(context, new StreamSource(getClass().getResourceAsStream("02_number.xml")), result);

      Total total = (Total) result.getBean("total");

      assertEquals(20, (int) total.getTotal());
      assertEquals("10,20,30,40", total.getCsv());

    }
View Full Code Here

*/
public class MILYN_356_Test extends TestCase {

  public void test_decoder_defined() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config_01.xml"));
    JavaResult javaResult = new JavaResult();
   
    smooks.filterSource(new StringSource("<price>123'456,00</price>"), javaResult);
   
    OrderItem orderItem = (OrderItem) javaResult.getBean("orderItem");   
    assertEquals(123456.00D, orderItem.getPrice());

    BigDecimal baseBigD = (BigDecimal) javaResult.getBean("price");
    assertEquals(new BigDecimal("123456.00"), baseBigD);
  }
View Full Code Here

    assertEquals(new BigDecimal("123456.00"), baseBigD);
  }

  public void test_decoder_undefined() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config_02.xml"));
    JavaResult javaResult = new JavaResult();
   
    smooks.filterSource(new StringSource("<price>123'456,00</price>"), javaResult);
   
    OrderItem orderItem = (OrderItem) javaResult.getBean("orderItem");   
    assertEquals(123456.00D, orderItem.getPrice());
  }
View Full Code Here

*/
public class MILYN_444_Test extends TestCase {

  public void test() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));
    JavaResult jResult = new JavaResult();

    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("message.xml")), jResult);

        X x = jResult.getBean(X.class);
        assertEquals("456", x.getVal1()); // default will be overridden by value in the message
        assertEquals(987, x.getVal2()); // default will be applied
        assertEquals(99.65d, x.getVal3()); // default will be applied
  }
View Full Code Here

        smooks.setFilterSettings(FilterSettings.DEFAULT_SAX);
       
        try {
            StringResult xmlResult = new StringResult();
            JavaResult javaResult = new JavaResult();
           
            smooks.filterSource(new StreamSource(MILYN_364_Test.class.getResourceAsStream("order.xml")), xmlResult, javaResult);
           
            Header bean = (Header) javaResult.getBean("header");
           
            // Truncate to avoid rounding differences etc...
      assertEquals(81, (int)bean.getNetAmount());
      assertEquals(18, bean.getNetAmountObj().intValue());
      assertEquals(16, (int)bean.getTax());
View Full Code Here

TOP

Related Classes of org.milyn.payload.JavaResult

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.