You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2009/02/02 00:35:56 UTC

svn commit: r739885 [5/5] - in /activemq/activemq-blaze/trunk/src: main/java/org/apache/activeblaze/ main/java/org/apache/activeblaze/group/ main/java/org/apache/activeblaze/impl/transport/ main/java/org/apache/activeblaze/jms/ main/java/org/apache/act...

Modified: activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/BlazeMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/BlazeMessageTest.java?rev=739885&r1=739884&r2=739885&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/BlazeMessageTest.java (original)
+++ activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/BlazeMessageTest.java Sun Feb  1 23:35:54 2009
@@ -32,104 +32,104 @@
 
     public void testBytesConversion() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setBoolean("boolean", true);
-        msg.setByte("byte", (byte) 1);
-        msg.setBytes("bytes", new byte[1]);
-        msg.setChar("char", 'a');
-        msg.setDouble("double", 1.5);
-        msg.setFloat("float", 1.5f);
-        msg.setInt("int", 1);
-        msg.setLong("long", 1);
+        msg.setBooleanValue("boolean", true);
+        msg.setByteValue("byte", (byte) 1);
+        msg.setBytesValue("bytes", new byte[1]);
+        msg.setCharValue("char", 'a');
+        msg.setDoubleValue("double", 1.5);
+        msg.setFloatValue("float", 1.5f);
+        msg.setIntValue("int", 1);
+        msg.setLongValue("long", 1);
         msg.put("object", "stringObj");
-        msg.setShort("short", (short) 1);
-        msg.setString("string", "string");
+        msg.setShortValue("short", (short) 1);
+        msg.setStringValue("string", "string");
         // Test with a 1Meg String
         StringBuffer bigSB = new StringBuffer(1024 * 1024);
         for (int i = 0; i < 1024 * 1024; i++) {
             bigSB.append((char) 'a' + i % 26);
         }
         String bigString = bigSB.toString();
-        msg.setString("bigString", bigString);
+        msg.setStringValue("bigString", bigString);
         msg = msg.clone();
-        assertEquals(msg.getBoolean("boolean"), true);
-        assertEquals(msg.getByte("byte"), (byte) 1);
-        assertEquals(msg.getBytes("bytes").length, 1);
-        assertEquals(msg.getChar("char"), 'a');
-        assertEquals(msg.getDouble("double"), 1.5, 0);
-        assertEquals(msg.getFloat("float"), 1.5f, 0);
-        assertEquals(msg.getInt("int"), 1);
-        assertEquals(msg.getLong("long"), 1);
-        assertEquals(msg.getObject("object"), "stringObj");
-        assertEquals(msg.getShort("short"), (short) 1);
-        assertEquals(msg.getString("string"), "string");
-        assertEquals(msg.getString("bigString"), bigString);
+        assertEquals(msg.getBooleanValue("boolean"), true);
+        assertEquals(msg.getByteValue("byte"), (byte) 1);
+        assertEquals(msg.getBytesValue("bytes").length, 1);
+        assertEquals(msg.getCharValue("char"), 'a');
+        assertEquals(msg.getDoubleValue("double"), 1.5, 0);
+        assertEquals(msg.getFloatValue("float"), 1.5f, 0);
+        assertEquals(msg.getIntValue("int"), 1);
+        assertEquals(msg.getLongValue("long"), 1);
+        assertEquals(msg.getObjectValue("object"), "stringObj");
+        assertEquals(msg.getShortValue("short"), (short) 1);
+        assertEquals(msg.getStringValue("string"), "string");
+        assertEquals(msg.getStringValue("bigString"), bigString);
     }
 
     public void testGetBoolean() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setBoolean(NAME, true);
-        assertTrue(msg.getBoolean(NAME));
+        msg.setBooleanValue(NAME, true);
+        assertTrue(msg.getBooleanValue(NAME));
         msg.clear();
-        msg.setString(NAME, "true");
+        msg.setStringValue(NAME, "true");
         msg = msg.clone();
-        assertTrue(msg.getBoolean(NAME));
+        assertTrue(msg.getBooleanValue(NAME));
     }
 
     public void testGetByte() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setByte(this.NAME, (byte) 1);
+        msg.setByteValue(this.NAME, (byte) 1);
         msg = msg.clone();
