Search in sources :

Example 1 with StubCloudConnector

use of org.springframework.cloud.CloudTestUtil.StubCloudConnector in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method serviceConnectorCreationDefaultTypeAndConfig.

@Test
public void serviceConnectorCreationDefaultTypeAndConfig() {
    StubServiceInfo testServiceInfo = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password");
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo);
    serviceConnectorCreators.add(new StubServiceConnectorCreator());
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    StubServiceConnector connector = testCloud.getServiceConnector(testServiceInfo.getId(), null, null);
    assertStubService(testServiceInfo, connector, null);
}
Also used : StubServiceInfo(org.springframework.cloud.CloudTestUtil.StubServiceInfo) StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Example 2 with StubCloudConnector

use of org.springframework.cloud.CloudTestUtil.StubCloudConnector in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method getSingletonServiceConnectorNoMatchingServiceConnectorCreator.

@Test(expected = CloudException.class)
public void getSingletonServiceConnectorNoMatchingServiceConnectorCreator() {
    // Think an app bound to a (user) service that doesn't have a corresponding
    // registered ServiceConnectorCreator. When user asks for singleton service connector
    // for another type (with a corresponding creator registered), 
    // getSingletonServiceConnector() should throw a CloudException.
    BaseServiceInfo testServiceInfo = new BaseServiceInfo("user-service");
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo);
    serviceConnectorCreators.add(new StubServiceConnectorCreator());
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    testCloud.getSingletonServiceConnector(StubServiceConnector.class, null);
}
Also used : BaseServiceInfo(org.springframework.cloud.service.BaseServiceInfo) StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Example 3 with StubCloudConnector

use of org.springframework.cloud.CloudTestUtil.StubCloudConnector in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method getSingletonServiceConnectorMultipleServices.

@Test(expected = CloudException.class)
public void getSingletonServiceConnectorMultipleServices() {
    StubServiceInfo testServiceInfo1 = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password");
    StubServiceInfo testServiceInfo2 = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password");
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo1, testServiceInfo2);
    serviceConnectorCreators.add(new StubServiceConnectorCreator());
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    testCloud.getSingletonServiceConnector(null, null);
}
Also used : StubServiceInfo(org.springframework.cloud.CloudTestUtil.StubServiceInfo) StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Example 4 with StubCloudConnector

use of org.springframework.cloud.CloudTestUtil.StubCloudConnector in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method serviceInfoNoServices.

@Test
public void serviceInfoNoServices() {
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector();
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    assertEquals(0, testCloud.getServiceInfos().size());
    assertEquals(0, testCloud.getServiceInfos(StubServiceInfo.class).size());
}
Also used : StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Example 5 with StubCloudConnector

use of org.springframework.cloud.CloudTestUtil.StubCloudConnector in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method servicePropsTwoServicesOfTheSameLabel.

@Test
public void servicePropsTwoServicesOfTheSameLabel() {
    StubServiceInfo testServiceInfo1 = new StubServiceInfo("test-id1", "test-host", 1000, "test-username", "test-password");
    StubServiceInfo testServiceInfo2 = new StubServiceInfo("test-id2", "test-host", 1000, "test-username", "test-password");
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo1, testServiceInfo2);
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    Properties cloudProperties = testCloud.getCloudProperties();
    assertStubServiceProp("cloud.services.test-id1", testServiceInfo1, cloudProperties);
    assertStubServiceProp("cloud.services.test-id2", testServiceInfo2, cloudProperties);
    assertNull(cloudProperties.get("cloud.services.stub.connection.host"));
}
Also used : StubServiceInfo(org.springframework.cloud.CloudTestUtil.StubServiceInfo) Properties(java.util.Properties) StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 StubCloudConnector (org.springframework.cloud.CloudTestUtil.StubCloudConnector)15 StubServiceInfo (org.springframework.cloud.CloudTestUtil.StubServiceInfo)10 BaseServiceInfo (org.springframework.cloud.service.BaseServiceInfo)3 Properties (java.util.Properties)2 StubCompositeServiceInfo (org.springframework.cloud.CloudTestUtil.StubCompositeServiceInfo)2 ServiceInfo (org.springframework.cloud.service.ServiceInfo)2 HashMap (java.util.HashMap)1 StubApplicationInstanceInfo (org.springframework.cloud.CloudTestUtil.StubApplicationInstanceInfo)1