The new SCARuntimeActivator.locateService API was throwing an NPE when the
provided componentName was not found in the Domain.  I changed this to throw
IllegalArgumentException with an explanatory message.  I can easily back
this out or change it if some other behavior is preferable.

Thanks,
--Kevin

On 5/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Author: kwilliams
Date: Fri May  4 13:29:35 2007
New Revision: 535374

URL: http://svn.apache.org/viewvc?view=rev&rev=535374
Log:
Fix for NPE on bad componentName and new test

Modified:

    
incubator/tuscany/java/sca/itest/extended-api/src/test/java/org/apache/tuscany/sca/test/extended/ServiceLocateTestCase.java

    
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java

Modified:
incubator/tuscany/java/sca/itest/extended-api/src/test/java/org/apache/tuscany/sca/test/extended/ServiceLocateTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/extended-api/src/test/java/org/apache/tuscany/sca/test/extended/ServiceLocateTestCase.java?view=diff&rev=535374&r1=535373&r2=535374

==============================================================================
---
incubator/tuscany/java/sca/itest/extended-api/src/test/java/org/apache/tuscany/sca/test/extended/ServiceLocateTestCase.java
(original)
+++
incubator/tuscany/java/sca/itest/extended-api/src/test/java/org/apache/tuscany/sca/test/extended/ServiceLocateTestCase.java
Fri May  4 13:29:35 2007
@@ -36,7 +36,7 @@
         assertEquals(-99, service.negate(99));

     }
-
+
     @Test
     public void managedLocateService() {

@@ -46,20 +46,13 @@

     }

-    @Ignore
-    @Test
+    @Test(expected = IllegalArgumentException.class)
     public void badComponentName() {

-        BasicService service = SCARuntimeActivator.locateService(
BasicService.class, "IvalidComponentName");
-
-        assertEquals(-99, service.delegateNegate(99));
+        SCARuntimeActivator.locateService(BasicService.class,
"IvalidComponentName");

     }

-
-
-
-
     @Before
     public void init() throws Exception {


Modified:
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java?view=diff&rev=535374&r1=535373&r2=535374

==============================================================================
---
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java
Fri May  4 13:29:35 2007
@@ -272,7 +272,7 @@
                 return (ComponentContext)component;
             }
         }
-        return null;
+        throw new IllegalArgumentException("ComponentContext for
component named: " + componentName + " not found in this domain");
     }

     public void start(Contribution contribution) throws
ActivationException {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to