struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r647062 - in /struts/struts2/trunk: core/ core/src/main/java/org/apache/struts2/ core/src/test/java/org/apache/struts2/ plugins/ plugins/codebehind/ plugins/dojo/ plugins/junit/ plugins/junit/src/ plugins/junit/src/main/ plugins/junit/src/m...
Date Fri, 11 Apr 2008 06:07:39 GMT
Author: mrdon
Date: Thu Apr 10 23:07:13 2008
New Revision: 647062

URL: http://svn.apache.org/viewvc?rev=647062&view=rev
Log:
Moving JUnit and TestNG base classes into their own plugins
WW-2588

Added:
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsTestCase.java
      - copied unchanged from r647046, struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/plugins/junit/
    struts/struts2/trunk/plugins/junit/pom.xml
    struts/struts2/trunk/plugins/junit/src/
    struts/struts2/trunk/plugins/junit/src/main/
    struts/struts2/trunk/plugins/junit/src/main/java/
    struts/struts2/trunk/plugins/junit/src/main/java/org/
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/plugins/testng/
    struts/struts2/trunk/plugins/testng/pom.xml
    struts/struts2/trunk/plugins/testng/src/
    struts/struts2/trunk/plugins/testng/src/main/
    struts/struts2/trunk/plugins/testng/src/main/java/
    struts/struts2/trunk/plugins/testng/src/main/java/org/
    struts/struts2/trunk/plugins/testng/src/main/java/org/apache/
    struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/
    struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java
    struts/struts2/trunk/plugins/testng/src/test/
    struts/struts2/trunk/plugins/testng/src/test/java/
    struts/struts2/trunk/plugins/testng/src/test/java/org/
    struts/struts2/trunk/plugins/testng/src/test/java/org/apache/
    struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/
    struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java
Removed:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java
Modified:
    struts/struts2/trunk/core/pom.xml
    struts/struts2/trunk/plugins/codebehind/pom.xml
    struts/struts2/trunk/plugins/dojo/pom.xml
    struts/struts2/trunk/plugins/pom.xml
    struts/struts2/trunk/plugins/portlet/pom.xml
    struts/struts2/trunk/plugins/sitegraph/pom.xml
    struts/struts2/trunk/plugins/struts1/pom.xml

Modified: struts/struts2/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/core/pom.xml (original)
+++ struts/struts2/trunk/core/pom.xml Thu Apr 10 23:07:13 2008
@@ -334,18 +334,8 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>compile</scope>
+            <scope>test</scope>
             <version>3.8.2</version>
-            <!-- compile time dependency for StrutsTestCase, which is part of the base
package so others can write unit tests -->
-            <optional>true</optional>
-        </dependency>
-
-        <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-            <version>5.1</version>
-            <optional>true</optional>
-            <classifier>jdk15</classifier>
         </dependency>
 
         <dependency>

Modified: struts/struts2/trunk/plugins/codebehind/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/codebehind/pom.xml (original)
+++ struts/struts2/trunk/plugins/codebehind/pom.xml Thu Apr 10 23:07:13 2008
@@ -42,6 +42,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

Modified: struts/struts2/trunk/plugins/dojo/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/dojo/pom.xml (original)
+++ struts/struts2/trunk/plugins/dojo/pom.xml Thu Apr 10 23:07:13 2008
@@ -128,6 +128,7 @@
     </build>
 
     <dependencies>
+
         <!-- Core -->
         <dependency>
             <groupId>org.apache.struts</groupId>
@@ -155,20 +156,15 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>compile</scope>
+            <scope>test</scope>
             <version>3.8.2</version>
-            <!-- has to be compile for StrutsTestCase, which is part of the base package
so others can write unit tests -->
-            <optional>true</optional>
         </dependency>
-
         <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-            <version>5.1</version>
-            <optional>true</optional>
-            <classifier>jdk15</classifier>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
         </dependency>
-
         <dependency>
             <groupId>jmock</groupId>
             <artifactId>jmock</artifactId>
@@ -242,7 +238,7 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-mock</artifactId>
             <version>2.0.8</version>
-            <optional>true</optional>
+            <scope>test</scope>
         </dependency>
 
         <dependency>

