[jboss-cvs] JBossCache/tests-50/functional/org/jboss/cache/pojo/collection ...

Manik Surtani msurtani at jboss.com
Sat Dec 30 14:48:48 EST 2006


  User: msurtani
  Date: 06/12/30 14:48:48

  Modified:    tests-50/functional/org/jboss/cache/pojo/collection 
                        CachedMapTest.java
  Log:
  Genericised, autoboxed
  
  Revision  Changes    Path
  1.6       +84 -77    JBossCache/tests-50/functional/org/jboss/cache/pojo/collection/CachedMapTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CachedMapTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/collection/CachedMapTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CachedMapTest.java	31 Oct 2006 11:07:16 -0000	1.5
  +++ CachedMapTest.java	30 Dec 2006 19:48:48 -0000	1.6
  @@ -130,7 +130,7 @@
      public void testLongValue() throws Throwable
      {
         Long val = new Long("8225676592564383");
  -      Long val2 = new Long(8225676592564383L);
  +      Long val2 = 8225676592564383L;
         assertTrue(0 == val.compareTo(val2));   // sanity check
         hobbies.put(val, "prateek");
         assertTrue(hobbies.containsKey(val));
  @@ -209,12 +209,12 @@
      {
         Map map1 = new HashMap();
         cache_.attach("map1", map1);
  -      map1 = (Map)cache_.find("map1");
  +      map1 = (Map) cache_.find("map1");
         map1.put("1", "test");
   
         Map map2 = new HashMap();
         cache_.attach("map2", map2);
  -      map2 = (Map)cache_.find("map2");
  +      map2 = (Map) cache_.find("map2");
         map2.put("1", "me");
   
         assertFalse("Map should not be the same ", map1.equals(map2));
  @@ -224,13 +224,13 @@
      {
         Map map1 = new HashMap();
         cache_.attach("map1", map1);
  -      map1 = (Map)cache_.find("map1");
  +      map1 = (Map) cache_.find("map1");
         map1.put("1", "test");
         map1.put("2", "test");
   
         Map map2 = new HashMap();
         cache_.attach("map2", map2);
  -      map2 = (Map)cache_.find("map2");
  +      map2 = (Map) cache_.find("map2");
         map2.put("1", "me");
         map2.put("2", "me");
   
  @@ -253,9 +253,9 @@
   
         System.out.println("**** End of cache content **** ");
         map.remove("2");
  -      map.put(new Integer(2), "Hoklo");
  +      map.put(2, "Hoklo");
         assertEquals("Size ", 3, map.size());
  -      assertEquals("Content ", "Hoklo", map.get(new Integer(2)));
  +      assertEquals("Content ", "Hoklo", map.get(2));
   
         // Try to re-attach
         cache_.attach("/test", map);
  @@ -303,61 +303,65 @@
   
      public void testKeyAsObject() throws Exception
      {
  -      SerializableKeyValue key = new SerializableKeyValue(42,"Novell");
  +      SerializableKeyValue key = new SerializableKeyValue(42, "Novell");
         Address add1 = new Address();
         add1.setCity("Waltham");
         add1.setStreet("404 Wyman Street");
         add1.setZip(02451);
   
         Map map = new HashMap();
  -      map.put(key,add1);
  +      map.put(key, add1);
         cache_.attach("/keytest", map);
  -      Map ref = (Map)cache_.find("/keytest");
  +      Map ref = (Map) cache_.find("/keytest");
   
         Iterator iter = ref.keySet().iterator();
         assertTrue(iter.hasNext());
         Object keyFromMap = iter.next();
         assertEquals("original key is same as key in pojocache map, key class=" +
  -            key.getClass().getName() +", keyFromMap class=" + keyFromMap.getClass().getName(),
  -            key , keyFromMap);
  -      assertEquals("local map is equal to pojocache map",map, ref);
  +              key.getClass().getName() + ", keyFromMap class=" + keyFromMap.getClass().getName(),
  +              key, keyFromMap);
  +      assertEquals("local map is equal to pojocache map", map, ref);
         }
   
      public void testNonSerializableKeyAsObject() throws Exception
      {
         // negative test as we should get a java.io.NotSerializableException
  -      NotSerializableKeyValue key = new NotSerializableKeyValue(42,"Novell");
  +      NotSerializableKeyValue key = new NotSerializableKeyValue(42, "Novell");
         Address add1 = new Address();
         add1.setCity("Waltham");
         add1.setStreet("404 Wyman Street");
         add1.setZip(02451);
   
         Map map = new HashMap();
  -      map.put(key,add1);
  -      try {
  +      map.put(key, add1);
  +      try
  +      {
            cache_.attach("/keytest", map);  // this should throw RuntimeException with cause of java.io.NotSerializableException
            fail("failed to get expected runtimeException when adding nonserializable key to pojocache map");
         }
  -      catch(RuntimeException e) {
  +      catch (RuntimeException e)
  +      {
            Throwable t = e;
  -         while((t.getCause() instanceof RuntimeException )) // get through wrapped runtimeexceptions
  +         while ((t.getCause() instanceof RuntimeException)) // get through wrapped runtimeexceptions
               t = t.getCause();
  -         assertTrue("we got expected RuntimeException, test that cause is java.io.NotSerializableException, t.getCause()= "+t.getCause().getClass().getName(), t.getCause() instanceof java.io.NotSerializableException);
  +         assertTrue("we got expected RuntimeException, test that cause is java.io.NotSerializableException, t.getCause()= " + t.getCause().getClass().getName(), t.getCause() instanceof java.io.NotSerializableException);
         }
         map.clear();
         cache_.attach("/keytest", map);  // this should succeed
  -      Map ref = (Map)cache_.find("/keytest");
  +      Map ref = (Map) cache_.find("/keytest");
   
         // try adding nonserializable key to pojocache based map
  -      try {
  +      try
  +      {
            ref.put(key, add1);  // this should throw RuntimeException with cause of java.io.NotSerializableException
            fail("failed to get expected runtimeException when putting nonserializable key to pojocache map");
         }
  -      catch(RuntimeException e) {
  +      catch (RuntimeException e)
  +      {
            Throwable t = e;
  -         while((t.getCause() instanceof RuntimeException )) // get through wrapped runtimeexceptions
  +         while ((t.getCause() instanceof RuntimeException)) // get through wrapped runtimeexceptions
               t = t.getCause();
  -         assertTrue("we got expected RuntimeException, test that cause is java.io.NotSerializableException, t.getCause()= "+t.getCause().getClass().getName(), t.getCause() instanceof java.io.NotSerializableException);
  +         assertTrue("we got expected RuntimeException, test that cause is java.io.NotSerializableException, t.getCause()= " + t.getCause().getClass().getName(), t.getCause() instanceof java.io.NotSerializableException);
         }
      }
   
  @@ -370,6 +374,7 @@
      {
         junit.textui.TestRunner.run(suite());
      }
  +
      static class SerializableKeyValue implements Serializable
      {
          Integer ivalue;
  @@ -378,7 +383,7 @@
          SerializableKeyValue(Integer ivalue, String svalue)
          {
              this.ivalue = ivalue;
  -           this.svalue= svalue;
  +         this.svalue = svalue;
          }
   
          public int hashCode()
  @@ -388,15 +393,16 @@
   
          public boolean equals(Object o)
          {
  -           if(o == this)
  +         if (o == this)
              {
                  return true;
              }
  -           if(! (o instanceof SerializableKeyValue)) {
  +         if (!(o instanceof SerializableKeyValue))
  +         {
                  System.out.println("equals: not instanceof SerializableKeyValue , it is a " + o.getClass().getName());
                  return false;
              }
  -           SerializableKeyValue val = (SerializableKeyValue)o;
  +         SerializableKeyValue val = (SerializableKeyValue) o;
              return val.ivalue == this.ivalue && val.svalue == this.svalue;
          }
      }
  @@ -409,7 +415,7 @@
             NotSerializableKeyValue(Integer ivalue, String svalue)
             {
                 this.ivalue = ivalue;
  -              this.svalue= svalue;
  +         this.svalue = svalue;
             }
   
             public int hashCode()
  @@ -419,15 +425,16 @@
   
             public boolean equals(Object o)
             {
  -              if(o == this)
  +         if (o == this)
                 {
                     return true;
                 }
  -              if(! (o instanceof SerializableKeyValue)) {
  +         if (!(o instanceof SerializableKeyValue))
  +         {
                     System.out.println("equals: not instanceof SerializableKeyValue , it is a " + o.getClass().getName());
                     return false;
                 }
  -              SerializableKeyValue val = (SerializableKeyValue)o;
  +         SerializableKeyValue val = (SerializableKeyValue) o;
                 return val.ivalue == this.ivalue && val.svalue == this.svalue;
             }
         }
  
  
  



More information about the jboss-cvs-commits mailing list