Moving JUnit and TestNG base classes into their own plugins

WW-2588


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@647062 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald J. Brown
2008-04-11 06:07:13 +00:00
parent 081c28d1ce
commit 1633765ee1
14 changed files with 306 additions and 32 deletions
+1 -11
View File
@@ -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>
+6
View File
@@ -41,6 +41,12 @@
</scm>
<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>
+7 -11
View File
@@ -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>
+60
View File
@@ -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>
@@ -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();
}
}
+2 -2
View File
@@ -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>
+7 -1
View File
@@ -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>
+6
View File
@@ -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>
+7 -1
View File
@@ -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>
+78
View File
@@ -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>
@@ -1,5 +1,5 @@
/*
* $Id$
* $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
@@ -33,7 +33,7 @@ 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 TestNGStrutsTestCase extends TestNGXWorkTestCase {
public class StrutsTestCase extends TestNGXWorkTestCase {
@BeforeTest
protected void setUp() throws Exception {
@@ -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 {
}
@@ -1,5 +1,5 @@
/*
* $Id$
* $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
@@ -49,12 +49,12 @@ public class TestNGStrutsTestCaseTest extends TestCase {
}
}
@Test
public static class RunTest extends TestNGStrutsTestCase {
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;