-        assertTrue(msg.getByte(this.NAME) == (byte) 1);
+        assertTrue(msg.getByteValue(this.NAME) == (byte) 1);
     }
 
     public void testGetShort() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setShort(this.NAME, (short) 1);
+        msg.setShortValue(this.NAME, (short) 1);
         msg = msg.clone();
-        assertTrue(msg.getShort(this.NAME) == (short) 1);
+        assertTrue(msg.getShortValue(this.NAME) == (short) 1);
     }
 
     public void testGetChar() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setChar(this.NAME, 'a');
+        msg.setCharValue(this.NAME, 'a');
         msg = msg.clone();
-        assertTrue(msg.getChar(this.NAME) == 'a');
+        assertTrue(msg.getCharValue(this.NAME) == 'a');
     }
 
     public void testGetInt() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setInt(this.NAME, 1);
+        msg.setIntValue(this.NAME, 1);
         msg = msg.clone();
-        assertTrue(msg.getInt(this.NAME) == 1);
+        assertTrue(msg.getIntValue(this.NAME) == 1);
     }
 
     public void testGetLong() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setLong(this.NAME, 1);
+        msg.setLongValue(this.NAME, 1);
         msg = msg.clone();
-        assertTrue(msg.getLong(this.NAME) == 1);
+        assertTrue(msg.getLongValue(this.NAME) == 1);
     }
 
     public void testGetFloat() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setFloat(this.NAME, 1.5f);
+        msg.setFloatValue(this.NAME, 1.5f);
         msg = msg.clone();
-        assertTrue(msg.getFloat(this.NAME) == 1.5f);
+        assertTrue(msg.getFloatValue(this.NAME) == 1.5f);
     }
 
     public void testGetDouble() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setDouble(this.NAME, 1.5);
+        msg.setDoubleValue(this.NAME, 1.5);
         msg = msg.clone();
