use of io.fabric8.api.DataStore in project fabric8 by jboss-fuse.
the class ContainerImplTest method testGetContainerProfileOverlay.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testGetContainerProfileOverlay() throws Exception {
String v = "1.0";
String defaultProfile = "default";
String camelProfile = "feature-camel";
String cxfProfile = "feature-cxf";
// new VersionImpl(v, fabricService);
Version version = null;
List<String> profiles = Arrays.asList(camelProfile, cxfProfile);
Map<String, String> defaultAttributes = new HashMap<String, String>();
Map<String, String> camelAttributes = new HashMap<String, String>();
Map<String, String> cxfAttributes = new HashMap<String, String>();
Map<String, byte[]> defaultFiles = new HashMap<String, byte[]>();
Map<String, byte[]> camelFiles = new HashMap<String, byte[]>();
Map<String, byte[]> cxfFiles = new HashMap<String, byte[]>();
Map<String, Map<String, String>> defaultPids = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> camelPids = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> cxfPids = new HashMap<String, Map<String, String>>();
camelAttributes.put("attribute." + Profile.PARENTS, "default");
cxfAttributes.put("attribute." + Profile.PARENTS, "feature-camel");
defaultFiles.put("test1.properties", "key=fromDefault".getBytes());
camelFiles.put("test1.properties", "key=fromCamel".getBytes());
cxfFiles.put("test2.properties", "key=fromCxf".getBytes());
expect(fabricService.getEnvironment()).andReturn("").anyTimes();
expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
// Define Attributes
// expect(profileRegistry.getProfileAttributes(eq(v), eq(defaultProfile))).andReturn(defaultAttributes).anyTimes();
// expect(profileRegistry.getProfileAttributes(eq(v), eq(camelProfile))).andReturn(camelAttributes).anyTimes();
// expect(profileRegistry.getProfileAttributes(eq(v), eq(cxfProfile))).andReturn(cxfAttributes).anyTimes();
// Define Files
// expect(profileRegistry.getFileConfigurations(eq(v), eq(defaultProfile))).andReturn(defaultFiles).anyTimes();
// expect(profileRegistry.getFileConfigurations(eq(v), eq(camelProfile))).andReturn(camelFiles).anyTimes();
// expect(profileRegistry.getFileConfigurations(eq(v), eq(cxfProfile))).andReturn(cxfFiles).anyTimes();
// Define PIDS
// expect(profileRegistry.getConfigurations(eq(v), eq(defaultProfile))).andReturn(defaultPids).anyTimes();
// expect(profileRegistry.getConfigurations(eq(v), eq(camelProfile))).andReturn(camelPids).anyTimes();
// expect(profileRegistry.getConfigurations(eq(v), eq(cxfProfile))).andReturn(cxfPids).anyTimes();
fabricService.substituteConfigurations((Map<String, Map<String, String>>) anyObject());
expectLastCall().anyTimes();
expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
expect(profileRegistry.hasProfile(v, camelProfile)).andReturn(true).anyTimes();
expect(profileRegistry.hasProfile(v, cxfProfile)).andReturn(true).anyTimes();
replay(fabricService);
replay(dataStore);
Map<String, Map<String, String>> configs = container.getOverlayProfile().getConfigurations();
assertNotNull(configs);
assertEquals(2, configs.size());
assertNotNull(configs.get("test1"));
assertEquals(1, configs.get("test1").size());
assertEquals("fromCamel", configs.get("test1").get("key"));
assertNotNull(configs.get("test2"));
assertEquals(1, configs.get("test2").size());
assertEquals("fromCxf", configs.get("test2").get("key"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.api.DataStore in project fabric8 by jboss-fuse.
the class ContainerImplTest method testContainerProfileWithMissingParents.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testContainerProfileWithMissingParents() throws Exception {
String v = "1.0";
String profile1Id = "feature-camel";
String profile2Id = "feature-cxf";
String missing = "missing";
// new VersionImpl(v, fabricService);
Version version = null;
List<String> profiles = Arrays.asList(profile1Id, profile2Id, missing);
expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
expect(fabricService.getEnvironment()).andReturn("").anyTimes();
expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
expect(profileRegistry.hasProfile(v, profile1Id)).andReturn(true).anyTimes();
expect(profileRegistry.hasProfile(v, profile2Id)).andReturn(true).anyTimes();
expect(profileRegistry.hasProfile(v, missing)).andReturn(false).anyTimes();
// expect(profileRegistry.getProfileAttributes(eq(v), EasyMock.<String>anyObject())).andReturn(Maps.<String, String>newHashMap()).anyTimes();
replay(fabricService);
replay(dataStore);
Profile overlay = container.getOverlayProfile();
List<String> parents = overlay.getParentIds();
assertEquals(2, parents.size());
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.api.DataStore in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method setUp.
@Before
public void setUp() {
fabricService = createMock(FabricService.class);
dataStore = createMock(DataStore.class);
expect(fabricService.getCurrentContainerName()).andReturn("root").anyTimes();
expect(fabricService.adapt(DataStore.class)).andReturn(dataStore).anyTimes();
expect(fabricService.getContainer(EasyMock.<String>anyObject())).andStubAnswer(new IAnswer<Container>() {
@Override
public Container answer() throws Throwable {
return new ContainerImpl(null, (String) EasyMock.getCurrentArguments()[0], fabricService);
}
});
expect(dataStore.getContainerAttribute(eq("root"), eq(DataStore.ContainerAttribute.Ip), eq(""), eq(false), eq(true))).andReturn(ip).anyTimes();
expect(dataStore.getContainerAttribute(eq("root"), eq(DataStore.ContainerAttribute.LocalHostName), eq(""), eq(false), eq(true))).andReturn(localhostname).anyTimes();
expect(dataStore.getContainerAttribute(eq("root"), eq(DataStore.ContainerAttribute.BindAddress), eq(""), eq(false), eq(true))).andReturn(bindaddress).anyTimes();
expect(dataStore.getContainerAttribute(eq("root"), eq(DataStore.ContainerAttribute.Resolver), eq(""), eq(false), eq(true))).andReturn(containerResolver).anyTimes();
replay(fabricService);
replay(dataStore);
}
use of io.fabric8.api.DataStore in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveNameContainerAttributes.
@Test
public void testResolveNameContainerAttributes() throws Exception {
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals(ip, resolver.resolve(fabricService, null, null, null, "container:root/ip"));
assertEquals(localhostname, resolver.resolve(fabricService, null, null, null, "container:root/localhostname"));
assertEquals(bindaddress, resolver.resolve(fabricService, null, null, null, "container:root/bindaddress"));
assertEquals(containerResolver, resolver.resolve(fabricService, null, null, null, "container:root/resolver"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.api.DataStore in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveCurrentAttributes.
@Test
public void testResolveCurrentAttributes() throws Exception {
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals(ip, resolver.resolve(fabricService, null, null, null, "container:ip"));
assertEquals(localhostname, resolver.resolve(fabricService, null, null, null, "container:localhostname"));
assertEquals(bindaddress, resolver.resolve(fabricService, null, null, null, "container:bindaddress"));
assertEquals(containerResolver, resolver.resolve(fabricService, null, null, null, "container:resolver"));
verify(fabricService);
verify(dataStore);
}
Aggregations