qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1750323 - in /qpid/java/trunk/broker-core/src: main/java/org/apache/qpid/server/exchange/DefaultDestination.java test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
Date Mon, 27 Jun 2016 12:00:58 GMT
Author: kwall
Date: Mon Jun 27 12:00:58 2016
New Revision: 1750323

URL: http://svn.apache.org/viewvc?rev=1750323&view=rev
Log:
QPID-6954: [Java Broker] Add unit test for AttributeValueConverter for ManagedAttributeValue

Modified:
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java
    qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java?rev=1750323&r1=1750322&r2=1750323&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java
Mon Jun 27 12:00:58 2016
@@ -22,12 +22,9 @@ import org.apache.qpid.exchange.Exchange
 import org.apache.qpid.server.message.InstanceProperties;
 import org.apache.qpid.server.message.MessageDestination;
 import org.apache.qpid.server.message.MessageInstance;
-import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageEnqueueRecord;
 import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.Action;

Modified: qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java?rev=1750323&r1=1750322&r2=1750323&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
(original)
+++ qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
Mon Jun 27 12:00:58 2016
@@ -32,6 +32,7 @@ import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
 import java.text.ParseException;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -280,4 +281,72 @@ public class AttributeValueConverterTest
         assertEquals("CN=app2@acme.org,OU=art,O=acme,L=Toronto,ST=ON,C=CA", x509Certificate.getSubjectX500Principal().getName());
         assertEquals("CN=MyRootCA,O=ACME,ST=Ontario,C=CA", x509Certificate.getIssuerX500Principal().getName());
     }
+
+    public void testMapToManagedAttributeValue()
+    {
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
+
+        final AttributeValueConverter<TestManagedAttributeValue> converter =
+                getConverter(TestManagedAttributeValue.class, TestManagedAttributeValue.class);
+
+        final String expectedStringValue = "mystringvalue";
+        final Integer expectedIntegerValue = 31;
+        final int expectedIntegerPrimitiveValue = 32;
+        final Map<String, Object> input = new HashMap<>();
+        input.put("string", expectedStringValue);
+        input.put("integer", expectedIntegerValue);
+        input.put("int", expectedIntegerPrimitiveValue);
+
+        final TestManagedAttributeValue value = converter.convert(input, object);
+
+        assertEquals(expectedStringValue, value.getString());
+        assertEquals(expectedIntegerValue, value.getInteger());
+        assertEquals(expectedIntegerPrimitiveValue, value.getInt());
+        assertNull(expectedStringValue, value.getAnotherString());
+
+        // TODO: should changes to the underlying map be visible?
+//        input.put("anotherString", "laterchange");
+//        assertNull(expectedStringValue, value.getAnotherString());
+    }
+
+    @ManagedAttributeValueType
+    public interface TestManagedAttributeValue extends ManagedAttributeValue
+    {
+        String getString();
+        Integer getInteger();
+        int getInt();
+        String getAnotherString();
+    }
+
+    public void testMapToManagedAttributeValueEquality()
+    {
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
+
+        final AttributeValueConverter<SimpleTestManagedAttributeValue> converter =
+                getConverter(SimpleTestManagedAttributeValue.class, SimpleTestManagedAttributeValue.class);
+
+        Object elephant = new Object();
+
+        final Map<String, String> map = Collections.singletonMap("string", "mystring");
+        final Map<String, String> mapWithSameContent = Collections.singletonMap("string",
"mystring");
+        final Map<String, String> mapWithDifferentContent = Collections.singletonMap("string",
"mydifferentstring");
+
+        final SimpleTestManagedAttributeValue value = converter.convert(map, object);
+        final SimpleTestManagedAttributeValue same = converter.convert(map, object);
+        final SimpleTestManagedAttributeValue sameContent = converter.convert(mapWithSameContent,
object);
+        final SimpleTestManagedAttributeValue differentContent = converter.convert(mapWithDifferentContent,
object);
+
+        assertFalse(value.equals(elephant));
+        assertTrue(value.equals(value));
+        assertTrue(value.equals(same));
+        assertTrue(sameContent.equals(value));
+        assertFalse(differentContent.equals(value));
+    }
+
+    @ManagedAttributeValueType
+    public interface SimpleTestManagedAttributeValue extends ManagedAttributeValue
+    {
+        String getString();
+    }
+
 }



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


Mime
View raw message