You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-dev@portals.apache.org by wo...@apache.org on 2014/07/04 22:23:05 UTC

svn commit: r1607932 - in /portals/applications/webcontent/trunk: ./ portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/ portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/

Author: woonsan
Date: Fri Jul  4 20:23:04 2014
New Revision: 1607932

URL: http://svn.apache.org/r1607932
Log:
APA-62: converting test cases to junit4 based ones

Added:
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/AbstractRewriterTestCase.java
      - copied, changed from r1607928, portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/RewriterTestCase.java
Removed:
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/RewriterTestCase.java
Modified:
    portals/applications/webcontent/trunk/pom.xml
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientAuth.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientThroughProxy.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestProxyPathMappings.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestReverseProxyLinkRewritingParserAaptor.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestURICleaner.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestNekoRewriter.java
    portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestRewriterController.java

Modified: portals/applications/webcontent/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/pom.xml?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/pom.xml (original)
+++ portals/applications/webcontent/trunk/pom.xml Fri Jul  4 20:23:04 2014
@@ -39,7 +39,7 @@
     <org.apache.portals.bridges.common.version>2.0</org.apache.portals.bridges.common.version>
     <org.apache.portals.bridges.velocity.version>2.0</org.apache.portals.bridges.velocity.version>
     <slf4j.version>1.5.6</slf4j.version>
-    <junit.version>3.8.1</junit.version>
+    <junit.version>4.11</junit.version>
     <nekohtml.version>0.9.5</nekohtml.version>
     <castor.version>1.1.1</castor.version>
     <httpcomponents-httpcore.version>4.0.1</httpcomponents-httpcore.version>
@@ -274,12 +274,6 @@
         <artifactId>junit</artifactId>
         <version>${junit.version}</version>
         <scope>test</scope>
-        <exclusions>
-          <exclusion>
-            <groupId>junit-addons</groupId>
-            <artifactId>junit-addons-runner</artifactId>
-          </exclusion>
-        </exclusions>
       </dependency>
 
       <dependency>

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientAuth.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientAuth.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientAuth.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientAuth.java Fri Jul  4 20:23:04 2014
@@ -16,9 +16,9 @@
  */
 package org.apache.portals.applications.webcontent2.proxy;
 
-import java.net.URI;
+import static org.junit.Assert.assertNull;
 
-import junit.framework.TestCase;
+import java.net.URI;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.HttpEntity;
@@ -36,13 +36,16 @@ import org.apache.http.conn.ssl.SSLSocke
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Example test case to show how to implement multi-threaded http client invocations with authentications.
  * 
  * @version $Id$
  */
-public class TestHttpClientAuth extends TestCase
+public class TestHttpClientAuth
 {
     private String authHost;
     private int authPort = 80;
@@ -62,7 +65,7 @@ public class TestHttpClientAuth extends 
     private ClientConnectionManager connectionManager;    
     private int workersCount = 20;
     
-    @Override
+    @Before
     public void setUp()
     {
         targetURI = System.getProperty("TestHttpClientAuth.targetURI");
@@ -110,7 +113,7 @@ public class TestHttpClientAuth extends 
         connectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
     }
 
-    @Override
+    @After
     public void tearDown()
     {
         // When HttpClient instance is no longer needed,
@@ -122,6 +125,7 @@ public class TestHttpClientAuth extends 
         }
     }
 
