commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r806007 - in /commons/proper/io/trunk/src/test/org/apache/commons/io: ./ filefilter/ monitor/ output/
Date Wed, 19 Aug 2009 23:03:12 GMT
Author: sebb
Date: Wed Aug 19 23:03:11 2009
New Revision: 806007

URL: http://svn.apache.org/viewvc?rev=806007&view=rev
Log:
Fix up some raw types and unthrown Exceptions

Modified:
    commons/proper/io/trunk/src/test/org/apache/commons/io/DemuxTestCase.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/monitor/CollectionFilesystemListener.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/output/FileWriterWithEncodingTest.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/output/LockableFileWriterTest.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/output/StringBuilderWriterTest.java

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/DemuxTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/DemuxTestCase.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/DemuxTestCase.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/DemuxTestCase.java Wed Aug 19 23:03:11
2009
@@ -17,7 +17,6 @@
 package org.apache.commons.io;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.HashMap;
@@ -49,8 +48,8 @@
     private static final String DATA4 = "Data for thread4";
 
     private static Random c_random = new Random();
-    private HashMap m_outputMap = new HashMap();
-    private HashMap m_threadMap = new HashMap();
+    private HashMap<String, ByteArrayOutputStream> m_outputMap = new HashMap<String,
ByteArrayOutputStream>();
+    private HashMap<String, Thread> m_threadMap = new HashMap<String, Thread>();
 
     public DemuxTestCase( String name )
     {
@@ -58,17 +57,15 @@
     }
 
     private String getOutput( String threadName )
-        throws IOException
     {
         ByteArrayOutputStream output =
-            (ByteArrayOutputStream)m_outputMap.get( threadName );
+            m_outputMap.get( threadName );
         assertNotNull( "getOutput()", output );
 
         return output.toString();
     }
 
     private String getInput( String threadName )
-        throws IOException
     {
         ReaderThread thread = (ReaderThread)m_threadMap.get( threadName );
         assertNotNull( "getInput()", thread );
@@ -79,11 +76,11 @@
     private void doStart()
         throws Exception
     {
-        Iterator iterator = m_threadMap.keySet().iterator();
+        Iterator<String> iterator = m_threadMap.keySet().iterator();
         while( iterator.hasNext() )
         {
-            String name = (String)iterator.next();
-            Thread thread = (Thread)m_threadMap.get( name );
+            String name = iterator.next();
+            Thread thread = m_threadMap.get( name );
             thread.start();
         }
     }
@@ -91,11 +88,11 @@
     private void doJoin()
         throws Exception
     {
-        Iterator iterator = m_threadMap.keySet().iterator();
+        Iterator<String> iterator = m_threadMap.keySet().iterator();
         while( iterator.hasNext() )
         {
-            String name = (String)iterator.next();
-            Thread thread = (Thread)m_threadMap.get( name );
+            String name = iterator.next();
+            Thread thread = m_threadMap.get( name );
             thread.join();
         }
     }

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
Wed Aug 19 23:03:11 2009
@@ -139,9 +139,9 @@
     }
 
     private boolean chmod(File file, int mode, boolean recurse)
