Search in sources :

Example 1 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class ProxyPublishConsumeWithoutZKTest method setup.

@BeforeMethod
public void setup() throws Exception {
    super.internalSetup();
    super.producerBaseSetup();
    port = PortManager.nextFreePort();
    WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
    config.setWebServicePort(port);
    config.setClusterName("use");
    config.setServiceUrl(pulsar.getWebServiceAddress());
    config.setServiceUrlTls(pulsar.getWebServiceAddressTls());
    service = spy(new WebSocketService(config));
    doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
    proxyServer = new ProxyServer(config);
    WebSocketServiceStarter.start(proxyServer, service);
    log.info("Proxy Server Started");
}
Also used : WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) ProxyServer(org.apache.pulsar.websocket.service.ProxyServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class LookupProtocolTest method httpLookupTest.

@Test(timeOut = 10000)
public void httpLookupTest() throws Exception {
    WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
    conf.setServiceUrl("http://localhost:8080");
    conf.setServiceUrlTls("https://localhost:8443");
    WebSocketService service = new WebSocketService(conf);
    PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
    Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
    lookupField.setAccessible(true);
    Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.HttpLookupService");
    Assert.assertFalse(testClient.getConfiguration().isUseTls());
    service.close();
}
Also used : Field(java.lang.reflect.Field) WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) PulsarClientImpl(org.apache.pulsar.client.impl.PulsarClientImpl) Test(org.testng.annotations.Test)

Example 3 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class LookupProtocolTest method httpsLookupTest.

@Test(timeOut = 10000)
public void httpsLookupTest() throws Exception {
    WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
    conf.setServiceUrl("http://localhost:8080");
    conf.setServiceUrlTls("https://localhost:8443");
    conf.setBrokerServiceUrl("pulsar://localhost:6650");
    conf.setTlsEnabled(true);
    WebSocketService service = new WebSocketService(conf);
    PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
    Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
    lookupField.setAccessible(true);
    Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.HttpLookupService");
    Assert.assertTrue(testClient.getConfiguration().isUseTls());
    service.close();
}
Also used : Field(java.lang.reflect.Field) WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) PulsarClientImpl(org.apache.pulsar.client.impl.PulsarClientImpl) Test(org.testng.annotations.Test)

Example 4 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class LookupProtocolTest method binaryTlsLookupTest.

@Test(timeOut = 10000)
public void binaryTlsLookupTest() throws Exception {
    WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
    conf.setServiceUrl("http://localhost:8080");
    conf.setServiceUrlTls("https://localhost:8443");
    conf.setBrokerServiceUrl("pulsar://localhost:6650");
    conf.setBrokerServiceUrlTls("pulsar+ssl://localhost:6651");
    conf.setTlsEnabled(true);
    WebSocketService service = new WebSocketService(conf);
    PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
    Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
    lookupField.setAccessible(true);
    Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.BinaryProtoLookupService");
    Assert.assertTrue(testClient.getConfiguration().isUseTls());
    service.close();
}
Also used : Field(java.lang.reflect.Field) WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) PulsarClientImpl(org.apache.pulsar.client.impl.PulsarClientImpl) Test(org.testng.annotations.Test)

Example 5 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class LookupProtocolTest method binaryLookupTest.

@Test(timeOut = 10000)
public void binaryLookupTest() throws Exception {
    WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
    conf.setServiceUrl("http://localhost:8080");
    conf.setServiceUrlTls("https://localhost:8443");
    conf.setBrokerServiceUrl("pulsar://localhost:6650");
    conf.setBrokerServiceUrlTls("pulsar+ssl://localhost:6651");
    WebSocketService service = new WebSocketService(conf);
    PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
    Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
    lookupField.setAccessible(true);
    Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.BinaryProtoLookupService");
    Assert.assertFalse(testClient.getConfiguration().isUseTls());
    service.close();
}
Also used : Field(java.lang.reflect.Field) WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) PulsarClientImpl(org.apache.pulsar.client.impl.PulsarClientImpl) Test(org.testng.annotations.Test)

Aggregations

WebSocketService (org.apache.pulsar.websocket.WebSocketService)9 WebSocketProxyConfiguration (org.apache.pulsar.websocket.service.WebSocketProxyConfiguration)9 Field (java.lang.reflect.Field)4 PulsarClientImpl (org.apache.pulsar.client.impl.PulsarClientImpl)4 ProxyServer (org.apache.pulsar.websocket.service.ProxyServer)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Test (org.testng.annotations.Test)4 URI (java.net.URI)1 AuthenticationTls (org.apache.pulsar.client.impl.auth.AuthenticationTls)1 BeforeClass (org.testng.annotations.BeforeClass)1