+    @Test
     public void testClientAuthentication() throws Exception
     {
         if (!targetURIAvailable)

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientThroughProxy.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientThroughProxy.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientThroughProxy.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestHttpClientThroughProxy.java Fri Jul  4 20:23:04 2014
@@ -18,8 +18,6 @@ package org.apache.portals.applications.
 
 import java.io.InputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
@@ -31,26 +29,29 @@ import org.apache.http.conn.params.ConnR
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Example test case to show how to implement http client invocations with proxy configuration
  * 
  * @version $Id$
  */
-public class TestHttpClientThroughProxy extends TestCase
+public class TestHttpClientThroughProxy
 {
     
     private HttpClient httpClient;
     private HttpParams clientParams;
     private HttpHost defaultProxy = new HttpHost("localhost", 8000);
     
-    @Override
+    @Before
     public void setUp()
     {
         clientParams = new BasicHttpParams();
         httpClient = new DefaultHttpClient(clientParams);
     }
     
+    @Test
     public void testClientThroughProxy()
     {
         String targetURL = "http://portals.apache.org/issue-tracking.html";

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestProxyPathMappings.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestProxyPathMappings.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestProxyPathMappings.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestProxyPathMappings.java Fri Jul  4 20:23:04 2014
@@ -16,28 +16,30 @@
  */
 package org.apache.portals.applications.webcontent2.proxy;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultHttpReverseProxyPathMapperImpl;
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultHttpReverseProxyPathMapperProviderImpl;
 import org.apache.portals.applications.webcontent2.rewriter.RewriterController;
 import org.apache.portals.applications.webcontent2.rewriter.rules.Ruleset;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * TestProxyPassMappings
  * 
  * @version $Id$
  */
-public class TestProxyPathMappings extends TestCase
+public class TestProxyPathMappings
 {
     private DefaultHttpReverseProxyPathMapperProviderImpl pathMapperProvider;
     
-    @Override
+    @Before
     public void setUp()
     {
         Map<HttpReverseProxyPathMapper, RewriterController> rewriterControllerMap = new HashMap<HttpReverseProxyPathMapper, RewriterController>();
@@ -54,6 +56,7 @@ public class TestProxyPathMappings exten
         pathMapperProvider.setMaxMatchingPathPartCount(3);
     }
     
+    @Test
     public void testProxyPathMappings() throws Exception
     {
         HttpReverseProxyPathMapper mapper = null;
@@ -89,6 +92,7 @@ public class TestProxyPathMappings exten
         assertEquals("/secure/blogs_apache/index.html", mapper.getLocalPath("https://blogs.apache.org/index.html"));
     }
     
+    @Test
     public void testProxyURLMappings() throws Exception
     {
         HttpReverseProxyPathMapper mapper = pathMapperProvider.findMapperByRemoteURL("http://www.apache.org/index.html");

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestReverseProxyLinkRewritingParserAaptor.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestReverseProxyLinkRewritingParserAaptor.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestReverseProxyLinkRewritingParserAaptor.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestReverseProxyLinkRewritingParserAaptor.java Fri Jul  4 20:23:04 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.portals.applications.webcontent2.proxy;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -23,17 +25,17 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultHttpReverseProxyPathMapperImpl;
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultHttpReverseProxyPathMapperProviderImpl;
-import org.apache.portals.applications.webcontent2.proxy.impl.DefaultReverseProxyRewritingContext;
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultReverseProxyLinkRewritingParserAdaptor;
+import org.apache.portals.applications.webcontent2.proxy.impl.DefaultReverseProxyRewritingContext;
 import org.apache.portals.applications.webcontent2.rewriter.RewriterController;
 import org.apache.portals.applications.webcontent2.rewriter.rules.Ruleset;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,7 +44,7 @@ import org.slf4j.LoggerFactory;
  * 
  * @version $Id$
  */
-public class TestReverseProxyLinkRewritingParserAaptor extends TestCase
+public class TestReverseProxyLinkRewritingParserAaptor
 {
     
     private static Logger log = LoggerFactory.getLogger(TestReverseProxyLinkRewritingParserAaptor.class);
@@ -79,7 +81,7 @@ public class TestReverseProxyLinkRewriti
     private HttpReverseProxyPathMapper securedApacheProxyPathMapper;
     private HttpReverseProxyPathMapper localhostProxyPathMapper;
     
-    @Override
+    @Before
     public void setUp()
     {
         apacheProxyPathMapper = new DefaultHttpReverseProxyPathMapperImpl("apache", "/*_apache/", "http://$1.apache.org/");
@@ -98,6 +100,7 @@ public class TestReverseProxyLinkRewriti
         proxyPathMapperProvider = new DefaultHttpReverseProxyPathMapperProviderImpl(proxyPathMappers, rewriterControllerMap, rewriterRulesetMap);
     }
     
+    @Test
     public void testPathMappingRewriting() throws Exception
     {
         ReverseProxyRewritingContext rewritingContext = 

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestURICleaner.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestURICleaner.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestURICleaner.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/proxy/TestURICleaner.java Fri Jul  4 20:23:04 2014
@@ -16,15 +16,17 @@
  */
 package org.apache.portals.applications.webcontent2.proxy;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.portals.applications.webcontent2.proxy.impl.DefaultURICleanerImpl;
+import org.junit.Test;
 
 /**
  * @version $Id$
  */
-public class TestURICleaner extends TestCase
+public class TestURICleaner
 {
+    @Test
     public void testDefaultURICleaner() throws Exception
     {
         String wrongUriWithSpace = "http://SERVER/0/F8C57293124EDBF9C125783200376835/$FILE/EXXO-ADDM-2011-000020-01 (p2).doc";

Copied: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/AbstractRewriterTestCase.java (from r1607928, portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/RewriterTestCase.java)
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/AbstractRewriterTestCase.java?p2=portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/AbstractRewriterTestCase.java&p1=portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/RewriterTestCase.java&r1=1607928&r2=1607932&rev=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/RewriterTestCase.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/AbstractRewriterTestCase.java Fri Jul  4 20:23:04 2014
@@ -16,18 +16,12 @@
  */
 package org.apache.portals.applications.webcontent2.rewriter;
 
-import junit.framework.TestCase;
 
-public class RewriterTestCase extends TestCase
+public abstract class AbstractRewriterTestCase
 {
     private String baseDir;
 
-    public RewriterTestCase(String name)
-    {
-        super(name);
-    }
-    
-    public String getBaseDir()
+    protected String getBaseDir()
     {
         if (baseDir == null)
         {
@@ -40,9 +34,5 @@ public class RewriterTestCase extends Te
         }
         return baseDir;
     }
-    
-    public void testBase()
-    {
-        System.out.println("Testing...");
-    }
+
 }
\ No newline at end of file

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestNekoRewriter.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestNekoRewriter.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestNekoRewriter.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestNekoRewriter.java Fri Jul  4 20:23:04 2014
@@ -16,18 +16,18 @@
  */
 package org.apache.portals.applications.webcontent2.rewriter;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Arrays;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.portals.applications.webcontent2.rewriter.html.neko.NekoParserAdaptor;
 import org.apache.portals.applications.webcontent2.rewriter.rules.Ruleset;
 import org.apache.portals.applications.webcontent2.rewriter.xml.SaxParserAdaptor;
+import org.junit.Test;
 
 
 /**
@@ -36,39 +36,9 @@ import org.apache.portals.applications.w
  * @author <a href="mailto:dyoung@phase2systems.com">David L Young</a>
  * @version $Id$
  */
-public class TestNekoRewriter extends RewriterTestCase
+public class TestNekoRewriter extends AbstractRewriterTestCase
 {
 
-    /**
-     * Defines the testcase name for JUnit.
-     * 
-     * @param name
-     *            the testcase's name.
-     */
-    public TestNekoRewriter(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * Start the tests.
-     * 
-     * @param args
-     *            the arguments. Not used
-     */
-    public static void main(String args[])
-    {
-        junit.awtui.TestRunner.main(new String[]
-        { TestNekoRewriter.class.getName()});
-    }
-
-    public static Test suite()
-    {
-        // All methods starting with "test" will be executed in the test suite.
-        return new TestSuite(TestNekoRewriter.class);
-    }
-    
-    
     // DOMParser example
     
     /* BOZO
@@ -134,7 +104,7 @@ public class TestNekoRewriter extends Re
     
     
     // NekoParserAdapter test
-    
+    @Test
     public void testNekoParserAdaptor() throws Exception
     {
         RewriterController controller = getController();

Modified: portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestRewriterController.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestRewriterController.java?rev=1607932&r1=1607931&r2=1607932&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestRewriterController.java (original)
+++ portals/applications/webcontent/trunk/portlets/src/test/java/org/apache/portals/applications/webcontent2/rewriter/TestRewriterController.java Fri Jul  4 20:23:04 2014
@@ -16,6 +16,11 @@
  */
 package org.apache.portals.applications.webcontent2.rewriter;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
@@ -27,9 +32,6 @@ import java.net.URL;
 import java.util.Arrays;
 import java.util.Iterator;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.portals.applications.webcontent2.rewriter.html.SwingParserAdaptor;
@@ -38,6 +40,8 @@ import org.apache.portals.applications.w
 import org.apache.portals.applications.webcontent2.rewriter.rules.Ruleset;
 import org.apache.portals.applications.webcontent2.rewriter.rules.Tag;
 import org.apache.portals.applications.webcontent2.rewriter.xml.SaxParserAdaptor;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * TestRewriterRules
@@ -46,38 +50,10 @@ import org.apache.portals.applications.w
  * @version $Id: TestRewriterController.java,v 1.3 2004/10/13 15:53:22 weaver
  *          Exp $
  */
-public class TestRewriterController extends RewriterTestCase
+public class TestRewriterController extends AbstractRewriterTestCase
 {
 
-    /**
-     * Defines the testcase name for JUnit.
-     * 
-     * @param name
-     *            the testcase's name.
-     */
-    public TestRewriterController(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * Start the tests.
-     * 
-     * @param args
-     *            the arguments. Not used
-     */
-    public static void main(String args[])
-    {
-        junit.awtui.TestRunner.main(new String[]
-        { TestRewriterController.class.getName()});
-    }
-
-    public static Test suite()
-    {
-        // All methods starting with "test" will be executed in the test suite.
-        return new TestSuite(TestRewriterController.class);
-    }
-
+    @Test
     public void testFactories() throws Exception
     {
         RewriterController component = getController();
@@ -93,6 +69,7 @@ public class TestRewriterController exte
         assertNotNull("ruleset is null", rewriter.getRuleset());
     }
 
+    @Test
     public void testRules() throws Exception
     {
         RewriterController component = getController();
@@ -188,6 +165,7 @@ public class TestRewriterController exte
 
     }
 
+    @Test
     public void testRewriting() throws Exception
     {
         RewriterController component = getController();
@@ -261,7 +239,8 @@ public class TestRewriterController exte
                 .asList(rewriterClasses), Arrays.asList(adaptorClasses));
     }
     
-    public void XXXtestExternalRewriting() throws Exception
+    @Ignore
+    public void testExternalRewriting() throws Exception
     {
         RewriterController component = getController();
         assertNotNull("template component is null", component);