You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/02/22 00:40:29 UTC
svn commit: r379627 [13/34] - in /incubator/servicemix/trunk: ./ etc/
sandbox/servicemix-wsn-1.2/src/sa/META-INF/
sandbox/servicemix-wsn-1.2/src/su/META-INF/ servicemix-assembly/
servicemix-assembly/src/main/assembly/ servicemix-assembly/src/main/relea...
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=379627&r1=379626&r2=379627&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 Tue Feb 21 15:40:05 2006
@@ -1,148 +1,148 @@
-package org.apache.servicemix.jbi.installation;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-
-import javax.jbi.management.AdminServiceMBean;
-import javax.jbi.management.DeploymentServiceMBean;
-import javax.jbi.management.InstallationServiceMBean;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.util.FileUtil;
-
-public abstract class AbstractManagementTest extends TestCase {
-
- protected Log logger = LogFactory.getLog(getClass());
-
- protected JBIContainer container;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- try {
- shutdownContainer();
- } catch (Exception e) {
- logger.info("Error shutting down container", e);
- }
- }
-
- protected void startContainer(boolean clean) throws Exception {
- shutdownContainer();
- if (clean) {
- Thread.sleep(1000);
- assertTrue(FileUtil.deleteFile(new File("testWDR")));
- }
- container = new JBIContainer();
- container.setRootDir("testWDR");
- initContainer();
- container.init();
- container.start();
- }
-
- protected void initContainer() {
- container.setCreateMBeanServer(true);
- container.setMonitorInstallationDirectory(false);
- container.setMonitorDeploymentDirectory(false);
- }
-
- protected void shutdownContainer() throws Exception {
- if (container != null) {
- container.shutDown();
- }
- }
-
- protected File createInstallerArchive(String jbi) throws Exception {
- InputStream is = getClass().getResourceAsStream(jbi + "-jbi.xml");
- File jar = File.createTempFile("jbi", ".zip");
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar));
- jos.putNextEntry(new ZipEntry("META-INF/jbi.xml"));
- byte[] buffer = new byte[is.available()];
- is.read(buffer);
- jos.write(buffer);
- jos.closeEntry();
- jos.close();
- is.close();
- return jar;
- }
-
- protected File createServiceAssemblyArchive(String saName, String suName, String compName) throws Exception {
- File jar = File.createTempFile("jbi", ".zip");
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar));
- // Write jbi.xml
- jos.putNextEntry(new ZipEntry("META-INF/jbi.xml"));
- XMLOutputFactory xof = XMLOutputFactory.newInstance();
- //xof.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
- XMLStreamWriter xsw = xof.createXMLStreamWriter(jos);
- xsw.writeStartDocument();
- xsw.writeStartElement("jbi");
- xsw.writeAttribute("xmlns", "http://java.sun.com/xml/ns/jbi");
- xsw.writeStartElement("service-assembly");
- xsw.writeStartElement("identification");
- xsw.writeStartElement("name");
- xsw.writeCharacters(saName);
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeStartElement("service-unit");
- xsw.writeStartElement("identification");
- xsw.writeStartElement("name");
- xsw.writeCharacters(suName);
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeStartElement("target");
- xsw.writeStartElement("artifacts-zip");
- xsw.writeCharacters(suName + ".zip");
- xsw.writeEndElement();
- xsw.writeStartElement("component-name");
- xsw.writeCharacters(compName);
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeEndElement();
- xsw.writeEndDocument();
- xsw.flush();
- jos.closeEntry();
- // Put su artifact
- jos.putNextEntry(new ZipEntry(suName + ".zip"));
- JarOutputStream jos2 = new JarOutputStream(jos, new Manifest());
- jos2.finish();
- jos2.flush();
- jos.closeEntry();
- // Close jar
- jos.close();
- return jar;
- }
-
- protected InstallationServiceMBean getInstallationService() throws Exception {
- return container.getInstallationService();
- }
-
- protected DeploymentServiceMBean getDeploymentService() throws Exception {
- return container.getDeploymentService();
- }
-
- protected AdminServiceMBean getAdminService() throws Exception {
- return container.getManagementContext();
- }
-
-
-}
+package org.apache.servicemix.jbi.installation;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import javax.jbi.management.AdminServiceMBean;
+import javax.jbi.management.DeploymentServiceMBean;
+import javax.jbi.management.InstallationServiceMBean;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.util.FileUtil;
+
+public abstract class AbstractManagementTest extends TestCase {
+
+ protected Log logger = LogFactory.getLog(getClass());
+
+ protected JBIContainer container;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ try {
+ shutdownContainer();
+ } catch (Exception e) {
+ logger.info("Error shutting down container", e);
+ }
+ }
+
+ protected void startContainer(boolean clean) throws Exception {
+ shutdownContainer();
+ if (clean) {
+ Thread.sleep(1000);
+ assertTrue(FileUtil.deleteFile(new File("testWDR")));
+ }
+ container = new JBIContainer();
+ container.setRootDir("testWDR");
+ initContainer();
+ container.init();
+ container.start();
+ }
+
+ protected void initContainer() {
+ container.setCreateMBeanServer(true);
+ container.setMonitorInstallationDirectory(false);
+ container.setMonitorDeploymentDirectory(false);
+ }
+
+ protected void shutdownContainer() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ protected File createInstallerArchive(String jbi) throws Exception {
+ InputStream is = getClass().getResourceAsStream(jbi + "-jbi.xml");
+ File jar = File.createTempFile("jbi", ".zip");
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar));
+ jos.putNextEntry(new ZipEntry("META-INF/jbi.xml"));
+ byte[] buffer = new byte[is.available()];
+ is.read(buffer);
+ jos.write(buffer);
+ jos.closeEntry();
+ jos.close();
+ is.close();
+ return jar;
+ }
+
+ protected File createServiceAssemblyArchive(String saName, String suName, String compName) throws Exception {
+ File jar = File.createTempFile("jbi", ".zip");
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar));
+ // Write jbi.xml
+ jos.putNextEntry(new ZipEntry("META-INF/jbi.xml"));
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ //xof.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ XMLStreamWriter xsw = xof.createXMLStreamWriter(jos);
+ xsw.writeStartDocument();
+ xsw.writeStartElement("jbi");
+ xsw.writeAttribute("xmlns", "http://java.sun.com/xml/ns/jbi");
+ xsw.writeStartElement("service-assembly");
+ xsw.writeStartElement("identification");
+ xsw.writeStartElement("name");
+ xsw.writeCharacters(saName);
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeStartElement("service-unit");
+ xsw.writeStartElement("identification");
+ xsw.writeStartElement("name");
+ xsw.writeCharacters(suName);
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeStartElement("target");
+ xsw.writeStartElement("artifacts-zip");
+ xsw.writeCharacters(suName + ".zip");
+ xsw.writeEndElement();
+ xsw.writeStartElement("component-name");
+ xsw.writeCharacters(compName);
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeEndElement();
+ xsw.writeEndDocument();
+ xsw.flush();
+ jos.closeEntry();
+ // Put su artifact
+ jos.putNextEntry(new ZipEntry(suName + ".zip"));
+ JarOutputStream jos2 = new JarOutputStream(jos, new Manifest());
+ jos2.finish();
+ jos2.flush();
+ jos.closeEntry();
+ // Close jar
+ jos.close();
+ return jar;
+ }
+
+ protected InstallationServiceMBean getInstallationService() throws Exception {
+ return container.getInstallationService();
+ }
+
+ protected DeploymentServiceMBean getDeploymentService() throws Exception {
+ return container.getDeploymentService();
+ }
+
+ protected AdminServiceMBean getAdminService() throws Exception {
+ return container.getManagementContext();
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/AbstractManagementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/BootstrapDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/BootstrapDelegate.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/BootstrapDelegate.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/BootstrapDelegate.java Tue Feb 21 15:40:05 2006
@@ -1,59 +1,59 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.jbi.installation;
-
-import javax.jbi.JBIException;
-import javax.jbi.component.Bootstrap;
-import javax.jbi.component.InstallationContext;
-import javax.management.ObjectName;
-
-public class BootstrapDelegate implements Bootstrap {
-
- private Bootstrap delegate;
-
- public BootstrapDelegate(Bootstrap delegate) {
- this.delegate = delegate;
- }
-
- public Bootstrap getDelegate() {
- return delegate;
- }
-
- public void setDelegate(Bootstrap delegate) {
- this.delegate = delegate;
- }
-
- public void cleanUp() throws JBIException {
- delegate.cleanUp();
- }
-
- public ObjectName getExtensionMBeanName() {
- return delegate.getExtensionMBeanName();
- }
-
- public void init(InstallationContext installContext) throws JBIException {
- delegate.init(installContext);
- }
-
- public void onInstall() throws JBIException {
- delegate.onInstall();
- }
-
- public void onUninstall() throws JBIException {
- delegate.onUninstall();
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.installation;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.ObjectName;
+
+public class BootstrapDelegate implements Bootstrap {
+
+ private Bootstrap delegate;
+
+ public BootstrapDelegate(Bootstrap delegate) {
+ this.delegate = delegate;
+ }
+
+ public Bootstrap getDelegate() {
+ return delegate;
+ }
+
+ public void setDelegate(Bootstrap delegate) {
+ this.delegate = delegate;
+ }
+
+ public void cleanUp() throws JBIException {
+ delegate.cleanUp();
+ }
+
+ public ObjectName getExtensionMBeanName() {
+ return delegate.getExtensionMBeanName();
+ }
+
+ public void init(InstallationContext installContext) throws JBIException {
+ delegate.init(installContext);
+ }
+
+ public void onInstall() throws JBIException {
+ delegate.onInstall();
+ }
+
+ public void onUninstall() throws JBIException {
+ delegate.onUninstall();
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/BootstrapDelegate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/ComponentDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/ComponentDelegate.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/ComponentDelegate.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/ComponentDelegate.java Tue Feb 21 15:40:05 2006
@@ -1,67 +1,67 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.jbi.installation;
-
-import javax.jbi.component.Component;
-import javax.jbi.component.ComponentLifeCycle;
-import javax.jbi.component.ServiceUnitManager;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.servicedesc.ServiceEndpoint;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-
-public class ComponentDelegate implements Component {
-
- private Component delegate;
-
- public ComponentDelegate(Component delegate) {
- this.delegate = delegate;
- }
-
- public Component getDelegate() {
- return delegate;
- }
-
- public void setDelegate(Component delegate) {
- this.delegate = delegate;
- }
-
- public ComponentLifeCycle getLifeCycle() {
- return delegate.getLifeCycle();
- }
-
- public Document getServiceDescription(ServiceEndpoint endpoint) {
- return delegate.getServiceDescription(endpoint);
- }
-
- public ServiceUnitManager getServiceUnitManager() {
- return delegate.getServiceUnitManager();
- }
-
- public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
- return delegate.isExchangeWithConsumerOkay(endpoint, exchange);
- }
-
- public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
- return delegate.isExchangeWithProviderOkay(endpoint, exchange);
- }
-
- public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
- return delegate.resolveEndpointReference(epr);
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.installation;
+
+import javax.jbi.component.Component;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+public class ComponentDelegate implements Component {
+
+ private Component delegate;
+
+ public ComponentDelegate(Component delegate) {
+ this.delegate = delegate;
+ }
+
+ public Component getDelegate() {
+ return delegate;
+ }
+
+ public void setDelegate(Component delegate) {
+ this.delegate = delegate;
+ }
+
+ public ComponentLifeCycle getLifeCycle() {
+ return delegate.getLifeCycle();
+ }
+
+ public Document getServiceDescription(ServiceEndpoint endpoint) {
+ return delegate.getServiceDescription(endpoint);
+ }
+
+ public ServiceUnitManager getServiceUnitManager() {
+ return delegate.getServiceUnitManager();
+ }
+
+ public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
+ return delegate.isExchangeWithConsumerOkay(endpoint, exchange);
+ }
+
+ public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
+ return delegate.isExchangeWithProviderOkay(endpoint, exchange);
+ }
+
+ public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
+ return delegate.resolveEndpointReference(epr);
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/ComponentDelegate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/DeploymentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/DeploymentTest.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/DeploymentTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/DeploymentTest.java Tue Feb 21 15:40:05 2006
@@ -1,397 +1,397 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.jbi.installation;
-
-import java.io.File;
-
-import javax.jbi.component.Bootstrap;
-import javax.jbi.component.Component;
-import javax.jbi.component.ComponentLifeCycle;
-import javax.jbi.component.ServiceUnitManager;
-import javax.jbi.management.DeploymentServiceMBean;
-import javax.jbi.management.InstallerMBean;
-import javax.jbi.management.LifeCycleMBean;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-
-import org.easymock.MockControl;
-
-public class DeploymentTest extends AbstractManagementTest {
-
- // Create mocks
- protected ExtMockControl bootstrapMock;
- protected Bootstrap bootstrap;
- protected ExtMockControl componentMock;
- protected Component component;
- protected ExtMockControl lifecycleMock;
- protected ComponentLifeCycle lifecycle;
- protected ExtMockControl managerMock;
- protected ServiceUnitManager manager;
-
- protected void setUp() throws Exception {
- super.setUp();
- // Create mocks
- bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
- bootstrap = (Bootstrap) bootstrapMock.getMock();
- Bootstrap1.setDelegate(bootstrap);
- componentMock = ExtMockControl.createControl(Component.class);
- component = (Component) componentMock.getMock();
- Component1.setDelegate(component);
- lifecycleMock = ExtMockControl.createControl(ComponentLifeCycle.class);
- lifecycle = (ComponentLifeCycle) lifecycleMock.getMock();
- managerMock = ExtMockControl.createControl(ServiceUnitManager.class);
- manager = (ServiceUnitManager) managerMock.getMock();
- }
-
- protected void reset() {
- bootstrapMock.reset();
- componentMock.reset();
- lifecycleMock.reset();
- managerMock.reset();
- }
-
- protected void replay() {
- bootstrapMock.replay();
- componentMock.replay();
- lifecycleMock.replay();
- managerMock.replay();
- }
-
- protected void verify() {
- bootstrapMock.verify();
- componentMock.verify();
- lifecycleMock.verify();
- managerMock.verify();
- }
-
- /**
- * SA is deployed and started
- * @throws Exception
- */
- public void testDeployAndStart() throws Exception {
- // configure mocks
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- 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
- verify();
-
- // configure mocks
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- replay();
- // test component installation
- lifecycleMBean.start();
- assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.deploy(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- managerMock.setReturnValue(null);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- replay();
- // deploy sa
- assertTrue(getDeploymentService().canDeployToComponent("component1"));
- File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
- getDeploymentService().deploy(installSaUrl.getAbsolutePath());
- String[] sas = getDeploymentService().getDeployedServiceAssemblies();
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.start("su");
- replay();
- // start sa
- getDeploymentService().start("sa");
- assertEquals(DeploymentServiceMBean.STARTED, getDeploymentService().getState("sa"));
- // check mocks
- verify();
-
- // Clean shutdown
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- lifecycle.stop();
- lifecycle.shutDown();
- //manager.stop("su");
- manager.shutDown("su");
- replay();
- shutdownContainer();
- }
-
- /**
- * SA is deployed and started
- * @throws Exception
- */
- public void testDeployAndRestart() throws Exception {
- // configure mocks
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- 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
- verify();
-
- // configure mocks
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- replay();
- // test component installation
- lifecycleMBean.start();
- assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.deploy(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- managerMock.setReturnValue(null);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- replay();
- // deploy sa
- assertTrue(getDeploymentService().canDeployToComponent("component1"));
- File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
- getDeploymentService().deploy(installSaUrl.getAbsolutePath());
- String[] sas = getDeploymentService().getDeployedServiceAssemblies();
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
- // check mocks
- verify();
-
- // configure mocks
- reset();
- lifecycle.stop();
- lifecycle.shutDown();
- replay();
- // shutdown container
- shutdownContainer();
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- replay();
- // start container
- startContainer(false);
- // check mocks
- verify();
-
- // Clean shutdown
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- lifecycle.stop();
- lifecycle.shutDown();
- //manager.stop("su");
- manager.shutDown("su");
- replay();
- shutdownContainer();
- }
-
- /**
- * SA is deployed and started
- * @throws Exception
- */
- public void testDeployStartAndRestart() throws Exception {
- // configure mocks
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- 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
- verify();
-
- // configure mocks
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- replay();
- // test component installation
- lifecycleMBean.start();
- assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.deploy(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- managerMock.setReturnValue(null);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- replay();
- // deploy sa
- assertTrue(getDeploymentService().canDeployToComponent("component1"));
- File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
- getDeploymentService().deploy(installSaUrl.getAbsolutePath());
- String[] sas = getDeploymentService().getDeployedServiceAssemblies();
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
- assertNotNull(sas);
- assertEquals(1, sas.length);
- assertEquals("sa", sas[0]);
- assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.start("su");
- replay();
- // start sa
- getDeploymentService().start("sa");
- assertEquals(DeploymentServiceMBean.STARTED, getDeploymentService().getState("sa"));
- // check mocks
- verify();
-
- // configure mocks
- reset();
- lifecycle.stop();
- lifecycle.shutDown();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.shutDown("su");
- replay();
- // shutdown container
- shutdownContainer();
- // check mocks
- verify();
-
- // configure mocks
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- manager.start("su");
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- replay();
- // start container
- startContainer(false);
- // check mocks
- verify();
-
- // Clean shutdown
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- lifecycle.stop();
- lifecycle.shutDown();
- //manager.stop("su");
- manager.shutDown("su");
- replay();
- shutdownContainer();
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.installation;
+
+import java.io.File;
+
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.Component;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
+import javax.jbi.management.DeploymentServiceMBean;
+import javax.jbi.management.InstallerMBean;
+import javax.jbi.management.LifeCycleMBean;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+
+import org.easymock.MockControl;
+
+public class DeploymentTest extends AbstractManagementTest {
+
+ // Create mocks
+ protected ExtMockControl bootstrapMock;
+ protected Bootstrap bootstrap;
+ protected ExtMockControl componentMock;
+ protected Component component;
+ protected ExtMockControl lifecycleMock;
+ protected ComponentLifeCycle lifecycle;
+ protected ExtMockControl managerMock;
+ protected ServiceUnitManager manager;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Create mocks
+ bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
+ bootstrap = (Bootstrap) bootstrapMock.getMock();
+ Bootstrap1.setDelegate(bootstrap);
+ componentMock = ExtMockControl.createControl(Component.class);
+ component = (Component) componentMock.getMock();
+ Component1.setDelegate(component);
+ lifecycleMock = ExtMockControl.createControl(ComponentLifeCycle.class);
+ lifecycle = (ComponentLifeCycle) lifecycleMock.getMock();
+ managerMock = ExtMockControl.createControl(ServiceUnitManager.class);
+ manager = (ServiceUnitManager) managerMock.getMock();
+ }
+
+ protected void reset() {
+ bootstrapMock.reset();
+ componentMock.reset();
+ lifecycleMock.reset();
+ managerMock.reset();
+ }
+
+ protected void replay() {
+ bootstrapMock.replay();
+ componentMock.replay();
+ lifecycleMock.replay();
+ managerMock.replay();
+ }
+
+ protected void verify() {
+ bootstrapMock.verify();
+ componentMock.verify();
+ lifecycleMock.verify();
+ managerMock.verify();
+ }
+
+ /**
+ * SA is deployed and started
+ * @throws Exception
+ */
+ public void testDeployAndStart() throws Exception {
+ // configure mocks
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ 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
+ verify();
+
+ // configure mocks
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ replay();
+ // test component installation
+ lifecycleMBean.start();
+ assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.deploy(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ managerMock.setReturnValue(null);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ replay();
+ // deploy sa
+ assertTrue(getDeploymentService().canDeployToComponent("component1"));
+ File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
+ getDeploymentService().deploy(installSaUrl.getAbsolutePath());
+ String[] sas = getDeploymentService().getDeployedServiceAssemblies();
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.start("su");
+ replay();
+ // start sa
+ getDeploymentService().start("sa");
+ assertEquals(DeploymentServiceMBean.STARTED, getDeploymentService().getState("sa"));
+ // check mocks
+ verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ lifecycle.stop();
+ lifecycle.shutDown();
+ //manager.stop("su");
+ manager.shutDown("su");
+ replay();
+ shutdownContainer();
+ }
+
+ /**
+ * SA is deployed and started
+ * @throws Exception
+ */
+ public void testDeployAndRestart() throws Exception {
+ // configure mocks
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ 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
+ verify();
+
+ // configure mocks
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ replay();
+ // test component installation
+ lifecycleMBean.start();
+ assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.deploy(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ managerMock.setReturnValue(null);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ replay();
+ // deploy sa
+ assertTrue(getDeploymentService().canDeployToComponent("component1"));
+ File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
+ getDeploymentService().deploy(installSaUrl.getAbsolutePath());
+ String[] sas = getDeploymentService().getDeployedServiceAssemblies();
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ lifecycle.stop();
+ lifecycle.shutDown();
+ replay();
+ // shutdown container
+ shutdownContainer();
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ replay();
+ // start container
+ startContainer(false);
+ // check mocks
+ verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ lifecycle.stop();
+ lifecycle.shutDown();
+ //manager.stop("su");
+ manager.shutDown("su");
+ replay();
+ shutdownContainer();
+ }
+
+ /**
+ * SA is deployed and started
+ * @throws Exception
+ */
+ public void testDeployStartAndRestart() throws Exception {
+ // configure mocks
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ 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
+ verify();
+
+ // configure mocks
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ replay();
+ // test component installation
+ lifecycleMBean.start();
+ assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.deploy(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ managerMock.setReturnValue(null);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ replay();
+ // deploy sa
+ assertTrue(getDeploymentService().canDeployToComponent("component1"));
+ File installSaUrl = createServiceAssemblyArchive("sa", "su", "component1");
+ getDeploymentService().deploy(installSaUrl.getAbsolutePath());
+ String[] sas = getDeploymentService().getDeployedServiceAssemblies();
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ sas = getDeploymentService().getDeployedServiceAssembliesForComponent("component1");
+ assertNotNull(sas);
+ assertEquals(1, sas.length);
+ assertEquals("sa", sas[0]);
+ assertEquals(DeploymentServiceMBean.SHUTDOWN, getDeploymentService().getState("sa"));
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.start("su");
+ replay();
+ // start sa
+ getDeploymentService().start("sa");
+ assertEquals(DeploymentServiceMBean.STARTED, getDeploymentService().getState("sa"));
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ lifecycle.stop();
+ lifecycle.shutDown();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.shutDown("su");
+ replay();
+ // shutdown container
+ shutdownContainer();
+ // check mocks
+ verify();
+
+ // configure mocks
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ manager.start("su");
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ replay();
+ // start container
+ startContainer(false);
+ // check mocks
+ verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle, MockControl.ONE_OR_MORE);
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ lifecycle.stop();
+ lifecycle.shutDown();
+ //manager.stop("su");
+ manager.shutDown("su");
+ replay();
+ shutdownContainer();
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/DeploymentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
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=379627&r1=379626&r2=379627&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 Tue Feb 21 15:40:05 2006
@@ -1,269 +1,269 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.jbi.installation;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-
-import javax.jbi.JBIException;
-import javax.jbi.component.Bootstrap;
-import javax.jbi.component.Component;
-import javax.jbi.component.ComponentLifeCycle;
-import javax.jbi.component.ServiceUnitManager;
-import javax.jbi.management.LifeCycleMBean;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-
-import org.apache.servicemix.jbi.util.FileUtil;
-import org.easymock.MockControl;
-
-public class HotDeployTest extends AbstractManagementTest {
-
- // Create mocks
- protected ExtMockControl bootstrapMock;
- protected Bootstrap bootstrap;
- protected ExtMockControl componentMock;
- protected Component component;
- protected ExtMockControl lifecycleMock;
- protected ComponentLifeCycle lifecycle;
- protected ExtMockControl managerMock;
- protected ServiceUnitManager manager;
-
- protected void setUp() throws Exception {
- super.setUp();
- // Create mocks
- bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
- bootstrap = (Bootstrap) bootstrapMock.getMock();
- Bootstrap1.setDelegate(bootstrap);
- componentMock = ExtMockControl.createControl(Component.class);
- component = (Component) componentMock.getMock();
- Component1.setDelegate(component);
- lifecycleMock = ExtMockControl.createControl(ComponentLifeCycle.class);
- lifecycle = (ComponentLifeCycle) lifecycleMock.getMock();
- managerMock = ExtMockControl.createControl(ServiceUnitManager.class);
- manager = (ServiceUnitManager) managerMock.getMock();
- }
-
- protected void reset() {
- bootstrapMock.reset();
- componentMock.reset();
- lifecycleMock.reset();
- managerMock.reset();
- }
-
- protected void replay() {
- bootstrapMock.replay();
- componentMock.replay();
- lifecycleMock.replay();
- managerMock.replay();
- }
-
- protected void verify() {
- bootstrapMock.verify();
- componentMock.verify();
- lifecycleMock.verify();
- managerMock.verify();
- }
-
- protected void initContainer() {
- container.setCreateMBeanServer(true);
- container.setMonitorInstallationDirectory(true);
- container.setMonitorDeploymentDirectory(true);
- container.setMonitorInterval(1);
- }
-
-
-
- public void testHotDeployComponent() throws Exception {
- final Object lock = new Object();
- // configure mocks
- Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
- public void cleanUp() throws JBIException {
- super.cleanUp();
- synchronized (lock) {
- lock.notify();
- }
- }
- });
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- replay();
- // test component installation
- startContainer(true);
- String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
- File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
- synchronized (lock) {
- FileUtil.copyInputStream(new FileInputStream(installJarUrl),
- new FileOutputStream(hdInstaller));
- lock.wait(5000);
- }
- Thread.sleep(50);
- ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
- assertNotNull(lifecycleName);
- LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
- assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
- // check mocks
- verify();
-
- // Clean shutdown
- reset();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle);
- lifecycle.stop();
- lifecycle.shutDown();
- replay();
- shutdownContainer();
- }
-
- public void testHotDeployUndeployComponent() throws Exception {
- final Object lock = new Object();
- // configure mocks
- Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
- public void cleanUp() throws JBIException {
- super.cleanUp();
- synchronized (lock) {
- lock.notify();
- }
- }
- });
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- replay();
- // test component installation
- startContainer(true);
- String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
- File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
- synchronized (lock) {
- FileUtil.copyInputStream(new FileInputStream(installJarUrl),
- new FileOutputStream(hdInstaller));
- lock.wait(5000);
- }
- Thread.sleep(50);
- ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
- assertNotNull(lifecycleName);
- LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
- assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
- // check mocks
- verify();
-
- // Configure mocks
- reset();
- bootstrap.onUninstall();
- bootstrap.cleanUp();
- lifecycle.stop();
- lifecycle.shutDown();
- //manager.shutDown("su");
- replay();
- // test component uninstallation
- synchronized (lock) {
- assertTrue(hdInstaller.delete());
- lock.wait(5000);
- }
- Thread.sleep(50);
- lifecycleName = container.getRegistry().getComponentObjectName("component1");
- assertNull(lifecycleName);
- // check mocks
- verify();
-
- // Clean shutdown
- reset();
- replay();
- shutdownContainer();
- }
-
- public void testDeploySAThenComponent() throws Exception {
- final Object lock = new Object();
- // configure mocks
- Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
- public void cleanUp() throws JBIException {
- super.cleanUp();
- synchronized (lock) {
- lock.notify();
- }
- }
- });
- reset();
- bootstrap.init(null);
- bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
- bootstrap.onInstall();
- bootstrap.cleanUp();
- component.getLifeCycle();
- componentMock.setReturnValue(lifecycle);
- lifecycle.init(null);
- lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
- lifecycle.start();
- component.getServiceUnitManager();
- componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
- manager.deploy(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- managerMock.setReturnValue(null);
- manager.init(null, null);
- managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
- manager.start("su");
- replay();
- // test component installation
- startContainer(true);
- File saJarUrl = createServiceAssemblyArchive("sa", "su", "component1");
- File hdSa = new File(container.getEnvironmentContext().getDeploymentDir(), saJarUrl.getName());
- FileUtil.copyInputStream(new FileInputStream(saJarUrl),
- new FileOutputStream(hdSa));
- Thread.sleep(2000);
-
- String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
- File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
- synchronized (lock) {
- FileUtil.copyInputStream(new FileInputStream(installJarUrl),
- new FileOutputStream(hdInstaller));
- lock.wait(5000);
- }
- Thread.sleep(2000);
- ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
- assertNotNull(lifecycleName);
- LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
- assertEquals(LifeCycleMBean.STARTED, 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();
- }
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.installation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.Component;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
+import javax.jbi.management.LifeCycleMBean;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+
+import org.apache.servicemix.jbi.util.FileUtil;
+import org.easymock.MockControl;
+
+public class HotDeployTest extends AbstractManagementTest {
+
+ // Create mocks
+ protected ExtMockControl bootstrapMock;
+ protected Bootstrap bootstrap;
+ protected ExtMockControl componentMock;
+ protected Component component;
+ protected ExtMockControl lifecycleMock;
+ protected ComponentLifeCycle lifecycle;
+ protected ExtMockControl managerMock;
+ protected ServiceUnitManager manager;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Create mocks
+ bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
+ bootstrap = (Bootstrap) bootstrapMock.getMock();
+ Bootstrap1.setDelegate(bootstrap);
+ componentMock = ExtMockControl.createControl(Component.class);
+ component = (Component) componentMock.getMock();
+ Component1.setDelegate(component);
+ lifecycleMock = ExtMockControl.createControl(ComponentLifeCycle.class);
+ lifecycle = (ComponentLifeCycle) lifecycleMock.getMock();
+ managerMock = ExtMockControl.createControl(ServiceUnitManager.class);
+ manager = (ServiceUnitManager) managerMock.getMock();
+ }
+
+ protected void reset() {
+ bootstrapMock.reset();
+ componentMock.reset();
+ lifecycleMock.reset();
+ managerMock.reset();
+ }
+
+ protected void replay() {
+ bootstrapMock.replay();
+ componentMock.replay();
+ lifecycleMock.replay();
+ managerMock.replay();
+ }
+
+ protected void verify() {
+ bootstrapMock.verify();
+ componentMock.verify();
+ lifecycleMock.verify();
+ managerMock.verify();
+ }
+
+ protected void initContainer() {
+ container.setCreateMBeanServer(true);
+ container.setMonitorInstallationDirectory(true);
+ container.setMonitorDeploymentDirectory(true);
+ container.setMonitorInterval(1);
+ }
+
+
+
+ public void testHotDeployComponent() throws Exception {
+ final Object lock = new Object();
+ // configure mocks
+ Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
+ public void cleanUp() throws JBIException {
+ super.cleanUp();
+ synchronized (lock) {
+ lock.notify();
+ }
+ }
+ });
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ replay();
+ // test component installation
+ startContainer(true);
+ String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
+ File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
+ synchronized (lock) {
+ FileUtil.copyInputStream(new FileInputStream(installJarUrl),
+ new FileOutputStream(hdInstaller));
+ lock.wait(5000);
+ }
+ Thread.sleep(50);
+ ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+ assertNotNull(lifecycleName);
+ LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
+ assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
+ // check mocks
+ verify();
+
+ // Clean shutdown
+ reset();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ lifecycle.stop();
+ lifecycle.shutDown();
+ replay();
+ shutdownContainer();
+ }
+
+ public void testHotDeployUndeployComponent() throws Exception {
+ final Object lock = new Object();
+ // configure mocks
+ Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
+ public void cleanUp() throws JBIException {
+ super.cleanUp();
+ synchronized (lock) {
+ lock.notify();
+ }
+ }
+ });
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ replay();
+ // test component installation
+ startContainer(true);
+ String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
+ File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
+ synchronized (lock) {
+ FileUtil.copyInputStream(new FileInputStream(installJarUrl),
+ new FileOutputStream(hdInstaller));
+ lock.wait(5000);
+ }
+ Thread.sleep(50);
+ ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+ assertNotNull(lifecycleName);
+ LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
+ assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
+ // check mocks
+ verify();
+
+ // Configure mocks
+ reset();
+ bootstrap.onUninstall();
+ bootstrap.cleanUp();
+ lifecycle.stop();
+ lifecycle.shutDown();
+ //manager.shutDown("su");
+ replay();
+ // test component uninstallation
+ synchronized (lock) {
+ assertTrue(hdInstaller.delete());
+ lock.wait(5000);
+ }
+ Thread.sleep(50);
+ lifecycleName = container.getRegistry().getComponentObjectName("component1");
+ assertNull(lifecycleName);
+ // check mocks
+ verify();
+
+ // Clean shutdown
+ reset();
+ replay();
+ shutdownContainer();
+ }
+
+ public void testDeploySAThenComponent() throws Exception {
+ final Object lock = new Object();
+ // configure mocks
+ Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {
+ public void cleanUp() throws JBIException {
+ super.cleanUp();
+ synchronized (lock) {
+ lock.notify();
+ }
+ }
+ });
+ reset();
+ bootstrap.init(null);
+ bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ bootstrap.onInstall();
+ bootstrap.cleanUp();
+ component.getLifeCycle();
+ componentMock.setReturnValue(lifecycle);
+ lifecycle.init(null);
+ lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ lifecycle.start();
+ component.getServiceUnitManager();
+ componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);
+ manager.deploy(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ managerMock.setReturnValue(null);
+ manager.init(null, null);
+ managerMock.setMatcher(MockControl.ALWAYS_MATCHER);
+ manager.start("su");
+ replay();
+ // test component installation
+ startContainer(true);
+ File saJarUrl = createServiceAssemblyArchive("sa", "su", "component1");
+ File hdSa = new File(container.getEnvironmentContext().getDeploymentDir(), saJarUrl.getName());
+ FileUtil.copyInputStream(new FileInputStream(saJarUrl),
+ new FileOutputStream(hdSa));
+ Thread.sleep(2000);
+
+ String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
+ File hdInstaller = new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());
+ synchronized (lock) {
+ FileUtil.copyInputStream(new FileInputStream(installJarUrl),
+ new FileOutputStream(hdInstaller));
+ lock.wait(5000);
+ }
+ Thread.sleep(2000);
+ ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+ assertNotNull(lifecycleName);
+ LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
+ assertEquals(LifeCycleMBean.STARTED, 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();
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java
------------------------------------------------------------------------------
svn:eol-style = native