qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1694454 - in /qpid/java/trunk/broker-core/src: main/java/org/apache/qpid/server/model/ test/java/org/apache/qpid/server/model/testmodels/singleton/
Date Thu, 06 Aug 2015 11:20:02 GMT
Author: kwall
Date: Thu Aug  6 11:20:02 2015
New Revision: 1694454

URL: http://svn.apache.org/r1694454
Log:
QPID-6681: Disallow the chnaging of an object's type

Modified:
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
    qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1694454&r1=1694453&r2=1694454&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
Thu Aug  6 11:20:02 2015
@@ -2310,11 +2310,6 @@ public abstract class AbstractConfigured
 
     protected void validateChange(final ConfiguredObject<?> proxyForValidation, final
Set<String> changedAttributes)
     {
-        if(!getId().equals(proxyForValidation.getId()))
-        {
-            throw new IllegalConfigurationException("Cannot change existing configured object
id");
-        }
-
         for(ConfiguredObjectAttribute<?,?> attr : _attributeTypes.values())
         {
             if (attr.isAutomated() && changedAttributes.contains(attr.getName()))

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1694454&r1=1694453&r2=1694454&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
Thu Aug  6 11:20:02 2015
@@ -61,7 +61,7 @@ public interface ConfiguredObject<X exte
      *
      * @return the objects id
      */
-    @ManagedAttribute( mandatory = true )
+    @ManagedAttribute( mandatory = true, immutable = true )
     UUID getId();
 
     /**
@@ -69,14 +69,14 @@ public interface ConfiguredObject<X exte
      *
      * @return the name of the object
      */
-    @ManagedAttribute( mandatory = true)
+    @ManagedAttribute( mandatory = true )
     String getName();
 
 
     @ManagedAttribute
     String getDescription();
 
-    @ManagedAttribute
+    @ManagedAttribute ( immutable = true )
     String getType();
 
     @ManagedAttribute

Modified: qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java?rev=1694454&r1=1694453&r2=1694454&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
(original)
+++ qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
Thu Aug  6 11:20:02 2015
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.security.auth.Subject;
@@ -495,24 +496,22 @@ public class AbstractConfiguredObjectTes
                              return null;
                          }
                      });
-
-
     }
 
     public void testImmutableAttribute()
     {
-        final String value = "myvalue";
+        final String originalValue = "myvalue";
 
         Map<String, Object> attributes = new HashMap<>();
         attributes.put(ConfiguredObject.NAME, "myName");
-        attributes.put(TestSingleton.IMMUTABLE_VALUE, value);
+        attributes.put(TestSingleton.IMMUTABLE_VALUE, originalValue);
 
         final TestSingleton object = _model.getObjectFactory().create(TestSingleton.class,
attributes);
 
-        assertEquals(value, object.getImmutableValue());
+        assertEquals("Immutable value unexpectedly changed", originalValue, object.getImmutableValue());
 
-        // Update to the same value is allowed
-        object.setAttributes(Collections.singletonMap(TestSingleton.IMMUTABLE_VALUE, value));
+                     // Update to the same value is allowed
+                     object.setAttributes(Collections.singletonMap(TestSingleton.IMMUTABLE_VALUE,
originalValue));
 
         try
         {
@@ -523,7 +522,7 @@ public class AbstractConfiguredObjectTes
         {
             // PASS
         }
-        assertEquals(value, object.getImmutableValue());
+        assertEquals(originalValue, object.getImmutableValue());
 
         try
         {
@@ -535,12 +534,11 @@ public class AbstractConfiguredObjectTes
             // PASS
         }
 
-        assertEquals(value, object.getImmutableValue());
+        assertEquals("Immutable value unexpectedly changed", originalValue, object.getImmutableValue());
     }
 
     public void testImmutableAttributeNullValue()
     {
-
         Map<String, Object> attributes = new HashMap<>();
         attributes.put(ConfiguredObject.NAME, "myName");
         attributes.put(TestSingleton.IMMUTABLE_VALUE, null);
@@ -561,7 +559,42 @@ public class AbstractConfiguredObjectTes
         {
             // PASS
         }
-        assertNull(object.getImmutableValue());
+        assertNull("Immutable value unexpectedly changed", object.getImmutableValue());
+    }
+
+    /** Id and Type are key attributes in the model and are thus worthy of test of their
own */
+    public void testIdAndTypeAreImmutableAttribute()
+    {
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, "myName");
+
+        final TestSingleton object = _model.getObjectFactory().create(TestSingleton.class,
attributes);
+        UUID originalUuid = object.getId();
+        String originalType = object.getType();
+
+        try
+        {
+            object.setAttributes(Collections.singletonMap(TestSingleton.ID, UUID.randomUUID()));
+            fail("Exception not thrown");
+        }
+        catch(IllegalConfigurationException e)
+        {
+            // PASS
+        }
+
+        assertEquals(originalUuid, object.getId());
+
+        try
+        {
+            object.setAttributes(Collections.singletonMap(TestSingleton.TYPE, "newtype"));
+            fail("Exception not thrown");
+        }
+        catch(IllegalConfigurationException e)
+        {
+            // PASS
+        }
+
+        assertEquals(originalType, object.getType());
     }
 
     public void testAttributeSetListenerFiring()



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


Mime
View raw message