Search in sources :

Example 1 with MockFeedHandler

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();
}
Also used : HttpHandler(io.cdap.http.HttpHandler) MockFeedHandler(io.cdap.plugin.mock.MockFeedHandler) ArtifactVersion(io.cdap.cdap.api.artifact.ArtifactVersion) HttpURLConnection(java.net.HttpURLConnection) ArtifactRange(io.cdap.cdap.api.artifact.ArtifactRange) ArrayList(java.util.ArrayList) URL(java.net.URL) HashSet(java.util.HashSet) BeforeClass(org.junit.BeforeClass)

Aggregations

ArtifactRange (io.cdap.cdap.api.artifact.ArtifactRange)1 ArtifactVersion (io.cdap.cdap.api.artifact.ArtifactVersion)1 HttpHandler (io.cdap.http.HttpHandler)1 MockFeedHandler (io.cdap.plugin.mock.MockFeedHandler)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BeforeClass (org.junit.BeforeClass)1