qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1488957 - in /qpid/trunk/qpid/java: broker/src/test/java/org/apache/qpid/server/queue/ client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/ common/src/ma...
Date Mon, 03 Jun 2013 11:24:35 GMT
Author: rgodfrey
Date: Mon Jun  3 11:24:34 2013
New Revision: 1488957

URL: http://svn.apache.org/r1488957
Log:
QPID-4904 : [Java] AMQShortString.equals should on return true if it is being compared to
another AMQShortString

Modified:
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
    qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
    qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
    qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java?rev=1488957&r1=1488956&r2=1488957&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
(original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
Mon Jun  3 11:24:34 2013
@@ -156,7 +156,7 @@ public class AMQQueueFactoryTest extends
 
         Exchange altExchange = queue.getAlternateExchange();
         assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange);
-        assertEquals("Alternate exchange name was not as expected", dlExchangeName, altExchange.getName());
+        assertEquals("Alternate exchange name was not as expected", dlExchangeName.asString(),
altExchange.getName());
         assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS,
altExchange.getType().getName());
 
         assertNotNull("The alternate exchange was not registered as expected", exReg.getExchange(dlExchangeName));
@@ -195,7 +195,7 @@ public class AMQQueueFactoryTest extends
         assertEquals("Unexpected maximum delivery count", 5, queue.getMaximumDeliveryCount());
         Exchange altExchange = queue.getAlternateExchange();
         assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange);
-        assertEquals("Alternate exchange name was not as expected", dlExchangeName, altExchange.getName());
+        assertEquals("Alternate exchange name was not as expected", dlExchangeName.toString(),
altExchange.getName());
         assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS,
altExchange.getType().getName());
 
         assertNotNull("The alternate exchange was not registered as expected", exReg.getExchange(dlExchangeName));

Modified: qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java?rev=1488957&r1=1488956&r2=1488957&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
(original)
+++ qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
Mon Jun  3 11:24:34 2013
@@ -447,13 +447,13 @@ public class ConnectionURLTest extends T
 
         AMQConnectionURL conn = new AMQConnectionURL(url);
 
-        assertEquals(conn.getDefaultQueueExchangeName(),"test.direct");
+        assertEquals(conn.getDefaultQueueExchangeName().asString(),"test.direct");
 
-        assertEquals(conn.getDefaultTopicExchangeName(),"test.topic");
+        assertEquals(conn.getDefaultTopicExchangeName().asString(),"test.topic");
 
-        assertEquals(conn.getTemporaryQueueExchangeName(),"tmp.direct");
+        assertEquals(conn.getTemporaryQueueExchangeName().asString(),"tmp.direct");
 
-        assertEquals(conn.getTemporaryTopicExchangeName(),"tmp.topic");
+        assertEquals(conn.getTemporaryTopicExchangeName().asString(),"tmp.topic");
 
     }
 

Modified: qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java?rev=1488957&r1=1488956&r2=1488957&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
(original)
+++ qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
Mon Jun  3 11:24:34 2013
@@ -45,10 +45,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(dest.toString()));
 
-        assertTrue(dest.getExchangeClass().equals("exchange.Class"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals("Destination"));
-        assertTrue(dest.getQueueName().equals("Queue"));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchange.Class"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(dest.getQueueName().equalsCharSequence("Queue"));
     }
 
     public void testQueue() throws URISyntaxException
@@ -60,10 +60,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(dest.toString()));
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals(""));
-        assertTrue(dest.getQueueName().equals("Queue"));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence(""));
+        assertTrue(dest.getQueueName().equalsCharSequence("Queue"));
     }
 
     public void testQueueWithOption() throws URISyntaxException
@@ -75,10 +75,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(dest.toString()));
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals(""));
-        assertTrue(dest.getQueueName().equals("Queue"));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence(""));
+        assertTrue(dest.getQueueName().equalsCharSequence("Queue"));
         assertTrue(dest.getOption("option").equals("value"));
     }
 
@@ -92,10 +92,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(dest.toString()));
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals("Destination"));
-        assertTrue(dest.getQueueName().equals(""));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(dest.getQueueName().equalsCharSequence(""));
     }
 
     public void testDestinationWithOption() throws URISyntaxException
@@ -107,10 +107,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(dest.toString()));
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals("Destination"));
-        assertTrue(dest.getQueueName().equals(""));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(dest.getQueueName().equalsCharSequence(""));
 
         assertTrue(dest.getOption("option").equals("value"));
     }
@@ -122,10 +122,10 @@ public class DestinationURLTest extends 
 
         AMQBindingURL dest = new AMQBindingURL(url);
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals("Destination"));
-        assertTrue(dest.getQueueName().equals(""));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(dest.getQueueName().equalsCharSequence(""));
 
         assertTrue(dest.getOption("option").equals("value"));
         assertTrue(dest.getOption("option2").equals("value2"));
@@ -139,9 +139,9 @@ public class DestinationURLTest extends 
         AMQBindingURL dest = new AMQBindingURL(url);
 
         assertTrue(dest.getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS));
-        assertTrue(dest.getExchangeName().equals(""));
-        assertTrue(dest.getDestinationName().equals(""));
-        assertTrue(dest.getQueueName().equals("IBMPerfQueue1"));
+        assertTrue(dest.getExchangeName().equalsCharSequence(""));
+        assertTrue(dest.getDestinationName().equalsCharSequence(""));
+        assertTrue(dest.getQueueName().equalsCharSequence("IBMPerfQueue1"));
 
         assertTrue(dest.getOption("durable").equals("true"));
     }
@@ -153,10 +153,10 @@ public class DestinationURLTest extends 
 
         AMQBindingURL dest = new AMQBindingURL(url);
 
