tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r412323 - in /incubator/tuscany/sandbox/jboynes/sca: core2/src/main/java/org/apache/tuscany/core/component/scope/ core2/src/main/java/org/apache/tuscany/core/wire/ core2/src/test/java/org/apache/tuscany/core/integration/system/builder/ spi/...
Date Wed, 07 Jun 2006 08:15:24 GMT
Author: jmarino
Date: Wed Jun  7 01:15:23 2006
New Revision: 412323

URL: http://svn.apache.org/viewvc?rev=412323&view=rev
Log:
increase test coverage in spi; remove dead code

Added:
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
  (with props)
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
  (with props)
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
  (with props)
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
  (with props)
Removed:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/OneWayInterceptor.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/system/builder/AutowireBuilderTestcase.java
Modified:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
    incubator/tuscany/sandbox/jboynes/sca/spi/pom.xml
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
Wed Jun  7 01:15:23 2006
@@ -96,7 +96,7 @@
     protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException
{
         checkInit();
         InstanceWrapper ctx = instanceContexts.get(component);
-        assert ctx != null : "SCAObject not registered with scope: " + component;
+        assert ctx != null : "Component not registered with scope: " + component;
         if (ctx == EMPTY) {
             ctx = new InstanceWrapperImpl(component, component.createInstance());
             ctx.start();

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/pom.xml?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/pom.xml (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/pom.xml Wed Jun  7 01:15:23 2006
@@ -60,5 +60,12 @@
             <version>3.8.1</version>
             <scope>test</scope>
         </dependency>
+		  <dependency>
+            <groupId>jmock</groupId>
+            <artifactId>jmock</artifactId>
+            <version>1.0.1</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 </project>

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
Wed Jun  7 01:15:23 2006
@@ -101,6 +101,6 @@
     }
 
     public String toString() {
-        return "SCAObject [" + name + "] in state [" + super.toString() + ']';
+        return "[" + name + "] in state [" + super.toString() + ']';
     }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
Wed Jun  7 01:15:23 2006
@@ -64,6 +64,9 @@
 
     public InboundWire getInboundWire(String serviceName) {
         if (serviceName == null) {
+            if (serviceWires.size() <1){
+                return null;
+            }
             return serviceWires.values().iterator().next();
         } else {
             return serviceWires.get(serviceName);

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
Wed Jun  7 01:15:23 2006
@@ -80,6 +80,7 @@
     }
 
     public void prepare() {
+        assert(inboundWire != null) :"Inbound wire not set";
         for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
             chain.setTargetInvoker(createTargetInvoker(outboundWire.getTargetName().getQualifiedName(),
chain.getMethod()));
             chain.build();

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java?rev=412323&r1=412322&r2=412323&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java
Wed Jun  7 01:15:23 2006
@@ -50,10 +50,6 @@
 
     public T getServiceInstance() throws TargetException {
         return wireService.createProxy(inboundWire);
-//        if (target == null) {
-//            target = inboundWire.getTargetService();
-//        }
-//        return target;
     }
 
     public WireInvocationHandler getHandler() {
@@ -61,6 +57,7 @@
     }
 
     public Class<T> getInterface() {
+        assert(inboundWire != null): "Inbound wire not set";
         return inboundWire.getBusinessInterface();
     }
 

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java?rev=412323&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
Wed Jun  7 01:15:23 2006
@@ -0,0 +1,106 @@
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.TrueFilter;
+import org.jmock.MockObjectTestCase;
+import org.jmock.Mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractSCAObjectTestCase extends MockObjectTestCase {
+
+    public void testFireListener(){
+        SCAObject object = new TestSCAObject("foo",null);
+        Mock mock = mock(RuntimeEventListener.class);
+        Event event = new TestEvent();
+        mock.expects(once()).method("onEvent").with(eq(event));
+        RuntimeEventListener listener = (RuntimeEventListener)mock.proxy();
+        object.addListener(listener);
+        object.publish(event);
+    }
+
+    public void testRemoveListener(){
+        SCAObject object = new TestSCAObject("foo",null);
+        Mock mock = mock(RuntimeEventListener.class);
+        Event event = new TestEvent();
+        mock.expects(never()).method("onEvent").with(eq(event));
+        RuntimeEventListener listener = (RuntimeEventListener)mock.proxy();
+        object.addListener(listener);
+        object.removeListener(listener);
+        object.publish(event);
+    }
+
+    public void testFalseFilterListener(){
+        SCAObject object = new TestSCAObject("foo",null);
+        Mock mock = mock(RuntimeEventListener.class);
+        Event event = new TestEvent();
+        mock.expects(never()).method("onEvent").with(eq(event));
+        RuntimeEventListener listener = (RuntimeEventListener)mock.proxy();
+        object.addListener(new FalseFilter(),listener);
+        object.publish(event);
+    }
+
+    public void testTrueFilterListener(){
+        SCAObject object = new TestSCAObject("foo",null);
+        Mock mock = mock(RuntimeEventListener.class);
+        Event event = new TestEvent();
+        mock.expects(once()).method("onEvent").with(eq(event));
+        RuntimeEventListener listener = (RuntimeEventListener)mock.proxy();
+        object.addListener(new TrueFilter(),listener);
+        object.publish(event);
+    }
+
+    public void testToString(){
+        SCAObject object = new TestSCAObject("foo",null);
+        assertNotNull(object.toString());
+    }
+
+    public void testGetName(){
+        SCAObject object = new TestSCAObject("foo",null);
+        assertEquals("foo",object.getName());
+    }
+
+
+    public void testToPrepare(){
+        SCAObject object = new TestSCAObject("foo",null);
+       object.prepare();
+    }
+
+
+    private class TestSCAObject extends AbstractSCAObject{
+        public TestSCAObject(String name, CompositeComponent parent) {
+            super(name, parent);
+        }
+
+        public Scope getScope() {
+            return null;
+        }
+
+        public Object getServiceInstance() throws TargetException {
+            return null;
+        }
+    }
+
+    private class TestEvent implements Event{
+        public Object getSource() {
+            return null;
+        }
+    }
+
+    private class FalseFilter implements EventFilter{
+
+        public boolean match(Event event) {
+            return false;
+        }
+    }
+
+
+
+}
+
+
+

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java?rev=412323&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
Wed Jun  7 01:15:23 2006
@@ -0,0 +1,66 @@
+package org.apache.tuscany.spi.extension;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AtomicComponentExtensionTestCase extends TestCase {
+
+    public void testIsEagerInit() throws Exception {
+        TestExtension ext = new TestExtension();
+        ext.isEagerInit();
+    }
+
+    public void testPrepare() throws Exception {
+        TestExtension ext = new TestExtension();
+        ext.prepare();
+    }
+
+    public void testInit() throws Exception {
+        TestExtension ext = new TestExtension();
+        ext.init(null);
+    }
+
+    public void testDestroy() throws Exception {
+        TestExtension ext = new TestExtension();
+        ext.destroy(null);
+    }
+
+    public void testInboundWire() throws Exception {
+        TestExtension ext = new TestExtension();
+        ext.getInboundWire(null);
+    }
+
+    private class TestExtension extends AtomicComponentExtension {
+        public TestExtension() {
+            super(null, null, null, null);
+        }
+
+        public Object getServiceInstance() throws TargetException {
+            return null;
+        }
+
+        public Object createInstance() throws ObjectCreationException {
+            return null;
+        }
+
+        public Object getServiceInstance(String name) throws TargetException {
+            return null;
+        }
+
+        public List getServiceInterfaces() {
+            return null;
+        }
+
+        public TargetInvoker createTargetInvoker(String serviceName, Method operation) {
+            return null;
+        }
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java?rev=412323&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
Wed Jun  7 01:15:23 2006
@@ -0,0 +1,50 @@
+package org.apache.tuscany.spi.extension;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTestCase extends TestCase {
+
+    public void testScope() throws Exception {
+        TestReference ref = new TestReference(null, null, null);
+        assertEquals(Scope.COMPOSITE, ref.getScope());
+
+    }
+
+    public void testSetGetInterface() throws Exception {
+        TestReference<TestReference> ref = new TestReference<TestReference>(null,
null, null);
+        ref.setInterface(TestReference.class);
+        assertEquals(TestReference.class, ref.getInterface());
+
+    }
+
+
+    public void testPrepare() throws Exception {
+        TestReference ref = new TestReference(null, null, null);
+        try {
+            ref.prepare();
+            fail();
+        } catch (AssertionError e) {
+            //expected
+        }
+
+    }
+
+    private class TestReference<T> extends ReferenceExtension<T> {
+        public TestReference(String name, CompositeComponent parent, WireService wireService)
{
+            super(name, parent, wireService);
+        }
+
+        public TargetInvoker createTargetInvoker(String serviceName, Method operation) {
+            return null;
+        }
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java?rev=412323&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
Wed Jun  7 01:15:23 2006
@@ -0,0 +1,33 @@
+package org.apache.tuscany.spi.extension;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceExtensionTestCase extends TestCase {
+
+    public void testScope() throws Exception {
+        ServiceExtension service = new ServiceExtension(null, null, null);
+        assertEquals(Scope.COMPOSITE, service.getScope());
+
+    }
+
+    public void testSetGetInterface() throws Exception {
+        ServiceExtension service = new ServiceExtension(null, null, null);
+        try {
+            service.getInterface();
+            fail();
+        } catch (AssertionError e) {
+            //expected
+        }
+    }
+
+
+    public void testPrepare() throws Exception {
+        ServiceExtension service = new ServiceExtension(null, null, null);
+        service.prepare();
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message