-            throws IOException, InterruptedException {
+            throws InterruptedException {
         // TODO: Refactor this to FileSystemUtils
-        List args = new ArrayList();
+        List<String> args = new ArrayList<String>();
         args.add("chmod");
 
         if (recurse) {
@@ -155,7 +155,7 @@
 
         try {
             proc = Runtime.getRuntime().exec(
-                    (String[]) args.toArray(new String[args.size()]));
+                    args.toArray(new String[args.size()]));
         } catch (IOException e) {
             return false;
         }

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java
Wed Aug 19 23:03:11 2009
@@ -239,7 +239,7 @@
 
     private void setupSymlink(File res, File link) throws Exception {
         // create symlink
-        List args = new ArrayList();
+        List<String> args = new ArrayList<String>();
         args.add("ln");
         args.add("-s");
 
@@ -248,7 +248,7 @@
 
         Process proc;
 
-        proc = Runtime.getRuntime().exec((String[]) args.toArray(new String[args.size()]));
+        proc = Runtime.getRuntime().exec(args.toArray(new String[args.size()]));
         proc.waitFor();
     }
 

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
Wed Aug 19 23:03:11 2009
@@ -106,7 +106,7 @@
         assertTrue( filter.accept( testFile.getParentFile(), testFile.getName() ) );
         assertTrue( !filter.accept( fredFile.getParentFile(), fredFile.getName() ) );
 
-        List prefixes = Arrays.asList( new String[] { "ood", "red" } );
+        List<String> prefixes = Arrays.asList( new String[] { "ood", "red" } );
         IOFileFilter listFilter = new SuffixFileFilter( prefixes );
 
         assertTrue( !listFilter.accept( testFile.getParentFile(), testFile.getName() ) );
@@ -125,7 +125,7 @@
         }
 
         try {
-            new SuffixFileFilter((List) null);
+            new SuffixFileFilter((List<String>) null);
             fail();
         } catch (IllegalArgumentException ex) {
         }
@@ -144,7 +144,7 @@
         assertFiltering(filter, new File("test"), true);
         assertFiltering(filter, new File("TEST"), true);
 
-        List suffixes = Arrays.asList( new String[] { "tes", "est" } );
+        List<String> suffixes = Arrays.asList( new String[] { "tes", "est" } );
         filter = new SuffixFileFilter(suffixes, IOCase.INSENSITIVE);
         assertFiltering(filter, new File("bar.tes"), true);
         assertFiltering(filter, new File("bar.est"), true);
@@ -165,7 +165,7 @@
         }
 
         try {
-            new SuffixFileFilter((List) null, IOCase.INSENSITIVE);
+            new SuffixFileFilter((List<String>) null, IOCase.INSENSITIVE);
             fail();
         } catch (IllegalArgumentException ex) {
         }
@@ -227,7 +227,7 @@
         assertTrue( filter.accept( testFile.getParentFile(), testFile.getName() ) );
         assertTrue( !filter.accept( fredFile.getParentFile(), fredFile.getName() ) );
 
-        List prefixes = Arrays.asList( new String[] { "foo", "fre" } );
+        List<String> prefixes = Arrays.asList( new String[] { "foo", "fre" } );
         IOFileFilter listFilter = new PrefixFileFilter( prefixes );
 
         assertTrue( !listFilter.accept( testFile.getParentFile(), testFile.getName() ) );
@@ -247,7 +247,7 @@
         }
 
         try {
-            new PrefixFileFilter((List) null);
+            new PrefixFileFilter((List<String>) null);
             fail();
         } catch (IllegalArgumentException ex) {
         }
@@ -267,7 +267,7 @@
         assertFiltering(filter, new File("FOO.test2"), false); //case-sensitive
         assertFiltering(filter, new File("BAR.test2"), true);  //case-sensitive
 
-        List prefixes = Arrays.asList( new String[] { "foo", "bar" } );
+        List<String> prefixes = Arrays.asList( new String[] { "foo", "bar" } );
         filter = new PrefixFileFilter(prefixes, IOCase.INSENSITIVE);
         assertFiltering(filter, new File("foo.test3"), true);
         assertFiltering(filter, new File("bar.test3"), true);
@@ -287,7 +287,7 @@
         }
 
         try {
-            new PrefixFileFilter((List) null, IOCase.INSENSITIVE);
+            new PrefixFileFilter((List<String>) null, IOCase.INSENSITIVE);
             fail();
         } catch (IllegalArgumentException ex) {
         }
@@ -324,7 +324,7 @@
         assertFiltering(filter, new File("BAR"), false);
 
         // repeat for a List
-        java.util.ArrayList list = new java.util.ArrayList();
+        java.util.ArrayList<String> list = new java.util.ArrayList<String>();
         list.add("foo");
         list.add("bar");
         filter = new NameFileFilter(list);