Added: struts/struts2/trunk/plugins/junit/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/pom.xml?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/junit/pom.xml (added)
+++ struts/struts2/trunk/plugins/junit/pom.xml Thu Apr 10 23:07:13 2008
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * $Id: pom.xml 612481 2008-01-16 15:24:54Z husted $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-plugins</artifactId>
+        <version>2.1.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.struts</groupId>
+    <artifactId>struts2-junit-plugin</artifactId>
+    <packaging>jar</packaging>
+    <name>Struts 2 JUnit Plugin</name>
+
+    <scm>
+       <connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/junit/</connection>
+       <developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/junit/</developerConnection>
+       <url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/junit/</url>
+    </scm>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-mock</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+    </dependencies>
+</project>

Added: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
(added)
+++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
Thu Apr 10 23:07:13 2008
@@ -0,0 +1,96 @@
+/*
+ * $Id: StrutsTestCase.java 588186 2007-10-25 10:01:04Z mrdon $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.util.StrutsTestCaseHelper;
+
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory;
+
+/**
+ * Base test case for JUnit testing Struts.
+ */
+public abstract class StrutsTestCase extends XWorkTestCase {
+
+    static {
+        ConsoleHandler handler = new ConsoleHandler();
+        final SimpleDateFormat df = new SimpleDateFormat("mm:ss.SSS");
+        Formatter formatter = new Formatter() {
+            @Override
+            public String format(LogRecord record) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(record.getLevel());
+                sb.append(':');
+                for (int x=9-record.getLevel().toString().length(); x>0; x--) {
+                    sb.append(' ');
+                }
+                sb.append('[');
+                sb.append(df.format(new Date(record.getMillis())));
+                sb.append("] ");
+                sb.append(formatMessage(record));
+                sb.append('\n');
+                return sb.toString();
+            }
+        };
+        handler.setFormatter(formatter);
+        Logger logger = Logger.getLogger("");
+        if (logger.getHandlers().length > 0)
+            logger.removeHandler(logger.getHandlers ()[0]);
+        logger.addHandler(handler);
+        logger.setLevel(Level.WARNING);
+        LoggerFactory.setLoggerFactory(new JdkLoggerFactory());
+    }
+    
+    /**
+     * Sets up the configuration settings, XWork configuration, and
+     * message resources
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        initDispatcher(null);
+    }
+    
+    protected Dispatcher initDispatcher(Map<String,String> params) {
+        Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
+        configurationManager = du.getConfigurationManager();
+        configuration = configurationManager.getConfiguration();
+        container = configuration.getContainer();
+        return du;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        StrutsTestCaseHelper.tearDown();
+    }
+
+}

Modified: struts/struts2/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/pom.xml (original)
+++ struts/struts2/trunk/plugins/pom.xml Thu Apr 10 23:07:13 2008
@@ -56,6 +56,8 @@
         <module>dojo</module>
         <module>rest</module>
         <module>portlet</module>
+        <module>junit</module>
+        <module>testng</module>
     </modules>
 
     <dependencies>
@@ -72,8 +74,6 @@
             <artifactId>junit</artifactId>
             <scope>compile</scope>
             <version>3.8.2</version>
-            <!-- has to be compile for StrutsTestCase, which is part of the base package
so others can write unit tests -->
-            <optional>true</optional>
         </dependency>
 
 

Modified: struts/struts2/trunk/plugins/portlet/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/pom.xml (original)
+++ struts/struts2/trunk/plugins/portlet/pom.xml Thu Apr 10 23:07:13 2008
@@ -47,6 +47,12 @@
             <scope>test</scope>
             <version>3.8.2</version>
         </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
 
       <dependency>
             <groupId>javax.servlet</groupId>
@@ -81,7 +87,7 @@
             <groupId>portlet-api</groupId>
             <artifactId>portlet-api</artifactId>
             <version>1.0</version>
-            <optional>true</optional>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>

Modified: struts/struts2/trunk/plugins/sitegraph/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitegraph/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/sitegraph/pom.xml (original)
+++ struts/struts2/trunk/plugins/sitegraph/pom.xml Thu Apr 10 23:07:13 2008
@@ -58,6 +58,12 @@
     </build>
 
     <dependencies>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>javax.servlet</groupId>

Modified: struts/struts2/trunk/plugins/struts1/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/pom.xml?rev=647062&r1=647061&r2=647062&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/struts1/pom.xml (original)
+++ struts/struts2/trunk/plugins/struts1/pom.xml Thu Apr 10 23:07:13 2008
@@ -46,6 +46,12 @@
             <artifactId>struts-core</artifactId>
             <version>1.3.5</version>
         </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>mockobjects</groupId>
@@ -59,7 +65,7 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-mock</artifactId>
             <version>2.0.8</version>
-            <optional>true</optional>
+            <scope>test</scope>
         </dependency>
 
         <dependency>

Added: struts/struts2/trunk/plugins/testng/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/testng/pom.xml?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/testng/pom.xml (added)
+++ struts/struts2/trunk/plugins/testng/pom.xml Thu Apr 10 23:07:13 2008
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * $Id: pom.xml 612481 2008-01-16 15:24:54Z husted $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-plugins</artifactId>
+        <version>2.1.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.struts</groupId>
+    <artifactId>struts2-testng-plugin</artifactId>
+    <packaging>jar</packaging>
+    <name>Struts 2 TestNG Plugin</name>
+
+    <scm>
+       <connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/testng/</connection>
+       <developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/testng/</developerConnection>
+       <url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/testng/</url>
+    </scm>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.1</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-mock</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jsp-api</artifactId>
+            <version>2.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+
+
+    </dependencies>
+</project>

Added: struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
(added)
+++ struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
Thu Apr 10 23:07:13 2008
@@ -0,0 +1,58 @@
+/*
+ * $Id: TestNGStrutsTestCase.java 502294 2007-02-01 17:28:00Z niallp $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+import java.util.Map;
+
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.util.StrutsTestCaseHelper;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+
+import com.opensymphony.xwork2.TestNGXWorkTestCase;
+
+/**
+ * Base test class for TestNG unit tests.  Provides common Struts variables
+ * and performs Struts setup and teardown processes
+ */
+public class StrutsTestCase extends TestNGXWorkTestCase {
+
+    @BeforeTest
+    protected void setUp() throws Exception {
+        super.setUp();
+        initDispatcher(null);
+    }
+    
+    protected Dispatcher initDispatcher(Map<String,String> params) {
+        Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
+        configurationManager = du.getConfigurationManager();
+        configuration = configurationManager.getConfiguration();
+        container = configuration.getContainer();
+        return du;
+    }
+
+    @AfterTest
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        StrutsTestCaseHelper.tearDown();
+    }
+}
+

