Search in sources :

Example 51 with DirtiesContext

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

the class ExecOutFileTest method testOutFile.

@Test
@DirtiesContext
public void testOutFile() throws Exception {
    Exchange e = sendWithMockedExecutor();
    ExecResult result = e.getIn().getBody(ExecResult.class);
    assertNotNull(result);
    File outFile = result.getCommand().getOutFile();
    assertNotNull(outFile);
    assertEquals(FILE_CONTENT, FileUtils.readFileToString(outFile));
}
Also used : Exchange(org.apache.camel.Exchange) File(java.io.File) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 52 with DirtiesContext

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

the class ExecProducerTest method testOverrideExecutable.

@Test
@DirtiesContext
public void testOverrideExecutable() {
    final String command = "java";
    producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("noinput");
            exchange.getIn().setHeader(EXEC_COMMAND_EXECUTABLE, command);
        }
    });
    assertEquals(command, execCommandExecutorMock.lastCommandResult.getCommand().getExecutable());
}
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 53 with DirtiesContext

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

the class ExecProducerTest method testOutCapableExchange.

@Test
@DirtiesContext
public void testOutCapableExchange() throws Exception {
    Exchange exchange = producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.setPattern(ExchangePattern.InOut);
            exchange.getIn().setBody("inout");
        }
    });
    // test the conversion
    ExecResult result = exchange.getOut().getBody(ExecResult.class);
    assertNotNull(result);
}
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 54 with DirtiesContext

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

the class ExecProducerTest method testOverrideTimeout.

@Test
@DirtiesContext
public void testOverrideTimeout() {
    producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("noinput");
            exchange.getIn().setHeader(EXEC_COMMAND_TIMEOUT, "1000");
        }
    });
    assertEquals(1000, execCommandExecutorMock.lastCommandResult.getCommand().getTimeout());
}
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 55 with DirtiesContext

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

the class ExecProducerTest method testInInOnlyExchange.

@Test
@DirtiesContext
public void testInInOnlyExchange() throws Exception {
    Exchange exchange = producerTemplate.send(new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.setPattern(ExchangePattern.InOnly);
            exchange.getIn().setBody("inonly");
        }
    });
    // test the conversion
    ExecResult result = exchange.getIn().getBody(ExecResult.class);
    assertNotNull(result);
}
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)86 Test (org.junit.Test)83 Exchange (org.apache.camel.Exchange)21 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 ProducerTemplate (org.apache.camel.ProducerTemplate)7 Ignore (org.junit.Ignore)7 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 Message (org.apache.camel.Message)4 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3