commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1460018 - in /commons/proper/email/trunk: ./ src/test/java/org/apache/commons/mail/resolver/
Date Fri, 22 Mar 2013 21:54:04 GMT
Author: tn
Date: Fri Mar 22 21:54:04 2013
New Revision: 1460018

URL: http://svn.apache.org/r1460018
Log:
Migrate first tests to junit 4 annotation style.

Added:
    commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
  (with props)
Modified:
    commons/proper/email/trunk/pom.xml
    commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java
    commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java
    commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java
    commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java

Modified: commons/proper/email/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/pom.xml?rev=1460018&r1=1460017&r2=1460018&view=diff
==============================================================================
--- commons/proper/email/trunk/pom.xml (original)
+++ commons/proper/email/trunk/pom.xml Fri Mar 22 21:54:04 2013
@@ -296,6 +296,7 @@
                         <exclude>org/apache/commons/mail/BaseEmailTestCase.java</exclude>
                         <exclude>org/apache/commons/mail/mocks/*</exclude>
                         <exclude>org/apache/commons/mail/settings/*</exclude>
+                        <exclude>**/Abstract*Test.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>

Added: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java?rev=1460018&view=auto
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
(added)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
Fri Mar 22 21:54:04 2013
@@ -0,0 +1,25 @@
+package org.apache.commons.mail.resolver;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataSource;
+
+import org.apache.commons.io.IOUtils;
+
+public abstract class AbstractDataSourceResolverTest {
+
+    protected byte[] toByteArray(DataSource dataSource) throws IOException
+    {
+        if(dataSource != null)
+        {
+            InputStream is = dataSource.getInputStream();
+            return IOUtils.toByteArray(is);
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+}

Propchange: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision HeadURL

Propchange: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java?rev=1460018&r1=1460017&r2=1460018&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java
(original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java
Fri Mar 22 21:54:04 2013
@@ -16,32 +16,23 @@
  */
 package org.apache.commons.mail.resolver;
 
-import junit.framework.TestCase;
-import org.apache.commons.io.IOUtils;
+import static org.junit.Assert.*;
+
 import org.apache.commons.mail.DataSourceResolver;
+import org.junit.Test;
 
-import javax.activation.DataSource;
 import java.io.IOException;
-import java.io.InputStream;
 
 /**
- * JUnit test case for DataSourceClassPathResolver..
+ * JUnit test case for DataSourceClassPathResolver.
  *
  * @since 1.3
  */
-public class DataSourceClassPathResolverTest extends TestCase
+public class DataSourceClassPathResolverTest extends AbstractDataSourceResolverTest
 {
     private final int IMG_SIZE = 5866;
 
-    public DataSourceClassPathResolverTest(String name)
-    {
-        super(name);
-    }
-
-    // ======================================================================
-    // Start of Tests
-    // ======================================================================
-    
+    @Test
     public void testResolvingClassPathLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver;
@@ -59,6 +50,7 @@ public class DataSourceClassPathResolver
         assertNull(dataSourceResolver.resolve("./images/asf_logo_wide.gif"));
     }
 
+    @Test
     public void testResolvingClassPathNonLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver;
@@ -77,17 +69,4 @@ public class DataSourceClassPathResolver
         }
     }
 
-    private byte[] toByteArray(DataSource dataSource) throws IOException
-    {
-        if(dataSource != null)
-        {
-            InputStream is = dataSource.getInputStream();
-            return IOUtils.toByteArray(is);
-        }
-        else
-        {
-            return null;
-        }
-    }
-
 }

Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java?rev=1460018&r1=1460017&r2=1460018&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java
(original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java
Fri Mar 22 21:54:04 2013
@@ -16,13 +16,12 @@
  */
 package org.apache.commons.mail.resolver;
 
-import junit.framework.TestCase;
-import org.apache.commons.io.IOUtils;
+import static org.junit.Assert.*;
+
 import org.apache.commons.mail.DataSourceResolver;
+import org.junit.Test;
 
-import javax.activation.DataSource;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 
 /**
@@ -30,13 +29,9 @@ import java.net.URL;
  *
  * @since 1.3
  */
-public class DataSourceCompositeResolverTest extends TestCase
+public class DataSourceCompositeResolverTest extends AbstractDataSourceResolverTest
 {
-    public DataSourceCompositeResolverTest(String name)
-    {
-        super(name);
-    }
-
+    @Test
     public void testResolvingFilesLenient() throws Exception
     {
         DataSourceResolver urlResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"),
false);
@@ -51,6 +46,7 @@ public class DataSourceCompositeResolver
         assertTrue(toByteArray(dataSourceResolver.resolve("/contentTypeTest.gif")).length
> 0);
     }
 
+    @Test
     public void testResolvingFilesNonLenient() throws Exception
     {
         DataSourceResolver urlResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"),
false);
@@ -70,6 +66,7 @@ public class DataSourceCompositeResolver
         }
     }
 
