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 2009/02/26 18:44:37 UTC

svn commit: r748225 - /servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java

Author: gnodet
Date: Thu Feb 26 17:44:37 2009
New Revision: 748225

URL: http://svn.apache.org/viewvc?rev=748225&view=rev
Log:
SMX4NMR-110: add a unit test

Modified:
    servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java

Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java?rev=748225&r1=748224&r2=748225&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/test/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImplTest.java Thu Feb 26 17:44:37 2009
@@ -21,8 +21,13 @@
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Collections;
+
+import javax.jbi.JBIException;
 
 import org.apache.servicemix.jbi.deployer.ServiceAssembly;
+import org.apache.servicemix.jbi.deployer.Component;
+import org.apache.servicemix.jbi.deployer.ServiceUnit;
 import org.apache.servicemix.jbi.deployer.artifacts.AbstractLifecycleJbiArtifact.State;
 import org.apache.servicemix.jbi.deployer.descriptor.DescriptorFactory;
 import org.apache.servicemix.jbi.deployer.descriptor.ServiceAssemblyDesc;
@@ -36,7 +41,27 @@
  * Test cases for {@link ServiceAssemblyImpl}
  */
 public class ServiceAssemblyImplTest extends TestCase {
+
+    public void testStartAssemblyWithStoppedComponents() throws Exception {
+        ServiceAssemblyDesc descriptor = DescriptorFactory.buildDescriptor(DescriptorFactory.class.getResource("serviceAssembly.xml")).getServiceAssembly();
+        final Preferences prefs = createMock(Preferences.class);
+        expect(prefs.get("state", State.Shutdown.name())).andReturn(State.Shutdown.name()).anyTimes();
+        replay(prefs);
+
+        ComponentImpl comp = new ComponentImpl(null, null, null, prefs, false, null, null);
+        comp.state = State.Shutdown;
+        ServiceUnitImpl su = new ServiceUnitImpl(descriptor.getServiceUnits()[0], null, comp);
+        ServiceAssemblyImpl sa = new ServiceAssemblyImpl(null, descriptor, Collections.singletonList(su), prefs, new AssemblyReferencesListener(), false);
+        sa.state = State.Shutdown;
         
+        try {
+            sa.start();
+            fail("Exception should have been thrown");
+        } catch (JBIException e) {
+            // ok
+        }
+    }
+    
     public void testWiringOnServiceAssemblyConnections() throws Exception {
         ServiceAssemblyDesc descriptor = DescriptorFactory.buildDescriptor(DescriptorFactory.class.getResource("serviceAssembly.xml")).getServiceAssembly();
         final Preferences prefs = createMock(Preferences.class);