@@ -359,7 +359,7 @@
     }
 
     public void testNameFilterNullListArgument() throws Exception {
-        List test = null;
+        List<String> test = null;
         try {
             new NameFileFilter(test);
             fail( "constructing a NameFileFilter with a null List argument should fail.");
@@ -403,7 +403,7 @@
         assertFiltering(new AndFileFilter(falseFilter, trueFilter), new File("foo.test"),
false);
         assertFiltering(new AndFileFilter(falseFilter, falseFilter), new File("foo.test"),
false);
 
-        List filters = new ArrayList();
+        List<IOFileFilter> filters = new ArrayList<IOFileFilter>();
         assertFiltering( new AndFileFilter( filters ), new File( "test" ), false );
         assertFiltering( new AndFileFilter(), new File( "test" ), false );
         
@@ -413,7 +413,7 @@
         } catch (IllegalArgumentException ex) {
         }
 
-        AndFileFilter f = new AndFileFilter((List) null);
+        AndFileFilter f = new AndFileFilter((List<IOFileFilter>) null);
         assertEquals(true, f.getFileFilters().isEmpty());
     }
 
@@ -427,7 +427,7 @@
         assertFiltering(new OrFileFilter(falseFilter, falseFilter), testFile, false);
         assertFiltering(new OrFileFilter(), testFile, false);
         
-        List filters = new ArrayList();
+        List<IOFileFilter> filters = new ArrayList<IOFileFilter>();
         filters.add( trueFilter );
         filters.add( falseFilter );
 
@@ -450,13 +450,13 @@
         } catch (IllegalArgumentException ex) {
         }
         
-        OrFileFilter f = new OrFileFilter((List) null);
+        OrFileFilter f = new OrFileFilter((List<IOFileFilter>) null);
         assertEquals(true, f.getFileFilters().isEmpty());
     }
 
     public void testDeprecatedWildcard() throws Exception {
         IOFileFilter filter = new WildcardFilter("*.txt");
-        List patternList = Arrays.asList( new String[] { "*.txt", "*.xml", "*.gif" } );
+        List<String> patternList = Arrays.asList( new String[] { "*.txt", "*.xml",
"*.gif" } );
         IOFileFilter listFilter = new WildcardFilter( patternList );
         File txtFile = new File( "test.txt" );
         File bmpFile = new File( "test.bmp" );
@@ -508,7 +508,7 @@
         }
 
         try {
-            new WildcardFilter((List) null);
+            new WildcardFilter((List<String>) null);
             fail();
         } catch (IllegalArgumentException ex) {
             // expected
@@ -557,7 +557,7 @@
         assertFiltering(filter, new File("Test.java"), true);
         assertFiltering(filter, new File("Test.JAVA"), false);
         
-        List patternList = Arrays.asList( new String[] { "*.txt", "*.xml", "*.gif" } );
+        List<String> patternList = Arrays.asList( new String[] { "*.txt", "*.xml",
"*.gif" } );
         IOFileFilter listFilter = new WildcardFileFilter( patternList );
         assertFiltering(listFilter, new File("Test.txt"), true);
         assertFiltering(listFilter, new File("Test.xml"), true);
@@ -584,7 +584,7 @@
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            new WildcardFileFilter((List) null);
+            new WildcardFileFilter((List<String>) null);
             fail();
         } catch (IllegalArgumentException ex) {}
     }

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/monitor/CollectionFilesystemListener.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/monitor/CollectionFilesystemListener.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/monitor/CollectionFilesystemListener.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/monitor/CollectionFilesystemListener.java
Wed Aug 19 23:03:11 2009
@@ -53,7 +53,7 @@
      *
      * @return Directories which have changed
      */
