use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class DeployToProfileMojo method uploadRequirements.
protected DeployResults uploadRequirements(J4pClient client, ProjectRequirements requirements) throws Exception {
String json = DtoHelper.getMapper().writeValueAsString(requirements);
ObjectName mbeanName = ProjectDeployerImpl.OBJECT_NAME;
getLog().info("Updating " + (requirements.isAbstractProfile() ? "abstract " : "") + "profile: " + requirements.getProfileId() + " with parent profile(s): " + requirements.getParentProfiles() + (requirements.isUseResolver() ? " using OSGi resolver" : "") + (requirements.isLocked() ? " locked" : ""));
getLog().info("About to invoke mbean " + mbeanName + " on jolokia URL: " + jolokiaUrl + " with user: " + fabricServer.getUsername());
getLog().debug("JSON: " + json);
try {
// Append bundles to existing profile bundles if we're not running the plugin at project root
Boolean appendBundles = !mavenSession.getExecutionRootDirectory().equalsIgnoreCase(project.getBasedir().toString());
J4pExecRequest request = new J4pExecRequest(mbeanName, "deployProjectJsonMergeOption(java.lang.String,boolean)", json, appendBundles);
J4pResponse<J4pExecRequest> response = client.execute(request, "POST");
Object value = response.getValue();
if (value == null) {
return null;
} else {
DeployResults answer = DtoHelper.getMapper().reader(DeployResults.class).readValue(value.toString());
if (answer != null) {
String profileUrl = answer.getProfileUrl();
if (profileUrl != null) {
getLog().info("");
getLog().info("Profile page: " + profileUrl);
getLog().info("");
} else {
getLog().info("Result: " + answer);
}
} else {
getLog().info("Result: " + value);
}
return answer;
}
} catch (J4pRemoteException e) {
if (e.getMessage().contains(".InstanceNotFoundException")) {
throw new MojoExecutionException("Could not find the mbean " + mbeanName + " in the JVM for " + jolokiaUrl + ". Are you sure this JVM is running the Fabric8 console?");
} else {
getLog().error("Failed to invoke mbean " + mbeanName + " on jolokia URL: " + jolokiaUrl + " with user: " + fabricServer.getUsername() + ". Error: " + e.getErrorType());
getLog().error("Stack: " + e.getRemoteStackTrace());
throw e;
}
}
}
use of io.fabric8.patch.management.conflicts.Resolver 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.patch.management.conflicts.Resolver 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.patch.management.conflicts.Resolver 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.patch.management.conflicts.Resolver 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);
}
Aggregations