Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-10-04 10:24:40 -0400
committerGlyn Normington2011-10-04 10:24:40 -0400
commita279ddb207ea8822c159f5831d1fa471e8c62cbb (patch)
tree6b27ecd2a63f68f14f5f7239638d8d97f506c6d0 /org.eclipse.virgo.kernel.deployer.test/src/test/java
parent7e23f24378d4b9e2ac2c931effb03faab9870049 (diff)
downloadorg.eclipse.virgo.kernel-a279ddb207ea8822c159f5831d1fa471e8c62cbb.tar.gz
org.eclipse.virgo.kernel-a279ddb207ea8822c159f5831d1fa471e8c62cbb.tar.xz
org.eclipse.virgo.kernel-a279ddb207ea8822c159f5831d1fa471e8c62cbb.zip
bug 353996: test configuration in ArtifactModel
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.test/src/test/java')
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JmxArtifactModelTests.java54
1 files changed, 48 insertions, 6 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JmxArtifactModelTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JmxArtifactModelTests.java
index db8cf61d..fd321212 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JmxArtifactModelTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JmxArtifactModelTests.java
@@ -32,16 +32,18 @@ import org.junit.Test;
import org.osgi.framework.ServiceReference;
/**
- * Test deployed artifacts show up correctly on JMX.
+ * Test deployed artifacts show up correctly in JMX, in both the older Model and the newer, region-aware ArtifactModel.
*
*/
public class JmxArtifactModelTests extends AbstractDeployerIntegrationTest {
- private static final String CONFIGURATION_VERSION = "0.0.0";
+ private static final String GLOBAL_USER_REGION = "global";
+
+ private static final String CONFIGURATION_TYPE = "configuration";
private static final String CONFIGURATION_NAME = "t";
- private static final String CONFIGURATION_TYPE = "configuration";
+ private static final String CONFIGURATION_VERSION = "0.0.0";
private ServiceReference<ApplicationDeployer> appDeployerServiceReference;
@@ -62,9 +64,9 @@ public class JmxArtifactModelTests extends AbstractDeployerIntegrationTest {
this.context.ungetService(this.appDeployerServiceReference);
}
}
-
+
@Test
- public void testDeployConfig() throws Exception {
+ public void testConfigModel() throws Exception {
File file = new File("src/test/resources/configuration.deployment/t.properties");
DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(file.toURI());
@@ -73,12 +75,35 @@ public class JmxArtifactModelTests extends AbstractDeployerIntegrationTest {
assertArtifactState(CONFIGURATION_TYPE, CONFIGURATION_NAME, CONFIGURATION_VERSION, "ACTIVE");
- TabularDataSupport attribute = (TabularDataSupport) getMBeanServerConnection().getAttribute(
+ TabularDataSupport attribute = (TabularDataSupport) this.mBeanServerConnection.getAttribute(
getObjectName(CONFIGURATION_TYPE, CONFIGURATION_NAME, CONFIGURATION_VERSION), "Properties");
assertEquals("b", getStringValue(attribute, "a"));
assertEquals("d", getStringValue(attribute, "c"));
+
+ this.appDeployer.undeploy(deploymentIdentity);
}
+ @Test
+ public void testConfigArtifactModel() throws Exception {
+ File file = new File("src/test/resources/configuration.deployment/t.properties");
+
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(file.toURI());
+
+ assertDeploymentIdentityEquals(deploymentIdentity, "t.properties", CONFIGURATION_TYPE, CONFIGURATION_NAME, "0");
+
+ assertArtifactState(GLOBAL_USER_REGION, CONFIGURATION_TYPE, CONFIGURATION_NAME, CONFIGURATION_VERSION, "ACTIVE");
+
+ TabularDataSupport attribute = (TabularDataSupport) this.mBeanServerConnection.getAttribute(
+ getObjectName(GLOBAL_USER_REGION, CONFIGURATION_TYPE, CONFIGURATION_NAME, CONFIGURATION_VERSION), "Properties");
+ assertEquals("b", getStringValue(attribute, "a"));
+ assertEquals("d", getStringValue(attribute, "c"));
+
+ this.appDeployer.undeploy(deploymentIdentity);
+
+ }
+
+ //TODO: test other artefact types
+
private String getStringValue(TabularDataSupport attribute, String key) {
Object[] keys = { key };
CompositeDataSupport cds = (CompositeDataSupport) attribute.get(keys);
@@ -101,6 +126,23 @@ public class JmxArtifactModelTests extends AbstractDeployerIntegrationTest {
return new ObjectName(String.format("org.eclipse.virgo.kernel:type=Model,artifact-type=%s,name=%s,version=%s", type, name, version));
}
+ private void assertArtifactState(String region, String type, String name, String version, String state) throws MalformedObjectNameException,
+ IOException, Exception {
+ assertArtifactExists(region, type, name, version);
+ assertEquals(String.format("Artifact %s:%s:%s:%s is not in state %s", region, type, name, version, state), state,
+ this.mBeanServerConnection.getAttribute(getObjectName(region, type, name, version), "State"));
+ }
+
+ private void assertArtifactExists(String region, String type, String name, String version) throws IOException, Exception, MalformedObjectNameException {
+ assertTrue(String.format("Artifact %s:%s:%s:%s does not exist", region, type, name, version),
+ this.mBeanServerConnection.isRegistered(getObjectName(region, type, name, version)));
+ }
+
+ protected static ObjectName getObjectName(String region, String type, String name, String version) throws MalformedObjectNameException {
+ return new ObjectName(String.format("org.eclipse.virgo.kernel:type=ArtifactModel,region=%s,artifact-type=%s,name=%s,version=%s", region,
+ type, name, version));
+ }
+
private static MBeanServerConnection getMBeanServerConnection() throws Exception {
return ManagementFactory.getPlatformMBeanServer();
}

Back to the top