Search in sources :

Example 6 with AmqpServiceInfo

use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationMultipleUris.

@Test
public void rabbitServiceCreationMultipleUris() {
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadMultipleUris("rabbit-1", hostname, hostname2, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadMultipleUris("rabbit-2", hostname, hostname2, port, username, password, "q-2", "vhost2")));
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
    assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class);
    AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
    assertNotNull(amqpServiceInfo.getUri());
    assertTrue(amqpServiceInfo.getUri().contains(hostname));
    assertNotNull(amqpServiceInfo.getManagementUri());
    assertTrue(amqpServiceInfo.getManagementUri().contains(hostname));
    assertNotNull(amqpServiceInfo.getUris());
    assertEquals(2, amqpServiceInfo.getUris().size());
    assertTrue(amqpServiceInfo.getUris().get(0).contains(hostname));
    assertTrue(amqpServiceInfo.getUris().get(1).contains(hostname2));
    assertNotNull(amqpServiceInfo.getManagementUris());
    assertEquals(2, amqpServiceInfo.getManagementUris().size());
    assertTrue(amqpServiceInfo.getManagementUris().get(0).contains(hostname));
    assertTrue(amqpServiceInfo.getManagementUris().get(1).contains(hostname2));
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 7 with AmqpServiceInfo

use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationWithManagementUri.

@Test
public void rabbitServiceCreationWithManagementUri() {
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadWithTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1")));
    String expectedManagementUri = "http://" + username + ":" + password + "@" + hostname + "/api";
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
    AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
    assertEquals(amqpServiceInfo.getManagementUri(), expectedManagementUri);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 8 with AmqpServiceInfo

use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.

the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationNoUri.

@Test
public void cloudRabbitCreationNoUri() throws Exception {
    AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", TEST_HOST, TEST_PORT, TEST_USERNAME, TEST_PASSWORD, TEST_VH);
    ConnectionFactory connector = testCreator.create(serviceInfo, null);
    assertConnectorPropertiesMatchUri(connector, serviceInfo.getUri());
}
Also used : ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 9 with AmqpServiceInfo

use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.

the class RabbitServiceInfoTest method uriBasedParsingDefaultVhost.

@Test
public void uriBasedParsingDefaultVhost() {
    AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", "amqp://myuser:mypass@myhost:12345/");
    assertEquals("myhost", serviceInfo.getHost());
    assertEquals(12345, serviceInfo.getPort());
    assertEquals("myuser", serviceInfo.getUserName());
    assertEquals("mypass", serviceInfo.getPassword());
    assertNull(serviceInfo.getVirtualHost());
}
Also used : AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 10 with AmqpServiceInfo

use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.

the class RabbitServiceInfoTest method uriBasedParsing.

@Test
public void uriBasedParsing() {
    AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", "amqp://myuser:mypass@myhost:12345/myvhost");
    assertEquals("myhost", serviceInfo.getHost());
    assertEquals(12345, serviceInfo.getPort());
    assertEquals("myuser", serviceInfo.getUserName());
    assertEquals("mypass", serviceInfo.getPassword());
    assertEquals("myvhost", serviceInfo.getVirtualHost());
}
Also used : AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)13 AmqpServiceInfo (org.springframework.cloud.service.common.AmqpServiceInfo)13 ServiceInfo (org.springframework.cloud.service.ServiceInfo)6 URI (java.net.URI)3 ConnectionFactory (org.springframework.amqp.rabbit.connection.ConnectionFactory)3 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 CloudTestUtil.getTestCloudConnector (org.springframework.cloud.CloudTestUtil.getTestCloudConnector)1