Search in sources :

Example 1 with MockRestRequestResponseHandler

use of com.github.ambry.rest.MockRestRequestResponseHandler in project ambry by linkedin.

the class AmbryBlobStorageServiceFactoryTest method getAmbryBlobStorageServiceFactoryWithBadInputTest.

/**
 * Tests instantiation of {@link AmbryBlobStorageServiceFactory} with bad input.
 * @throws Exception
 */
@Test
public void getAmbryBlobStorageServiceFactoryWithBadInputTest() throws Exception {
    // dud properties. server should pick up defaults
    Properties properties = new Properties();
    VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
    ClusterMap clusterMap = new MockClusterMap();
    RestResponseHandler restResponseHandler = new MockRestRequestResponseHandler();
    Router router = new InMemoryRouter(verifiableProperties, clusterMap);
    // VerifiableProperties null.
    try {
        new AmbryBlobStorageServiceFactory(null, clusterMap, restResponseHandler, router, new MockNotifier());
        fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
    // expected. Nothing to do.
    }
    // ClusterMap null.
    try {
        new AmbryBlobStorageServiceFactory(verifiableProperties, null, restResponseHandler, router, new MockNotifier());
        fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
    // expected. Nothing to do.
    }
    // RestResponseHandler null.
    try {
        new AmbryBlobStorageServiceFactory(verifiableProperties, clusterMap, null, router, new MockNotifier());
        fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
    // expected. Nothing to do.
    }
    // Router null.
    try {
        new AmbryBlobStorageServiceFactory(verifiableProperties, clusterMap, restResponseHandler, null, new MockNotifier());
        fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
    // expected. Nothing to do.
    }
}
Also used : ClusterMap(com.github.ambry.clustermap.ClusterMap) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) InMemoryRouter(com.github.ambry.router.InMemoryRouter) MockNotifier(com.github.ambry.account.MockNotifier) RestResponseHandler(com.github.ambry.rest.RestResponseHandler) VerifiableProperties(com.github.ambry.config.VerifiableProperties) InMemoryRouter(com.github.ambry.router.InMemoryRouter) Router(com.github.ambry.router.Router) MockRestRequestResponseHandler(com.github.ambry.rest.MockRestRequestResponseHandler) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Test(org.junit.Test)

Example 2 with MockRestRequestResponseHandler

use of com.github.ambry.rest.MockRestRequestResponseHandler in project ambry by linkedin.

the class AmbryBlobStorageServiceFactoryTest method getAmbryBlobStorageServiceTest.

/**
 * Tests the instantiation of an {@link AmbryBlobStorageService} instance through the
 * {@link AmbryBlobStorageServiceFactory}.
 * @throws Exception
 */
@Test
public void getAmbryBlobStorageServiceTest() throws Exception {
    // dud properties. server should pick up defaults
    Properties properties = new Properties();
    VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
    AmbryBlobStorageServiceFactory ambryBlobStorageServiceFactory = new AmbryBlobStorageServiceFactory(verifiableProperties, new MockClusterMap(), new MockRestRequestResponseHandler(), new InMemoryRouter(verifiableProperties, new MockClusterMap()), new MockNotifier());
    BlobStorageService ambryBlobStorageService = ambryBlobStorageServiceFactory.getBlobStorageService();
    assertNotNull("No BlobStorageService returned", ambryBlobStorageService);
    assertEquals("Did not receive an AmbryBlobStorageService instance", AmbryBlobStorageService.class.getCanonicalName(), ambryBlobStorageService.getClass().getCanonicalName());
}
Also used : InMemoryRouter(com.github.ambry.router.InMemoryRouter) MockNotifier(com.github.ambry.account.MockNotifier) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockRestRequestResponseHandler(com.github.ambry.rest.MockRestRequestResponseHandler) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) BlobStorageService(com.github.ambry.rest.BlobStorageService) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Test(org.junit.Test)

Aggregations

MockNotifier (com.github.ambry.account.MockNotifier)2 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)2 VerifiableProperties (com.github.ambry.config.VerifiableProperties)2 MockRestRequestResponseHandler (com.github.ambry.rest.MockRestRequestResponseHandler)2 InMemoryRouter (com.github.ambry.router.InMemoryRouter)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 ClusterMap (com.github.ambry.clustermap.ClusterMap)1 BlobStorageService (com.github.ambry.rest.BlobStorageService)1 RestResponseHandler (com.github.ambry.rest.RestResponseHandler)1 Router (com.github.ambry.router.Router)1