You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2006/08/29 21:51:26 UTC

svn commit: r438180 - /incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java

Author: jboynes
Date: Tue Aug 29 12:51:25 2006
New Revision: 438180

URL: http://svn.apache.org/viewvc?rev=438180&view=rev
Log:
convert testcase to EasyMock

Modified:
    incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java

Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java?rev=438180&r1=438179&r2=438180&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java Tue Aug 29 12:51:25 2006
@@ -20,47 +20,50 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
-
 import javax.xml.namespace.QName;
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-import org.osoa.sca.Version;
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
 
 import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.model.CompositeImplementation;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ImplementationCompositeLoaderTestCase extends MockObjectTestCase {
-    private static final QName IMPLEMENTATION_COMPOSITE =
-            new QName(Version.XML_NAMESPACE_1_0, "implementation.composite");
+public class ImplementationCompositeLoaderTestCase extends TestCase {
+    private static final QName IMPLEMENTATION_COMPOSITE = new QName(XML_NAMESPACE_1_0, "implementation.composite");
 
     private ImplementationCompositeLoader loader;
-    private Mock mockReader;
+    private XMLStreamReader reader;
+    private DeploymentContext context;
 
     public void testName() throws LoaderException, XMLStreamException, MalformedURLException {
         String name = "foo";
-        mockReader.expects(once()).method("getName").will(returnValue(IMPLEMENTATION_COMPOSITE));
-        mockReader.expects(atLeastOnce()).method("getAttributeValue")
-                .with(ANYTHING, ANYTHING)
-                .will(returnValue(name));
-        mockReader.expects(once()).method("next").will(returnValue(END_ELEMENT));
-        URL scdlLocation = new URL("http://META-INF/sca/");
-        CompositeImplementation impl = loader.load(null, (XMLStreamReader) mockReader.proxy(),
-                new RootDeploymentContext(getClass().getClassLoader(), null, null, scdlLocation));
+        expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE);
+        expect(reader.getAttributeValue(null, "name")).andReturn(name);
+        expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("bar.scdl");
+        expect(reader.next()).andReturn(END_ELEMENT);
+        replay(reader);
+        CompositeImplementation impl = loader.load(null, reader, context);
+        verify(reader);
         assertEquals(name, impl.getName());
+        assertEquals(new URL("http://www.example.com/sca/bar.scdl"), impl.getScdlLocation());
     }
 
     protected void setUp() throws Exception {
         super.setUp();
-        this.loader = new ImplementationCompositeLoader(null);
-        mockReader = mock(XMLStreamReader.class);
-
+        loader = new ImplementationCompositeLoader(null);
+        reader = createMock(XMLStreamReader.class);
+        context = new RootDeploymentContext(null, null, null, new URL("http://www.example.com/sca/base.scdl"));
     }
 }



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