Author: ptahchiev Date: Mon Mar 17 03:01:07 2008 New Revision: 637813 URL: http://svn.apache.org/viewvc?rev=637813&view=rev Log: All Mock tests migrated to JMOck.
Modified: jakarta/cactus/trunk/framework/framework-12-13-14/src/test/java/org/apache/cactus/server/runner/TestServletTestRunner.java jakarta/cactus/trunk/framework/framework-13-14/src/test/java/org/apache/cactus/extension/jetty/TestJettyTestSetup.java jakarta/cactus/trunk/framework/pom.xml jakarta/cactus/trunk/integration/ant/pom.xml jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/TestEarParser.java jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/webapp/TestWebXmlMerger.java jakarta/cactus/trunk/pom.xml Modified: jakarta/cactus/trunk/framework/framework-12-13-14/src/test/java/org/apache/cactus/server/runner/TestServletTestRunner.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/framework/framework-12-13-14/src/test/java/org/apache/cactus/server/runner/TestServletTestRunner.java?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/framework/framework-12-13-14/src/test/java/org/apache/cactus/server/runner/TestServletTestRunner.java (original) +++ jakarta/cactus/trunk/framework/framework-12-13-14/src/test/java/org/apache/cactus/server/runner/TestServletTestRunner.java Mon Mar 17 03:01:07 2008 @@ -27,8 +27,9 @@ import javax.servlet.ServletException; import javax.servlet.UnavailableException; -import com.mockobjects.dynamic.C; -import com.mockobjects.dynamic.Mock; + +import org.jmock.MockObjectTestCase; +import org.jmock.Mock; import junit.framework.TestCase; @@ -37,9 +38,10 @@ * * @version $Id: TestServletTestRunner.java 238991 2004-05-22 11:34:50Z vmassol $ */ -public final class TestServletTestRunner extends TestCase +public final class TestServletTestRunner extends MockObjectTestCase + { - /** + /** * Control mock for [EMAIL PROTECTED] ServletConfig}. */ private Mock mockServletConfig; @@ -70,14 +72,17 @@ protected void setUp() { mockServletConfig = new Mock(ServletConfig.class); + servletConfig = (ServletConfig) mockServletConfig.proxy(); mockServletContext = new Mock(ServletContext.class); servletContext = (ServletContext) mockServletContext.proxy(); - mockServletConfig.matchAndReturn("getServletContext", servletContext); - mockServletConfig.matchAndReturn("getServletName", "TestServlet"); - mockServletContext.expect("log", C.ANY_ARGS); + mockServletConfig.expects( atLeastOnce() ).method( "getServletContext" ).will( returnValue( servletContext) ); + + mockServletConfig.expects( once() ).method( "getServletName" ).will( returnValue("TestServlet") ); + + mockServletContext.expects( once() ).method("log").withAnyArguments(); runner = new ServletTestRunner(); } @@ -90,8 +95,7 @@ */ public void testInitWhenNoXslStylesheet() throws ServletException { - mockServletConfig.expectAndReturn("getInitParameter", - "xsl-stylesheet", null); + mockServletConfig.expects( once() ).method("getInitParameter").with(eq("xsl-stylesheet")).will(returnValue(null)); runner.init(servletConfig); } @@ -105,10 +109,8 @@ */ public void testInitWhenXslStylesheetNotFound() throws ServletException { - mockServletConfig.expectAndReturn("getInitParameter", - "xsl-stylesheet", "some-stylesheet.xsl"); - mockServletContext.expectAndReturn("getResourceAsStream", C.ANY_ARGS, - null); + mockServletConfig.expects( once() ).method("getInitParameter").with(eq("xsl-stylesheet")).will(returnValue("some-stylesheet.xsl")); + mockServletContext.expects( atMostOnce() ).method("getResourceAsStream").withAnyArguments().will(returnValue(null)); try { @@ -130,8 +132,8 @@ */ public void testInitWithXslStylesheet() throws ServletException { - mockServletConfig.expectAndReturn("getInitParameter", - "xsl-stylesheet", "some-stylesheet.xsl"); + + mockServletConfig.expects( atLeastOnce() ).method("getInitParameter").with(eq("xsl-stylesheet")).will(returnValue("some-stylesheet.xsl")); InputStream mockInputStream = new InputStream() { @@ -151,10 +153,8 @@ return -1; } }; - - mockServletContext.expectAndReturn("getResourceAsStream", C.ANY_ARGS, - mockInputStream); - + + mockServletContext.expects(once()).method("getResourceAsStream").withAnyArguments().will(returnValue(mockInputStream)); // Note: There should be no call to log. If there is it means there // has been an error... Modified: jakarta/cactus/trunk/framework/framework-13-14/src/test/java/org/apache/cactus/extension/jetty/TestJettyTestSetup.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/framework/framework-13-14/src/test/java/org/apache/cactus/extension/jetty/TestJettyTestSetup.java?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/framework/framework-13-14/src/test/java/org/apache/cactus/extension/jetty/TestJettyTestSetup.java (original) +++ jakarta/cactus/trunk/framework/framework-13-14/src/test/java/org/apache/cactus/extension/jetty/TestJettyTestSetup.java Mon Mar 17 03:01:07 2008 @@ -21,11 +21,12 @@ import java.net.URL; +import org.apache.cactus.extension.jetty.Jetty5xTestSetup; import org.apache.cactus.internal.configuration.Configuration; import org.apache.cactus.internal.configuration.FilterConfiguration; import org.apache.cactus.internal.configuration.ServletConfiguration; - -import com.mockobjects.dynamic.Mock; +import org.jmock.Mock; +import org.jmock.MockObjectTestCase; import junit.framework.TestCase; @@ -37,7 +38,7 @@ * * @version $Id: TestJettyTestSetup.java 238991 2004-05-22 11:34:50Z vmassol $ */ -public class TestJettyTestSetup extends TestCase +public class TestJettyTestSetup extends MockObjectTestCase { /** * Control mock for [EMAIL PROTECTED] Configuration}. @@ -105,15 +106,18 @@ filterConfiguration = (FilterConfiguration) mockFilterConfiguration.proxy(); - mockConfiguration.matchAndReturn("getContextURL", CONTEXT_URL); - mockServletConfiguration.matchAndReturn("getDefaultRedirectorName", - "ServletRedirector"); + mockConfiguration.expects( atLeastOnce() ).method("getContextURL").will( returnValue(CONTEXT_URL) ); + //mockConfiguration.matchAndReturn("getContextURL", CONTEXT_URL); + mockServletConfiguration.expects( atLeastOnce() ).method( "getDefaultRedirectorName" ).will( returnValue("ServletRedirector") ); + //mockServletConfiguration.matchAndReturn("getDefaultRedirectorName", + // "ServletRedirector"); URL testURL = new URL(CONTEXT_URL + "/" + servletConfiguration.getDefaultRedirectorName()); - - mockServletConfiguration.matchAndReturn("getDefaultRedirectorURL", - testURL.getPath()); + + mockServletConfiguration.expects( atMostOnce() ).method("getDefaultRedirectorURL").will( returnValue(testURL.getPath()) ); + //mockServletConfiguration.matchAndReturn("getDefaultRedirectorURL", + // testURL.getPath()); jettyTestSetup = new Jetty5xTestSetup(new SampleTestCase(), configuration, servletConfiguration, filterConfiguration); Modified: jakarta/cactus/trunk/framework/pom.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/framework/pom.xml?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/framework/pom.xml (original) +++ jakarta/cactus/trunk/framework/pom.xml Mon Mar 17 03:01:07 2008 @@ -53,8 +53,8 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>mockobjects</groupId> - <artifactId>mockobjects-core</artifactId> + <groupId>jmock</groupId> + <artifactId>jmock</artifactId> <scope>test</scope> </dependency> <dependency> Modified: jakarta/cactus/trunk/integration/ant/pom.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/ant/pom.xml?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/ant/pom.xml (original) +++ jakarta/cactus/trunk/integration/ant/pom.xml Mon Mar 17 03:01:07 2008 @@ -48,8 +48,8 @@ <artifactId>commons-logging</artifactId> </dependency> <dependency> - <groupId>mockobjects</groupId> - <artifactId>mockobjects-core</artifactId> + <groupId>jmock</groupId> + <artifactId>jmock</artifactId> <scope>test</scope> </dependency> <dependency> Modified: jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/TestEarParser.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/TestEarParser.java?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/TestEarParser.java (original) +++ jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/TestEarParser.java Mon Mar 17 03:01:07 2008 @@ -31,17 +31,17 @@ import org.apache.tools.ant.BuildException; import org.codehaus.cargo.module.application.ApplicationXml; import org.codehaus.cargo.module.application.EarArchive; +import org.jmock.Mock; +import org.jmock.MockObjectTestCase; import org.w3c.dom.Document; import org.xml.sax.SAXException; -import com.mockobjects.dynamic.Mock; - /** * Unit tests for [EMAIL PROTECTED] EarParser}. * * @version $Id: TestEarParser.java 239003 2004-05-31 20:05:27Z vmassol $ */ -public final class TestEarParser extends TestCase +public final class TestEarParser extends MockObjectTestCase { /** * This is the actual content of the application.xml @@ -107,11 +107,14 @@ //This shouldn't happen; e.printStackTrace(); } + applicationXml = new ApplicationXml(document); mockArchive = new Mock(EarArchive.class); archive = (EarArchive) mockArchive.proxy(); - mockArchive.expectAndReturn("getApplicationXml", applicationXml); + + mockArchive.expects( atLeastOnce() ).method( "getApplicationXml" ).will( returnValue(applicationXml) ); + //mockArchive.expectAndReturn("getApplicationXml", applicationXml); } /** Modified: jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/webapp/TestWebXmlMerger.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/webapp/TestWebXmlMerger.java?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/webapp/TestWebXmlMerger.java (original) +++ jakarta/cactus/trunk/integration/ant/src/test/java/org/apache/cactus/integration/ant/deployment/webapp/TestWebXmlMerger.java Mon Mar 17 03:01:07 2008 @@ -32,7 +32,6 @@ import org.codehaus.cargo.module.webapp.WebXmlIo; import org.codehaus.cargo.module.webapp.WebXmlMerger; import org.codehaus.cargo.module.webapp.WebXmlTag; -import org.codehaus.cargo.module.webapp.WebXmlVersion; import org.w3c.dom.Document; import org.w3c.dom.Element; Modified: jakarta/cactus/trunk/pom.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/pom.xml?rev=637813&r1=637812&r2=637813&view=diff ============================================================================== --- jakarta/cactus/trunk/pom.xml (original) +++ jakarta/cactus/trunk/pom.xml Mon Mar 17 03:01:07 2008 @@ -182,10 +182,10 @@ <version>1.2.8</version> </dependency> <dependency> - <groupId>mockobjects</groupId> - <artifactId>mockobjects-core</artifactId> - <version>0.09</version> - </dependency> + <groupId>jmock</groupId> + <artifactId>jmock</artifactId> + <version>1.2.0</version> + </dependency> <dependency> <!-- used by httpunit --> <groupId>nekohtml</groupId> <artifactId>nekohtml</artifactId> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]