-        assertTrue(msg.getDouble(this.NAME) == 1.5);
+        assertTrue(msg.getDoubleValue(this.NAME) == 1.5);
     }
 
     public void testGetString() throws Exception {
         BlazeMessage msg = new BlazeMessage();
         String str = "test";
-        msg.setString(this.NAME, str);
+        msg.setStringValue(this.NAME, str);
         msg = msg.clone();
-        assertEquals(msg.getString(this.NAME), str);
+        assertEquals(msg.getStringValue(this.NAME), str);
     }
 
     public void testGetBytes() throws Exception {
@@ -137,11 +137,11 @@
         byte[] bytes1 = new byte[3];
         byte[] bytes2 = new byte[2];
         System.arraycopy(bytes1, 0, bytes2, 0, 2);
-        msg.setBytes(this.NAME, bytes1);
-        msg.setBytes(this.NAME + "2", bytes1, 0, 2);
+        msg.setBytesValue(this.NAME, bytes1);
+        msg.setBytesValue(this.NAME + "2", bytes1, 0, 2);
         msg = msg.clone();
-        assertTrue(Arrays.equals(msg.getBytes(this.NAME), bytes1));
-        assertEquals(msg.getBytes(this.NAME + "2").length, bytes2.length);
+        assertTrue(Arrays.equals(msg.getBytesValue(this.NAME), bytes1));
+        assertEquals(msg.getBytesValue(this.NAME + "2").length, bytes2.length);
     }
 
     public void testGetObject() throws Exception {
@@ -167,55 +167,55 @@
         msg.put("short", shortValue);
         msg.put("string", stringValue);
         msg = msg.clone();
-        assertTrue(msg.getObject("boolean") instanceof Boolean);
-        assertEquals(msg.getObject("boolean"), booleanValue);
-        assertEquals(msg.getBoolean("boolean"), booleanValue.booleanValue());
-        assertTrue(msg.getObject("byte") instanceof Byte);
-        assertEquals(msg.getObject("byte"), byteValue);
-        assertEquals(msg.getByte("byte"), byteValue.byteValue());
-        assertTrue(msg.getObject("bytes") instanceof byte[]);
-        assertEquals(((byte[]) msg.getObject("bytes")).length,
+        assertTrue(msg.getObjectValue("boolean") instanceof Boolean);
+        assertEquals(msg.getObjectValue("boolean"), booleanValue);
+        assertEquals(msg.getBooleanValue("boolean"), booleanValue.booleanValue());
+        assertTrue(msg.getObjectValue("byte") instanceof Byte);
+        assertEquals(msg.getObjectValue("byte"), byteValue);
+        assertEquals(msg.getByteValue("byte"), byteValue.byteValue());
+        assertTrue(msg.getObjectValue("bytes") instanceof byte[]);
+        assertEquals(((byte[]) msg.getObjectValue("bytes")).length,
                 bytesValue.length);
-        assertEquals(msg.getBytes("bytes").length, bytesValue.length);
-        assertTrue(msg.getObject("char") instanceof Character);
-        assertEquals(msg.getObject("char"), charValue);
-        assertEquals(msg.getChar("char"), charValue.charValue());
-        assertTrue(msg.getObject("double") instanceof Double);
-        assertEquals(msg.getObject("double"), doubleValue);
-        assertEquals(msg.getDouble("double"), doubleValue.doubleValue(), 0);
-        assertTrue(msg.getObject("float") instanceof Float);
-        assertEquals(msg.getObject("float"), floatValue);
-        assertEquals(msg.getFloat("float"), floatValue.floatValue(), 0);
-        assertTrue(msg.getObject("int") instanceof Integer);
-        assertEquals(msg.getObject("int"), intValue);
-        assertEquals(msg.getInt("int"), intValue.intValue());
-        assertTrue(msg.getObject("long") instanceof Long);
-        assertEquals(msg.getObject("long"), longValue);
-        assertEquals(msg.getLong("long"), longValue.longValue());
-        assertTrue(msg.getObject("short") instanceof Short);
-        assertEquals(msg.getObject("short"), shortValue);
-        assertEquals(msg.getShort("short"), shortValue.shortValue());
-        assertTrue(msg.getObject("string") instanceof String);
-        assertEquals(msg.getObject("string"), stringValue);
-        assertEquals(msg.getString("string"), stringValue);
+        assertEquals(msg.getBytesValue("bytes").length, bytesValue.length);
+        assertTrue(msg.getObjectValue("char") instanceof Character);
+        assertEquals(msg.getObjectValue("char"), charValue);
+        assertEquals(msg.getCharValue("char"), charValue.charValue());
+        assertTrue(msg.getObjectValue("double") instanceof Double);
+        assertEquals(msg.getObjectValue("double"), doubleValue);
+        assertEquals(msg.getDoubleValue("double"), doubleValue.doubleValue(), 0);
+        assertTrue(msg.getObjectValue("float") instanceof Float);
+        assertEquals(msg.getObjectValue("float"), floatValue);
+        assertEquals(msg.getFloatValue("float"), floatValue.floatValue(), 0);
+        assertTrue(msg.getObjectValue("int") instanceof Integer);
+        assertEquals(msg.getObjectValue("int"), intValue);
+        assertEquals(msg.getIntValue("int"), intValue.intValue());
+        assertTrue(msg.getObjectValue("long") instanceof Long);
+        assertEquals(msg.getObjectValue("long"), longValue);
+        assertEquals(msg.getLongValue("long"), longValue.longValue());
+        assertTrue(msg.getObjectValue("short") instanceof Short);
+        assertEquals(msg.getObjectValue("short"), shortValue);
+        assertEquals(msg.getShortValue("short"), shortValue.shortValue());
+        assertTrue(msg.getObjectValue("string") instanceof String);
+        assertEquals(msg.getObjectValue("string"), stringValue);
+        assertEquals(msg.getStringValue("string"), stringValue);
     }
 
     public void testGetMapNames() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setBoolean("boolean", true);
-        msg.setByte("byte", (byte) 1);
-        msg.setBytes("bytes1", new byte[1]);
-        msg.setBytes("bytes2", new byte[3], 0, 2);
-        msg.setChar("char", 'a');
-        msg.setDouble("double", 1.5);
-        msg.setFloat("float", 1.5f);
-        msg.setInt("int", 1);
-        msg.setLong("long", 1);
+        msg.setBooleanValue("boolean", true);
+        msg.setByteValue("byte", (byte) 1);
+        msg.setBytesValue("bytes1", new byte[1]);
+        msg.setBytesValue("bytes2", new byte[3], 0, 2);
+        msg.setCharValue("char", 'a');
+        msg.setDoubleValue("double", 1.5);
+        msg.setFloatValue("float", 1.5f);
+        msg.setIntValue("int", 1);
+        msg.setLongValue("long", 1);
         msg.put("object", "stringObj");
-        msg.setShort("short", (short) 1);
-        msg.setString("string", "string");
+        msg.setShortValue("short", (short) 1);
+        msg.setStringValue("string", "string");
         msg = msg.clone();
-        Enumeration<String> mapNamesEnum = msg.getMapNames();
+        Enumeration<String> mapNamesEnum = msg.getNames();
         List<String> mapNamesList = Collections.list(mapNamesEnum);
         assertEquals(mapNamesList.size(), 12);
         assertTrue(mapNamesList.contains("boolean"));
@@ -234,7 +234,7 @@
 
     public void testItemExists() throws Exception {
         BlazeMessage msg = new BlazeMessage();
-        msg.setString("exists", "test");
+        msg.setStringValue("exists", "test");
         msg = msg.clone();
         assertTrue(msg.containsKey("exists"));
         assertFalse(msg.containsKey("doesntExist"));

Modified: activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/group/BlazeGroupChannelTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/group/BlazeGroupChannelTest.java?rev=739885&r1=739884&r2=739885&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/group/BlazeGroupChannelTest.java (original)
+++ activemq/activemq-blaze/trunk/src/test/java/org/apache/activeblaze/group/BlazeGroupChannelTest.java Sun Feb  1 23:35:54 2009
@@ -22,6 +22,7 @@
 import junit.framework.TestCase;
 import org.apache.activeblaze.BlazeChannel;
 import org.apache.activeblaze.BlazeMessage;
+import org.apache.activeblaze.BlazeMessageListener;
 
 /**
  * Test BlazeGroupChannel
@@ -44,7 +45,7 @@
             channel.addToGroup("test");
             channel.start();
             channels.add(channel);
-            channel.setInboxListener(new BlazeQueueListener() {
+            channel.setInboxListener(new BlazeMessageListener() {
                 public void onMessage(BlazeMessage message) {
                     synchronized (count) {
                         synchronized (count) {
@@ -57,7 +58,7 @@
         }
         channels.get(0).getAndWaitForMemberByName(channels.get(number - 1).getName(), 2000);
         BlazeMessage msg = new BlazeMessage();
-        msg.setString("test", "hello");
+        msg.setStringValue("test", "hello");
         channels.get(0).send(channels.get(1).getLocalMember(), msg);
         synchronized (count) {
             if (count.get() == 0) {
@@ -93,7 +94,7 @@
         reply.addToGroup("test");
         request.start();
         reply.start();
-        reply.setInboxListener(new BlazeQueueListener() {
+        reply.setInboxListener(new BlazeMessageListener() {
             public void onMessage(BlazeMessage message) {
                 if (!replies.isEmpty()) {
                     BlazeMessage replyMsg = replies.remove(0);
@@ -120,7 +121,7 @@
 
     public void testSendRequestString() throws Exception {
         String destination = "/test/foo";
-        final int number = 100;
+        final int number = 10;
         final List<BlazeMessage> requests = new ArrayList<BlazeMessage>();
         final List<BlazeMessage> replies = new ArrayList<BlazeMessage>();
         for (int i = 0; i < number; i++) {
@@ -130,7 +131,7 @@
         BlazeGroupChannelFactory factory = new BlazeGroupChannelFactory();
         final BlazeGroupChannel request = factory.createGroupChannel("request");
         final BlazeGroupChannel reply = factory.createGroupChannel("reply");
-        reply.addBlazeQueueMessageListener(destination, new BlazeQueueListener() {
+        reply.addBlazeQueueMessageListener(destination, new BlazeMessageListener() {
             public void onMessage(BlazeMessage message) {
                 if (!replies.isEmpty()) {
                     BlazeMessage replyMsg = replies.remove(0);
@@ -176,7 +177,7 @@
             channel.addToGroup("test");
             channel.start();
             channels.add(channel);
-            channel.addBlazeQueueMessageListener(destination, new BlazeQueueListener() {
+            channel.addBlazeQueueMessageListener(destination, new BlazeMessageListener() {
                 public void onMessage(BlazeMessage message) {
                     synchronized (count) {
                         synchronized (count) {