-        assertTrue(dest.getExchangeClass().equals("exchangeClass"));
-        assertTrue(dest.getExchangeName().equals("exchangeName"));
-        assertTrue(dest.getDestinationName().equals("Destination"));
-        assertTrue(dest.getQueueName().equals(""));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(dest.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(dest.getQueueName().equalsCharSequence(""));
 
         assertTrue(dest.getBindingKeys().length == 2);
     }
@@ -188,9 +188,9 @@ public class DestinationURLTest extends 
 
         AMQBindingURL dest = new AMQBindingURL(url);
 
-        assertTrue(dest.getExchangeClass().equals("topic"));
-        assertTrue(dest.getExchangeName().equals("amq.topic"));
-        assertTrue(dest.getQueueName().equals("test:testQueueD"));
+        assertTrue(dest.getExchangeClass().equalsCharSequence("topic"));
+        assertTrue(dest.getExchangeName().equalsCharSequence("amq.topic"));
+        assertTrue(dest.getQueueName().equalsCharSequence("test:testQueueD"));
     }
 
     public void testExchangeOptionsNotPresent() throws URISyntaxException
@@ -320,10 +320,10 @@ public class DestinationURLTest extends 
         AMQBindingURL burl = new AMQBindingURL(url);
 
         assertTrue(url.equals(burl.toString()));
-        assertTrue(burl.getExchangeClass().equals("exchangeClass"));
-        assertTrue(burl.getExchangeName().equals("exchangeName"));
-        assertTrue(burl.getDestinationName().equals("Destination"));
-        assertTrue(burl.getQueueName().equals("Queue"));
+        assertTrue(burl.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(burl.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(burl.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(burl.getQueueName().equalsCharSequence("Queue"));
 
         //check that the MaxDeliveryCount property has the right value
         assertEquals("server",burl.getOption(BindingURL.OPTION_REJECT_BEHAVIOUR));
@@ -353,10 +353,10 @@ public class DestinationURLTest extends 
 
         assertTrue(url.equals(burl.toString()));
 
-        assertTrue(burl.getExchangeClass().equals("exchangeClass"));
-        assertTrue(burl.getExchangeName().equals("exchangeName"));
-        assertTrue(burl.getDestinationName().equals("Destination"));
-        assertTrue(burl.getQueueName().equals("Queue"));
+        assertTrue(burl.getExchangeClass().equalsCharSequence("exchangeClass"));
+        assertTrue(burl.getExchangeName().equalsCharSequence("exchangeName"));
+        assertTrue(burl.getDestinationName().equalsCharSequence("Destination"));
+        assertTrue(burl.getQueueName().equalsCharSequence("Queue"));
 
         class MyTestAMQDestination extends AMQDestination
         {

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java?rev=1488957&r1=1488956&r2=1488957&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
(original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
Mon Jun  3 11:24:34 2013
@@ -461,26 +461,15 @@ public final class AMQShortString implem
     public boolean equals(Object o)
     {
 
-
-        if(o instanceof AMQShortString)
-        {
-            return equals((AMQShortString)o);
-        }
-        if(o instanceof CharSequence)
-        {
-            return equals((CharSequence)o);
-        }
-
-        if (o == null)
-        {
-            return false;
-        }
-
         if (o == this)
         {
             return true;
         }
 
+        if(o instanceof AMQShortString)
+        {
+            return equals((AMQShortString) o);
+        }
 
         return false;
 
@@ -544,11 +533,11 @@ public final class AMQShortString implem
 
     }
 
-    public boolean equals(CharSequence s)
+    public boolean equalsCharSequence(CharSequence s)
     {
         if(s instanceof AMQShortString)
         {
-            return equals((AMQShortString)s);
+            return equals((AMQShortString) s);
         }
 
         if (s == null)
@@ -602,7 +591,11 @@ public final class AMQShortString implem
 
     public int compareTo(AMQShortString name)
     {
-        if (name == null)
+        if(name == this)
+        {
+            return 0;
+        }
+        else if (name == null)
         {
             return 1;
         }

Modified: qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java?rev=1488957&r1=1488956&r2=1488957&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
(original)
+++ qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
Mon Jun  3 11:24:34 2013
@@ -126,7 +126,7 @@ public class AMQShortStringTest extends 
         }
         AMQShortString string = new AMQShortString(bytes);
         assertEquals("constructed amq short string length differs from expected", 4, string.length());
-        assertTrue("constructed amq short string differs from expected", string.equals("test"));
+        assertTrue("constructed amq short string differs from expected", string.equalsCharSequence("test"));
     }
 
     /**
@@ -139,7 +139,7 @@ public class AMQShortStringTest extends 
     {
         AMQShortString string = new AMQShortString("test");
         assertEquals("constructed amq short string length differs from expected", 4, string.length());
-        assertTrue("constructed amq short string differs from expected", string.equals("test"));
+        assertTrue("constructed amq short string differs from expected", string.equalsCharSequence("test"));
     }
 
     /**
@@ -153,7 +153,7 @@ public class AMQShortStringTest extends 
         char[] chars = "test".toCharArray();
         AMQShortString string = new AMQShortString(chars);
         assertEquals("constructed amq short string length differs from expected", 4, string.length());
-        assertTrue("constructed amq short string differs from expected", string.equals("test"));
+        assertTrue("constructed amq short string differs from expected", string.equalsCharSequence("test"));
     }
 
     /**
@@ -166,7 +166,7 @@ public class AMQShortStringTest extends 
     {
         AMQShortString string = new AMQShortString((CharSequence) "test");
         assertEquals("constructed amq short string length differs from expected", 4, string.length());
-        assertTrue("constructed amq short string differs from expected", string.equals("test"));
+        assertTrue("constructed amq short string differs from expected", string.equalsCharSequence("test"));
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message