[Title] Fix test cases
authorBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 22 Feb 2013 06:53:56 +0000 (15:53 +0900)
committerBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 22 Feb 2013 06:58:29 +0000 (15:58 +0900)
[Desc.] Upgrade mockito and powermock. furthermore fix test cases
[Issue]

org.tizen.common/.classpath
org.tizen.common/META-INF/MANIFEST.MF
org.tizen.common/test/lib/mockito-all-1.9.5.jar [moved from org.tizen.common/test/lib/mockito-all-1.9.0.jar with 72% similarity, mode: 0755]
org.tizen.common/test/lib/powermock-mockito-1.5-full.jar [moved from org.tizen.common/test/lib/powermock-mockito-1.4.12-full.jar with 57% similarity]
org.tizen.common/test/src/log4j.xml
org.tizen.common/test/src/org/tizen/common/core/command/file/FileHandlingCommandTest.java [changed mode: 0644->0755]
org.tizen.common/test/src/org/tizen/common/file/filter/WildCardFilterFactoryTest.java [changed mode: 0644->0755]
org.tizen.common/test/src/org/tizen/common/util/ArrayUtilTest.java
org.tizen.common/test/src/org/tizen/common/util/HostUtilTest.java [changed mode: 0644->0755]

index 13f5c5b..aab2b5a 100755 (executable)
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/commons-collections-3.2.1.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/commons-pool-1.6.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.1.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/commons-io-2.4.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/freemarker.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.17.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/slf4j-log4j12-1.6.4.jar"/>
-       <classpathentry exported="true" kind="lib" path="test/lib/junit-4.10.jar" sourcepath="test/lib/junit-4.10-src.jar"/>
-       <classpathentry exported="true" kind="lib" path="test/lib/mockito-all-1.9.0.jar"/>
-       <classpathentry kind="lib" path="test/lib/asm-4.0.jar"/>
-       <classpathentry kind="lib" path="test/lib/asm-tree-4.0.jar"/>
-       <classpathentry exported="true" kind="lib" path="test/lib/powermock-mockito-1.4.12-full.jar"/>
-       <classpathentry exported="true" kind="lib" path="test/lib/javassist-3.16.1-GA.jar"/>
-       <classpathentry kind="lib" path="lib/ant.jar"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="src" path="test/src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/commons-collections-3.2.1.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/commons-pool-1.6.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.1.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/commons-io-2.4.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/freemarker.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.17.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.6.4.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/slf4j-log4j12-1.6.4.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="test/lib/junit-4.10.jar" sourcepath="test/lib/junit-4.10-src.jar"/>\r
+       <classpathentry kind="lib" path="test/lib/asm-4.0.jar"/>\r
+       <classpathentry kind="lib" path="test/lib/asm-tree-4.0.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="test/lib/javassist-3.16.1-GA.jar"/>\r
+       <classpathentry kind="lib" path="lib/ant.jar"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="src" path="test/src"/>\r
+       <classpathentry exported="true" kind="lib" path="test/lib/powermock-mockito-1.5-full.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="test/lib/mockito-all-1.9.5.jar"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
index 863a545..278de7e 100755 (executable)
@@ -71,22 +71,27 @@ Export-Package:
  org.mockito.exceptions,
  org.mockito.exceptions.base,
  org.mockito.exceptions.misusing,
+ org.mockito.exceptions.stacktrace,
  org.mockito.exceptions.verification,
  org.mockito.exceptions.verification.junit,
  org.mockito.internal,
  org.mockito.internal.configuration,
  org.mockito.internal.configuration.injection,
  org.mockito.internal.configuration.injection.filter,
+ org.mockito.internal.configuration.injection.scanner,
  org.mockito.internal.creation,
  org.mockito.internal.creation.cglib,
  org.mockito.internal.creation.jmock,
+ org.mockito.internal.creation.settings,
  org.mockito.internal.debugging,
  org.mockito.internal.exceptions,
- org.mockito.internal.exceptions.base,
+ org.mockito.internal.exceptions.stacktrace,
  org.mockito.internal.exceptions.util,
+ org.mockito.internal.handler,
  org.mockito.internal.invocation,
  org.mockito.internal.invocation.finder,
  org.mockito.internal.invocation.realmethod,
+ org.mockito.internal.junit,
  org.mockito.internal.listeners,
  org.mockito.internal.matchers,
  org.mockito.internal.matchers.apachecommons,
@@ -98,6 +103,7 @@ Export-Package:
  org.mockito.internal.stubbing.answers,
  org.mockito.internal.stubbing.defaultanswers,
  org.mockito.internal.util,
+ org.mockito.internal.util.collections,
  org.mockito.internal.util.junit,
  org.mockito.internal.util.reflection,
  org.mockito.internal.verification,
@@ -106,6 +112,8 @@ Export-Package:
  org.mockito.internal.verification.checkers,
  org.mockito.invocation,
  org.mockito.listeners,
+ org.mockito.mock,
+ org.mockito.plugins,
  org.mockito.runners,
  org.mockito.stubbing,
  org.mockito.stubbing.answers,
