Search in sources :

Example 26 with VerifiableProperties

use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.

the class TestUtils method getDummyConfig.

/**
 * For use when the the actual values in {@link ClusterMapConfig} are unimportant.
 * @return a {@link ClusterMapConfig} with some default values.
 */
static ClusterMapConfig getDummyConfig() {
    Properties props = new Properties();
    props.setProperty("clustermap.host.name", "localhost");
    props.setProperty("clustermap.cluster.name", "cluster");
    props.setProperty("clustermap.datacenter.name", "");
    return new ClusterMapConfig(new VerifiableProperties(props));
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig)

Example 27 with VerifiableProperties

use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.

the class CommonTestUtils method getCurrentBlobIdVersion.

/**
 * Get the current active blob id version via {@link RouterConfig}
 * @return the current active blob id version.
 */
public static short getCurrentBlobIdVersion() {
    Properties props = new Properties();
    props.setProperty("router.hostname", "localhost");
    props.setProperty("router.datacenter.name", "localDC");
    return new RouterConfig(new VerifiableProperties(props)).routerBlobidCurrentVersion;
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RouterConfig(com.github.ambry.config.RouterConfig)

Example 28 with VerifiableProperties

use of com.github.ambry.config.VerifiableProperties 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 29 with VerifiableProperties

use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.

the class FrontendTestUrlSigningServiceFactory method runtimeExceptionRouterTest.

/**
 * Checks reactions of all methods in {@link AmbryBlobStorageService} to a {@link Router} that throws
 * {@link RuntimeException}.
 * @throws Exception
 */
@Test
public void runtimeExceptionRouterTest() throws Exception {
    // set InMemoryRouter up to throw RuntimeException
    Properties properties = new Properties();
    properties.setProperty(InMemoryRouter.OPERATION_THROW_EARLY_RUNTIME_EXCEPTION, "true");
    router.setVerifiableProperties(new VerifiableProperties(properties));
    doRuntimeExceptionRouterTest(RestMethod.GET);
    doRuntimeExceptionRouterTest(RestMethod.POST);
    doRuntimeExceptionRouterTest(RestMethod.DELETE);
    doRuntimeExceptionRouterTest(RestMethod.HEAD);
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RestUtilsTest(com.github.ambry.rest.RestUtilsTest) UtilsTest(com.github.ambry.utils.UtilsTest) Test(org.junit.Test)

Example 30 with VerifiableProperties

use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.

the class AmbrySecurityServiceFactoryTest method getAmbrySecurityServiceFactoryTest.

/**
 * Tests intantiation of {@link AmbrySecurityServiceFactory}.
 * @throws Exception
 */
@Test
public void getAmbrySecurityServiceFactoryTest() throws Exception {
    SecurityService securityService = new AmbrySecurityServiceFactory(new VerifiableProperties(new Properties()), new MockClusterMap(), null, null, null).getSecurityService();
    Assert.assertNotNull(securityService);
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Test(org.junit.Test)

Aggregations

VerifiableProperties (com.github.ambry.config.VerifiableProperties)137 Properties (java.util.Properties)88 Test (org.junit.Test)71 MetricRegistry (com.codahale.metrics.MetricRegistry)42 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)40 BlobProperties (com.github.ambry.messageformat.BlobProperties)35 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)25 StoreConfig (com.github.ambry.config.StoreConfig)25 ArrayList (java.util.ArrayList)25 ClusterMap (com.github.ambry.clustermap.ClusterMap)24 IOException (java.io.IOException)21 LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)20 RouterConfig (com.github.ambry.config.RouterConfig)18 CountDownLatch (java.util.concurrent.CountDownLatch)18 ClusterAgentsFactory (com.github.ambry.clustermap.ClusterAgentsFactory)15 MockTime (com.github.ambry.utils.MockTime)14 BlobId (com.github.ambry.commons.BlobId)13 HashMap (java.util.HashMap)12 File (java.io.File)11 AtomicReference (java.util.concurrent.atomic.AtomicReference)11