Modified: turbine/core/trunk/src/test/org/apache/turbine/services/template/DefaultsTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/services/template/DefaultsTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/services/template/DefaultsTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/services/template/DefaultsTest.java Fri Jun 27 14:46:47 2014 @@ -21,9 +21,14 @@ package org.apache.turbine.services.temp */ +import static org.junit.Assert.assertEquals; + import org.apache.turbine.services.TurbineServices; import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests all the various defaults for the Template Service. @@ -37,26 +42,33 @@ public class DefaultsTest private static TurbineConfig tc = null; private static TemplateService ts = null; - public DefaultsTest(String name) - throws Exception - { - super(name); + + @BeforeClass + public static void setUp() throws Exception { tc = new TurbineConfig(".", "/conf/test/TemplateService.properties"); tc.initialize(); ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); } + @AfterClass + public static void destroy() throws Exception { + ts.shutdown(); + tc.dispose(); + } + + @Test public void testDefaults() { - // Test if the caching property was loaded correctly. - assertEquals("isCaching failed!", ts.isCaching(), false); + // Test if the caching property was loaded correctly. (key:module.cache) + assertEquals("isCaching failed!",false, ts.isCaching()); // Test if the default values for Template and Extension were loaded correctly assertEquals("Default Extension failed", ts.getDefaultExtension(), ""); assertEquals("Default Template failed", ts.getDefaultTemplate(), TemplateService.DEFAULT_TEMPLATE_VALUE); } - + + @Test public void testTemplateDefaults() { // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct. @@ -66,7 +78,8 @@ public class DefaultsTest assertEquals("Default Navigation failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation()); assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate()); } - + + @Test public void testVelocityDefaults() { // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
Modified: turbine/core/trunk/src/test/org/apache/turbine/services/template/InitTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/services/template/InitTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/services/template/InitTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/services/template/InitTest.java Fri Jun 27 14:46:47 2014 @@ -21,10 +21,16 @@ package org.apache.turbine.services.temp */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.apache.turbine.services.TurbineServices; import org.apache.turbine.services.velocity.VelocityService; import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests startup of the Template Service and registration of the @@ -40,18 +46,26 @@ public class InitTest private static TurbineConfig tc = null; private static TemplateService ts = null; - public InitTest(String name) - throws Exception + + @BeforeClass + public static void setUp() throws Exception { - super(name); tc = new TurbineConfig(".", "/conf/test/TemplateService.properties"); tc.initialize(); ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); } + @AfterClass + public static void tearDown() throws Exception + { + if (tc != null) + { + tc.dispose(); + } + } - public void testService() + @Test public void testService() throws Exception { Modified: turbine/core/trunk/src/test/org/apache/turbine/services/template/TemplateTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/services/template/TemplateTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/services/template/TemplateTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/services/template/TemplateTest.java Fri Jun 27 14:46:47 2014 @@ -21,9 +21,14 @@ package org.apache.turbine.services.temp */ +import static org.junit.Assert.assertEquals; + import org.apache.turbine.services.TurbineServices; import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests all the various template mappings for Screen and Layout @@ -39,28 +44,38 @@ public class TemplateTest private static TurbineConfig tc = null; private static TemplateService ts = null; - public TemplateTest(String name) - throws Exception + + + @BeforeClass + public static void setUp() throws Exception { - super(name); tc = new TurbineConfig(".", "/conf/test/TemplateService.properties"); tc.initialize(); ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); } + @AfterClass + public static void tearDown() throws Exception + { + if (tc != null) + { + tc.dispose(); + } + } + - public void testTemplateDefaults() + @Test public void testTemplateDefaults() { assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate()); } - public void testVelocityDefaults() + @Test public void testVelocityDefaults() { assertEquals("Default LayoutTemplate failed", "Default.vm", ts.getDefaultLayoutTemplateName("foo.vm")); } - public void testTemplateExtension() + @Test public void testTemplateExtension() { assertEquals("Extension extraction failed", "vm", ts.getExtension("Default.vm")); assertEquals("Extension extraction failed", "txt", ts.getExtension("Default.txt")); @@ -68,7 +83,7 @@ public class TemplateTest assertEquals("Extension extraction failed", "vm", ts.getExtension("Default.txt.vm")); } - public void testNonExistingTemplate() + @Test public void testNonExistingTemplate() throws Exception { // @@ -80,7 +95,7 @@ public class TemplateTest assertEquals("ScreenTemplate translation failed", null, ts.getScreenTemplateName(templateName)); } - public void testNonExistingSublevelTemplate() + @Test public void testNonExistingSublevelTemplate() throws Exception { // @@ -92,7 +107,7 @@ public class TemplateTest assertEquals("ScreenTemplate translation failed", null, ts.getScreenTemplateName(templateName)); } - public void testExistingTemplate() + @Test public void testExistingTemplate() throws Exception { // @@ -117,7 +132,7 @@ public class TemplateTest assertEquals("ScreenTemplate translation failed", "existing/Page.vm", ts.getScreenTemplateName(templateName)); } - public void testExistingLayoutTemplate() + @Test public void testExistingLayoutTemplate() throws Exception { // @@ -129,7 +144,7 @@ public class TemplateTest assertEquals("ScreenTemplate translation failed", "ExistPageWithLayout.vm", ts.getScreenTemplateName(templateName)); } - public void testExistingSublevelLayoutTemplate() + @Test public void testExistingSublevelLayoutTemplate() throws Exception { // Modified: turbine/core/trunk/src/test/org/apache/turbine/services/velocity/PathConverterTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/services/velocity/PathConverterTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/services/velocity/PathConverterTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/services/velocity/PathConverterTest.java Fri Jun 27 14:46:47 2014 @@ -21,12 +21,18 @@ package org.apache.turbine.services.velo */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.apache.commons.collections.ExtendedProperties; import org.apache.commons.configuration.Configuration; import org.apache.turbine.Turbine; import org.apache.turbine.services.TurbineServices; import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests startup of the Velocity Service and translation of various @@ -43,18 +49,22 @@ public class PathConverterTest private static VelocityService vs = null; private static String fileSeperator = System.getProperty("file.separator"); - public PathConverterTest(String name) - throws Exception - { - super(name); + + @BeforeClass + public static void setUp() throws Exception { tc = new TurbineConfig(".", "/conf/test/TemplateService.properties"); tc.initialize(); vs = (VelocityService) TurbineServices.getInstance().getService(VelocityService.SERVICE_NAME); } + @AfterClass + public static void destroy() throws Exception { + vs.shutdown(); + tc.dispose(); + } - public void testService() + @Test public void testService() throws Exception { @@ -62,6 +72,7 @@ public class PathConverterTest assertNotNull("Could not load Service!", vs); } + @Test public void testPathTranslation() throws Exception { Modified: turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java Fri Jun 27 14:46:47 2014 @@ -31,8 +31,6 @@ import javax.servlet.ServletConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import junit.framework.TestCase; - import org.apache.log4j.PropertyConfigurator; import org.apache.turbine.TurbineConstants; import org.apache.turbine.om.security.User; @@ -40,6 +38,7 @@ import org.apache.turbine.pipeline.Pipel import org.apache.turbine.services.TurbineServices; import org.apache.turbine.services.rundata.RunDataService; import org.apache.turbine.util.RunData; +import org.junit.BeforeClass; import com.mockobjects.servlet.MockHttpServletRequest; @@ -53,14 +52,13 @@ import com.mockobjects.servlet.MockHttpS * @version $Id$ */ public abstract class BaseTestCase - extends TestCase { - File log4jFile = new File("conf/test/Log4j.properties"); + static File log4jFile = new File("conf/test/Log4j.properties"); - public BaseTestCase(String name) + @BeforeClass + public static void baseInit() throws Exception { - super(name); Properties p = new Properties(); try @@ -75,8 +73,6 @@ public abstract class BaseTestCase System.err.println("Could not open Log4J configuration file " + log4jFile); } - - } protected RunData getRunData(HttpServletRequest request,HttpServletResponse response,ServletConfig config) throws Exception { @@ -109,7 +105,6 @@ public abstract class BaseTestCase request.setupGetParameterNames(v.elements()); request.setSession(session); return request; - } } Modified: turbine/core/trunk/src/test/org/apache/turbine/test/BaseTurbineTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/test/BaseTurbineTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/test/BaseTurbineTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/test/BaseTurbineTest.java Fri Jun 27 14:46:47 2014 @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.turbine.TurbineConstants; import org.apache.turbine.util.TurbineConfig; +import org.junit.BeforeClass; /** * A base class to implement tests that need a running @@ -38,10 +39,9 @@ public abstract class BaseTurbineTest { private static TurbineConfig turbineConfig = null; - public BaseTurbineTest(String name, String config) - throws Exception + @BeforeClass + public static void turbineInit(String config) throws Exception { - super(name); if (turbineConfig == null) { Modified: turbine/core/trunk/src/test/org/apache/turbine/util/BrowserDetectorTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/util/BrowserDetectorTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/util/BrowserDetectorTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/util/BrowserDetectorTest.java Fri Jun 27 14:46:47 2014 @@ -19,7 +19,10 @@ package org.apache.turbine.util; * under the License. */ +import static org.junit.Assert.assertEquals; + import org.apache.turbine.test.BaseTestCase; +import org.junit.Test; /** * Testing of the BrowserDetector class. @@ -29,12 +32,9 @@ import org.apache.turbine.test.BaseTestC */ public class BrowserDetectorTest extends BaseTestCase { - public BrowserDetectorTest(String name) throws Exception - { - super(name); - } - public void testFirefox() + + @Test public void testFirefox() { String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5"; BrowserDetector bd = new BrowserDetector(userAgent); @@ -44,7 +44,7 @@ public class BrowserDetectorTest extends assertEquals(BrowserDetector.WINDOWS, bd.getBrowserPlatform()); } - public void testOpera() + @Test public void testOpera() { String userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.02"; BrowserDetector bd = new BrowserDetector(userAgent); @@ -59,7 +59,7 @@ public class BrowserDetectorTest extends assertEquals(BrowserDetector.WINDOWS, bd.getBrowserPlatform()); } - public void testIE() + @Test public void testIE() { String userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; BrowserDetector bd = new BrowserDetector(userAgent); Modified: turbine/core/trunk/src/test/org/apache/turbine/util/FormMessageTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/util/FormMessageTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/util/FormMessageTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/util/FormMessageTest.java Fri Jun 27 14:46:47 2014 @@ -21,18 +21,17 @@ package org.apache.turbine.util; */ +import static org.junit.Assert.assertTrue; + import org.apache.turbine.test.BaseTestCase; +import org.junit.Test; public class FormMessageTest extends BaseTestCase { - public FormMessageTest(String name) - throws Exception - { - super(name); - } - public void testCreateFormMessage() + + @Test public void testCreateFormMessage() { FormMessage fm = new FormMessage("mainForm","someField","A message!"); String fmString = fm.toString(); @@ -41,7 +40,7 @@ public class FormMessageTest assertTrue("Make sure toString works",fmString.indexOf("mainForm")>-1); } - public void testCreateFormMessageMultipleFields() + @Test public void testCreateFormMessageMultipleFields() { FormMessage fm = new FormMessage("mainForm","someField","A message!"); fm.setFieldName("someOtherField"); Modified: turbine/core/trunk/src/test/org/apache/turbine/util/parser/BaseValueParserTest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/util/parser/BaseValueParserTest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/util/parser/BaseValueParserTest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/util/parser/BaseValueParserTest.java Fri Jun 27 14:46:47 2014 @@ -21,6 +21,10 @@ package org.apache.turbine.util.parser; */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.math.BigDecimal; import org.apache.fulcrum.parser.BaseValueParser; @@ -28,6 +32,11 @@ import org.apache.fulcrum.parser.ParserS import org.apache.turbine.services.TurbineServices; import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; /** * Testing of the Fulcrum BaseValueParser class @@ -43,28 +52,20 @@ public class BaseValueParserTest extends private static TurbineConfig tc = null; - /** - * Constructor for test. - * - * @param testName name of the test being executed - */ - public BaseValueParserTest(String testName) - throws Exception - { - super(testName); - - // Setup configuration - tc = - new TurbineConfig( - ".", - "/conf/test/CompleteTurbineResources.properties"); - tc.initialize(); - } /** * Performs any initialization that must happen before each test is run. */ - protected void setUp() + @BeforeClass + public static void init() { + tc = + new TurbineConfig( + ".", + "/conf/test/CompleteTurbineResources.properties"); + tc.initialize(); + } + @Before + public void setUp() { try { @@ -80,17 +81,16 @@ public class BaseValueParserTest extends /** * Clean up after each test is run. */ - protected void tearDown() + @AfterClass + public static void tearDown() { if (tc != null) { tc.dispose(); } - - parser = null; } - public void testGetByte() + @Test public void testGetByte() { // no param byte result = parser.getByte("invalid"); @@ -111,7 +111,7 @@ public class BaseValueParserTest extends assertEquals(result, 0); } - public void testGetByteObject() + @Test public void testGetByteObject() { // no param Byte result = parser.getByteObject("invalid"); @@ -132,7 +132,7 @@ public class BaseValueParserTest extends assertNull(result); } - public void testGetInt() + @Test public void testGetInt() { // no param int result = parser.getInt("invalid"); @@ -177,7 +177,7 @@ public class BaseValueParserTest extends } } - public void testGetIntObject() + @Test public void testGetIntObject() { // no param Integer result = parser.getIntObject("invalid"); @@ -222,7 +222,7 @@ public class BaseValueParserTest extends } } - public void testGetFloat() + @Test public void testGetFloat() { // no param float result = parser.getFloat("invalid"); @@ -267,7 +267,7 @@ public class BaseValueParserTest extends } } - public void testGetFloatObject() + @Test public void testGetFloatObject() { // no param Float result = parser.getFloatObject("invalid"); @@ -312,7 +312,7 @@ public class BaseValueParserTest extends } } - public void testGetDouble() + @Test public void testGetDouble() { // no param double result = parser.getDouble("invalid"); @@ -357,7 +357,7 @@ public class BaseValueParserTest extends } } - public void testGetDoubleObject() + @Test public void testGetDoubleObject() { // no param Double result = parser.getDoubleObject("invalid"); @@ -402,7 +402,7 @@ public class BaseValueParserTest extends } } - public void testGetLong() + @Test public void testGetLong() { // no param long result = parser.getLong("invalid"); @@ -447,7 +447,7 @@ public class BaseValueParserTest extends } } - public void testGetLongObject() + @Test public void testGetLongObject() { // no param Long result = parser.getLongObject("invalid"); @@ -492,7 +492,7 @@ public class BaseValueParserTest extends } } - public void testGetBoolean() + @Test public void testGetBoolean() { // no param boolean result = parser.getBoolean("invalid"); @@ -523,7 +523,7 @@ public class BaseValueParserTest extends } - public void testGetBooleanObject() + @Test public void testGetBooleanObject() { // no param Boolean result = parser.getBooleanObject("invalid"); @@ -573,7 +573,7 @@ public class BaseValueParserTest extends * on Java 1.4.2_09 on OSX. * */ - public void OFFtestGetBigDecimal() + @Ignore public void testGetBigDecimal() { // no param BigDecimal result = parser.getBigDecimal("invalid"); @@ -653,7 +653,7 @@ public class BaseValueParserTest extends } - public void testRecycling() throws Exception { + @Test public void testRecycling() throws Exception { parser.setCharacterEncoding("fake"); parser.recycle(); assertEquals("US-ASCII",parser.getCharacterEncoding()); Modified: turbine/core/trunk/src/test/org/apache/turbine/util/uri/TurbineURITest.java URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/util/uri/TurbineURITest.java?rev=1606111&r1=1606110&r2=1606111&view=diff ============================================================================== --- turbine/core/trunk/src/test/org/apache/turbine/util/uri/TurbineURITest.java (original) +++ turbine/core/trunk/src/test/org/apache/turbine/util/uri/TurbineURITest.java Fri Jun 27 14:46:47 2014 @@ -19,6 +19,8 @@ package org.apache.turbine.util.uri; * under the License. */ +import static org.junit.Assert.assertEquals; + import org.apache.fulcrum.parser.DefaultParameterParser; import org.apache.fulcrum.parser.ParameterParser; import org.apache.fulcrum.parser.ParserService; @@ -26,6 +28,10 @@ import org.apache.turbine.services.Turbi import org.apache.turbine.test.BaseTestCase; import org.apache.turbine.util.ServerData; import org.apache.turbine.util.TurbineConfig; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; /** * Testing of the TurbineURI class @@ -42,29 +48,23 @@ public class TurbineURITest extends Base private static TurbineConfig tc = null; - /** - * Constructor for test. - * - * @param testName - * name of the test being executed - */ - public TurbineURITest(String testName) throws Exception - { - super(testName); - // Setup configuration - tc = - new TurbineConfig( - ".", - "/conf/test/CompleteTurbineResources.properties"); + @BeforeClass + public static void init() { + tc = new TurbineConfig( + ".", + "/conf/test/CompleteTurbineResources.properties"); tc.initialize(); } - /** * Performs any initialization that must happen before each test is run. */ - protected void setUp() + + @Before + public void setup() { + // Setup configuration + ServerData sd = new ServerData("www.testserver.com", URIConstants.HTTP_PORT, URIConstants.HTTP, "/servlet/turbine", "/context"); @@ -76,17 +76,17 @@ public class TurbineURITest extends Base /** * Clean up after each test is run. */ - protected void tearDown() + @AfterClass + public static void tearDown() { if (tc != null) { tc.dispose(); } - turi = null; } - public void testAddRemove() + @Test public void testAddRemove() { assertEquals("TurbineURI should not have a pathInfo", false, turi .hasPathInfo()); @@ -119,7 +119,7 @@ public class TurbineURITest extends Base .hasPathInfo()); } - public void testEmptyAndNullQueryData() + @Test public void testEmptyAndNullQueryData() { // Check empty String assertEquals("/context/servlet/turbine", turi.getRelativeLink()); @@ -136,7 +136,7 @@ public class TurbineURITest extends Base assertEquals("/context/servlet/turbine", turi.getRelativeLink()); } - public void testEmptyAndNullPathInfo() + @Test public void testEmptyAndNullPathInfo() { // Check empty String assertEquals("/context/servlet/turbine", turi.getRelativeLink()); @@ -154,14 +154,14 @@ public class TurbineURITest extends Base assertEquals("/context/servlet/turbine", turi.getRelativeLink()); } - public void testAddEmptyParameterParser() + @Test public void testAddEmptyParameterParser() { ParameterParser pp = new DefaultParameterParser(); turi.add(1, pp); // 1 = query data assertEquals("/context/servlet/turbine", turi.getRelativeLink()); } - public void testAddParameterParser() throws InstantiationException + @Test public void testAddParameterParser() throws InstantiationException { ParameterParser pp = (ParameterParser) parserService.getParser(DefaultParameterParser.class); pp.add("test", "");
