use of org.springframework.test.annotation.DirtiesContext in project atlasmap by atlasmap.
the class AtlasMapComponentJsonTest method testMocksAreValid.
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String) body);
assertEquals("Bob", outJson.get("FirstName").asText());
assertEquals("Vila", outJson.get("LastName").asText());
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
use of org.springframework.test.annotation.DirtiesContext in project atlasmap by atlasmap.
the class AtlasMapComponentTest method testMocksAreValid.
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String) body);
assertEquals("Bob", outJson.get("FirstName").asText());
assertEquals("Vila", outJson.get("LastName").asText());
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class ExecScriptTest method testExecuteScript.
/**
* TODO <b>the test is ignored for now to prevent accidental build
* failures.</b> Java 1.5 does not offer a method to check if a file is
* executable there is only a canRead method, which is not enough to
* guarantee that the script can be executed. <br>
*
* @throws Exception
*/
@Test
@DirtiesContext
@Ignore
public void testExecuteScript() throws Exception {
File scriptFile = getExecScriptFileOrNull("exec-test-script");
if (scriptFile != null) {
String classpathArg = getClasspathArg();
Exchange exchange = executeScript(scriptFile, NO_TIMEOUT, classpathArg, PRINT_IN_STDOUT);
if (exchange != null) {
String out = exchange.getIn().getBody(String.class);
String err = (String) exchange.getIn().getHeader(EXEC_STDERR);
assertNotNull(out);
assertTrue(out.contains(PRINT_IN_STDOUT));
assertNull(err);
}
} else {
String os = System.getProperty("os.name");
logger.warn("Executing batch scripts is not tested on " + os);
}
}
use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class ExecOutFileTest method testOutFileConvertToInputStream.
@Test
@DirtiesContext
public void testOutFileConvertToInputStream() throws Exception {
Exchange e = sendWithMockedExecutor();
InputStream body = e.getIn().getBody(InputStream.class);
assertNotNull(body);
assertEquals(FILE_CONTENT, IOUtils.toString(body));
}
use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class ExecOutFileTest method testOutFileConvertToDocument.
@Test
@DirtiesContext
public void testOutFileConvertToDocument() throws Exception {
Exchange e = sendWithMockedExecutor();
Document body = e.getIn().getBody(Document.class);
// do not parse it
assertNotNull(body);
}
Aggregations