use of com.github.ambry.router.InMemoryRouter in project ambry by linkedin.
the class FrontendRestRequestServiceFactoryTest method getFrontendRestRequestServiceTest.
/**
* Tests the instantiation of an {@link FrontendRestRequestService} instance through the
* {@link FrontendRestRequestServiceFactory}.
* @throws Exception
*/
@Test
public void getFrontendRestRequestServiceTest() throws Exception {
// dud properties. server should pick up defaults
JSONObject jsonObject = new JSONObject().put("POST", "http://uploadUrl:15158").put("GET", "http://downloadUrl:15158");
Properties properties = new Properties();
CommonTestUtils.populateRequiredRouterProps(properties);
properties.setProperty(FrontendConfig.URL_SIGNER_ENDPOINTS, jsonObject.toString());
properties.setProperty("clustermap.cluster.name", "Cluster-Name");
properties.setProperty("clustermap.datacenter.name", "Datacenter-Name");
properties.setProperty("clustermap.host.name", "localhost");
VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
FrontendRestRequestServiceFactory frontendRestRequestServiceFactory = new FrontendRestRequestServiceFactory(verifiableProperties, new MockClusterMap(), new InMemoryRouter(verifiableProperties, new MockClusterMap()), new InMemAccountService(false, true));
RestRequestService ambryRestRequestService = frontendRestRequestServiceFactory.getRestRequestService();
assertNotNull("No RestRequestService returned", ambryRestRequestService);
assertEquals("Did not receive an FrontendRestRequestService instance", FrontendRestRequestService.class.getCanonicalName(), ambryRestRequestService.getClass().getCanonicalName());
}
use of com.github.ambry.router.InMemoryRouter in project ambry by linkedin.
the class AsyncRequestResponseHandlerFactoryTest method getFactoryTestWithBadInputTest.
/**
* Tests instantiation of {@link AsyncRequestResponseHandlerFactory} with bad input.
*/
@Test
public void getFactoryTestWithBadInputTest() throws IOException {
VerifiableProperties verifiableProperties = new VerifiableProperties(new Properties());
Router router = new InMemoryRouter(verifiableProperties, new MockClusterMap());
RestRequestService restRequestService = new MockRestRequestService(verifiableProperties, router);
// handlerCount = 0
try {
new AsyncRequestResponseHandlerFactory(0, new MetricRegistry(), restRequestService);
fail("Instantiation should have failed because response handler count is 0");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// handlerCount < 0
try {
new AsyncRequestResponseHandlerFactory(-1, new MetricRegistry(), restRequestService);
fail("Instantiation should have failed because response handler count is less than 0");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// MetricRegistry null.
try {
new AsyncRequestResponseHandlerFactory(1, null, restRequestService);
fail("Instantiation should have failed because one of the arguments was null");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// handlerCount = 0
try {
new AsyncRequestResponseHandlerFactory(0, new MetricRegistry(), restRequestService);
fail("Instantiation should have failed because request handler count is 0");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// handlerCount < 0
try {
new AsyncRequestResponseHandlerFactory(-1, new MetricRegistry(), restRequestService);
fail("Instantiation should have failed because request handler count is less than 0");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// MetricRegistry null.
try {
new AsyncRequestResponseHandlerFactory(1, null, restRequestService);
fail("Instantiation should have failed because one of the arguments was null");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
// RestRequestService null.
try {
new AsyncRequestResponseHandlerFactory(1, new MetricRegistry(), null);
fail("Instantiation should have failed because one of the arguments was null");
} catch (IllegalArgumentException e) {
// expected. Nothing to do.
}
}
Aggregations