Search in sources :

Example 1 with AmqpServiceInfo

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

the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationWithUri.

@Test
public void cloudRabbitCreationWithUri() throws Exception {
    String userinfo = String.format("%s:%s", TEST_USERNAME, TEST_PASSWORD);
    URI uri = new URI("amqp", userinfo, TEST_HOST, TEST_PORT, "/" + TEST_VH, null, null);
    AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", uri.toString());
    ConnectionFactory connector = testCreator.create(serviceInfo, null);
    assertConnectorPropertiesMatchUri(connector, serviceInfo.getUri());
}
Also used : ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) URI(java.net.URI) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 2 with AmqpServiceInfo

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

the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationWithUris.

@Test
public void cloudRabbitCreationWithUris() throws Exception {
    String userinfo = String.format("%s:%s", TEST_USERNAME, TEST_PASSWORD);
    URI uri = new URI("amqp", userinfo, "0.0.0.0", 0, "/" + TEST_VH, null, null);
    URI uri1 = new URI("amqp", userinfo, TEST_HOST, TEST_PORT, "/" + TEST_VH, null, null);
    URI uri2 = new URI("amqp", userinfo, TEST_HOST2, TEST_PORT2, "/" + TEST_VH, null, null);
    List<String> uris = Arrays.asList(uri1.toString(), uri2.toString());
    AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", uri.toString(), null, uris, null);
    ConnectionFactory connector = testCreator.create(serviceInfo, null);
    assertConnectorPropertiesMatchUri(connector, uri1.toString());
    assertConnectorPropertiesMatchHosts(connector, uris);
}
Also used : ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) URI(java.net.URI) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 3 with AmqpServiceInfo

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

the class CloudTest method servicePropsRabbit.

@Test
public void servicePropsRabbit() {
    String serviceId = "my-rabbit";
    AmqpServiceInfo rabbitServiceInfo = createRabbitService(serviceId);
    CloudConnector stubCloudConnector = getTestCloudConnector(rabbitServiceInfo);
    Cloud testCloud = new Cloud(stubCloudConnector, serviceCreators);
    Properties cloudProperties = testCloud.getCloudProperties();
    assertRabbitProps("cloud.services.my-rabbit", rabbitServiceInfo, cloudProperties);
    assertRabbitProps("cloud.services.rabbitmq", rabbitServiceInfo, cloudProperties);
}
Also used : CloudTestUtil.getTestCloudConnector(org.springframework.cloud.CloudTestUtil.getTestCloudConnector) Properties(java.util.Properties) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 4 with AmqpServiceInfo

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

the class HerokuConnectorAmqpServiceTest method amqpServiceCreation.

@Test
public void amqpServiceCreation() {
    Map<String, String> env = new HashMap<String, String>();
    String amqpUrl = getAmqpServiceUrl("db");
    env.put("CLOUDAMQP_URL", amqpUrl);
    when(mockEnvironment.getEnv()).thenReturn(env);
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    ServiceInfo serviceInfo = getServiceInfo(serviceInfos, "CLOUDAMQP");
    assertNotNull(serviceInfo);
    assertTrue(serviceInfo instanceof AmqpServiceInfo);
    assertAmqpServiceInfo((AmqpServiceInfo) serviceInfo, "db");
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) HashMap(java.util.HashMap) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 5 with AmqpServiceInfo

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

the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationWithoutManagementUri.

@Test
public void rabbitServiceCreationWithoutManagementUri() {
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadNoLabelNoTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1")));
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
    AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
    assertNull(amqpServiceInfo.getManagementUri());
}
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)

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