-    public Collection getChangedDirectories() {
+    public Collection<File> getChangedDirectories() {
         return changedDirectories;
     }
 
@@ -62,7 +62,7 @@
      *
      * @return Files which have changed
      */
-    public Collection getChangedFiles() {
+    public Collection<File> getChangedFiles() {
         return changedFiles;
     }
 
@@ -71,7 +71,7 @@
      *
      * @return Directories which have been created
      */
-    public Collection getCreatedDirectories() {
+    public Collection<File> getCreatedDirectories() {
         return createdDirectories;
     }
 
@@ -80,7 +80,7 @@
      *
      * @return Files which have been created
      */
-    public Collection getCreatedFiles() {
+    public Collection<File> getCreatedFiles() {
         return createdFiles;
     }
 
@@ -89,7 +89,7 @@
      *
      * @return Directories which been deleted
      */
-    public Collection getDeletedDirectories() {
+    public Collection<File> getDeletedDirectories() {
         return deletedDirectories;
     }
 
@@ -98,7 +98,7 @@
      *
      * @return Files which been deleted
      */
-    public Collection getDeletedFiles() {
+    public Collection<File> getDeletedFiles() {
         return deletedFiles;
     }
 

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
Wed Aug 19 23:03:11 2009
@@ -17,8 +17,6 @@
 package org.apache.commons.io.output;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
 import junit.framework.TestCase;
 
 /**
@@ -43,7 +41,7 @@
 
     private int writeData(ByteArrayOutputStream baout, 
                 java.io.ByteArrayOutputStream ref,
-                int count) throws IOException {
+                int count) {
         if (count > DATA.length) {
             throw new IllegalArgumentException("Requesting too many bytes");
         }
@@ -60,7 +58,7 @@
     
     private int writeData(ByteArrayOutputStream baout, 
                 java.io.ByteArrayOutputStream ref, 
-                int[] instructions) throws IOException {
+                int[] instructions) {
         int written = 0;
         for (int i = 0; i < instructions.length; i++) {
             written += writeData(baout, ref, instructions[i]);

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/output/FileWriterWithEncodingTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/output/FileWriterWithEncodingTest.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/output/FileWriterWithEncodingTest.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/output/FileWriterWithEncodingTest.java
Wed Aug 19 23:03:11 2009
@@ -101,7 +101,7 @@
     }
 
     public void testDifferentEncoding() throws Exception {
-        Map map = Charset.availableCharsets();
+        Map<String, Charset> map = Charset.availableCharsets();
         if (map.containsKey("UTF-16BE")) {
             FileWriter fw1 = null;
             FileWriterWithEncoding fw2 = null;
@@ -161,7 +161,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testConstructor_File_encoding_badEncoding() throws IOException {
+    public void testConstructor_File_encoding_badEncoding() {
         Writer writer = null;
         try {
             writer = new FileWriterWithEncoding(file1, "BAD-ENCODE");
@@ -176,7 +176,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testConstructor_File_directory() throws IOException {
+    public void testConstructor_File_directory() {
         Writer writer = null;
         try {
             writer = new FileWriterWithEncoding(getTestDirectory(), defaultEncoding);

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/output/LockableFileWriterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/output/LockableFileWriterTest.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/output/LockableFileWriterTest.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/output/LockableFileWriterTest.java
Wed Aug 19 23:03:11 2009
@@ -159,7 +159,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testConstructor_File_encoding_badEncoding() throws IOException {
+    public void testConstructor_File_encoding_badEncoding() {
         Writer writer = null;
         try {
             writer = new LockableFileWriter(file, "BAD-ENCODE");
@@ -176,7 +176,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testConstructor_File_directory() throws IOException {
+    public void testConstructor_File_directory() {
         Writer writer = null;
         try {
             writer = new LockableFileWriter(getTestDirectory());

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/output/StringBuilderWriterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/output/StringBuilderWriterTest.java?rev=806007&r1=806006&r2=806007&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/output/StringBuilderWriterTest.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/output/StringBuilderWriterTest.java
Wed Aug 19 23:03:11 2009
@@ -44,7 +44,7 @@
     }
 
     /** Test {@link StringBuilderWriter} constructor. */
-    public void testAppendConstructStringBuilder() throws IOException {
+    public void testAppendConstructStringBuilder() {
         StringBuilder builder = new StringBuilder("Foo");
         StringBuilderWriter writer = new StringBuilderWriter(builder);
         writer.append("Bar");



Mime
View raw message