Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Sklyut2011-03-25 10:20:30 -0400
committerDmitry Sklyut2011-03-25 10:20:30 -0400
commitd5ef0fd2e551bb9357debcd1861a783fb01ad9bd (patch)
treea3118fa9f903455b9aeb9c000dc8755571f0e11d
parent8de113afa32e7c7d0d19d3e32edc0602eae47055 (diff)
downloadorg.eclipse.virgo.kernel-bug325735-manager-service-factory.tar.gz
org.eclipse.virgo.kernel-bug325735-manager-service-factory.tar.xz
org.eclipse.virgo.kernel-bug325735-manager-service-factory.zip
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/FactoryConfigurationDeploymentTests.java58
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanFactoryConfigurationDeploymentTests.java57
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/config/ConfigLookupKeyHidingConfigurationPlugin.java41
3 files changed, 114 insertions, 42 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/FactoryConfigurationDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/FactoryConfigurationDeploymentTests.java
index d4f76d39..d55615c8 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/FactoryConfigurationDeploymentTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/FactoryConfigurationDeploymentTests.java
@@ -40,7 +40,7 @@ import org.osgi.service.cm.ManagedServiceFactory;
/**
* Tests for Configuration artifacts that support ManagedServiceFactory
- *
+ *
*/
public class FactoryConfigurationDeploymentTests extends AbstractDeployerIntegrationTest {
@@ -360,4 +360,60 @@ public class FactoryConfigurationDeploymentTests extends AbstractDeployerIntegra
}
}
}
+
+ @Test
+ public void testChangeFactoryPidInExistingFile() throws Exception {
+ final String factoryPid = "test.factory.pid.hot.samefile";
+
+ final Properties configOne = new Properties();
+ configOne.setProperty(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid);
+ configOne.setProperty("prop1", "prop1");
+ configOne.setProperty("prop2", "1");
+
+ final Properties configTwo = new Properties();
+ configTwo.setProperty(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid + ".1");
+ configTwo.setProperty("prop1", "prop2");
+ configTwo.setProperty("prop2", "2");
+
+ final File target = new File("target/pickup/testChangeFactoryPidInExistingFile.properties");
+
+ if (target.exists()) {
+ assertTrue(target.delete());
+ }
+
+ try {
+
+ Hashtable<String, String> properties = new Hashtable<String, String>();
+ properties.put(Constants.SERVICE_PID, factoryPid);
+ TestManagedServiceFactory service = new TestManagedServiceFactory();
+ this.context.registerService(ManagedServiceFactory.class, service, properties);
+
+ // make sure that we are starting off with a clean slate
+ assertEquals(0, countFactoryConfigurations(this.configAdmin, factoryPid));
+
+ // copy file to hot deploy location
+ configOne.store(new FileOutputStream(target), "initial");
+
+ pollUntilFactoryInConfigurationAdmin(this.configAdmin, factoryPid);
+ // let events propagate
+ Thread.sleep(1000);
+ assertEquals(1, countFactoryConfigurations(this.configAdmin, factoryPid));
+ assertEquals(1, service.updateCount());
+ assertEquals(0, service.deleteCount());
+
+ // update with a different factoryPid -- should fail deployment.
+ configTwo.store(new FileOutputStream(target), "updated factorypid");
+ Thread.sleep(3000);
+ assertEquals(1, countFactoryConfigurations(this.configAdmin, factoryPid));
+ assertEquals(0, countFactoryConfigurations(this.configAdmin, factoryPid + ".1"));
+ // change to the existing file in hot deploy will not change the pid of the factory.
+ assertEquals(2, service.updateCount());
+ assertEquals(0, service.deleteCount());
+
+ } finally {
+ if (target.exists()) {
+ target.delete();
+ }
+ }
+ }
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanFactoryConfigurationDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanFactoryConfigurationDeploymentTests.java
index 2d4da9ce..f0d54e83 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanFactoryConfigurationDeploymentTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanFactoryConfigurationDeploymentTests.java
@@ -253,4 +253,61 @@ public class PlanFactoryConfigurationDeploymentTests extends AbstractDeployerInt
registration.unregister();
}
+
+ @Test
+ public void validateRefreshOfScopedPlan() throws Exception {
+
+ TestManagedServiceFactory service = new TestManagedServiceFactory();
+ Hashtable<String, String> properties = new Hashtable<String, String>();
+ properties.put(Constants.SERVICE_PID, factoryPid);
+ ServiceRegistration<ManagedServiceFactory> registration = this.context.registerService(ManagedServiceFactory.class, service, properties);
+
+ // let repository indexing complete
+ Thread.sleep(2000);
+
+ // deploy the plan
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(new File(
+ "src/test/resources/configuration.deployment/scoped.factory.config.plan").toURI());
+ assertNotNull(deploymentIdentity);
+
+ // let config admin events propagate
+ Thread.sleep(300);
+
+ // this will fail if factory or configurations got scoped as BSN/PID will change.
+ int factoryConfigCount = countFactoryConfigurations(this.configAdmin, factoryPid);
+ assertEquals(2, factoryConfigCount);
+
+ // check managed service factory for update events
+ assertEquals(2, service.updateCount());
+ assertEquals(2, service.getProperties().size());
+
+ // refresh or deploy again - causes undeploy/deploy
+ this.appDeployer.deploy(new File("src/test/resources/configuration.deployment/scoped.factory.config.plan").toURI());
+
+ // let config admin events propagate
+ Thread.sleep(300);
+
+ factoryConfigCount = countFactoryConfigurations(this.configAdmin, factoryPid);
+ assertEquals(2, factoryConfigCount);
+
+ // check managed service factory on delete count
+ assertEquals(2, service.deleteCount());
+ assertEquals(4, service.updateCount());
+ assertEquals(2, service.getProperties().size());
+
+ this.appDeployer.undeploy(deploymentIdentity);
+
+ // let config admin events propagate
+ Thread.sleep(300);
+
+ factoryConfigCount = countFactoryConfigurations(this.configAdmin, factoryPid);
+ assertEquals(0, factoryConfigCount);
+
+ // check managed service factory on delete count
+ assertEquals(4, service.deleteCount());
+ assertEquals(4, service.updateCount());
+ assertEquals(0, service.getProperties().size());
+
+ registration.unregister();
+ }
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/config/ConfigLookupKeyHidingConfigurationPlugin.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/config/ConfigLookupKeyHidingConfigurationPlugin.java
deleted file mode 100644
index b26c2c84..00000000
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/config/ConfigLookupKeyHidingConfigurationPlugin.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 Chariot Solutions, LLC
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * dsklyut - initial contribution
- */
-
-package org.eclipse.virgo.kernel.install.artifact.internal.config;
-
-import java.util.Dictionary;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationPlugin;
-
-
-/**
- * This plugin is used to hide {@link ConfigLifecycleEngine#ARTIFACT_ID_PRIVATE_PROPERTY} from target of configuration.
- * <p />
- * That property is used internally by container and should not be visible to the configuration target.
- * This is only applicable to targets that are of type {@link org.osgi.service.cm.ManagedService} or {@link org.osgi.service.cm.ManagedServiceFactory}
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread Safe
- */
-public class ConfigLookupKeyHidingConfigurationPlugin implements ConfigurationPlugin {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
- properties.remove(ConfigLifecycleEngine.ARTIFACT_ID_PRIVATE_PROPERTY);
- }
-
-}

Back to the top