Search in sources :

Example 1 with PropertyWithDeploymentContext

use of com.netflix.config.PropertyWithDeploymentContext in project archaius by Netflix.

the class DynamoDbDeploymentContextConfigurationSourceTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    propCollection1 = new LinkedList<PropertyWithDeploymentContext>();
    propCollection1.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "foo", "bar"));
    propCollection1.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "goo", "goo"));
    propCollection1.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "boo", "who"));
    propCollection2 = new LinkedList<PropertyWithDeploymentContext>();
    propCollection2.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "foo", "bar"));
    propCollection2.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "goo", "boo"));
    propCollection2.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "prod", "goo", "foo"));
    propCollection2.add(new PropertyWithDeploymentContext(DeploymentContext.ContextKey.environment, "test", "boo", "who"));
    ConfigurationManager.getConfigInstance().setProperty(ConfigurationBasedDeploymentContext.DEPLOYMENT_ENVIRONMENT_PROPERTY, "test");
}
Also used : PropertyWithDeploymentContext(com.netflix.config.PropertyWithDeploymentContext) BeforeClass(org.junit.BeforeClass)

Example 2 with PropertyWithDeploymentContext

use of com.netflix.config.PropertyWithDeploymentContext in project archaius by Netflix.

the class DynamoDbDeploymentContextTableCacheTest method testPoll.

@Test
public void testPoll() throws Exception {
    AmazonDynamoDB mockContextDbClient = mock(AmazonDynamoDB.class);
    when(mockContextDbClient.scan(any(ScanRequest.class))).thenReturn(DynamoDbMocks.contextScanResult1, DynamoDbMocks.contextScanResult2);
    DynamoDbDeploymentContextTableCache cache = new DynamoDbDeploymentContextTableCache(mockContextDbClient, 100, 100);
    Collection<PropertyWithDeploymentContext> props = cache.getProperties();
    assertEquals(4, props.size());
    assertTrue(props.contains(test1));
    assertTrue(props.contains(test2));
    assertTrue(props.contains(test5));
    assertTrue(props.contains(test6));
    Thread.sleep(150);
    props = cache.getProperties();
    assertEquals(5, props.size());
    assertTrue(props.contains(test1));
    assertTrue(props.contains(test3));
    assertTrue(props.contains(test4));
    assertTrue(props.contains(test5));
    assertTrue(props.contains(test6));
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) PropertyWithDeploymentContext(com.netflix.config.PropertyWithDeploymentContext) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) Test(org.junit.Test)

Aggregations

PropertyWithDeploymentContext (com.netflix.config.PropertyWithDeploymentContext)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1