use of com.github.ambry.router.InMemoryRouter 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.
}
}
use of com.github.ambry.router.InMemoryRouter in project ambry by linkedin.
the class FrontendRestRequestServiceFactoryTest method getFrontendRestRequestServiceFactoryWithBadInputTest.
/**
* Tests instantiation of {@link FrontendRestRequestServiceFactory} with bad input.
* @throws Exception
*/
@Test
public void getFrontendRestRequestServiceFactoryWithBadInputTest() throws Exception {
// dud properties. server should pick up defaults
Properties properties = new Properties();
VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
ClusterMap clusterMap = new MockClusterMap();
Router router = new InMemoryRouter(verifiableProperties, clusterMap);
AccountService accountService = new InMemAccountService(false, true);
// VerifiableProperties null.
try {
new FrontendRestRequestServiceFactory(null, clusterMap, router, accountService);
fail("Instantiation should have failed because VerifiableProperties was null");
} catch (NullPointerException e) {
// expected. Nothing to do.
}
// ClusterMap null.
try {
new FrontendRestRequestServiceFactory(verifiableProperties, null, router, accountService);
fail("Instantiation should have failed because ClusterMap was null");
} catch (NullPointerException e) {
// expected. Nothing to do.
}
// Router null.
try {
new FrontendRestRequestServiceFactory(verifiableProperties, clusterMap, null, accountService);
fail("Instantiation should have failed because Router was null");
} catch (NullPointerException e) {
// expected. Nothing to do.
}
// AccountService null.
try {
new FrontendRestRequestServiceFactory(verifiableProperties, clusterMap, router, null);
fail("Instantiation should have failed because AccountService was null");
} catch (NullPointerException e) {
// expected. Nothing to do.
}
}
use of com.github.ambry.router.InMemoryRouter in project ambry by linkedin.
the class BadRestRequest method startRequestResponseHandler.
/**
* Sets up all the tests by providing a started {@link AsyncRequestResponseHandler} for their use.
* @throws InstantiationException
* @throws IOException
*/
@BeforeClass
public static void startRequestResponseHandler() throws InstantiationException, IOException {
verifiableProperties = new VerifiableProperties(new Properties());
router = new InMemoryRouter(verifiableProperties, new MockClusterMap());
restRequestService = new MockRestRequestService(verifiableProperties, router);
asyncRequestResponseHandler = new AsyncRequestResponseHandler(new RequestResponseHandlerMetrics(new MetricRegistry()), 5, restRequestService);
restRequestService.setupResponseHandler(asyncRequestResponseHandler);
restRequestService.start();
asyncRequestResponseHandler.start();
}
use of com.github.ambry.router.InMemoryRouter in project ambry by linkedin.
the class AsyncRequestResponseHandlerFactoryTest method getAsyncRequestResponseHandlerTest.
/**
* Tests the instantiation of an {@link AsyncRequestResponseHandler} instance through the
* {@link AsyncRequestResponseHandlerFactory}.
* @throws InstantiationException
*/
@Test
public void getAsyncRequestResponseHandlerTest() throws InstantiationException, IOException {
Properties properties = new Properties();
VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
Router router = new InMemoryRouter(verifiableProperties, new MockClusterMap());
RestRequestService restRequestService = new MockRestRequestService(verifiableProperties, router);
AsyncRequestResponseHandlerFactory handlerFactory = new AsyncRequestResponseHandlerFactory(1, new MetricRegistry(), restRequestService);
// Get response handler.
RestResponseHandler restResponseHandler = handlerFactory.getRestResponseHandler();
assertNotNull("No RestResponseHandler returned", restResponseHandler);
assertEquals("Did not receive an AsyncRequestResponseHandler instance", AsyncRequestResponseHandler.class.getCanonicalName(), restResponseHandler.getClass().getCanonicalName());
// Get request handler.
RestRequestHandler restRequestHandler = handlerFactory.getRestRequestHandler();
assertNotNull("No RestRequestHandler returned", restRequestHandler);
assertEquals("Did not receive an AsyncRequestResponseHandler instance", AsyncRequestResponseHandler.class.getCanonicalName(), restRequestHandler.getClass().getCanonicalName());
// make sure they are same instance
assertEquals("Instances of AsyncRequestResponseHandler are not the same", restResponseHandler, restRequestHandler);
// make sure the instance starts and shuts down OK.
restRequestHandler.start();
restRequestHandler.shutdown();
}
use of com.github.ambry.router.InMemoryRouter 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());
}
Aggregations