use of io.cdap.plugin.spark.mock.MockFeedHandler in project hydrator-plugins by cdapio.
the class SparkPluginTest method setupTest.
@BeforeClass
public static void setupTest() throws Exception {
// add the artifact for data pipeline app
setupBatchArtifacts(DATAPIPELINE_ARTIFACT_ID, DataPipelineApp.class);
setupStreamingArtifacts(DATASTREAMS_ARTIFACT_ID, DataStreamsApp.class);
// add artifact for spark plugins
Set<ArtifactRange> parents = ImmutableSet.of(new ArtifactRange(NamespaceId.DEFAULT.getNamespace(), DATAPIPELINE_ARTIFACT_ID.getArtifact(), new ArtifactVersion(DATAPIPELINE_ARTIFACT_ID.getVersion()), true, new ArtifactVersion(DATAPIPELINE_ARTIFACT_ID.getVersion()), true), new ArtifactRange(NamespaceId.DEFAULT.getNamespace(), DATASTREAMS_ARTIFACT_ID.getArtifact(), new ArtifactVersion(DATASTREAMS_ARTIFACT_ID.getVersion()), true, new ArtifactVersion(DATASTREAMS_ARTIFACT_ID.getVersion()), true));
addPluginArtifact(NamespaceId.DEFAULT.artifact("spark-plugins", "1.0.0"), parents, TwitterStreamingSource.class, FileStreamingSource.class, HTTPPollerSource.class, HTTPPollConfig.class);
List<HttpHandler> handlers = new ArrayList<>();
handlers.add(new MockFeedHandler());
httpService = NettyHttpService.builder("MockService").setHttpHandlers(handlers).build();
httpService.start();
int port = httpService.getBindAddress().getPort();
httpBase = "http://localhost:" + port;
// tell service what its port is.
URL setPortURL = new URL(httpBase + "/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