portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r643126 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test: ./ JetspeedTestCase.java
Date Mon, 31 Mar 2008 20:19:22 GMT
Author: ate
Date: Mon Mar 31 13:19:00 2008
New Revision: 643126

URL: http://svn.apache.org/viewvc?rev=643126&view=rev
Log:
Adding a new base JetspeedTestCase to help with:

* Running testcases unforked, meaning their current working directory is most likely not their
project directly in case of building multiple modules.
However maven (surefire) does provide the current project "basedir" as system property which
can be used to offset project relative paths.

* Running setup/tearDown functionality on TestCase level (not Test level).
As JUnit TestSuite puts the found tests in a vector, ordering of tests is not garanteed the
same as their definition order in the class itself.
The static createFixturedTestCase method allows for adding additional first/last tests which
will be executed in proper order.

Note: putting this class in jetspeed-cm isn't the best of places in my view, but will do for
now.
I'm planning to create a separate jetspeed-test-utils module for providing tests only features
and move all other "generic" test support classes there too.
These test support features shouldn't pollute our production runtime environment.  

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
  (with props)

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java?rev=643126&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
Mon Mar 31 13:19:00 2008
@@ -0,0 +1,79 @@
+/*
+ * 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.jetspeed.test;
+
+import java.util.Enumeration;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @version $Id$
+ *
+ */
+public class JetspeedTestCase extends TestCase
+{
+    public static TestSuite createFixturedTestSuite(Class testClass, String firstTest, String
lastTest)
+    {
+        // All methods starting with "test" will automatically be executed in the test suite.
+        TestSuite tmp = new TestSuite(testClass);
+        Enumeration e = tmp.tests();
+        TestSuite ts = new TestSuite();
+        if (firstTest != null)
+        {
+            // add lirst test to be executed
+            ts.addTest(ts.createTest(testClass, firstTest));
+        }
+        while (e.hasMoreElements())
+        {
+            ts.addTest((Test)e.nextElement());
+        }
+        if (lastTest != null)
+        {
+            // add lirst test to be executed
+            ts.addTest(ts.createTest(testClass, lastTest));
+        }
+        return ts;
+    }
+
+    private String baseDir;
+    
+    public JetspeedTestCase()
+    {
+        super();
+    }
+
+    public JetspeedTestCase(String name)
+    {
+        super(name);
+    }
+    
+    public String getBaseDir()
+    {
+        if (baseDir == null)
+        {
+            baseDir = System.getProperty("basedir");
+            if (baseDir == null || baseDir.length() == 0)
+            {
+                baseDir = ".";
+            }
+            baseDir += "/";
+        }
+        return baseDir;
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/JetspeedTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message