Java Code Examples for io.vertx.core.http.HttpServer#actualPort()

The following examples show how to use io.vertx.core.http.HttpServer#actualPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformFeaturesAvailabilityTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testVersionDetectionOpenShift39(VertxTestContext context) throws InterruptedException {
    String version = "{\n" +
            "  \"major\": \"1\",\n" +
            "  \"minor\": \"9\",\n" +
            "  \"gitVersion\": \"v1.9.1+a0ce1bc657\",\n" +
            "  \"gitCommit\": \"a0ce1bc\",\n" +
            "  \"gitTreeState\": \"clean\",\n" +
            "  \"buildDate\": \"2018-06-24T01:54:00Z\",\n" +
            "  \"goVersion\": \"go1.9\",\n" +
            "  \"compiler\": \"gc\",\n" +
            "  \"platform\": \"linux/amd64\"\n" +
            "}";

    HttpServer mockHttp = startMockApi(context, version, Collections.EMPTY_LIST);

    KubernetesClient client = new DefaultKubernetesClient("127.0.0.1:" + mockHttp.actualPort());

    Checkpoint a = context.checkpoint();

    PlatformFeaturesAvailability.create(vertx, client).onComplete(context.succeeding(pfa -> context.verify(() -> {
        assertThat("Versions are not equal", pfa.getKubernetesVersion(), is(KubernetesVersion.V1_9));
        stopMockApi(context, mockHttp);
        a.flag();
    })));
}
 
Example 2
Source File: PlatformFeaturesAvailabilityTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testVersionDetectionMinikube114(VertxTestContext context) throws InterruptedException {
    String version = "{\n" +
            "  \"major\": \"1\",\n" +
            "  \"minor\": \"14\",\n" +
            "  \"gitVersion\": \"v1.14.0\",\n" +
            "  \"gitCommit\": \"641856db18352033a0d96dbc99153fa3b27298e5\",\n" +
            "  \"gitTreeState\": \"clean\",\n" +
            "  \"buildDate\": \"2019-03-25T15:45:25Z\",\n" +
            "  \"goVersion\": \"go1.12.1\",\n" +
            "  \"compiler\": \"gc\",\n" +
            "  \"platform\": \"linux/amd64\"\n" +
            "}";

    HttpServer mockHttp = startMockApi(context, version, Collections.EMPTY_LIST);

    KubernetesClient client = new DefaultKubernetesClient("127.0.0.1:" + mockHttp.actualPort());

    Checkpoint async = context.checkpoint();

    PlatformFeaturesAvailability.create(vertx, client).onComplete(context.succeeding(pfa -> context.verify(() -> {
        assertThat("Versions are not equal", pfa.getKubernetesVersion(), is(KubernetesVersion.V1_14));
        stopMockApi(context, mockHttp);
        async.flag();
    })));
}
 
Example 3
Source File: PlatformFeaturesAvailabilityTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testApiDetectionOce(VertxTestContext context) throws InterruptedException {
    List<String> apis = new ArrayList<>();
    apis.add("/apis/route.openshift.io/v1");
    apis.add("/apis/build.openshift.io/v1");

    HttpServer mockHttp = startMockApi(context, apis);

    KubernetesClient client = new DefaultKubernetesClient("127.0.0.1:" + mockHttp.actualPort());

    Checkpoint async = context.checkpoint();

    PlatformFeaturesAvailability.create(vertx, client).onComplete(context.succeeding(pfa -> context.verify(() -> {
        assertThat(pfa.hasRoutes(), is(true));
        assertThat(pfa.hasBuilds(), is(true));
        assertThat(pfa.hasImages(), is(false));
        assertThat(pfa.hasApps(), is(false));
        stopMockApi(context, mockHttp);
        async.flag();
    })));
}
 
Example 4
Source File: PlatformFeaturesAvailabilityTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testApiDetectionOpenshift(VertxTestContext context) throws InterruptedException {
    List<String> apis = new ArrayList<>();
    apis.add("/apis/route.openshift.io/v1");
    apis.add("/apis/build.openshift.io/v1");
    apis.add("/apis/apps.openshift.io/v1");
    apis.add("/apis/image.openshift.io/v1");

    HttpServer mockHttp = startMockApi(context, apis);

    KubernetesClient client = new DefaultKubernetesClient("127.0.0.1:" + mockHttp.actualPort());

    Checkpoint async = context.checkpoint();

    PlatformFeaturesAvailability.create(vertx, client).onComplete(context.succeeding(pfa -> context.verify(() -> {
        assertThat(pfa.hasRoutes(), is(true));
        assertThat(pfa.hasBuilds(), is(true));
        assertThat(pfa.hasImages(), is(true));
        assertThat(pfa.hasApps(), is(true));
        stopMockApi(context, mockHttp);
        async.flag();
    })));
}
 
Example 5
Source File: PlatformFeaturesAvailabilityTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testApiDetectionKubernetes(VertxTestContext context) throws InterruptedException {
    HttpServer mockHttp = startMockApi(context, Collections.EMPTY_LIST);

    KubernetesClient client = new DefaultKubernetesClient("127.0.0.1:" + mockHttp.actualPort());

    Checkpoint async = context.checkpoint();

    PlatformFeaturesAvailability.create(vertx, client).onComplete(context.succeeding(pfa -> context.verify(() -> {
        assertThat(pfa.hasRoutes(), is(false));
        assertThat(pfa.hasBuilds(), is(false));
        assertThat(pfa.hasImages(), is(false));
        assertThat(pfa.hasApps(), is(false));
        stopMockApi(context, mockHttp);
        async.flag();
    })));
}
 
Example 6
Source File: AbstractVertxBasedHttpProtocolAdapter.java    From hono with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the http server instance configured to serve requests over a TLS secured socket.
 * <p>
 * If no server is set using this method, then a server instance is created during
 * startup of this adapter based on the <em>config</em> properties and the server options
 * returned by {@link #getHttpServerOptions()}.
 *
 * @param server The http server.
 * @throws NullPointerException if server is {@code null}.
 * @throws IllegalArgumentException if the server is already started and listening on an address/port.
 */
@Autowired(required = false)
public final void setHttpServer(final HttpServer server) {
    Objects.requireNonNull(server);
    if (server.actualPort() > 0) {
        throw new IllegalArgumentException("http server must not be started already");
    } else {
        this.server = server;
    }
}
 
Example 7
Source File: AbstractVertxBasedHttpProtocolAdapter.java    From hono with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the http server instance configured to serve requests over a plain socket.
 * <p>
 * If no server is set using this method, then a server instance is created during
 * startup of this adapter based on the <em>config</em> properties and the server options
 * returned by {@link #getInsecureHttpServerOptions()}.
 *
 * @param server The http server.
 * @throws NullPointerException if server is {@code null}.
 * @throws IllegalArgumentException if the server is already started and listening on an address/port.
 */
@Autowired(required = false)
public final void setInsecureHttpServer(final HttpServer server) {
    Objects.requireNonNull(server);
    if (server.actualPort() > 0) {
        throw new IllegalArgumentException("http server must not be started already");
    } else {
        this.insecureServer = server;
    }
}