+    @Test
     public void testExternalModification() throws Exception
     {
         DataSourceResolver urlResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"),
false);
@@ -88,16 +85,4 @@ public class DataSourceCompositeResolver
         assertNotNull(arr2[0]);        
     }
 
-    private byte[] toByteArray(DataSource dataSource) throws IOException
-    {
-        if(dataSource != null)
-        {
-            InputStream is = dataSource.getInputStream();
-            return IOUtils.toByteArray(is);
-        }
-        else
-        {
-            return null;
-        }
-    }
 }

Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java?rev=1460018&r1=1460017&r2=1460018&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java
(original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java
Fri Mar 22 21:54:04 2013
@@ -16,31 +16,24 @@
  */
 package org.apache.commons.mail.resolver;
 
+import static org.junit.Assert.*;
+
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-
-import javax.activation.DataSource;
-
-import junit.framework.TestCase;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.mail.DataSourceResolver;
+import org.junit.Test;
 
 /**
  * JUnit test case for DateSourceResolver.
  *
  * @since 1.3
  */
-public class DataSourceFileResolverTest extends TestCase
+public class DataSourceFileResolverTest extends AbstractDataSourceResolverTest
 {
     private final int IMG_SIZE = 5866;
 
-    public DataSourceFileResolverTest(String name)
-    {
-        super(name);
-    }
-
+    @Test
     public void testResolvingFileLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver = new DataSourceFileResolver(new File("./src/test/resources"),
true);
@@ -51,6 +44,7 @@ public class DataSourceFileResolverTest 
         assertNull(dataSourceResolver.resolve("./images/does-not-exist.gif"));
     }
 
+    @Test
     public void testResolvingFileNonLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver = new DataSourceFileResolver(new File("."),
false);
@@ -67,16 +61,4 @@ public class DataSourceFileResolverTest 
         }
     }
 
-    private byte[] toByteArray(DataSource dataSource) throws IOException
-    {
-        if(dataSource != null)
-        {
-            InputStream is = dataSource.getInputStream();
-            return IOUtils.toByteArray(is);
-        }
-        else
-        {
-            return null;
-        }
-    }
 }

Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java?rev=1460018&r1=1460017&r2=1460018&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java
(original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java
Fri Mar 22 21:54:04 2013
@@ -16,14 +16,13 @@
  */
 package org.apache.commons.mail.resolver;
 
-import junit.framework.TestCase;
-import org.apache.commons.io.IOUtils;
+import static org.junit.Assert.*;
+
 import org.apache.commons.mail.DataSourceResolver;
+import org.junit.Test;
 
-import javax.activation.DataSource;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 
 /**
@@ -31,21 +30,17 @@ import java.net.URL;
  *
  * @since 1.3
  */
-public class DataSourceUrlResolverTest extends TestCase
+public class DataSourceUrlResolverTest extends AbstractDataSourceResolverTest
 {
     private final int IMG_SIZE = 5866;
 
-    public DataSourceUrlResolverTest(String name)
-    {
-        super(name);
-    }
-
     /**
      * Shows how the DataSourceUrlResolver can resolve files as well but this should
      * be done using a DataSourceFileResolver.
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testResolvingFilesLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new File("./src/test/resources").toURI().toURL(),
true);
@@ -60,6 +55,7 @@ public class DataSourceUrlResolverTest e
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testResolvingHttpLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"),
true);
@@ -75,6 +71,7 @@ public class DataSourceUrlResolverTest e
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testResolvingHttpNonLenient() throws Exception
     {
         DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"),
false);
@@ -92,16 +89,4 @@ public class DataSourceUrlResolverTest e
         }
     }
 
-    private byte[] toByteArray(DataSource dataSource) throws IOException
-    {
-        if(dataSource != null)
-        {
-            InputStream is = dataSource.getInputStream();
-            return IOUtils.toByteArray(is);
-        }
-        else
-        {
-            return null;
-        }
-    }
 }



Mime
View raw message