activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r789850 - in /activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util: DataByteArrayInputStreamTest.java DataByteArrayOutputStreamTest.java ReflectionSupportTest.java TreeMapTest.java URISupportTest.java
Date Tue, 30 Jun 2009 17:50:55 GMT
Author: chirino
Date: Tue Jun 30 17:50:55 2009
New Revision: 789850

URL: http://svn.apache.org/viewvc?rev=789850&view=rev
Log:
Converted several test cases to junit

Modified:
    activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
    activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayOutputStreamTest.java
    activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java
    activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java
    activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/URISupportTest.java

Modified: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java?rev=789850&r1=789849&r2=789850&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
Tue Jun 30 17:50:55 2009
@@ -18,15 +18,16 @@
 
 import org.apache.activemq.util.buffer.DataByteArrayInputStream;
 import org.apache.activemq.util.buffer.DataByteArrayOutputStream;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
-import junit.framework.TestCase;
-
-public class DataByteArrayInputStreamTest extends TestCase {
+public class DataByteArrayInputStreamTest {
 
     /**
      * https://issues.apache.org/activemq/browse/AMQ-1911
      */
-    public void testNonAscii() throws Exception {
+    @Test()
+	public void testNonAscii() throws Exception {
         doMarshallUnMarshallValidation("meißen");
         
         int test = 0; // int to get Supplementary chars
@@ -48,6 +49,6 @@
         DataByteArrayInputStream in = new DataByteArrayInputStream(out.getData());
         in.readBoolean();
         String readBack = in.readUTF();
-        assertEquals(value, readBack);
+        Assert.assertEquals(readBack, value);
     }
 }

Modified: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayOutputStreamTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayOutputStreamTest.java?rev=789850&r1=789849&r2=789850&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayOutputStreamTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/DataByteArrayOutputStreamTest.java
Tue Jun 30 17:50:55 2009
@@ -19,16 +19,16 @@
 import java.io.IOException;
 
 import org.apache.activemq.util.buffer.DataByteArrayOutputStream;
+import org.testng.annotations.Test;
 
-import junit.framework.TestCase;
-
-public class DataByteArrayOutputStreamTest extends TestCase {
+public class DataByteArrayOutputStreamTest {
 
     /**
      * This test case assumes that an ArrayIndexOutOfBoundsException will be thrown when
the buffer fails to resize
      * @throws IOException
      */
-    public void testResize() throws IOException {
+    @Test()
+	public void testResize() throws IOException {
         int initSize = 64;
         DataByteArrayOutputStream out = new DataByteArrayOutputStream();
 

Modified: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java?rev=789850&r1=789849&r2=789850&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java
Tue Jun 30 17:50:55 2009
@@ -16,85 +16,25 @@
  */
 package org.apache.activemq.util;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
+import org.junit.Assert;
+import org.testng.annotations.Test;
 
-import junit.framework.TestCase;
-
-//import org.apache.activemq.command.ActiveMQDestination;
-//import org.apache.activemq.command.ActiveMQQueue;
-//import org.apache.activemq.command.ActiveMQTopic;
-
-public class ReflectionSupportTest extends TestCase {
+public class ReflectionSupportTest {
 	
-//    List<ActiveMQDestination> favorites = new ArrayList<ActiveMQDestination>();
     String favoritesString = "[queue://test, topic://test]";
-//    List<ActiveMQDestination> nonFavorites = new ArrayList<ActiveMQDestination>();
     String nonFavoritesString = "[topic://test1]";
     
-//    public void setUp() {
-//        favorites.add(new ActiveMQQueue("test"));
-//        favorites.add(new ActiveMQTopic("test"));
-//        nonFavorites.add(new ActiveMQTopic("test1"));
-//    }
-//
-//    public void testSetProperties() throws URISyntaxException {
-//        SimplePojo pojo = new SimplePojo();
-//        HashMap<String, String> map = new HashMap<String, String>();      
 
-//        map.put("age", "27");
-//        map.put("name", "Hiram");
-//        map.put("enabled", "true");
-//        map.put("uri", "test://value");        
-//        map.put("favorites", favoritesString);
-//        map.put("nonFavorites", nonFavoritesString);
-//        map.put("others", null);
-//        
-//        IntrospectionSupport.setProperties(pojo, map);
-//        
-//        assertEquals(27, pojo.getAge());
-//        assertEquals("Hiram", pojo.getName());
-//        assertEquals(true, pojo.isEnabled());
-//        assertEquals(new URI("test://value"), pojo.getUri());
-//        assertEquals(favorites, pojo.getFavorites());
-//        assertEquals(nonFavorites, pojo.getNonFavorites());
-//        assertNull(pojo.getOthers());
-//    }
-//    
-//    public void testGetProperties() {
-//    	SimplePojo pojo = new SimplePojo();
-//    	pojo.setAge(31);
-//    	pojo.setName("Dejan");
-//    	pojo.setEnabled(true);
-//    	pojo.setFavorites(favorites);
-//    	pojo.setNonFavorites(nonFavorites);
-//    	pojo.setOthers(null);
-//    	
-//    	Properties props = new Properties();
-//    	
-//    	IntrospectionSupport.getProperties(pojo, props, null);
-//    	
-//    	assertEquals("Dejan", props.get("name"));
-//    	assertEquals("31", props.get("age"));
-//    	assertEquals("True", props.get("enabled"));
-//    	assertEquals(favoritesString, props.get("favorites"));
-//    	assertEquals(nonFavoritesString, props.get("nonFavorites"));
-//    	assertNull(props.get("others"));
-//    }
-//    
-    public void testSetBoolean() {
+    @Test()
+	public void testSetBoolean() {
                   
         TestWitBoolean target = new TestWitBoolean();
-        assertTrue(!target.getKeepAlive());
+        Assert.assertTrue((!target.getKeepAlive()));
 
         IntrospectionSupport.setProperty(target, "keepAlive", "TRUE");
-        assertTrue(target.getKeepAlive());
+        Assert.assertTrue(target.getKeepAlive());
         
         IntrospectionSupport.setProperty(target, "keepAlive", "false");
-        assertTrue(!target.getKeepAlive());
+        Assert.assertTrue((!target.getKeepAlive()));
     }
 
     public static class TestWitBoolean {

Modified: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java?rev=789850&r1=789849&r2=789850&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java
Tue Jun 30 17:50:55 2009
@@ -19,15 +19,17 @@
 import java.util.Comparator;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 /**
  * @author cmacnaug
  * 
  */
-public class TreeMapTest extends TestCase {
+public class TreeMapTest {
 
-    public void testOrdering() {
+    @Test()
+	public void testOrdering() {
         Integer[] keys = new Integer[101];
         TreeMap<Integer, Integer> testMap = new TreeMap<Integer, Integer>(new
Comparator<Integer>() {
 
@@ -49,66 +51,66 @@
             refMap.put(keys[i], keys[i]);
         }
         
-        assertEquals(testMap.get(4), refMap.get(4));
-        assertEquals(testMap.get(3), refMap.get(3));
-        assertEquals(testMap.size(), refMap.size());
+        Assert.assertEquals(refMap.get(4), testMap.get(4));
+        Assert.assertEquals(refMap.get(3), testMap.get(3));
+        Assert.assertEquals(refMap.size(), testMap.size());
         
         //Test lookup:
-        assertEquals(null, testMap.lowerEntry(-2));
-        assertEquals(null, testMap.lowerEntry(-1));
-        assertEquals(null, testMap.lowerEntry(0));
-        assertEquals(new Integer(0), testMap.lowerEntry(1).getValue());
-        assertEquals(new Integer(0), testMap.lowerEntry(2).getValue());
-        assertEquals(new Integer(48), testMap.floorEntry(49).getValue());
-        assertEquals(new Integer(50), testMap.floorEntry(50).getValue());
-        assertEquals(new Integer(50), testMap.floorEntry(51).getValue());
-        assertEquals(new Integer(196), testMap.lowerEntry(198).getValue());
-        assertEquals(new Integer(198), testMap.lowerEntry(199).getValue());
-        assertEquals(new Integer(198), testMap.lowerEntry(200).getValue());
-        assertEquals(new Integer(200), testMap.lowerEntry(201).getValue());
-        assertEquals(new Integer(200), testMap.lowerEntry(202).getValue());
-        
-        assertEquals(null, testMap.floorEntry(-2));
-        assertEquals(null, testMap.floorEntry(-1));
-        assertEquals(new Integer(0), testMap.floorEntry(0).getValue());
-        assertEquals(new Integer(0), testMap.floorEntry(1).getValue());
-        assertEquals(new Integer(2), testMap.floorEntry(2).getValue());
-        assertEquals(new Integer(48), testMap.floorEntry(49).getValue());
-        assertEquals(new Integer(50), testMap.floorEntry(50).getValue());
-        assertEquals(new Integer(50), testMap.floorEntry(51).getValue());
-        assertEquals(new Integer(198), testMap.floorEntry(198).getValue());
-        assertEquals(new Integer(198), testMap.floorEntry(199).getValue());
-        assertEquals(new Integer(200), testMap.floorEntry(200).getValue());
-        assertEquals(new Integer(200), testMap.floorEntry(201).getValue());
-        assertEquals(new Integer(200), testMap.floorEntry(202).getValue());
-        
-        assertEquals(new Integer(0), testMap.upperEntry(-2).getValue());
-        assertEquals(new Integer(0), testMap.upperEntry(-1).getValue());
-        assertEquals(new Integer(2), testMap.upperEntry(0).getValue());
-        assertEquals(new Integer(2), testMap.upperEntry(1).getValue());
-        assertEquals(new Integer(4), testMap.upperEntry(2).getValue());
-        assertEquals(new Integer(50), testMap.upperEntry(49).getValue());
-        assertEquals(new Integer(52), testMap.upperEntry(50).getValue());
-        assertEquals(new Integer(52), testMap.upperEntry(51).getValue());
-        assertEquals(new Integer(200), testMap.upperEntry(198).getValue());
-        assertEquals(new Integer(200), testMap.upperEntry(199).getValue());
-        assertEquals(null, testMap.upperEntry(200));
-        assertEquals(null, testMap.upperEntry(201));
-        assertEquals(null, testMap.upperEntry(202));
-        
-        assertEquals(new Integer(0), testMap.ceilingEntry(-2).getValue());
-        assertEquals(new Integer(0), testMap.ceilingEntry(-1).getValue());
-        assertEquals(new Integer(0), testMap.ceilingEntry(0).getValue());
-        assertEquals(new Integer(2), testMap.ceilingEntry(1).getValue());
-        assertEquals(new Integer(2), testMap.ceilingEntry(2).getValue());
-        assertEquals(new Integer(50), testMap.ceilingEntry(49).getValue());
-        assertEquals(new Integer(50), testMap.ceilingEntry(50).getValue());
-        assertEquals(new Integer(52), testMap.ceilingEntry(51).getValue());
-        assertEquals(new Integer(198), testMap.ceilingEntry(198).getValue());
-        assertEquals(new Integer(200), testMap.ceilingEntry(199).getValue());
-        assertEquals(new Integer(200), testMap.ceilingEntry(200).getValue());
-        assertEquals(null, testMap.ceilingEntry(201));
-        assertEquals(null, testMap.ceilingEntry(202));
+        Assert.assertEquals(testMap.lowerEntry(-2), null);
+        Assert.assertEquals(testMap.lowerEntry(-1), null);
+        Assert.assertEquals(testMap.lowerEntry(0), null);
+        Assert.assertEquals(testMap.lowerEntry(1).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.lowerEntry(2).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.floorEntry(49).getValue(), new Integer(48));
+        Assert.assertEquals(testMap.floorEntry(50).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.floorEntry(51).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.lowerEntry(198).getValue(), new Integer(196));
+        Assert.assertEquals(testMap.lowerEntry(199).getValue(), new Integer(198));
+        Assert.assertEquals(testMap.lowerEntry(200).getValue(), new Integer(198));
+        Assert.assertEquals(testMap.lowerEntry(201).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.lowerEntry(202).getValue(), new Integer(200));
+        
+        Assert.assertEquals(testMap.floorEntry(-2), null);
+        Assert.assertEquals(testMap.floorEntry(-1), null);
+        Assert.assertEquals(testMap.floorEntry(0).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.floorEntry(1).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.floorEntry(2).getValue(), new Integer(2));
+        Assert.assertEquals(testMap.floorEntry(49).getValue(), new Integer(48));
+        Assert.assertEquals(testMap.floorEntry(50).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.floorEntry(51).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.floorEntry(198).getValue(), new Integer(198));
+        Assert.assertEquals(testMap.floorEntry(199).getValue(), new Integer(198));
+        Assert.assertEquals(testMap.floorEntry(200).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.floorEntry(201).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.floorEntry(202).getValue(), new Integer(200));
+        
+        Assert.assertEquals(testMap.upperEntry(-2).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.upperEntry(-1).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.upperEntry(0).getValue(), new Integer(2));
+        Assert.assertEquals(testMap.upperEntry(1).getValue(), new Integer(2));
+        Assert.assertEquals(testMap.upperEntry(2).getValue(), new Integer(4));
+        Assert.assertEquals(testMap.upperEntry(49).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.upperEntry(50).getValue(), new Integer(52));
+        Assert.assertEquals(testMap.upperEntry(51).getValue(), new Integer(52));
+        Assert.assertEquals(testMap.upperEntry(198).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.upperEntry(199).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.upperEntry(200), null);
+        Assert.assertEquals(testMap.upperEntry(201), null);
+        Assert.assertEquals(testMap.upperEntry(202), null);
+        
+        Assert.assertEquals(testMap.ceilingEntry(-2).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.ceilingEntry(-1).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.ceilingEntry(0).getValue(), new Integer(0));
+        Assert.assertEquals(testMap.ceilingEntry(1).getValue(), new Integer(2));
+        Assert.assertEquals(testMap.ceilingEntry(2).getValue(), new Integer(2));
+        Assert.assertEquals(testMap.ceilingEntry(49).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.ceilingEntry(50).getValue(), new Integer(50));
+        Assert.assertEquals(testMap.ceilingEntry(51).getValue(), new Integer(52));
+        Assert.assertEquals(testMap.ceilingEntry(198).getValue(), new Integer(198));
+        Assert.assertEquals(testMap.ceilingEntry(199).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.ceilingEntry(200).getValue(), new Integer(200));
+        Assert.assertEquals(testMap.ceilingEntry(201), null);
+        Assert.assertEquals(testMap.ceilingEntry(202), null);
         
         //Test iterators:
         assertEquals(refMap.keySet().iterator(), testMap.keySet().iterator());
@@ -116,7 +118,7 @@
         assertEquals(refMap.entrySet().iterator(), testMap.entrySet().iterator());
         
         //Test removal:
-        assertEquals(refMap.remove(refMap.firstKey()), testMap.remove(testMap.firstKey()));
+        Assert.assertEquals(testMap.remove(testMap.firstKey()), refMap.remove(refMap.firstKey()));
         Iterator<Integer> refIt = refMap.values().iterator();
         Iterator<Integer> testIt = testMap.values().iterator();
         refIt.next();
@@ -128,10 +130,10 @@
     
     private static <T> void assertEquals(Iterator<T> i1, Iterator<T> i2)
     {
-        assertEquals(i1.hasNext(), i2.hasNext());
+        Assert.assertEquals(i2.hasNext(), i1.hasNext());
         if(i1.hasNext())
         {
-            assertEquals(i1.next(), i2.next());
+            Assert.assertEquals(i2.next(), i1.next());
         }
     }
 }

Modified: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/URISupportTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/URISupportTest.java?rev=789850&r1=789849&r2=789850&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/URISupportTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/URISupportTest.java
Tue Jun 30 17:50:55 2009
@@ -20,64 +20,76 @@
 import java.net.URISyntaxException;
 import java.util.Map;
 
-import junit.framework.TestCase;
 import org.apache.activemq.util.URISupport.CompositeData;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 /**
  *
  * @version $Revision: 1.1 $
  */
-public class URISupportTest extends TestCase {
+public class URISupportTest {
     
-    public void testEmptyCompositePath() throws Exception {
+    @Test()
+	public void testEmptyCompositePath() throws Exception {
         CompositeData data = URISupport.parseComposite(new URI("broker:()/localhost?persistent=false"));
-        assertEquals(0, data.getComponents().length);        
+        Assert.assertEquals(data.getComponents().length, 0);        
     }
             
-    public void testCompositePath() throws Exception {
+    @Test()
+	public void testCompositePath() throws Exception {
         CompositeData data = URISupport.parseComposite(new URI("test:(path)/path"));
-        assertEquals("path", data.getPath());        
+        Assert.assertEquals(data.getPath(), "path");        
         data = URISupport.parseComposite(new URI("test:path"));
         assertNull(data.getPath());
     }
 
-    public void testSimpleComposite() throws Exception {
+    private void assertNull(Object path) {
+    	Assert.assertNull(path);
+	}
+
+	@Test()
+	public void testSimpleComposite() throws Exception {
         CompositeData data = URISupport.parseComposite(new URI("test:part1"));
-        assertEquals(1, data.getComponents().length);
+        Assert.assertEquals(data.getComponents().length, 1);
     }
 
-    public void testComposite() throws Exception {
+    @Test()
+	public void testComposite() throws Exception {
         CompositeData data = URISupport.parseComposite(new URI("test:(part1://host,part2://(sub1://part,sube2:part))"));
-        assertEquals(2, data.getComponents().length);
+        Assert.assertEquals(data.getComponents().length, 2);
     }
 
-    public void testParsingURI() throws Exception {
+    @Test()
+	public void testParsingURI() throws Exception {
         URI source = new URI("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
         
         Map map = URISupport.parseParamters(source);
     
-        assertEquals("Size: " + map, 2, map.size());
+        Assert.assertEquals(map.size(), 2, ("Size: " + map));
         assertMapKey(map, "cheese", "Edam");
         assertMapKey(map, "x", "123");
         
         URI result = URISupport.removeQuery(source);
         
-        assertEquals("result", new URI("tcp://localhost:61626/foo/bar"), result);
+        Assert.assertEquals(result, new URI("tcp://localhost:61626/foo/bar"), "result");
     }
     
     protected void assertMapKey(Map map, String key, Object expected) {
-        assertEquals("Map key: " + key, map.get(key), expected);
+        Assert.assertEquals(expected, map.get(key), ("Map key: " + key));
     }
     
-    public void testParsingCompositeURI() throws URISyntaxException {
+    @Test()
+	public void testParsingCompositeURI() throws URISyntaxException {
         URISupport.parseComposite(new URI("broker://(tcp://localhost:61616)?name=foo"));
     }
     
-    public void testCheckParenthesis() throws Exception {
+    @Test()
+	public void testCheckParenthesis() throws Exception {
         String str = "fred:(((ddd))";
-        assertFalse(URISupport.checkParenthesis(str));
+        Assert.assertFalse(URISupport.checkParenthesis(str));
         str += ")";
-        assertTrue(URISupport.checkParenthesis(str));
+        Assert.assertTrue(URISupport.checkParenthesis(str));
     }
     
 }



Mime
View raw message