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/02/08 17:45:26 UTC
svn commit: r375991 - in /incubator/servicemix/trunk/servicemix-core/src:
main/java/org/apache/servicemix/jbi/framework/
test/java/org/apache/servicemix/jbi/installation/
Author: gnodet
Date: Wed Feb 8 08:45:24 2006
New Revision: 375991
URL: http://svn.apache.org/viewcvs?rev=375991&view=rev
Log:
Fix broken installation tests
Modified:
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.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/AbstractManagementTest.java
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.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/framework/InstallationService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?rev=375991&r1=375990&r2=375991&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java Wed Feb 8 08:45:24 2006
@@ -616,9 +616,16 @@
throws DeploymentException {
try {
String componentName = componentDirectory.getName();
- InstallerMBeanImpl installer = createInstaller(componentName);
- installer.activateComponent();
- nonLoadedInstallers.put(componentName, installer);
+ File stateFile = container.getEnvironmentContext().getComponentStateFile(componentName);
+ if (!stateFile.exists()) {
+ // An installer has been created but the component has not been installed
+ // So remove it
+ FileUtil.deleteFile(componentDirectory);
+ } else {
+ InstallerMBeanImpl installer = createInstaller(componentName);
+ installer.activateComponent();
+ nonLoadedInstallers.put(componentName, installer);
+ }
} catch (Throwable e) {
log.error("Failed to deploy component: "
+ componentDirectory.getName(), e);
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=375991&r1=375990&r2=375991&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 Feb 8 08:45:24 2006
@@ -69,40 +69,40 @@
this.bootstrapClassLoader = bootstrapLoader;
this.bootstrapClassName = bootstrapClassName;
this.installed = installed;
- //initialize the bootstrap
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- if (bootstrapLoader != null && bootstrapClassName != null && bootstrapClassName.length() > 0){
-
-
- Class bootstrapClass;
- try {
- bootstrapClass = bootstrapClassLoader.loadClass(bootstrapClassName);
- if (bootstrapClass == null){
- throw new DeploymentException("Could not find bootstrap class: " + bootstrapClassName);
- }
- this.bootstrap = (Bootstrap) bootstrapClass.newInstance();
- this.bootstrap.init(this.context);
- }
- catch (ClassNotFoundException e) {
- log.error("Class not found: " + bootstrapClassName,e);
- throw new DeploymentException(e);
- }
- catch (InstantiationException e) {
- log.error("Could not instantiate : " + bootstrapClassName,e);
- throw new DeploymentException(e);
- }
- catch (IllegalAccessException e) {
- log.error("Illegal access on: " + bootstrapClassName,e);
- throw new DeploymentException(e);
- }
- catch (JBIException e) {
- log.error("Could not initialize : " + bootstrapClassName,e);
- throw new DeploymentException(e);
+ if (!installed) {
+ createBootstrap();
+ }
+ }
+
+ protected void createBootstrap() throws DeploymentException {
+ if (bootstrap == null && bootstrapClassLoader != null && bootstrapClassName != null) {
+ //initialize the bootstrap
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ Class bootstrapClass;
+ try {
+ bootstrapClass = bootstrapClassLoader.loadClass(bootstrapClassName);
+ if (bootstrapClass == null){
+ throw new DeploymentException("Could not find bootstrap class: " + bootstrapClassName);
}
-
-
-
-
+ this.bootstrap = (Bootstrap) bootstrapClass.newInstance();
+ this.bootstrap.init(this.context);
+ }
+ catch (ClassNotFoundException e) {
+ log.error("Class not found: " + bootstrapClassName,e);
+ throw new DeploymentException(e);
+ }
+ catch (InstantiationException e) {
+ log.error("Could not instantiate : " + bootstrapClassName,e);
+ throw new DeploymentException(e);
+ }
+ catch (IllegalAccessException e) {
+ log.error("Illegal access on: " + bootstrapClassName,e);
+ throw new DeploymentException(e);
+ }
+ catch (JBIException e) {
+ log.error("Could not initialize : " + bootstrapClassName,e);
+ throw new DeploymentException(e);
+ }
}
}
@@ -126,12 +126,16 @@
if (installed) {
throw new DeploymentException("Component is already installed");
}
+ createBootstrap();
if (bootstrap != null) {
bootstrap.onInstall();
}
ObjectName result = null;
try {
result = activateComponent();
+ ComponentNameSpace cns = new ComponentNameSpace(container.getName(), context.getComponentName(), null);
+ LocalComponentConnector lcc = container.getRegistry().getLocalComponentConnector(cns);
+ lcc.getComponentMBean().persistRunningState();
installed = true;
} finally {
if (bootstrap != null) {
@@ -187,6 +191,7 @@
if (!installed) {
throw new DeploymentException("Component is not installed");
}
+ createBootstrap();
if (bootstrap != null){
bootstrap.onUninstall();
}
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/AbstractManagementTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/AbstractManagementTest.java?rev=375991&r1=375990&r2=375991&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/AbstractManagementTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/AbstractManagementTest.java Wed Feb 8 08:45:24 2006
@@ -48,6 +48,7 @@
protected void startContainer(boolean clean) throws Exception {
shutdownContainer();
if (clean) {
+ Thread.sleep(1000);
assertTrue(FileUtil.deleteFile(new File("testWDR")));
}
container = new JBIContainer();
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java?rev=375991&r1=375990&r2=375991&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java Wed Feb 8 08:45:24 2006
@@ -126,6 +126,15 @@
assertEquals(LifeCycleMBean.RUNNING, lifecycleMBean.getCurrentState());
// check mocks
verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ lifecycle.stop();
+ lifecycle.shutDown();
+ replay();
+ shutdownContainer();
}
public void testHotDeployUndeployComponent() throws Exception {
@@ -171,8 +180,9 @@
reset();
bootstrap.onUninstall();
bootstrap.cleanUp();
- //lifecycle.stop();
+ lifecycle.stop();
lifecycle.shutDown();
+ //manager.shutDown("su");
replay();
// test component uninstallation
synchronized (lock) {
@@ -184,6 +194,11 @@
assertNull(lifecycleName);
// check mocks
verify();
+
+ // Clean shutdown
+ reset();
+ replay();
+ shutdownContainer();
}
public void testDeploySAThenComponent() throws Exception {
@@ -238,5 +253,17 @@
assertEquals(LifeCycleMBean.RUNNING, lifecycleMBean.getCurrentState());
// check mocks
verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ lifecycle.stop();
+ manager.shutDown("su");
+ lifecycle.shutDown();
+ replay();
+ shutdownContainer();
}
}
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=375991&r1=375990&r2=375991&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 Feb 8 08:45:24 2006
@@ -337,8 +337,6 @@
// configure bootstrap
bootstrapMock.reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
bootstrapMock.replay();
// configure component
componentMock.reset();