@BeforeClass(groups = "contentaware", dependsOnGroups = "passthroughPost") public void setUp() { listenerConfiguration = new ListenerConfiguration(); listenerConfiguration.setHost(TestUtil.TEST_HOST); listenerConfiguration.setId("test-listener"); listenerConfiguration.setPort(TestUtil.TEST_ESB_PORT); senderConfiguration = new SenderConfiguration("passthrough-sender"); httpTransportListener = TestUtil.startCarbonTransport( listenerConfiguration, senderConfiguration, new MessageEchoingMessageProcessor()); httpServer = TestUtil.startHTTPServer(TestUtil.TEST_SERVER_PORT); }
@Test(groups = "contentaware", dependsOnGroups = "passthroughPost") public void messageEchoingFromProcessorTestCase() { String testValue = "Test Message"; try { HttpURLConnection urlConn = TestUtil.request(baseURI, "/", HttpMethod.POST.name(), true); TestUtil.writeContent(urlConn, testValue); assertEquals(200, urlConn.getResponseCode()); String content = TestUtil.getContent(urlConn); assertEquals(testValue, content); urlConn.disconnect(); } catch (IOException e) { LOGGER.error("IO Exception occurred", e); assertTrue(false); } }
@Test(groups = "contentaware", dependsOnMethods = "requestResponseStreamingFromProcessorTestCase") public void requestResponseTransformStreamingFromProcessorTestCase() { String requestValue = "<A><B><C>Test Message</C></B></A>"; try { CarbonMessageProcessor carbonMessageProcessor = new RequestResponseTransformStreamingProcessor(); TestUtil.updateMessageProcessor( carbonMessageProcessor, senderConfiguration, listenerConfiguration); HttpURLConnection urlConn = TestUtil.request(baseURI, "/", HttpMethod.POST.name(), true); TestUtil.writeContent(urlConn, requestValue); assertEquals(200, urlConn.getResponseCode()); String content = TestUtil.getContent(urlConn); assertEquals(requestValue, content); urlConn.disconnect(); } catch (IOException e) { LOGGER.error("IO Exception occurred", e); assertTrue(false); } }
@AfterClass(groups = "contentaware", alwaysRun = true) public void cleanUp() { TestUtil.cleanUp(httpTransportListener, httpServer); }