use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveAttributeCase.
@Test
public void testResolveAttributeCase() 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.FabricService in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveCurrentName.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testResolveCurrentName() throws Exception {
final FabricService fabricService = createMock(FabricService.class);
final DataStore dataStore = createMock(DataStore.class);
expect(fabricService.getCurrentContainerName()).andReturn("root").anyTimes();
expect(fabricService.getContainer(EasyMock.<String>anyObject())).andReturn(new ContainerImpl(null, "root", fabricService));
replay(fabricService);
replay(dataStore);
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals("root", resolver.resolve(fabricService, null, null, null, "container:name"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class EncryptedPropertyResolverTest method testResolve.
@Test
public void testResolve() throws Exception {
CuratorFramework curator = createMock(CuratorFramework.class);
GetDataBuilder getDataBuilder = createMock(GetDataBuilder.class);
expect(curator.getData()).andReturn(getDataBuilder).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_ALGORITHM.getPath())).andReturn("PBEWithMD5AndDES".getBytes()).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_PASSWORD.getPath())).andReturn("mypassword".getBytes()).anyTimes();
replay(curator);
replay(getDataBuilder);
FabricService fabricService = createMock(FabricService.class);
expect(fabricService.adapt(CuratorFramework.class)).andReturn(curator).anyTimes();
replay(fabricService);
PlaceholderResolver resolver = getEncryptedPropertyResolver();
assertEquals("encryptedpassword", resolver.resolve(fabricService, null, null, null, "crypt:URdoo9++D3tsoC9ODrTfLNK5WzviknO3Ig6qbI2HuvQ="));
verify(curator);
verify(getDataBuilder);
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class EncryptedPropertyResolverTest method testResolveZkEnc.
@Test
public void testResolveZkEnc() throws Exception {
CuratorFramework curator = createMock(CuratorFramework.class);
GetDataBuilder getDataBuilder = createMock(GetDataBuilder.class);
expect(curator.getData()).andReturn(getDataBuilder).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_ALGORITHM.getPath())).andReturn("PBEWithMD5AndDES".getBytes()).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_PASSWORD.getPath())).andReturn("ZKENC=bXlwYXNzd29yZA==".getBytes()).anyTimes();
replay(curator);
replay(getDataBuilder);
FabricService fabricService = createMock(FabricService.class);
expect(fabricService.adapt(CuratorFramework.class)).andReturn(curator).anyTimes();
replay(fabricService);
PlaceholderResolver resolver = getEncryptedPropertyResolver();
assertEquals("encryptedpassword", resolver.resolve(fabricService, null, null, null, "crypt:URdoo9++D3tsoC9ODrTfLNK5WzviknO3Ig6qbI2HuvQ="));
verify(curator);
verify(getDataBuilder);
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class AutoScalers method requirementsSatisfied.
/**
* Returns true if the requirements are satisfied for the given profile requirements; updating the auto scale status
* accordingly
*/
public static boolean requirementsSatisfied(FabricService service, String version, FabricRequirements requirements, ProfileRequirements profileRequirement, AutoScaleStatus status) {
String profile = profileRequirement.getProfile();
List<String> dependentProfiles = profileRequirement.getDependentProfiles();
if (dependentProfiles != null) {
for (String dependentProfile : dependentProfiles) {
ProfileRequirements dependentProfileRequirements = requirements.getOrCreateProfileRequirement(dependentProfile);
Integer minimumInstances = dependentProfileRequirements.getMinimumInstances();
if (minimumInstances != null) {
List<Container> containers = Containers.aliveAndSuccessfulContainersForProfile(version, dependentProfile, service);
int dependentSize = containers.size();
if (minimumInstances > dependentSize) {
status.profileStatus(profile).missingDependency(dependentProfile, dependentSize, minimumInstances);
return false;
}
}
}
}
return true;
}
Aggregations