org.springframework.cloud.service.common.AmqpServiceInfo Java Examples
The following examples show how to use
org.springframework.cloud.service.common.AmqpServiceInfo.
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: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Test public void qpidServiceCreationNoLabelNoTags() throws Exception { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getQpidServicePayloadNoLabelNoTags("qpid-1", hostname, port, username, password, "q-1", "vhost1"), getQpidServicePayloadNoLabelNoTags("qpid-2", hostname, port, username, password, "q-2", "vhost2"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, "qpid-1", AmqpServiceInfo.class); assertServiceFoundOfType(serviceInfos, "qpid-2", AmqpServiceInfo.class); AmqpServiceInfo serviceInfo = (AmqpServiceInfo) getServiceInfo(serviceInfos, "qpid-1"); assertNotNull(serviceInfo); assertEquals(username, serviceInfo.getUserName()); assertEquals(password, serviceInfo.getPassword()); assertEquals("vhost1", serviceInfo.getVirtualHost()); URI uri = new URI(serviceInfo.getUri()); assertTrue(uri.getQuery().contains("tcp://" + hostname + ":" + port)); }
Example #2
Source File: RabbitConnectionFactoryCreator.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
private CachingConnectionFactory createSpringConnectionFactory(AmqpServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfiguration, com.rabbitmq.client.ConnectionFactory connectionFactory) { CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(connectionFactory); if (serviceInfo.getUris() != null) { cachingConnectionFactory.setAddresses(getAddresses(serviceInfo)); } if (serviceConnectorConfiguration != null) { Integer channelCacheSize = ((RabbitConnectionFactoryConfig) serviceConnectorConfiguration).getChannelCacheSize(); if (channelCacheSize != null) { cachingConnectionFactory.setChannelCacheSize(channelCacheSize); } } return cachingConnectionFactory; }
Example #3
Source File: AmqpServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public AmqpServiceInfo createServiceInfo(Map<String,Object> serviceData) { Map<String,Object> credentials = getCredentials(serviceData); String id = getId(serviceData); String uri = getUriFromCredentials(credentials); String managementUri = getStringFromCredentials(credentials, "http_api_uri"); if (credentials.containsKey("uris")) { List<String> uris = (List<String>) credentials.get("uris"); List<String> managementUris = (List<String>) credentials.get("http_api_uris"); return new AmqpServiceInfo(id, uri, managementUri, uris, managementUris); } return new AmqpServiceInfo(id, uri, managementUri); }
Example #4
Source File: RabbitConnectionFactoryCreatorTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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); }
Example #5
Source File: HerokuConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
protected void assertAmqpServiceInfo(AmqpServiceInfo serviceInfo, String virtualHost) { assertEquals(hostname, serviceInfo.getHost()); assertEquals(port, serviceInfo.getPort()); assertEquals(username, serviceInfo.getUserName()); assertEquals(password, serviceInfo.getPassword()); assertEquals(virtualHost, serviceInfo.getPath()); }
Example #6
Source File: HerokuConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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"); }
Example #7
Source File: LocalConfigConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void serviceCreation() { List<ServiceInfo> services = connector.getServiceInfos(); ServiceInfo service = getServiceInfo(services, "rabbit"); assertNotNull(service); assertTrue(service instanceof AmqpServiceInfo); assertUriParameters((AmqpServiceInfo) service); }
Example #8
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void rabbitServiceCreationNoLabelNoTagsSecure() { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getRabbitServicePayloadNoLabelNoTagsSecure("rabbit-1", hostname, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadNoLabelNoTagsSecure("rabbit-2", hostname, port, username, password, "q-2", "vhost2"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class); assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class); }
Example #9
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void rabbitServiceCreationNoLabelNoTags() { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getRabbitServicePayloadNoLabelNoTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadNoLabelNoTags("rabbit-2", hostname, port, username, password, "q-2", "vhost2"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class); assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class); }
Example #10
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void rabbitServiceCreationMultipleUris() { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getRabbitServicePayloadMultipleUris("rabbit-1", hostname, hostname2, port, username, password, "q-1", "v%2Fhost1"), getRabbitServicePayloadMultipleUris("rabbit-2", hostname, hostname2, port, username, password, "q-2", "v%2Fhost2"))); 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)); assertEquals("v/host1", amqpServiceInfo.getVirtualHost()); assertEquals(5672, amqpServiceInfo.getPort()); 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)); }
Example #11
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void rabbitServiceCreationWithoutTags() { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getRabbitServicePayloadWithoutTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadWithoutTags("rabbit-2", hostname, port, username, password, "q-2", "vhost2"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class); assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class); }
Example #12
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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()); }
Example #13
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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); }
Example #14
Source File: CloudFoundryConnectorAmqpServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void rabbitServiceCreationWithTags() { when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getRabbitServicePayloadWithTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadWithTags("rabbit-2", hostname, port, username, password, "q-2", "vhost2"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class); assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class); }
Example #15
Source File: AmqpServiceInfoCreator.java From spring-cloud-lattice with Apache License 2.0 | 5 votes |
@Override public AmqpServiceInfo createServiceInfo(Process process) { ActualLRPResponse actual = process.getFirstActual(); String address = actual.getAddress(); int port = actual.getPorts()[0].getHostPort(); String username = "guest"; String password = "guest"; String virtualHost = null; return new LatticeAmqpServiceInfo(actual.getInstanceGuid(), address, port, username, password, virtualHost); }
Example #16
Source File: RabbitConnectionFactoryCreatorTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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()); }
Example #17
Source File: HystrixAmqpServiceInfo.java From spring-cloud-services-connector with Apache License 2.0 | 5 votes |
private int getSchemeBasedPort(final int currentPort, String scheme) { int port = currentPort; if (currentPort == -1) { if (AmqpServiceInfo.AMQP_SCHEME.equals(scheme)) { port = AMQP_PORT; } else if (AmqpServiceInfo.AMQPS_SCHEME.equals(scheme)) { port = AMQPS_PORT; } } return port; }
Example #18
Source File: AmqpServiceInfoCreatorTests.java From spring-cloud-lattice with Apache License 2.0 | 5 votes |
@Test public void amqpLatticeWorks() { LatticeConnector connector = createConnector(); AmqpServiceInfo serviceInfo = findServiceInfo(connector, AmqpServiceInfo.class, "rabbit-1"); assertThat(serviceInfo.getUri(), equalTo("amqp://guest:[email protected]:61002")); }
Example #19
Source File: HystrixAmqpServiceInfoCreatorTest.java From spring-cloud-services-connector with Apache License 2.0 | 5 votes |
@Test public void hystrixAmqpServiceCreation() { when(mockEnvironment.getEnvValue(VCAP_SERVICES_ENV_KEY)) .thenReturn(getServicesPayload(getServicePayload(SERVICE_TAG_NAME, hostname, port, username, password, "vhost1"))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); assertServiceFoundOfType(serviceInfos, SERVICE_TAG_NAME, HystrixAmqpServiceInfo.class); // ensure this type will not match on AmqpServiceInfos assertServiceNotFoundOfType(serviceInfos, AmqpServiceInfo.class); }
Example #20
Source File: RabbitConnectionFactoryCreatorTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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()); }
Example #21
Source File: HystrixStreamServiceConnectorIntegrationTest.java From spring-cloud-services-connector with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() { List<ServiceInfo> serviceInfosWithAddedRabbitCloudBinding = new ArrayList<>(MockCloudConnector.instance.getServiceInfos()); serviceInfosWithAddedRabbitCloudBinding.add( new AmqpServiceInfo("rabbitmq", "example.com", 5672, "username", "password", "virtualHost") ); when(MockCloudConnector.instance.getServiceInfos()).thenReturn(serviceInfosWithAddedRabbitCloudBinding); }
Example #22
Source File: RabbitConnectionFactoryCreator.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
private com.rabbitmq.client.ConnectionFactory createRabbitConnectionFactory(AmqpServiceInfo serviceInfo) { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); if (serviceInfo.getUris() != null && serviceInfo.getUris().size() > 0) { setConnectionFactoryUri(connectionFactory, serviceInfo.getUris().get(0)); } else { setConnectionFactoryUri(connectionFactory, serviceInfo.getUri()); } return connectionFactory; }
Example #23
Source File: RabbitConnectionFactoryCreator.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
private String getAddresses(AmqpServiceInfo serviceInfo) { try { StringBuilder addresses = new StringBuilder(); for (String uriString : serviceInfo.getUris()) { URI uri = new URI(uriString); if (addresses.length() > 0) { addresses.append(','); } addresses.append(uri.getHost()).append(':').append(uri.getPort()); } return addresses.toString(); } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid AMQP URI", e); } }
Example #24
Source File: CloudTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@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); }
Example #25
Source File: StubCloudConnectorTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
protected AmqpServiceInfo createRabbitService(String id) { return new AmqpServiceInfo(id, "10.20.30.40", 1234, "username", "password", "vh"); }
Example #26
Source File: AmqpServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public AmqpServiceInfoCreator() { super(new Tags("rabbitmq"), AmqpServiceInfo.AMQP_SCHEME, AmqpServiceInfo.AMQPS_SCHEME); }
Example #27
Source File: HystrixAmqpServiceInfo.java From spring-cloud-services-connector with Apache License 2.0 | 4 votes |
public AmqpServiceInfo getAmqpInfo() { return delegate; }
Example #28
Source File: HystrixAmqpServiceInfo.java From spring-cloud-services-connector with Apache License 2.0 | 4 votes |
public HystrixAmqpServiceInfo(String id, String uri, List<String> uris, boolean sslEnabled) { super(id); delegate = new AmqpServiceInfo(id, uri, null, uris, null); this.sslEnabled = sslEnabled; }
Example #29
Source File: AmqpServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public AmqpServiceInfoCreator() { super(AmqpServiceInfo.AMQP_SCHEME, AmqpServiceInfo.AMQPS_SCHEME); }
Example #30
Source File: AmqpServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public AmqpServiceInfo createServiceInfo(String id, String uri) { return new AmqpServiceInfo(id, uri); }