@Test public void sendLongSubmitSM() throws Exception { result.expectedMessageCount(2); Exchange exchange = start.createExchange(ExchangePattern.InOnly); exchange .getIn() .setBody( "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! " + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! " + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "); // 270 chars template.send(start, exchange); assertMockEndpointsSatisfied(); assertEquals( SmppMessageType.DeliveryReceipt.toString(), result.getExchanges().get(0).getIn().getHeader(SmppConstants.MESSAGE_TYPE)); assertEquals( SmppMessageType.DeliveryReceipt.toString(), result.getExchanges().get(1).getIn().getHeader(SmppConstants.MESSAGE_TYPE)); assertNotNull(exchange.getIn().getHeader(SmppConstants.ID)); assertEquals(2, exchange.getIn().getHeader(SmppConstants.SENT_MESSAGE_COUNT)); }
/** * Test multi dir. * * @throws Exception the exception */ @Test public void testMultiDir() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Bye World", "Hello World", "Goodday World"); assertMockEndpointsSatisfied(); Exchange exchange = mock.getExchanges().get(0); RemoteFile<?> file = (RemoteFile<?>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); assertNotNull(file); assertDirectoryEquals("webdav/multidir/bye.txt", file.getAbsoluteFilePath()); assertDirectoryEquals("bye.txt", file.getRelativeFilePath()); assertEquals("bye.txt", file.getFileName()); exchange = mock.getExchanges().get(1); file = (RemoteFile<?>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); assertNotNull(file); assertDirectoryEquals("webdav/multidir/sub/hello.txt", file.getAbsoluteFilePath()); assertDirectoryEquals("sub/hello.txt", file.getRelativeFilePath()); assertEquals("sub/hello.txt", file.getFileName()); assertEquals("hello.txt", file.getFileNameOnly()); exchange = mock.getExchanges().get(2); file = (RemoteFile<?>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); assertNotNull(file); assertDirectoryEquals("webdav/multidir/sub/sub2/godday.txt", file.getAbsoluteFilePath()); assertDirectoryEquals("sub/sub2/godday.txt", file.getRelativeFilePath()); assertEquals("sub/sub2/godday.txt", file.getFileName()); assertEquals("godday.txt", file.getFileNameOnly()); }
@Test /** Operation: DELETE Body contains: 12345678900987654321abcdeffedcba */ public void testDeleteWithIngestException() throws Exception { resetMocks(); // Setup expectations to verify final MockEndpoint mockVerifierEndpoint = getMockEndpoint("mock:result"); mockVerifierEndpoint.expectedMessageCount(1); final List<Metacard> metacards = new ArrayList<Metacard>(); metacards.add(metacard1); // setup mock catalog framework final String[] metacardIds = new String[metacards.size()]; for (int i = 0; i < metacards.size(); i++) { metacardIds[i] = metacards.get(i).getId(); } DeleteRequest deleteRequest = new DeleteRequestImpl(metacardIds); DeleteResponse deleteResponse = new DeleteResponseImpl(deleteRequest, new HashMap(), metacards); when(catalogFramework.delete(any(DeleteRequest.class))).thenThrow(new IngestException()); // Exercise the route with a DELETE operation template.sendBodyAndHeader("direct:sampleInput", metacardIds, "Operation", "DELETE"); // Verify that the number of metacards in the exchange after the records // is identical to the input assertListSize(mockVerifierEndpoint.getExchanges(), 1); final Exchange exchange = mockVerifierEndpoint.getExchanges().get(0); final List<Update> cardsDeleted = (List<Update>) exchange.getIn().getBody(); assertListSize(cardsDeleted, 0); mockVerifierEndpoint.assertIsSatisfied(); }
@Test /** Operation: CREATE Body contains: Metacard */ public void testCreateWithIngestException() throws Exception { resetMocks(); // Setup expectations to verify final MockEndpoint mockVerifierEndpoint = getMockEndpoint("mock:result"); mockVerifierEndpoint.expectedMessageCount(1); final List<Metacard> metacards = new ArrayList<Metacard>(); metacards.add(metacard1); // Mock catalog framework final CreateRequest createRequest = new CreateRequestImpl(metacards); final CreateResponse createResponse = new CreateResponseImpl(createRequest, new HashMap(), metacards); when(catalogFramework.create(any(CreateRequest.class))).thenThrow(new IngestException()); // Exercise the route with a CREATE operation template.sendBodyAndHeader("direct:sampleInput", metacard1, "Operation", "CREATE"); // Verify that the number of metacards in the exchange after the records // is identical to the input assertListSize(mockVerifierEndpoint.getExchanges(), 1); final Exchange exchange = mockVerifierEndpoint.getExchanges().get(0); final List<Metacard> cardsCreated = (List<Metacard>) exchange.getIn().getBody(); assertListSize(cardsCreated, 0); mockVerifierEndpoint.assertIsSatisfied(); }
public void testDuplicateMessagesAreFilteredOut() throws Exception { assertEquals(0, repo.getExchange().size()); context.addRoutes( new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").idempotentConsumer(header("messageId"), repo).to("mock:result"); } }); context.start(); resultEndpoint.expectedBodiesReceived("one", "two", "three"); sendMessage("1", "one"); sendMessage("2", "two"); sendMessage("1", "one"); sendMessage("2", "two"); sendMessage("1", "one"); sendMessage("3", "three"); assertMockEndpointsSatisfied(); // we used 6 different exchanges assertEquals(6, repo.getExchange().size()); for (Exchange exchange : resultEndpoint.getExchanges()) { // should be in repo list assertTrue( "Should contain the exchange", repo.getExchange().contains(exchange.getExchangeId())); } }
@Test public void testHeaderAndTrailer() throws Exception { results.expectedMessageCount(1); results.message(0).body().isInstanceOf(List.class); results.message(0).header("camelFlatpackCounter").isEqualTo(6); results.assertIsSatisfied(); List<Map<String, String>> data = CastUtils.cast(results.getExchanges().get(0).getIn().getBody(List.class)); // assert header Map<String, String> header = data.get(0); assertEquals("HBT", header.get("INDICATOR")); assertEquals("20080817", header.get("DATE")); // assert body int counter = 0; for (Map<String, String> row : data.subList(1, 5)) { assertEquals("FIRSTNAME", expectedFirstName[counter], row.get("FIRSTNAME")); LOG.info("Result: " + counter + " = " + row); counter++; } // assert trailer Map<String, String> trailer = data.get(5); assertEquals("FBT", trailer.get("INDICATOR")); assertEquals("SUCCESS", trailer.get("STATUS")); }
@Test public void testSendMessageToPartner() throws Exception { mockAgreement1.setExpectedMessageCount(1); mockAgreement2.setExpectedMessageCount(1); mockUpdateMessageStore.setExpectedMessageCount(4); mockEbmsResponseInbound.setExpectedMessageCount(1); mockEbmsResponseInbound.expectedBodiesReceived( IOUtils.toString(new FileInputStream(fileFromClasspath("simple-as4-receipt.xml")))); mockEbmsResponseInbound.expectedHeaderReceived( EbmsConstants.CONTENT_TYPE, EbmsConstants.SOAP_XML_CONTENT_TYPE); mockEbmsResponseInbound.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST"); sendMessage( "agreement1", "simple-as4-user-message.txt", "Multipart/Related; boundary=\"----=_Part_7_10584188.1123489648993\"; type=\"application/soap+xml\"; start=\"<*****@*****.**>\"", "*****@*****.**", MessageType.USER_MESSAGE); sendMessage( "agreement2", "simple-as4-receipt.xml", EbmsConstants.SOAP_XML_CONTENT_TYPE, "*****@*****.**", MessageType.SIGNAL_MESSAGE_WITH_USER_MESSAGE); assertMockEndpointsSatisfied(); Exchange e = mockEbmsResponseInbound.getExchanges().get(0); assertThat(e.getIn().getHeaders().values(), hasSize(3)); }
public void testSimpleSplitWriteRead() throws Exception { context.addRoutes( new RouteBuilder() { @Override public void configure() { from("direct:start") .to( "hdfs://localhost:9000/tmp/test/test-camel-simple-write-file?fileSystemType=HDFS&splitStrategy=BYTES:5,IDLE:1000"); from("hdfs://localhost:9000/tmp/test/test-camel-simple-write-file?pattern=seg*&initialDelay=2000&fileSystemType=HDFS&chunkSize=5") .to("mock:result"); } }); context.start(); for (int i = 0; i < 10; ++i) { template.sendBody("direct:start", "CIAO" + i); } MockEndpoint resultEndpoint = (MockEndpoint) context.getEndpoint("mock:result"); resultEndpoint.expectedMessageCount(10); resultEndpoint.assertIsSatisfied(); int i = 0; List<Exchange> exchanges = resultEndpoint.getExchanges(); for (Exchange exchange : exchanges) { Assert.assertEquals("CIAO" + i++, exchange.getIn().getBody(String.class)); } }
@Test public void sendSubmitSMInOnly() throws Exception { result.expectedMessageCount(1); Exchange exchange = start.createExchange(ExchangePattern.InOnly); exchange.getIn().setBody("Hello SMPP World!"); template.send(start, exchange); assertMockEndpointsSatisfied(); Exchange resultExchange = result.getExchanges().get(0); assertEquals( SmppMessageType.DeliveryReceipt.toString(), resultExchange.getIn().getHeader(SmppConstants.MESSAGE_TYPE)); assertEquals("Hello SMPP World!", resultExchange.getIn().getBody()); assertNotNull(resultExchange.getIn().getHeader(SmppConstants.ID)); assertEquals(1, resultExchange.getIn().getHeader(SmppConstants.SUBMITTED)); assertEquals(1, resultExchange.getIn().getHeader(SmppConstants.DELIVERED)); assertNotNull(resultExchange.getIn().getHeader(SmppConstants.DONE_DATE)); assertNotNull(resultExchange.getIn().getHeader(SmppConstants.SUBMIT_DATE)); assertNull(resultExchange.getIn().getHeader(SmppConstants.ERROR)); assertNotNull(exchange.getIn().getHeader(SmppConstants.ID)); assertEquals(1, exchange.getIn().getHeader(SmppConstants.SENT_MESSAGE_COUNT)); }
public void testXPathWithNamespaceDifferentNamespace() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("<number xmlns=\"http://acme.com/cake\">55</number>"); template.sendBody("direct:in", "<number xmlns=\"http://acme.com/cake\">55</number>"); mock.assertIsSatisfied(); Assert.assertNull(mock.getExchanges().get(0).getIn().getHeader("foo")); }
@Test public void testDefault() throws Exception { mock.expectedBodiesReceived("test1"); mock.expectedHeaderReceived("test", "test2"); producerTemplate.sendBodyAndHeader("direct:input", "test1", "test", "test2"); mock.assertIsSatisfied(); Message received = mock.getExchanges().get(0).getIn(); assertEquals("default", received.getHeader(GTaskBinding.GTASK_QUEUE_NAME)); assertEquals(0, received.getHeader(GTaskBinding.GTASK_RETRY_COUNT)); }
@Test public void testNoFeedInHeader() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.assertIsSatisfied(); Exchange exchange = mock.getExchanges().get(0); Message in = exchange.getIn(); assertNotNull(in); assertNull(in.getHeader(RssConstants.RSS_FEED)); }
public void testEcho() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("echo Hello World"); template.sendBody("direct:echo", "Hello World"); assertMockEndpointsSatisfied(); assertNull( "There should no Bean_METHOD_NAME header", mock.getExchanges().get(0).getIn().getHeader(Exchange.BEAN_METHOD_NAME)); }
@Test public void testEndpointWithoutHttps() { mockEndpoint.reset(); try { template.sendBodyAndHeader( "http://localhost:" + port + "/test", expectedBody, "Content-Type", "application/xml"); fail("expect exception on access to https endpoint via http"); } catch (RuntimeCamelException expected) { } assertTrue("mock endpoint was not called", mockEndpoint.getExchanges().isEmpty()); }
@Test public void test() throws Exception { deleteDirectory("target/smooks"); template.sendBody("file://target/smooks", "<blah />"); MockEndpoint mock = getMockEndpoint("mock:a"); mock.expectedMessageCount(1); assertMockEndpointsSatisfied(); assertEquals("<blah />", mock.getExchanges().get(0).getIn().getBody(String.class)); }
@Test public void testOnline() throws InterruptedException { // Wait for 5 seconds while Camel route is exercised resultEndpoint.whenAnyExchangeReceived(null); Thread.sleep(5000); // Ensure online symptoms are reported List<Exchange> exchanges = resultEndpoint.getExchanges(); Assert.assertTrue(!exchanges.isEmpty()); Assert.assertEquals(1, alerts); Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getSucceeded()); Assert.assertEquals(0, builder.getPingProcessor().getFailed()); Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getTotal()); }
public void testSortReverse() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); template.sendBody("direct:reverse", "Hadrian,William,Claus"); assertMockEndpointsSatisfied(); List<?> list = mock.getExchanges().get(0).getIn().getBody(List.class); assertEquals("William", list.get(0)); assertEquals("Hadrian", list.get(1)); assertEquals("Claus", list.get(2)); }
@Test /** Operation: UPDATE Body contains: Metacard */ public void testUpdateWithSingleMetacard() throws Exception { resetMocks(); // Setup expectations to verify final MockEndpoint mockVerifierEndpoint = getMockEndpoint("mock:result"); mockVerifierEndpoint.expectedMessageCount(1); final List<Metacard> metacards = new ArrayList<Metacard>(); metacards.add(metacard1); // setup mock catalog framework final Update update = new UpdateImpl(metacard1, metacard2); List<Update> updates = new ArrayList<Update>(); updates.add(update); final String[] metacardIds = new String[metacards.size()]; for (int i = 0; i < metacards.size(); i++) { metacardIds[i] = metacards.get(i).getId(); } UpdateRequest updateRequest = new UpdateRequestImpl(metacardIds, metacards); UpdateResponse updateResponse = new UpdateResponseImpl(updateRequest, new HashMap(), updates); when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(updateResponse); // Exercise the route with a UPDATE operation template.sendBodyAndHeader("direct:sampleInput", metacard1, "Operation", "UPDATE"); // Verify that the number of metacards in the exchange after the records // is identical to the input assertListSize(mockVerifierEndpoint.getExchanges(), 1); final Exchange exchange = mockVerifierEndpoint.getExchanges().get(0); final List<Update> cardsUpdated = (List<Update>) exchange.getIn().getBody(); assertListSize(cardsUpdated, 1); mockVerifierEndpoint.assertIsSatisfied(); }
private void testAttributes(String mockEndpoint, String prefix) throws Exception { MockEndpoint mock = getMockEndpoint(mockEndpoint); mock.expectedMessageCount(1); mock.message(0).header("CamelFileExtendedAttributes").isNotNull(); mock.message(0).header("CamelFileExtendedAttributes").convertTo(Map.class); assertMockEndpointsSatisfied(); Map<String, Object> attributes = mock.getExchanges().get(0).getIn().getHeader("CamelFileExtendedAttributes", Map.class); assertNotNull(attributes); assertFalse(attributes.isEmpty()); for (Map.Entry<String, Object> entry : attributes.entrySet()) { assertTrue(entry.getKey().startsWith(prefix)); } }
@Test public void shouldLookupBeanByTypeAndInjectFields() throws InterruptedException { resultEndpoint.expectedMessageCount(1); template.sendBody("direct:injectByType", "hello"); assertMockEndpointsSatisfied(); Exchange exchange = resultEndpoint.getExchanges().get(0); List<?> results = exchange.getIn().getBody(List.class); List<Item> expected = itemsExpected(); assertNotNull(results); assertNotNull(expected); assertEquals(expected.size(), results.size()); assertEquals(expected, results); }
@Test public void testUnMarshallingJsonComplete() throws InterruptedException, IOException { out.setExpectedMessageCount(1); String s = readFile(NOTIFICATION_JSON, Charset.defaultCharset()); in.sendBody(s); out.await(5, TimeUnit.SECONDS); out.assertIsSatisfied(); List<Exchange> exchanges = out.getExchanges(); for (Exchange exchange : exchanges) { Message message = exchange.getIn(); Notification notif = message.getBody(Notification.class); validateNotification(notif); } }
/** * You get three keys with the UserId "keyflag", a primary key and its two sub-keys. The sub-key * with KeyFlag {@link KeyFlags#SIGN_DATA} should be used for signing and the sub-key with KeyFlag * {@link KeyFlags#ENCRYPT_COMMS} or {@link KeyFlags#ENCRYPT_COMMS} or {@link * KeyFlags#ENCRYPT_STORAGE} should be used for decryption. * * @throws Exception */ @Test public void testKeyFlagSelectsCorrectKey() throws Exception { MockEndpoint mockKeyFlag = getMockEndpoint("mock:encrypted_keyflag"); mockKeyFlag.setExpectedMessageCount(1); template.sendBody("direct:keyflag", "Test Message"); assertMockEndpointsSatisfied(); List<Exchange> exchanges = mockKeyFlag.getExchanges(); assertEquals(1, exchanges.size()); Exchange exchange = exchanges.get(0); Message inMess = exchange.getIn(); assertNotNull(inMess); // must contain exactly one encryption key and one signature assertEquals(1, inMess.getHeader(PGPDataFormat.NUMBER_OF_ENCRYPTION_KEYS)); assertEquals(1, inMess.getHeader(PGPDataFormat.NUMBER_OF_SIGNING_KEYS)); }
@Test public void testTranslatedEvent() throws Exception { out.expectedMinimumMessageCount(1); trap.send(); out.assertIsSatisfied(); List<Exchange> exchanges = out.getExchanges(); Exchange exchange = exchanges.get(0); Message message = exchange.getIn(); RawEvent event = message.getBody(RawEvent.class); assertNotNull("check for not null", event); assertEquals("check event title", "linkDown trap received from 127.0.0.1", event.getTitle()); assertEquals("check event message", "Received linkDown trap", event.getMessage()); Map<String, Object> properties = event.getProperties(); assertEquals("check trap property", "Host has been restarted", properties.get("linkDown")); assertEquals("check uptime property", "7:12:00.00", properties.get("sysUpTimeInstance")); assertEquals("check description property", "Test Trap!", properties.get("sysDescr.0")); }
@Test public void getAllContentFromServerOrderedFromRootToLeaves() throws Exception { resultEndpoint.expectedMessageCount(5); Consumer treeBasedConsumer = createConsumerFor(getUrl()); treeBasedConsumer.start(); resultEndpoint.assertIsSatisfied(); treeBasedConsumer.stop(); List<Exchange> exchanges = resultEndpoint.getExchanges(); assertTrue(getNodeNameForIndex(exchanges, 0).equals("RootFolder")); assertTrue(getNodeNameForIndex(exchanges, 1).equals("Folder1")); assertTrue(getNodeNameForIndex(exchanges, 2).equals("Folder2")); assertTrue(getNodeNameForIndex(exchanges, 3).contains(".txt")); assertTrue(getNodeNameForIndex(exchanges, 4).contains(".txt")); }
public static void checkThrownException( MockEndpoint mock, Class<? extends Exception> cl, Class<? extends Exception> expectedCauseClass, String expectedMessagePart) throws Exception { Exception e = (Exception) mock.getExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT); assertNotNull("Expected excpetion " + cl.getName() + " missing", e); if (e.getClass() != cl) { String stackTrace = getStrackTrace(e); fail( "Exception " + cl.getName() + " excpected, but was " + e.getClass().getName() + ": " + stackTrace); } if (expectedMessagePart != null) { if (e.getMessage() == null) { fail("Expected excption does not contain a message. Stack trace: " + getStrackTrace(e)); } else { if (!e.getMessage().contains(expectedMessagePart)) { fail( "Expected excption message does not contain a expected message part " + expectedMessagePart + ". Stack trace: " + getStrackTrace(e)); } } } if (expectedCauseClass != null) { Throwable cause = e.getCause(); assertNotNull("Expected cause exception" + expectedCauseClass.getName() + " missing", cause); if (expectedCauseClass != cause.getClass()) { fail( "Cause exception " + expectedCauseClass.getName() + " expected, but was " + cause.getClass().getName() + ": " + getStrackTrace(e)); } } }
@Test public void testUnmarshal() throws Exception { final String xml = "<Person><firstName>FOO</firstName><lastName>BAR</lastName></Person>"; PersonType expected = new PersonType(); expected.setFirstName("FOO"); expected.setLastName("BAR"); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedBodiesReceived(expected); resultEndpoint.expectedHeaderReceived("foo", "bar"); template.sendBodyAndHeader("direct:getJAXBElementValue", xml, "foo", "bar"); resultEndpoint.assertIsSatisfied(); resultEndpoint.reset(); resultEndpoint.expectedMessageCount(1); template.sendBody("direct:getJAXBElement", xml); resultEndpoint.assertIsSatisfied(); assertTrue( "We should get the JAXBElement here", resultEndpoint.getExchanges().get(0).getIn().getBody() instanceof JAXBElement); }
@Test public void testPostStatusUpdateRequestResponse() throws Exception { Date now = new Date(); String tweet = "UserProducerInOnlyTest: This is a tweet posted on " + now.toString(); LOG.info("Tweet: " + tweet); ProducerTemplate producerTemplate = context.createProducerTemplate(); // send tweet to the twitter endpoint producerTemplate.sendBodyAndHeader("direct:tweets", tweet, "customHeader", 12312); resultEndpoint.expectedMessageCount(1); resultEndpoint.expectedBodyReceived().body(String.class); // Message headers should be preserved resultEndpoint.expectedHeaderReceived("customHeader", 12312); resultEndpoint.assertIsSatisfied(); List<Exchange> tweets = resultEndpoint.getExchanges(); assertNotNull(tweets); assertThat(tweets.size(), is(1)); String receivedTweet = tweets.get(0).getIn().getBody(String.class); assertThat(receivedTweet, is(tweet)); }
@Test public void testOffline() throws InterruptedException { resultEndpoint.whenAnyExchangeReceived( new Processor() { @Override public void process(Exchange exchange) throws Exception { // Treat the endpoint as offline throw new Exception("OFFLINE"); } }); // Wait for 5 seconds while Camel route is exercised Thread.sleep(5000); // Ensure offline symptoms are reported final List<Exchange> exchanges = resultEndpoint.getExchanges(); Assert.assertTrue(!exchanges.isEmpty()); Assert.assertEquals(1, alerts); Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getFailed()); Assert.assertEquals(0, builder.getPingProcessor().getSucceeded()); Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getTotal()); }
@Test public void testFtpSimpleConsumeAbsolute() throws Exception { if (!canTest()) { return; } String expected = "Hello World"; // create file using regular file // FTP Server does not support absolute path, so lets simulate it String path = FTP_ROOT_DIR + "/tmp/mytemp"; template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt"); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt"); context.startRoute("foo"); assertMockEndpointsSatisfied(); GenericFile<?> remoteFile = (GenericFile<?>) mock.getExchanges().get(0).getIn().getBody(); assertTrue(remoteFile.getBody() instanceof InputStream); }
@Test public void testMarshalPrettyPrint() throws Exception { PersonType person = new PersonType(); person.setFirstName("Willem"); person.setLastName("Jiang"); resultEndpoint.expectedMessageCount(1); template.sendBody("direct:prettyPrint", person); resultEndpoint.assertIsSatisfied(); Exchange exchange = resultEndpoint.getExchanges().get(0); String result = exchange.getIn().getBody(String.class); assertNotNull("The result should not be null", result); int indexPerson = result.indexOf("<Person>"); int indexFirstName = result.indexOf("<firstName>"); assertTrue("we should find the <Person>", indexPerson > 0); assertTrue("we should find the <firstName>", indexFirstName > 0); assertTrue( "There should some sapce between <Person> and <firstName>", indexFirstName - indexPerson > 8); }