commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestFactoryUtils.java
Date Wed, 21 May 2003 22:22:24 GMT
scolebourne    2003/05/21 15:22:24

  Modified:    collections/src/test/org/apache/commons/collections
                        TestFactoryUtils.java
  Log:
  Fix test class to remove time dependency for reliable test
  
  Revision  Changes    Path
  1.3       +19 -5     jakarta-commons/collections/src/test/org/apache/commons/collections/TestFactoryUtils.java
  
  Index: TestFactoryUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFactoryUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestFactoryUtils.java	16 May 2003 15:11:54 -0000	1.2
  +++ TestFactoryUtils.java	21 May 2003 22:22:24 -0000	1.3
  @@ -254,6 +254,17 @@
           }
       }
       
  +    public static class Mock3 {
  +        private static int cCounter = 0;
  +        private final int iVal;
  +        public Mock3() {
  +            iVal = cCounter++;
  +        }
  +        public int getValue() {
  +            return iVal;
  +        }
  +    }
  +    
       // reflectionFactory
       //------------------------------------------------------------------
       
  @@ -268,11 +279,12 @@
       }
   
       public void testReflectionFactorySimple() {
  -        Factory factory = FactoryUtils.reflectionFactory(Date.class);
  +        Factory factory = FactoryUtils.reflectionFactory(Mock3.class);
           assertNotNull(factory);
           Object created = factory.create();
  -        assertTrue(created instanceof Date);
  -        assertEquals((double) System.currentTimeMillis(), (double) ((Date) created).getTime(),
0.05d);
  +        assertEquals(0, ((Mock3) created).getValue());
  +        created = factory.create();
  +        assertEquals(1, ((Mock3) created).getValue());
       }
   
       public void testReflectionFactoryMismatch() {
  @@ -297,12 +309,14 @@
   
       public void testReflectionFactoryComplex() {
           TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
  +        // 2nd Jan 1970
           Factory factory = FactoryUtils.reflectionFactory(Date.class,
               new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE},
               new Object[] {new Integer(70), new Integer(0), new Integer(2)});
           assertNotNull(factory);
           Object created = factory.create();
           assertTrue(created instanceof Date);
  +        // long time of 1 day (== 2nd Jan 1970)
           assertEquals(new Date(1000 * 60 * 60 * 24), created);
       }
   
  
  
  

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


Mime
View raw message