You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/03/15 10:38:50 UTC
svn commit: r386018 - in /incubator/servicemix/trunk/servicemix-core/src:
main/java/org/apache/servicemix/jbi/container/
main/java/org/apache/servicemix/jbi/framework/
test/java/org/apache/servicemix/jbi/installation/
Author: gnodet
Date: Wed Mar 15 01:38:48 2006
New Revision: 386018
URL: http://svn.apache.org/viewcvs?rev=386018&view=rev
Log:
Fix problem when deleting component install dir at uninstallation time
Modified:
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/InstallationTest.java
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java?rev=386018&r1=386017&r2=386018&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java Wed Mar 15 01:38:48 2006
@@ -506,15 +506,6 @@
}
else {
log.info("Removed directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
- File parent = file.getParentFile();
- if (parent.list().length == 0) {
- if (!FileUtil.deleteFile(parent)) {
- log.warn("Failed to remove root directory for component: " + componentName);
- }
- else {
- log.info("Removed root directory structure for component: " + componentName);
- }
- }
}
}
}
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java?rev=386018&r1=386017&r2=386018&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java Wed Mar 15 01:38:48 2006
@@ -188,6 +188,8 @@
* @throws javax.jbi.JBIException if the uninstallation fails.
*/
public void uninstall() throws javax.jbi.JBIException {
+ // TODO: check component status
+ // the component must not be started and not have any SUs deployed
if (!installed) {
throw new DeploymentException("Component is not installed");
}
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/InstallationTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/InstallationTest.java?rev=386018&r1=386017&r2=386018&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/InstallationTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/InstallationTest.java Wed Mar 15 01:38:48 2006
@@ -358,4 +358,90 @@
componentMock.verify();
}
+ /**
+ * Installer is created, component installed, uninstalled and reinstalled
+ * @throws Exception
+ */
+ public void testInstallAndReinstall() throws Exception {
+ // Create mocks
+ ExtMockControl bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
+ Bootstrap bootstrap = (Bootstrap) bootstrapMock.getMock();
+ Bootstrap1.setDelegate(bootstrap);
+ ExtMockControl componentMock = ExtMockControl.createControl(Component.class);
+ Component component = (Component) componentMock.getMock();
+ Component1.setDelegate(component);
+
+ // configure bootstrap
+ bootstrapMock.reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ bootstrapMock.replay();
+ // configure component
+ componentMock.reset();
+ componentMock.replay();
+ // test component installation
+ startContainer(true);
+ String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
+ ObjectName installerName = getInstallationService().loadNewInstaller(installJarUrl);
+ InstallerMBean installer = (InstallerMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), installerName, InstallerMBean.class, false);
+ assertFalse(installer.isInstalled());
+ ObjectName lifecycleName = installer.install();
+ LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
+ assertEquals(LifeCycleMBean.SHUTDOWN, lifecycleMBean.getCurrentState());
+ // check mocks
+ bootstrapMock.verify();
+ componentMock.verify();
+
+ // configure bootstrap
+ bootstrapMock.reset();
+ bootstrap.onUninstall();
+ bootstrap.cleanUp();
+ bootstrapMock.replay();
+ // configure component
+ componentMock.reset();
+ componentMock.replay();
+ // unload installer
+ container.getInstallationService().unloadInstaller("component1", true);
+ // check mocks
+ bootstrapMock.verify();
+ componentMock.verify();
+
+ // configure bootstrap
+ bootstrapMock.reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ bootstrapMock.replay();
+ // configure component
+ componentMock.reset();
+ componentMock.replay();
+ // test component installation
+ startContainer(true);
+ installJarUrl = createInstallerArchive("component1").getAbsolutePath();
+ installerName = getInstallationService().loadNewInstaller(installJarUrl);
+ installer = (InstallerMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), installerName, InstallerMBean.class, false);
+ assertFalse(installer.isInstalled());
+ lifecycleName = installer.install();
+ lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
+ assertEquals(LifeCycleMBean.SHUTDOWN, lifecycleMBean.getCurrentState());
+ // check mocks
+ bootstrapMock.verify();
+ componentMock.verify();
+
+ // configure bootstrap
+ bootstrapMock.reset();
+ bootstrapMock.replay();
+ // configure component
+ componentMock.reset();
+ componentMock.replay();
+ // shutdown container
+ shutdownContainer();
+ // check mocks
+ bootstrapMock.verify();
+ componentMock.verify();
+ }
+
}