Search in sources :

Example 1 with StubCompositeTransport

use of org.apache.activemq.transport.StubCompositeTransport in project activemq-artemis by apache.

the class DiscoveryTransportNoBrokerTest method testSetDiscoveredStaticBrokerProperties.

public void testSetDiscoveredStaticBrokerProperties() throws Exception {
    final String extraParameterName = "connectionTimeout";
    final String extraParameterValue = "3000";
    final URI uri = new URI("discovery:(static:tcp://localhost:61616)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue);
    CompositeData compositeData = URISupport.parseComposite(uri);
    StubCompositeTransport compositeTransport = new StubCompositeTransport();
    DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());
    discoveryTransport.start();
    assertEquals("expected added URI after discovery event", 1, compositeTransport.getTransportURIs().length);
    URI discoveredServiceURI = compositeTransport.getTransportURIs()[0];
    Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI);
    assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName));
    assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue);
}
Also used : CompositeData(org.apache.activemq.util.URISupport.CompositeData) URI(java.net.URI) StubCompositeTransport(org.apache.activemq.transport.StubCompositeTransport)

Example 2 with StubCompositeTransport

use of org.apache.activemq.transport.StubCompositeTransport in project activemq-artemis by apache.

the class DiscoveryTransportNoBrokerTest method testAddRemoveDiscoveredBroker.

public void testAddRemoveDiscoveredBroker() throws Exception {
    final URI uri = new URI("discovery:(multicast://default)?initialReconnectDelay=100&connectionTimeout=3000");
    CompositeData compositeData = URISupport.parseComposite(uri);
    StubCompositeTransport compositeTransport = new StubCompositeTransport();
    DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());
    final String serviceName = "tcp://localhost:61616";
    discoveryTransport.onServiceAdd(new DiscoveryEvent(serviceName));
    assertEquals("expected added URI after discovery event", 1, compositeTransport.getTransportURIs().length);
    discoveryTransport.onServiceRemove(new DiscoveryEvent(serviceName));
    assertEquals("expected URI removed after discovery event", 0, compositeTransport.getTransportURIs().length);
}
Also used : CompositeData(org.apache.activemq.util.URISupport.CompositeData) DiscoveryEvent(org.apache.activemq.command.DiscoveryEvent) URI(java.net.URI) StubCompositeTransport(org.apache.activemq.transport.StubCompositeTransport)

Example 3 with StubCompositeTransport

use of org.apache.activemq.transport.StubCompositeTransport in project activemq-artemis by apache.

the class DiscoveryTransportNoBrokerTest method testSetDiscoveredBrokerProperties.

public void testSetDiscoveredBrokerProperties() throws Exception {
    final String extraParameterName = "connectionTimeout";
    final String extraParameterValue = "3000";
    final URI uri = new URI("discovery:(multicast://default)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue);
    CompositeData compositeData = URISupport.parseComposite(uri);
    StubCompositeTransport compositeTransport = new StubCompositeTransport();
    DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());
    discoveryTransport.onServiceAdd(new DiscoveryEvent("tcp://localhost:61616"));
    assertEquals("expected added URI after discovery event", compositeTransport.getTransportURIs().length, 1);
    URI discoveredServiceURI = compositeTransport.getTransportURIs()[0];
    Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI);
    assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName));
    assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue);
}
Also used : CompositeData(org.apache.activemq.util.URISupport.CompositeData) DiscoveryEvent(org.apache.activemq.command.DiscoveryEvent) URI(java.net.URI) StubCompositeTransport(org.apache.activemq.transport.StubCompositeTransport)

Aggregations

URI (java.net.URI)3 StubCompositeTransport (org.apache.activemq.transport.StubCompositeTransport)3 CompositeData (org.apache.activemq.util.URISupport.CompositeData)3 DiscoveryEvent (org.apache.activemq.command.DiscoveryEvent)2