@@ -117,8 +125,9 @@ Export-Package:
  org.powermock.api.mockito.internal,
  org.powermock.api.mockito.internal.configuration,
  org.powermock.api.mockito.internal.expectation,
- org.powermock.api.mockito.internal.invocationcontrol,
+ org.powermock.api.mockito.internal.invocation,
  org.powermock.api.mockito.internal.mockcreation,
+ org.powermock.api.mockito.internal.mockmaker,
  org.powermock.api.mockito.internal.verification,
  org.powermock.api.mockito.mockpolicies,
  org.powermock.api.mockito.powermocklistener,
old mode 100644 (file)
new mode 100755 (executable)
similarity index 72%
rename from org.tizen.common/test/lib/mockito-all-1.9.0.jar
rename to org.tizen.common/test/lib/mockito-all-1.9.5.jar
index 273fd50..00416eb
Binary files a/org.tizen.common/test/lib/mockito-all-1.9.0.jar and b/org.tizen.common/test/lib/mockito-all-1.9.5.jar differ
similarity index 57%
rename from org.tizen.common/test/lib/powermock-mockito-1.4.12-full.jar
rename to org.tizen.common/test/lib/powermock-mockito-1.5-full.jar
index b70358d..fb8b2c2 100755 (executable)
Binary files a/org.tizen.common/test/lib/powermock-mockito-1.4.12-full.jar and b/org.tizen.common/test/lib/powermock-mockito-1.5-full.jar differ
index 1a2fc8f..50e440a 100755 (executable)
@@ -8,10 +8,6 @@
                </layout>
        </appender>
        
-    <logger name="org.tizen.common.util">
-        <level value="info" />
-    </logger>
-       
     <logger name="org.tizen.common.verrari.util">
         <level value="info" />
     </logger>
old mode 100644 (file)
new mode 100755 (executable)
index b1bcb6e..abfae70
@@ -71,7 +71,7 @@ FileHandlingCommandTest
                        command.setFilter( null );
                        fail();
                }
-               catch ( NullPointerException e )
+               catch ( final IllegalArgumentException e )
                {
                        // Then
                }
old mode 100644 (file)
new mode 100755 (executable)
index 0bb5f3b..e85614d
@@ -71,7 +71,7 @@ WildCardFilterFactoryTest
                        factory.create( null );
                        fail();
                }
-               catch ( NullPointerException e )
+               catch ( final IllegalArgumentException e )
                {
                }
                
index 965352f..ce0c431 100755 (executable)
@@ -40,6 +40,7 @@ import java.util.ConcurrentModificationException;
 import java.util.Iterator;
 
 import org.junit.Test;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
@@ -54,6 +55,8 @@ import org.slf4j.LoggerFactory;
  */
 public class ArrayUtilTest
 {
+    protected Logger logger = LoggerFactory.getLogger( getClass() );
+
     public static int arrayIndex = 0;
     public static boolean successTest = true;
 
@@ -616,7 +619,7 @@ public class ArrayUtilTest
         }
         catch( final IllegalArgumentException e )
         {
-            LoggerFactory.getLogger( getClass() ).info( "Test case successfult" );
+            logger.info( "Test case successfult" );
         }
 
         for ( Object[] input : inputArray ) {
@@ -625,6 +628,7 @@ public class ArrayUtilTest
                     int deleteCount = 0;
                     Object[] actualData = null;
                     try {
+                        logger.trace( "{}: {}, {}", new Object[] { ObjectUtil.toString( input ), i, j } );
                         actualData = ArrayUtil.remove( input, i, j);
                         i = Math.max( 0, i );
                         if( j <= i) {
@@ -656,18 +660,11 @@ public class ArrayUtilTest
                         }
                     }
                     catch ( IllegalArgumentException e ) {
-                        if ( i >= j ) {
-                            continue;
-                        }
-                        else {
-                            fail("Failed remove(Object[], int, int) test");
-                        }
-                    }
-                    catch ( NullPointerException e ){
-                        if ( input == null) {
+                        if ( null == input || i >= j ) {
                             continue;
                         }
                         else {
+                            e.printStackTrace();
                             fail("Failed remove(Object[], int, int) test");
                         }
                     }
old mode 100644 (file)
new mode 100755 (executable)
index 9939dff..f189a28
  */
 package org.tizen.common.util;
 
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+import java.io.FileReader;
+import java.io.IOException;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
 
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { HostUtil.class } )
 public class HostUtilTest {
 
     private String packageName = HostUtilTest.class.getPackage().getName().replace('.', '/');
@@ -52,10 +63,14 @@ public class HostUtilTest {
      * 
      * @see HostUtil#getContents( String)
      */
+    @SuppressWarnings("unchecked")
     @Test
     public void test_getContents() throws Exception {
+        FileReader file = PowerMockito.mock( FileReader.class );
+        whenNew( FileReader.class ).withParameterTypes( String.class ).withArguments( fullPath ).thenReturn( file );
         Assert.notNull(HostUtil.getContents(fullPath));        
-        Assert.isNull(HostUtil.getContents(null));
+        
+        whenNew( FileReader.class ).withParameterTypes( String.class ).withArguments( "nullPath" ).thenThrow( IOException.class );
         Assert.isNull(HostUtil.getContents("nullPath"));
     }