Search in sources :

Example 11 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project camel by apache.

the class BindyComplexOneToManyKeyValuePairUnMarshallTest method testUnMarshallMessage.

@Test
@DirtiesContext
public void testUnMarshallMessage() throws Exception {
    String message = "8=FIX 4.19=2034=135=049=INVMGR56=BRKR" + "1=BE.CHM.00111=CHM0001-0158=this is a camel - bindy test" + "22=448=BE000124567854=1" + "22=548=BE000987654354=2" + "22=648=BE000999999954=3" + "10=220";
    String message2 = "8=FIX 4.19=2034=135=049=INVMGR56=BRKR" + "1=BE.CHM.00111=CHM0001-0158=this is a camel - bindy test10=220";
    result.expectedMessageCount(2);
    template.sendBody(message);
    template.sendBody(message2);
    result.assertIsSatisfied();
    Order order1 = result.getReceivedExchanges().get(0).getIn().getBody(Order.class);
    Order order2 = result.getReceivedExchanges().get(1).getIn().getBody(Order.class);
    Assert.assertTrue(order1.toString().contains("BE.CHM.001, 11: CHM0001-01, 58: this is a camel - bindy test"));
    Assert.assertTrue(order1.getSecurities().get(0).toString().contains("22: 4, 48: BE0001245678, 54: 1"));
    Assert.assertTrue(order1.getSecurities().get(1).toString().contains("22: 5, 48: BE0009876543, 54: 2"));
    Assert.assertTrue(order1.getSecurities().get(2).toString().contains("22: 6, 48: BE0009999999, 54: 3"));
    Assert.assertTrue(order2.getHeader().toString().contains("FIX 4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR"));
    Assert.assertTrue(order2.getTrailer().toString().contains("10: 220"));
}
Also used : Order(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order) Test(org.junit.Test) CommonBindyTest(org.apache.camel.dataformat.bindy.CommonBindyTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 12 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project camel by apache.

the class BindySimpleKeyValuePairTabUnmarshallTest method testUnMarshallMessage.

@Test
@DirtiesContext
public void testUnMarshallMessage() throws Exception {
    result.expectedMessageCount(1);
    result.assertIsSatisfied();
    Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class);
    Assert.assertTrue(order.getHeader().toString().contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR"));
    Assert.assertTrue(order.toString().contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test"));
    Assert.assertTrue(order.getTrailer().toString().contains("10: 220"));
}
Also used : Order(org.apache.camel.dataformat.bindy.model.fix.tab.Order) Test(org.junit.Test) CommonBindyTest(org.apache.camel.dataformat.bindy.CommonBindyTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 13 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project camel by apache.

the class BindySimpleCsvIntegerMarshallTest method testMarshallMessage.

@Test
@DirtiesContext
public void testMarshallMessage() throws Exception {
    MyOrder order = new MyOrder();
    order.setInstrument("XX23456789");
    order.setQuantity(12345678);
    order.setPrice(new BigDecimal("400.25"));
    result.expectedBodiesReceived("XX23456789,12345678,400.25\r\n");
    template.sendBody(order);
    result.assertIsSatisfied();
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 14 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project camel by apache.

the class BindyImpliedTest method testMarshall.

// *************************************************************************
// TEST
// *************************************************************************
@Test
@DirtiesContext
public void testMarshall() throws Exception {
    Record rec = new Record();
    rec.setField1(123.45);
    rec.setField2(67.89);
    rec.setField3(11.24F);
    rec.setField4(33.45F);
    rec.setField5(new BigDecimal(60.52));
    rec.setField6(new BigDecimal(70.62));
    mresult.expectedBodiesReceived("1234567.89 112433.45 605270.62\r\n");
    mtemplate.sendBody(rec);
    mresult.assertIsSatisfied();
}
Also used : FixedLengthRecord(org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 15 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project camel by apache.

the class BindyImpliedTest method testUnMarshall.

@Test
@DirtiesContext
public void testUnMarshall() throws Exception {
    utemplate.sendBody("1234567.89 112433.45 605270.62");
    uresult.expectedMessageCount(1);
    uresult.assertIsSatisfied();
    // check the model
    Exchange exc = uresult.getReceivedExchanges().get(0);
    Record data = exc.getIn().getBody(Record.class);
    Assert.assertEquals(123.45D, data.getField1(), 0D);
    Assert.assertEquals(67.89D, data.getField2(), 0D);
    Assert.assertEquals(11.24F, data.getField3(), 0.001);
    Assert.assertEquals(33.45F, data.getField4(), 0.001);
    Assert.assertEquals(60.52D, data.getField5().doubleValue(), 0.001);
    Assert.assertEquals(70.62D, data.getField6().doubleValue(), 0.001);
}
Also used : Exchange(org.apache.camel.Exchange) FixedLengthRecord(org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DirtiesContext (org.springframework.test.annotation.DirtiesContext)78 Test (org.junit.Test)76 Exchange (org.apache.camel.Exchange)20 Event (org.opennms.netmgt.xml.event.Event)19 Processor (org.apache.camel.Processor)11 DroolsCorrelationEngine (org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine)10 IOException (java.io.IOException)9 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)9 Ignore (org.junit.Ignore)7 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3 MyProvider (org.opennms.core.soa.support.MyProvider)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2