summaryrefslogtreecommitdiff
path: root/qpid/java/broker-core/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/broker-core/src/test/java')
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java4
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java37
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java5
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java16
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java35
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java60
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java11
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java6
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java10
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java5
10 files changed, 183 insertions, 6 deletions
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
index 8d025c50dc..ad33ecadcf 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
@@ -167,13 +167,15 @@ public class MockConsumer implements ConsumerTarget
{
}
- public void send(MessageInstance entry, boolean batch)
+ public long send(MessageInstance entry, boolean batch)
{
+ long size = entry.getMessage().getSize();
if (messages.contains(entry))
{
entry.setRedelivered();
}
messages.add(entry);
+ return size;
}
public void flushBatched()
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
index 8bd599f22f..3301c046a8 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
@@ -20,12 +20,14 @@
*/
package org.apache.qpid.server.model;
+import java.util.Arrays;
import java.util.Collection;
import junit.framework.TestCase;
import org.apache.qpid.server.model.testmodel.Test2RootCategory;
import org.apache.qpid.server.model.testmodel.Test2RootCategoryImpl;
+import org.apache.qpid.server.model.testmodel.TestChildCategory;
import org.apache.qpid.server.model.testmodel.TestModel;
import org.apache.qpid.server.model.testmodel.TestRootCategory;
import org.apache.qpid.server.model.testmodel.TestRootCategoryImpl;
@@ -76,6 +78,21 @@ public class ConfigureObjectTypeRegistryTest extends TestCase
Test2RootCategory.DEFAULTED_VALUE_DEFAULT);
}
+ public void testValidValues()
+ {
+ checkValidValues("validValue",_typeRegistry.getAttributes((Class) TestRootCategoryImpl.class),
+ Arrays.asList( TestRootCategory.VALID_VALUE1, TestRootCategory.VALID_VALUE2 ) );
+
+ checkValidValues("validValue", _typeRegistry.getAttributes((Class) Test2RootCategoryImpl.class),
+ Test2RootCategoryImpl.functionGeneratedValidValues());
+
+
+ checkValidValues("validValueNotInterpolated", _typeRegistry.getAttributes((Class) TestChildCategory.class),
+ Arrays.asList(TestChildCategory.NON_INTERPOLATED_VALID_VALUE));
+
+
+ }
+
private void checkDefaultedValue(final Collection<ConfiguredObjectAttribute<?, ?>> attrs,
final String defaultedValueDefault)
{
@@ -92,4 +109,24 @@ public class ConfigureObjectTypeRegistryTest extends TestCase
}
assertTrue("Could not find attribute defaultedValue", found);
}
+
+ private void checkValidValues(final String attrName, final Collection<ConfiguredObjectAttribute<?, ?>> attrs,
+ final Collection<String> validValues)
+ {
+ boolean found = false;
+ for(ConfiguredObjectAttribute<?, ?> attr : attrs)
+ {
+ if(attr.getName().equals(attrName))
+ {
+ Collection<String> foundValues = ((ConfiguredAutomatedAttribute<?, ?>) attr).validValues();
+ assertEquals("Valid values not as expected, counts differ", validValues.size(), foundValues.size());
+ assertTrue("Valid values do not include all expected values", foundValues.containsAll(validValues));
+ assertTrue("Valid values contain unexpected addtional values", validValues.containsAll(foundValues));
+ found = true;
+ break;
+ }
+
+ }
+ assertTrue("Could not find attribute " + attrName, found);
+ }
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java
index e47c76cbbb..23f03db507 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java
@@ -26,10 +26,15 @@ import org.apache.qpid.server.model.ManagedAttribute;
public interface Test2RootCategory<X extends Test2RootCategory<X>> extends TestRootCategory<X>
{
String DEFAULTED_VALUE_DEFAULT = "differentDefault";
+
@Override
@ManagedAttribute( defaultValue = DEFAULTED_VALUE_DEFAULT)
String getDefaultedValue();
+ @Override
+ @ManagedAttribute( validValues = {"org.apache.qpid.server.model.testmodel.Test2RootCategoryImpl#functionGeneratedValidValues()"})
+ String getValidValue();
+
@DerivedAttribute
public int getDerivedAttribute();
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java
index 022e0a256f..e98a9fa3dc 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.model.testmodel;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
@@ -49,6 +51,9 @@ public class Test2RootCategoryImpl extends AbstractConfiguredObject<Test2RootCat
@ManagedAttributeField
private Map<String,String> _mapValue;
+ @ManagedAttributeField
+ private String _validValue;
+
@ManagedObjectFactoryConstructor
public Test2RootCategoryImpl(final Map<String, Object> attributes)
{
@@ -93,6 +98,12 @@ public class Test2RootCategoryImpl extends AbstractConfiguredObject<Test2RootCat
}
@Override
+ public String getValidValue()
+ {
+ return _validValue;
+ }
+
+ @Override
public int getDerivedAttribute()
{
return 0;
@@ -115,4 +126,9 @@ public class Test2RootCategoryImpl extends AbstractConfiguredObject<Test2RootCat
{
return null;
}
+
+ public static Collection<String> functionGeneratedValidValues()
+ {
+ return Collections.singleton("generated");
+ }
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
new file mode 100644
index 0000000000..0c8dcc8744
--- /dev/null
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.testmodel;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedObject;
+
+@ManagedObject
+public interface TestChildCategory<X extends TestChildCategory<X>> extends ConfiguredObject<X>
+{
+
+ String NON_INTERPOLATED_VALID_VALUE = "${file.separator}";
+
+ @ManagedAttribute(validValues = { NON_INTERPOLATED_VALID_VALUE })
+ String getValidValueNotInterpolated();
+}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
new file mode 100644
index 0000000000..b5a4182f79
--- /dev/null
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+import org.apache.qpid.server.model.State;
+
+@ManagedObject( category = false , type = "test" )
+public class TestChildCategoryImpl
+ extends AbstractConfiguredObject<TestChildCategoryImpl> implements TestChildCategory<TestChildCategoryImpl>
+{
+
+
+ @ManagedAttributeField
+ private String _validValueNotInterpolated;
+
+
+ @ManagedObjectFactoryConstructor
+ public TestChildCategoryImpl(final Map<String, Object> attributes, TestRootCategory<?> parent)
+ {
+ super(parentsMap(parent), attributes);
+ }
+
+ @Override
+ public State getState()
+ {
+ return null;
+ }
+
+
+
+ @Override
+ public String getValidValueNotInterpolated()
+ {
+ return _validValueNotInterpolated;
+ }
+}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
index fc98b51731..ab9d753b7d 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
@@ -36,7 +36,8 @@ public class TestModel extends Model
private static final Model INSTANCE = new TestModel();
private Class<? extends ConfiguredObject>[] _supportedClasses =
new Class[] {
- TestRootCategory.class
+ TestRootCategory.class,
+ TestChildCategory.class
};
private final ConfiguredObjectFactory _objectFactory;
@@ -77,7 +78,9 @@ public class TestModel extends Model
@Override
public Collection<Class<? extends ConfiguredObject>> getChildTypes(final Class<? extends ConfiguredObject> parent)
{
- return Collections.emptySet();
+ return TestRootCategory.class.isAssignableFrom(parent)
+ ? Collections.<Class<? extends ConfiguredObject>>singleton(TestChildCategory.class)
+ : Collections.<Class<? extends ConfiguredObject>>emptySet();
}
@Override
@@ -89,7 +92,9 @@ public class TestModel extends Model
@Override
public Collection<Class<? extends ConfiguredObject>> getParentTypes(final Class<? extends ConfiguredObject> child)
{
- return Collections.emptySet();
+ return TestChildCategory.class.isAssignableFrom(child)
+ ? Collections.<Class<? extends ConfiguredObject>>singleton(TestRootCategory.class)
+ : Collections.<Class<? extends ConfiguredObject>>emptySet();
}
@Override
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
index 954fe4dcb1..7f804006b2 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
@@ -42,9 +42,15 @@ public interface TestRootCategory<X extends TestRootCategory<X>> extends Configu
String getAutomatedNonPersistedValue();
String DEFAULTED_VALUE_DEFAULT = "myDefaultVar";
+ String VALID_VALUE1 = "FOO";
+ String VALID_VALUE2 = "BAR";
+
@ManagedAttribute( defaultValue = DEFAULTED_VALUE_DEFAULT)
String getDefaultedValue();
+ @ManagedAttribute(validValues = {VALID_VALUE1, VALID_VALUE2} )
+ String getValidValue();
+
@ManagedAttribute
String getStringValue();
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
index d549086686..0c6a0cb0ca 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
@@ -49,6 +49,10 @@ public class TestRootCategoryImpl extends AbstractConfiguredObject<TestRootCateg
@ManagedAttributeField
private Map<String,String> _mapValue;
+ @ManagedAttributeField
+ private String _validValue;
+
+
@ManagedObjectFactoryConstructor
public TestRootCategoryImpl(final Map<String, Object> attributes)
{
@@ -109,4 +113,10 @@ public class TestRootCategoryImpl extends AbstractConfiguredObject<TestRootCateg
{
return null;
}
+
+ @Override
+ public String getValidValue()
+ {
+ return _validValue;
+ }
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
index ce1c95e674..f13886d2b2 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
@@ -208,10 +208,11 @@ public class StandardQueueTest extends AbstractQueueTestBase
* @param entry
* @param batch
*/
- public void send(MessageInstance entry, boolean batch)
+ public long send(MessageInstance entry, boolean batch)
{
- super.send(entry, batch);
+ long size = super.send(entry, batch);
latch.countDown();
+ return size;
}
};