Search in sources :

Example 1 with DirtiesContext

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

the class ExecOutFileTest method testOutFileConvertToString.

@Test
@DirtiesContext
public void testOutFileConvertToString() throws Exception {
    Exchange e = sendWithMockedExecutor();
    assertEquals(FILE_CONTENT, e.getIn().getBody(String.class));
}
Also used : Exchange(org.apache.camel.Exchange) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 2 with DirtiesContext

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

the class ExecOutFileTest method testOutFileConvertToByteArray.

@Test
@DirtiesContext
public void testOutFileConvertToByteArray() throws Exception {
    Exchange e = sendWithMockedExecutor();
    byte[] body = e.getIn().getBody(byte[].class);
    assertEquals(FILE_CONTENT, new String(body));
}
Also used : Exchange(org.apache.camel.Exchange) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 3 with DirtiesContext

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

the class ExecProducerTest method testOverrideArgs.

/**
     * Tests that the args are set literally.
     */
@Test
@DirtiesContext
public void testOverrideArgs() {
    final String[] args = { "-version", "classpath:c:/program files/test/" };
    producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("noinput");
            exchange.getIn().setHeader(EXEC_COMMAND_ARGS, Arrays.asList(args));
        }
    });
    List<String> commandArgs = execCommandExecutorMock.lastCommandResult.getCommand().getArgs();
    assertEquals(args[0], commandArgs.get(0));
    assertEquals(args[1], commandArgs.get(1));
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) IOException(java.io.IOException) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 4 with DirtiesContext

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

the class ExecProducerTest method testInputLines.

@Test
@DirtiesContext
public void testInputLines() throws IOException {
    // String must be convertible to InputStream
    final String input = "line1" + LINE_SEPARATOR + "line2";
    producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody(input);
        }
    });
    assertEquals(input, IOUtils.toString(execCommandExecutorMock.lastCommandResult.getCommand().getInput()));
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) IOException(java.io.IOException) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 5 with DirtiesContext

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

the class ExecProducerTest method testNullInBody.

@Test
@DirtiesContext
public void testNullInBody() throws IOException {
    // Null body must also be supported
    Exchange e = producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody(null);
        }
    });
    ExecResult result = e.getIn().getBody(ExecResult.class);
    assertNotNull(result);
    assertNull(result.getCommand().getInput());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) IOException(java.io.IOException) 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