Skip to content

Commit

Permalink
artifactId extracted from feature name
Browse files Browse the repository at this point in the history
  • Loading branch information
jlolling committed Aug 22, 2017
1 parent fca766d commit a6ea1f8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<groupId>de.jlo.karaf.jmx</groupId>
<artifactId>jlo-karaf-jmx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>jlo-karaf-jmx</name>
Expand All @@ -22,4 +21,5 @@
<scope>test</scope>
</dependency>
</dependencies>
<version>1.0</version>
</project>
11 changes: 11 additions & 0 deletions src/main/java/de/jlo/karaf/jmx/ServiceFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class ServiceFeature {

private String featureName;
private String artifactId = null;
private String version;
private boolean isInstalled = false;
private String bundles = null;
Expand All @@ -14,6 +15,12 @@ private ServiceFeature() {}
public static ServiceFeature from(CompositeData cd) {
ServiceFeature f = new ServiceFeature();
f.featureName = (String) cd.get("Name");
int pos = f.featureName.indexOf("-feature");
if (pos > 0) {
f.artifactId = f.featureName.substring(0, pos);
} else {
f.artifactId = f.featureName;
}
f.version = (String) cd.get("Version");
f.isInstalled = (Boolean) cd.get("Installed");
f.bundles = getStringArrayAsString((String[]) cd.get("Bundles"));
Expand Down Expand Up @@ -64,4 +71,8 @@ public String toString() {
return sb.toString();
}

public String getArtifactId() {
return artifactId;
}

}
47 changes: 22 additions & 25 deletions src/test/java/de/jlo/karaf/jmx/TestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

import java.lang.management.MemoryUsage;
import java.util.List;
import java.util.Set;

import javax.management.ObjectInstance;

import org.junit.Test;

Expand Down Expand Up @@ -49,13 +46,13 @@ public void testListFeatures() throws Exception {
KarafDeployer d = new KarafDeployer(c);
List<ServiceFeature> list = d.fetchFeatures("_service_", true);
for (ServiceFeature f : list) {
System.out.println(f + "\n");
System.out.println(f.getArtifactId() + " - " + f.getVersion() + "\n");
}
}

@Test
public void testInstallFeature() throws Exception {
String host = "talendjob02.gvl.local";
String host = "talendjobtest01.gvl.local";
int jmxPort = 44444;
int jstatdPort = 1099;
String karafInstance = "trun";
Expand Down Expand Up @@ -89,7 +86,7 @@ public void testInstallFeature() throws Exception {

@Test
public void testInstallTalendService() throws Exception {
String host = "talendjob02.gvl.local";
String host = "talendjobtest01.gvl.local";
int jmxPort = 44444;
int jstatdPort = 1099;
String karafInstance = "trun";
Expand All @@ -106,24 +103,24 @@ public void testInstallTalendService() throws Exception {
d.installTalendService("de.gvl","navi_service_uploaded_files", "26.17.0");
}

@Test
public void testQueryObjectNames() throws Exception {
String host = "talendjobtest01.gvl.local";
int jmxPort = 44444;
int jstatdPort = 1099;
String karafInstance = "trun";
String user = "karaf";
String passwd = "karaf";
KarafClient c = new KarafClient();
c.setJmxUser(user);
c.setJmxPassword(passwd);
c.setKarafRemoteJmxUrl(host, jmxPort, karafInstance, jstatdPort);
c.connect();
Set<ObjectInstance> result = c.getmBeanServerConnection().queryMBeans(null /*new ObjectName("org.apache.cxf.bus.id=*")*/, null);
for (ObjectInstance n : result) {
System.out.println(n.toString());
}

}
// @Test
// public void testQueryObjectNames() throws Exception {
// String host = "talendjobtest01.gvl.local";
// int jmxPort = 44444;
// int jstatdPort = 1099;
// String karafInstance = "trun";
// String user = "karaf";
// String passwd = "karaf";
// KarafClient c = new KarafClient();
// c.setJmxUser(user);
// c.setJmxPassword(passwd);
// c.setKarafRemoteJmxUrl(host, jmxPort, karafInstance, jstatdPort);
// c.connect();
// Set<ObjectInstance> result = c.getmBeanServerConnection().queryMBeans(null /*new ObjectName("org.apache.cxf.bus.id=*")*/, null);
// for (ObjectInstance n : result) {
// System.out.println(n.toString());
// }
//
// }

}

0 comments on commit a6ea1f8

Please sign in to comment.