use of io.cdap.plugin.mock.MockFeedHandler in project hydrator-plugins by cdapio.
the class HttpCallbackActionTest method setupTestClass.
@BeforeClass
public static void setupTestClass() throws Exception {
if (startCount++ > 0) {
return;
}
setupBatchArtifacts(BATCH_ARTIFACT_ID, DataPipelineApp.class);
Set<ArtifactRange> parents = new HashSet<>();
parents.add(new ArtifactRange(NamespaceId.DEFAULT.getNamespace(), BATCH_ARTIFACT_ID.getArtifact(), new ArtifactVersion(BATCH_ARTIFACT.getVersion()), true, new ArtifactVersion(BATCH_ARTIFACT.getVersion()), true));
addPluginArtifact(NamespaceId.DEFAULT.artifact("http-plugins", "1.0.0"), parents, HTTPCallbackAction.class);
List<HttpHandler> handlers = new ArrayList<>();
handlers.add(new MockFeedHandler());
httpService = NettyHttpService.builder("MockService").setHttpHandlers(handlers).build();
httpService.start();
int port = httpService.getBindAddress().getPort();
baseURL = "http://localhost:" + port;
// tell service what its port is.
URL setPortURL = new URL(baseURL + "/port");
HttpURLConnection urlConn = (HttpURLConnection) setPortURL.openConnection();
urlConn.setDoOutput(true);
urlConn.setRequestMethod(HttpMethod.PUT);
urlConn.getOutputStream().write(String.valueOf(port).getBytes(Charsets.UTF_8));
Assert.assertEquals(200, urlConn.getResponseCode());
urlConn.disconnect();
}
Aggregations