Added: struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java
(added)
+++ struts/struts2/trunk/plugins/testng/src/main/java/org/apache/struts2/TestNGStrutsTestCase.java
Thu Apr 10 23:07:13 2008
@@ -0,0 +1,30 @@
+/*
+ * $Id: TestNGStrutsTestCase.java 502294 2007-02-01 17:28:00Z niallp $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+/**
+ * Base test class for TestNG unit tests.  Provides common Struts variables
+ * and performs Struts setup and teardown processes
+ * @deprecated since 2.1.1, use StrutsTestCase instead
+ */
+public class TestNGStrutsTestCase extends StrutsTestCase {
+}
+

Added: struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java?rev=647062&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java
(added)
+++ struts/struts2/trunk/plugins/testng/src/test/java/org/apache/struts2/TestNGStrutsTestCaseTest.java
Thu Apr 10 23:07:13 2008
@@ -0,0 +1,65 @@
+/*
+ * $Id: TestNGStrutsTestCaseTest.java 502294 2007-02-01 17:28:00Z niallp $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+import junit.framework.TestCase;
+
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.testng.TestListenerAdapter;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+
+import com.opensymphony.xwork2.config.ConfigurationManager;
+
+public class TestNGStrutsTestCaseTest extends TestCase {
+
+    public void testSimpleTest() throws Exception {
+        TestListenerAdapter tla = new TestListenerAdapter();
+        TestNG testng = new TestNG();
+        testng.setTestClasses(new Class[] { RunTest.class });
+        testng.addListener(tla);
+        try {
+            testng.run();
+            assertEquals(1, tla.getPassedTests().size());
+            assertEquals(0, tla.getFailedTests().size());
+            assertTrue(RunTest.ran);
+            assertNotNull(RunTest.mgr);
+            assertNotNull(RunTest.du);
+            assertNull(Dispatcher.getInstance());
+        } finally {
+            RunTest.mgr = null;
+        }
+    }
+    
+    public static class RunTest extends StrutsTestCase {
+        public static boolean ran = false;
+        public static ConfigurationManager mgr;
+        public static Dispatcher du;
+       
+        @Test 
+        public void testRun() {
+            ran = true;
+            mgr = this.configurationManager;
+            du = Dispatcher.getInstance();
+        }
+    }
+}
+



Mime
View raw message