diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2008-10-31 10:04:12 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2008-10-31 10:04:12 +0000 |
| commit | 2406d2ff92e8893894ac849366620a0002a5b9cc (patch) | |
| tree | bc7999371d83d5aa528565b40fb4f49a92da9125 /qpid/java/management/client/src/test | |
| parent | b1ddca96952fd4f5af8157feaf38ab3ac012cd8b (diff) | |
| download | qpid-python-2406d2ff92e8893894ac849366620a0002a5b9cc.tar.gz | |
QPID-1411: Applied Andrea's patch; added config file sample
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@709374 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/management/client/src/test')
16 files changed, 149 insertions, 523 deletions
diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/AccessModeMappingTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/AccessModeMappingTest.java deleted file mode 100644 index 4c53c3d428..0000000000 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/AccessModeMappingTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * 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.management.configuration; - -import org.apache.qpid.management.TestConstants; -import org.apache.qpid.management.domain.model.AccessMode; - -import junit.framework.TestCase; - -/** - * Test case for AccessMode mapping. - * - * @author Andrea Gazzarini - */ -public class AccessModeMappingTest extends TestCase -{ - private AccessModeMapping _mapping; - - /** - * Set up fixture for this test case. - */ - @Override - protected void setUp () throws Exception - { - _mapping = new AccessModeMapping(); - } - - /** - * Tests the execution of the setCode method when a valid code is given. - * - * <br>precondition : given code is a valid number. - * <br>postcondition : no exception is thrown and the mapping contained the requested code. - */ - public void testSetCodeOK() - { - _mapping.setCode(String.valueOf(TestConstants.VALID_CODE)); - assertEquals(TestConstants.VALID_CODE,_mapping.getCode()); - } - - /** - * Tests the execution of the setCode method when an invalid code is given. - * - * <br>precondition : given code is an invalid number. - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testSetCodeKO_withInvalidNumber () - { - try { - _mapping.setCode(String.valueOf(TestConstants.VALID_CODE)+"a"); - fail("The given string is not a number and therefore an exception must be thrown."); - } catch(NumberFormatException expected) { - - } - } - - /** - * Tests the execution of the setAccessMode method when a valid access code is given. - * - * <br>precondition : given code is valid (i.e. RW, RC or RO). - * <br>postcondition : no exception is thrown and the mapping contained the requested access mode. - */ - public void testSetAccessModeOK() - { - _mapping.setAccessMode("RW"); - assertEquals(AccessMode.RW,_mapping.getAccessMode()); - - _mapping.setAccessMode("RC"); - assertEquals(AccessMode.RC,_mapping.getAccessMode()); - - _mapping.setAccessMode("RO"); - assertEquals(AccessMode.RO,_mapping.getAccessMode()); - } - - /** - * Tests the execution of the setAccessMode method when an unknown code is given. - * - * <br>precondition : given code is an unknown code. - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testSetAccessModeKO () - { - try { - _mapping.setAccessMode(AccessMode.RW.toString()+"X"); - fail("The given string is not a string representation of a valid access mode."); - } catch(IllegalArgumentException expected) { - - } - } -}
\ No newline at end of file diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java index c948db59bf..ca6ae846a8 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java @@ -57,11 +57,8 @@ public class ConfigurationTest extends TestCase */ public void testGetTypeOk() throws UnknownTypeCodeException { - TypeMapping mapping = new TypeMapping(); - mapping.setCode(String.valueOf(TestConstants.VALID_CODE)); - mapping.setType(Uint8.class.getName()); + TypeMapping mapping = new TypeMapping(TestConstants.VALID_CODE,new Uint8()); Configuration.getInstance().addTypeMapping(mapping); - Type type = Configuration.getInstance().getType(TestConstants.VALID_CODE); assertTrue(type instanceof Uint8); @@ -93,14 +90,10 @@ public class ConfigurationTest extends TestCase */ public void testGetAccessModeOk() throws UnknownAccessCodeException { - String accessModeAsString = "RW"; - - AccessModeMapping mapping = new AccessModeMapping(); - mapping.setCode(String.valueOf(TestConstants.VALID_CODE)); - mapping.setAccessMode(accessModeAsString); + AccessModeMapping mapping = new AccessModeMapping(TestConstants.VALID_CODE,AccessMode.RW); Configuration.getInstance().addAccessModeMapping(mapping); - AccessMode accessMode = Configuration.getInstance().getAccessMode(TestConstants.VALID_CODE); + assertSame(AccessMode.RW,accessMode); } @@ -234,4 +227,4 @@ public class ConfigurationTest extends TestCase assertEquals(schemaMessageHandlerClassName,handlerMappings.get(schemaMapping.getOpcode()).getClass().getName()); } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java index 639fe224ec..6237f21cc9 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java @@ -20,10 +20,32 @@ */ package org.apache.qpid.management.configuration; -import org.xml.sax.SAXException; +import java.util.Map; +import java.util.UUID; import junit.framework.TestCase; +import org.apache.qpid.management.Names; +import org.apache.qpid.management.Protocol; +import org.apache.qpid.management.domain.handler.base.IMessageHandler; +import org.apache.qpid.management.domain.handler.impl.ConfigurationMessageHandler; +import org.apache.qpid.management.domain.handler.impl.EventContentMessageHandler; +import org.apache.qpid.management.domain.handler.impl.HeartBeatIndicationMessageHandler; +import org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler; +import org.apache.qpid.management.domain.handler.impl.MethodResponseMessageHandler; +import org.apache.qpid.management.domain.handler.impl.SchemaResponseMessageHandler; +import org.apache.qpid.management.domain.model.AccessMode; +import org.apache.qpid.management.domain.model.type.AbsTime; +import org.apache.qpid.management.domain.model.type.DeltaTime; +import org.apache.qpid.management.domain.model.type.ObjectReference; +import org.apache.qpid.management.domain.model.type.Str16; +import org.apache.qpid.management.domain.model.type.Str8; +import org.apache.qpid.management.domain.model.type.Uint16; +import org.apache.qpid.management.domain.model.type.Uint32; +import org.apache.qpid.management.domain.model.type.Uint64; +import org.apache.qpid.management.domain.model.type.Uint8; +import org.xml.sax.SAXException; + /** * Test case for configurator. * @@ -32,40 +54,65 @@ import junit.framework.TestCase; */ public class ConfiguratorTest extends TestCase { - - /** - * Tests the execution of the configure() method when a inexistent configuration file is used. - * - * <br>precondition : the configuration file doesn't exist. - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testConfigureKO_WithConfigFileNotFound() - { - Configurator configurator = getConfiguratorWithDatafileInjected("pippo/pluto/paperino.xml"); - try { - configurator.configure(); - fail("If there's no configuration file the configuration cannot be built."); - } catch(ConfigurationException expected) { - - } - } - /** - * Tests the execution of the configure() method when configuration file is null. + * Tests the execution of the configure() method when no configuration file is given. * - * <br>precondition : the configuration file is null. - * <br>postcondition : an exception is thrown indicating the failure. + * <br>precondition : configuration file option is not set + * <br>postcondition : no exception is thrown, the configuration is holding no broker data and the predefined mappings are + * stored in configuration. */ - public void testConfigureKO_WithNullConfig() - { - Configurator configurator = getConfiguratorWithDatafileInjected(null); - try { - configurator.configure(); - fail("If there's no configuration file the configuration cannot be built."); - } catch(ConfigurationException expected) { - - } - } + public void testConfigureOK_WithNoConfigurationFile() throws Exception + { + Configurator configurator = new Configurator(); + configurator.configure(); + Configuration configuration = Configuration.getInstance(); + + assertEquals(new Uint8(), configuration.getType(1)); + assertEquals(new Uint16(), configuration.getType(2)); + assertEquals(new Uint32(), configuration.getType(3)); + assertEquals(new Uint64(), configuration.getType(4)); + assertEquals(new Str8(), configuration.getType(6)); + assertEquals(new Str16(), configuration.getType(7)); + assertEquals(new AbsTime(), configuration.getType(8)); + assertEquals(new DeltaTime(), configuration.getType(9)); + assertEquals(new ObjectReference(), configuration.getType(10)); + assertEquals(new org.apache.qpid.management.domain.model.type.Boolean(), configuration.getType(11)); + assertEquals(new org.apache.qpid.management.domain.model.type.Uuid(), configuration.getType(14)); + assertEquals(new org.apache.qpid.management.domain.model.type.Map(), configuration.getType(15)); + + assertEquals(AccessMode.RC,configuration.getAccessMode(1)); + assertEquals(AccessMode.RW,configuration.getAccessMode(2)); + assertEquals(AccessMode.RO,configuration.getAccessMode(3)); + + Map<Character, IMessageHandler> managementHandlers = configuration.getManagementQueueHandlers(); + assertEquals(4,managementHandlers.size()); + assertEquals( + InstrumentationMessageHandler.class, + managementHandlers.get(Protocol.INSTRUMENTATION_CONTENT_RESPONSE_OPCODE).getClass()); + + assertEquals( + ConfigurationMessageHandler.class, + managementHandlers.get(Protocol.CONFIGURATION_CONTENT_RESPONSE_OPCDE).getClass()); + + assertEquals( + EventContentMessageHandler.class, + managementHandlers.get(Protocol.EVENT_CONTENT_RESPONSE_OPCDE).getClass()); + + assertEquals( + HeartBeatIndicationMessageHandler.class, + managementHandlers.get(Protocol.HEARTBEAT_INDICATION_RESPONSE_OPCODE).getClass()); + + Map<Character, IMessageHandler> methodReplyHandlers = configuration.getMethodReplyQueueHandlers(); + assertEquals(2, methodReplyHandlers.size()); + + assertEquals( + MethodResponseMessageHandler.class, + methodReplyHandlers.get(Protocol.OPERATION_INVOCATION_RESPONSE_OPCODE).getClass()); + + assertEquals( + SchemaResponseMessageHandler.class, + methodReplyHandlers.get(Protocol.SCHEMA_RESPONSE_OPCODE).getClass()); + } /** * Tests the changes of the configurator internal state while configuration file is parsed. @@ -77,30 +124,41 @@ public class ConfiguratorTest extends TestCase Configurator configurator = new Configurator(); assertSame(Configurator.DEFAULT_PARSER,configurator._currentParser); - - configurator.startElement(null, null, Tag.TYPE_MAPPINGS.toString(), null); - assertSame(configurator._typeMappingParser,configurator._currentParser); - - configurator.startElement(null, null, Tag.ACCESS_MODE_MAPPINGS.toString(), null); - assertSame(configurator._accessModeMappingParser,configurator._currentParser); configurator.startElement(null, null, Tag.BROKERS.toString(), null); assertSame(configurator._brokerConfigurationParser,configurator._currentParser); } + /** - * Create a stub configurator which returns the given datafile path. + * It's not possibile to add twice the same broker connection data. + * Is so an exception must be thrown indicating that the given broker is already connected. * - * @param filename the configuration file to be injected. - * @return a configurator which returns the given datafile path. + * <br>precondition : the given data identifies an already connected broker. + * <br>postcondition : an exception is thrown indicating the failure. */ - private Configurator getConfiguratorWithDatafileInjected(final String filename) { - return new Configurator() - { - @Override - String getConfigurationFileName () - { - return filename; - } - }; + public void testAddTwoIdenticalBrokers() throws ConfigurationException, BrokerConnectionException + { + Configurator configurator = new Configurator(); + configurator.configure(); + + BrokerConnectionData data = new BrokerConnectionData("sofia.gazzax.com",5672,"virtualHost","user","pwd",1,4,-1); + + Configuration.getInstance()._brokerConnectionInfos.put(UUID.randomUUID(),data); + + try { + configurator.createAndReturnBrokerConnectionData( + UUID.randomUUID(), + data.getHost(), + data.getPort(), + "anotherUser", + "anotherPassword", + data.getVirtualHost(), + 33, + 12, + 1000); + fail("If a broker is added twice an exception must be thrown."); + } catch (BrokerAlreadyConnectedException expected) { + assertEquals(data,expected.getBrokerConnectionData()); + } } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java index 4c8885dbc8..af261024bd 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java @@ -25,9 +25,6 @@ import java.util.UUID; import junit.framework.TestCase; import org.apache.qpid.management.TestConstants; -import org.apache.qpid.management.domain.model.AccessMode; -import org.apache.qpid.management.domain.model.type.Type; -import org.apache.qpid.management.domain.model.type.Uint8; /** * Test case for mapping parsers. @@ -37,25 +34,6 @@ import org.apache.qpid.management.domain.model.type.Uint8; public class MappingParsersTest extends TestCase { /** - * Tests the execution of the access mode mapping parser. - * - * <br>precondition: An access mode mapping is built by the parser; - * <br>postcondition: the corresponding access mode is available on the configuration. - */ - public void testAccessModeMappingParser() throws UnknownAccessCodeException - { - AccessModeMappingParser parser = new AccessModeMappingParser(); - parser.setCurrrentAttributeValue(String.valueOf(TestConstants.VALID_CODE)); - parser.setCurrentAttributeName(Tag.CODE.toString()); - parser.setCurrrentAttributeValue("RW"); - parser.setCurrentAttributeName(Tag.VALUE.toString()); - parser.setCurrentAttributeName(Tag.MAPPING.toString()); - - AccessMode result = Configuration.getInstance().getAccessMode(TestConstants.VALID_CODE); - assertEquals(AccessMode.RW,result); - } - - /** * Tests the execution of the broker connection data mapping parser. * * <br>precondition: A broker connection datamapping is built by the parser; @@ -98,32 +76,4 @@ public class MappingParsersTest extends TestCase assertEquals(username,result.getUsername()); assertEquals(password,result.getPassword()); } - - /** - * Tests the execution of the type mapping parser. - * - * <br>precondition: two type mappings are built by the parser; - * <br>postcondition: the corresponding types are available on the configuration. - */ - public void testMappingParser() throws NumberFormatException, UnknownTypeCodeException - { - TypeMappingParser parser = new TypeMappingParser(); - - String className = Uint8.class.getName(); - String validatorClassName = "a.b.c.Validator"; - - parser.setCurrrentAttributeValue(String.valueOf(TestConstants.VALID_CODE)); - parser.setCurrentAttributeName(Tag.CODE.toString()); - parser.setCurrrentAttributeValue(className); - parser.setCurrentAttributeName(Tag.CLASS_NAME.toString()); - parser.setCurrrentAttributeValue(validatorClassName); - parser.setCurrentAttributeName(Tag.VALIDATOR_CLASS_NAME.toString()); - parser.setCurrentAttributeName(Tag.MAPPING.toString()); - - Type type =Configuration.getInstance().getType(TestConstants.VALID_CODE); - String vClassName = Configuration.getInstance().getValidatorClassName(type); - - assertEquals(Uint8.class, type.getClass()); - assertEquals(validatorClassName,vClassName); - } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/StubConfigurator.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/StubConfigurator.java deleted file mode 100644 index 8bb4985a89..0000000000 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/StubConfigurator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * 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.management.configuration; - -import org.apache.qpid.management.domain.model.type.Str8; - -public class StubConfigurator extends Configurator -{ - /** - * Builds whole configuration. - * - * @throws ConfigurationException when the build fails. - */ - public void configure() throws ConfigurationException - { - addAccessModeMapping("1", "RC"); - addAccessModeMapping("2", "RW"); - addAccessModeMapping("3", "RO"); - - addTypeMapping("1", Str8.class.getName()); - } - - public void addTypeMapping(String code,String clazzName) - { - TypeMapping mapping = new TypeMapping(); - mapping.setCode(code); - mapping.setType(clazzName); - Configuration.getInstance().addTypeMapping(mapping); - } - - public void addTypeMapping(String code,String clazzName,String validatorClassName) - { - TypeMapping mapping = new TypeMapping(); - mapping.setCode(code); - mapping.setType(clazzName); - mapping.setValidatorClassName(validatorClassName); - Configuration.getInstance().addTypeMapping(mapping); - } - - public void addAccessModeMapping(String code, String value) - { - AccessModeMapping mapping = new AccessModeMapping(); - mapping.setCode(code);; - mapping.setAccessMode(value); - Configuration.getInstance().addAccessModeMapping(mapping); - } -} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/TypeMappingTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/TypeMappingTest.java deleted file mode 100644 index bf44608c0e..0000000000 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/TypeMappingTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * 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.management.configuration; - -import org.apache.qpid.management.TestConstants; -import org.apache.qpid.management.domain.model.type.Uint8; - -import junit.framework.TestCase; - -/** - * Test case for type mapping. - * - * @author Andrea Gazzarini - */ -public class TypeMappingTest extends TestCase -{ - private TypeMapping _mapping; - - @Override - protected void setUp () throws Exception - { - _mapping = new TypeMapping(); - } - - /** - * Tests the execution of the setCode method when a valid code is given. - * - * <br>precondition : given code is a valid number. - * <br>postcondition : no exception is thrown and the mapping contained the requested code. - */ - public void testSetCodeOK() - { - _mapping.setCode(String.valueOf(TestConstants.VALID_CODE)); - assertEquals(TestConstants.VALID_CODE,_mapping.getCode()); - } - - /** - * Tests the execution of the setCode method when an invalid code is given. - * - * <br>precondition : given code is an invalid number. - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testSetCodeKO_withInvalidNumber () - { - try { - _mapping.setCode(String.valueOf(TestConstants.VALID_CODE)+"a"); - fail("The given string is not a number and therefore an exception must be thrown."); - } catch(NumberFormatException expected) - { - - } - } - - /** - * Tests the execution of the setType() method when a valid type class is given. - * - * <br>precondition : a valid class type is supplied. - * <br>postcondition : no exception is thrown and the mapping contains the previously associated type. - */ - public void testSetTypeOK() - { - _mapping.setType(Uint8.class.getName()); - assertTrue(_mapping.getType() instanceof Uint8); - } - - /** - * Tests the execution of the setType() method when a invalid type class is given. - * - * <br>precondition : an invalid class type is supplied. - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testSetTypeKO_withTypeClassNotFound() - { - try - { - _mapping.setType(Uint8.class.getName()+"a"); - fail("If the supplied class doesn't exist an exception must be thrown."); - } catch(IllegalArgumentException expected) { - assertTrue(expected.getCause() instanceof ClassNotFoundException); - } - } - - /** - * Tests the execution of the setType() method when a invalid type class is given. - * - * <br>precondition : an invalid class type is supplied (is not a Type). - * <br>postcondition : an exception is thrown indicating the failure. - */ - public void testSetTypeKO_withInvalidType() - { - try - { - _mapping.setType(String.class.getName()); - fail("If the supplied class is not a Type an exception must be thrown."); - } catch(IllegalArgumentException expected) { - assertTrue(expected.getCause() instanceof ClassCastException); - } - } -}
\ No newline at end of file diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java index 0c67811621..3ed9ed8a61 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java @@ -22,7 +22,7 @@ package org.apache.qpid.management.domain.model; import org.apache.qpid.management.configuration.Configurator; -import junit.framework.TestCase;; +import junit.framework.TestCase; /** * Layer supertype for all domain model related test cases. diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java index 43793e588a..3d3783eb04 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java @@ -28,9 +28,8 @@ import java.util.Map; import junit.framework.TestCase; -import org.apache.qpid.management.configuration.StubConfigurator; +import org.apache.qpid.management.configuration.Configurator; import org.apache.qpid.management.domain.model.QpidFeatureBuilder.Attribute; -import org.apache.qpid.management.domain.model.type.Uint16; /** * Layer supertype for feature builder test cases. @@ -42,23 +41,18 @@ public abstract class BaseQpidFeatureBuilderTestCase extends TestCase protected final static String NAME = "aName"; protected final static String DESCRIPTION = "A description."; - protected Integer _type; protected Map <String,Object> _featureDefinition; protected QpidFeatureBuilder _builder; - protected StubConfigurator configurator; - /** * Set up fixture for all concrete builder test cases. */ @Override protected void setUp () throws Exception { - _type = 1; - configurator = new StubConfigurator(); - configurator.addTypeMapping(_type.toString(),Uint16.class.getName()); - + Configurator configurator = new Configurator(); + configurator.configure(); _featureDefinition = new HashMap<String, Object>(); _featureDefinition.put(name.name(),NAME); _featureDefinition.put(desc.name(), DESCRIPTION); @@ -99,4 +93,4 @@ public abstract class BaseQpidFeatureBuilderTestCase extends TestCase } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java index fab35d4c59..ace8dc19bd 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java @@ -14,7 +14,7 @@ import junit.framework.TestCase; import org.apache.qpid.management.TestConstants; import org.apache.qpid.management.configuration.ConfigurationException; -import org.apache.qpid.management.configuration.StubConfigurator; +import org.apache.qpid.management.configuration.Configurator; import org.apache.qpid.management.domain.handler.impl.MethodOrEventDataTransferObject; import org.apache.qpid.management.domain.model.QpidClass.QpidManagedObject; @@ -31,7 +31,7 @@ public class QpidClassTest extends TestCase @Override protected void setUp () throws ConfigurationException { - StubConfigurator configurator = new StubConfigurator(); + Configurator configurator = new Configurator(); configurator.configure(); _package = new QpidPackage(TestConstants.QPID_PACKAGE_NAME,TestConstants.DOMAIN_MODEL); _class = new QpidClass(TestConstants.EXCHANGE_CLASS_NAME,TestConstants.HASH,_package); @@ -214,7 +214,7 @@ public class QpidClassTest extends TestCase assertEquals(TestConstants.SAMPLE_MAX_VALUE,property.getMaxValue()); assertEquals(Integer.MIN_VALUE,property.getMaxLength()); assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,property.getDescription()); - assertEquals(String.class,property.getJavaType()); + assertEquals(Short.class,property.getJavaType()); assertFalse(property.isOptional()); property = _class._properties.get(TestConstants.SURNAME_ATTRIBUTE_NAME); @@ -225,7 +225,7 @@ public class QpidClassTest extends TestCase assertEquals(Integer.MIN_VALUE,property.getMaxValue()); assertEquals(TestConstants.SAMPLE_MAX_VALUE,property.getMaxLength()); assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,property.getDescription()); - assertEquals(String.class,property.getJavaType()); + assertEquals(Short.class,property.getJavaType()); assertTrue(property.isOptional()); MBeanInfo mbeanInfo = _class._metadata; @@ -239,14 +239,14 @@ public class QpidClassTest extends TestCase assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,attribute.getDescription()); assertFalse(attribute.isWritable()); assertTrue(attribute.isReadable()); - assertEquals(String.class.getName(),attribute.getType()); + assertEquals(Short.class.getName(),attribute.getType()); attribute = attributes[1]; assertEquals(TestConstants.SURNAME_ATTRIBUTE_NAME,attribute.getName()); assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,attribute.getDescription()); assertFalse(attribute.isWritable()); assertTrue(attribute.isReadable()); - assertEquals(String.class.getName(),attribute.getType()); + assertEquals(Short.class.getName(),attribute.getType()); } /** diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java index 8a8adee294..954a419787 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java @@ -35,7 +35,7 @@ import junit.framework.TestCase; import org.apache.qpid.management.TestConstants;
import org.apache.qpid.management.configuration.ConfigurationException;
-import org.apache.qpid.management.configuration.StubConfigurator;
+import org.apache.qpid.management.configuration.Configurator;
import org.apache.qpid.management.domain.model.QpidEvent.QpidManagedEvent;
/**
@@ -142,7 +142,7 @@ public class QpidEventTest extends TestCase }
};
- StubConfigurator configurator = new StubConfigurator();
+ Configurator configurator = new Configurator();
configurator.configure();
List<Map<String,Object>> arguments = new ArrayList<Map<String, Object>>();
@@ -168,14 +168,14 @@ public class QpidEventTest extends TestCase assertEquals(TestConstants.AGE_ATTRIBUTE_NAME,argument.getName());
assertEquals(AccessMode.RO,argument.getAccessMode());
assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,argument.getDescription());
- assertEquals(String.class,argument.getJavaType());
+ assertEquals(Short.class,argument.getJavaType());
assertFalse(argument.isOptional());
argument = _event._arguments.get(TestConstants.SURNAME_ATTRIBUTE_NAME);
assertEquals(TestConstants.SURNAME_ATTRIBUTE_NAME,argument.getName());
assertEquals(AccessMode.RO,argument.getAccessMode());
assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,argument.getDescription());
- assertEquals(String.class,argument.getJavaType());
+ assertEquals(Short.class,argument.getJavaType());
assertFalse(argument.isOptional());
assertEquals(1,_event._eventInstances.size());
diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidMethodBuilderTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidMethodBuilderTest.java index 53320e5c28..06dc35b0b1 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidMethodBuilderTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidMethodBuilderTest.java @@ -56,19 +56,19 @@ public class QpidMethodBuilderTest extends BaseQpidFeatureBuilderTestCase Map<String,Object> arg1 = new HashMap<String,Object>(); arg1.put(name.name(), "arg1"); - arg1.put(type.name(),_type); + arg1.put(type.name(),1); arg1.put(dir.name(),Direction.I.name()); arg1.put(unit.name(), "bytes"); Map<String,Object> arg2 = new HashMap<String,Object>(); arg2.put(name.name(), "arg2"); - arg2.put(type.name(),_type); + arg2.put(type.name(),1); arg2.put(dir.name(),Direction.O.name()); arg2.put(unit.name(), "bytes"); Map<String,Object> arg3 = new HashMap<String,Object>(); arg3.put(name.name(), "arg3"); - arg3.put(type.name(),_type); + arg3.put(type.name(),1); arg3.put(dir.name(),Direction.IO.name()); arg3.put(unit.name(), "bytes"); @@ -144,4 +144,4 @@ public class QpidMethodBuilderTest extends BaseQpidFeatureBuilderTestCase assertEquals(method.getDescription(),info.getDescription()); assertEquals(method.getName(),info.getName()); } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidNumberPropertyTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidNumberPropertyTest.java index 55a9403bc8..374011d150 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidNumberPropertyTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidNumberPropertyTest.java @@ -22,8 +22,8 @@ package org.apache.qpid.management.domain.model; import junit.framework.TestCase; -import org.apache.qpid.management.configuration.StubConfigurator; -import org.apache.qpid.management.domain.model.type.Uint64; +import org.apache.qpid.management.configuration.Configurator; +import org.apache.qpid.management.domain.model.type.Uint8; public class QpidNumberPropertyTest extends TestCase { @@ -33,12 +33,12 @@ public class QpidNumberPropertyTest extends TestCase @Override protected void setUp () throws Exception { - StubConfigurator configurator = new StubConfigurator(); - configurator.addTypeMapping("1", Uint64.class.getName(),QpidProperty.NumberValidator.class.getName()); + Configurator configurator = new Configurator(); + configurator.configure(); _property = new QpidProperty(); _property.setName("average"); _property.setAccessMode(AccessMode.RW); - _property.setType(new Uint64()); + _property.setType(new Uint8()); } /** @@ -168,4 +168,4 @@ public class QpidNumberPropertyTest extends TestCase assertEquals(_property.getName(),expected.getFeatureName()); } } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidPropertyBuilderTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidPropertyBuilderTest.java index 4ac399def0..8ad177645c 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidPropertyBuilderTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidPropertyBuilderTest.java @@ -52,14 +52,12 @@ public class QpidPropertyBuilderTest extends BaseQpidFeatureBuilderTestCase super.setUp(); _access = 1; - configurator.addAccessModeMapping(_access.toString(), AccessMode.RW.name()); - _featureDefinition.put(access.name(), _access); _featureDefinition.put(unit.name(),UNIT); _featureDefinition.put(min.name(), MIN); _featureDefinition.put(max.name(),MAX); - _featureDefinition.put(type.name(), _type); + _featureDefinition.put(type.name(), 1); _featureDefinition.put(optional.name(),0); _featureDefinition.put(index.name(), 0); @@ -255,17 +253,17 @@ public class QpidPropertyBuilderTest extends BaseQpidFeatureBuilderTestCase MBeanAttributeInfo info = (MBeanAttributeInfo) _builder.getManagementFeature(); assertEquals(NAME,property.getName()); - assertEquals(AccessMode.RW,property.getAccessMode()); + assertEquals(AccessMode.RC,property.getAccessMode()); assertEquals(UNIT,property.getUnit()); assertEquals(MIN.intValue(),property.getMinValue()); assertEquals(MAX.intValue(),property.getMaxValue()); assertEquals(Integer.MIN_VALUE,property.getMaxLength()); assertEquals(DESCRIPTION,property.getDescription()); - assertEquals(Integer.class,property.getJavaType()); + assertEquals(Short.class,property.getJavaType()); assertFalse(property.isOptional()); assertEquals(property.getDescription(),info.getDescription()); assertEquals(property.getName(),info.getName()); assertEquals(property.getJavaType().getName(),info.getType()); } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStatisticBuilderTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStatisticBuilderTest.java index 7f4cf72895..b7a8540b2d 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStatisticBuilderTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStatisticBuilderTest.java @@ -42,7 +42,7 @@ public class QpidStatisticBuilderTest extends BaseQpidFeatureBuilderTestCase { super.setUp(); _featureDefinition.put(unit.name(),UNIT); - _featureDefinition.put(type.name(), _type); + _featureDefinition.put(type.name(), 1); _builder = QpidFeatureBuilder.createStatisticBuilder(_featureDefinition); } @@ -150,10 +150,10 @@ public class QpidStatisticBuilderTest extends BaseQpidFeatureBuilderTestCase assertEquals(NAME,statistic.getName()); assertEquals(UNIT,statistic.getUnit()); assertEquals(DESCRIPTION,statistic.getDescription()); - assertEquals(Integer.class,statistic.getJavaType()); + assertEquals(Short.class,statistic.getJavaType()); assertEquals(statistic.getDescription(),info.getDescription()); assertEquals(statistic.getName(),info.getName()); assertEquals(statistic.getJavaType().getName(),info.getType()); } -}
\ No newline at end of file +} diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStringPropertyTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStringPropertyTest.java index 534a019503..8aeb7c8550 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStringPropertyTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStringPropertyTest.java @@ -22,7 +22,7 @@ package org.apache.qpid.management.domain.model; import junit.framework.TestCase; -import org.apache.qpid.management.configuration.StubConfigurator; +import org.apache.qpid.management.configuration.Configurator; import org.apache.qpid.management.domain.model.type.Str16; public class QpidStringPropertyTest extends TestCase @@ -33,8 +33,8 @@ public class QpidStringPropertyTest extends TestCase @Override protected void setUp () throws Exception { - StubConfigurator configurator = new StubConfigurator(); - configurator.addTypeMapping("1", Str16.class.getName(),QpidProperty.StringValidator.class.getName()); + Configurator configurator = new Configurator(); + configurator.configure(); _property = new QpidProperty(); _property.setName("name"); _property.setAccessMode(AccessMode.RW); diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/online/TestMethodInvocation.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/online/TestMethodInvocation.java deleted file mode 100644 index dc4ab64503..0000000000 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/online/TestMethodInvocation.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * 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.management.online; - -import java.io.IOException; -import java.util.Set; - -import javax.management.InstanceNotFoundException; -import javax.management.MBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.ReflectionException; - -import org.apache.qpid.management.domain.handler.impl.InvocationResult; - -public class TestMethodInvocation extends BaseOnlineTestCase -{ - /** - * Tests the execution of the purge() method on a queue instance. - * - * <br>precondition : QMan is up and running; managed domain model contains at least one queue. - * <br>postcondition : method is invoked and result object indicates that all was performed correctly. - */ - public void testInvokePurgeOnQueue() throws Exception - { - Set<ObjectName> names = connection.queryNames( - new ObjectName("Q-MAN:*,package=org.apache.qpid.broker,class=queue"),null); - - for (ObjectName objectName : names) - { - InvocationResult result = (InvocationResult) connection.invoke(objectName,"purge",new Object[]{0},new String[]{Integer.class.getName()}); - assertEquals(0,result.getReturnCode()); - assertEquals("OK",result.getStatusText()); - } - } - - /** - * Tests the execution of the invocation request with an unknown method. - * - * <br>precondition : QMan is up and running; managed domain model contains at least one queue. - * <br>postcondition An exception is thrown indicating that the method was not found. - */ - public void testInvokeWithUnknwonMethod() throws MalformedObjectNameException, NullPointerException, IOException, InstanceNotFoundException, MBeanException - { - Set<ObjectName> names = connection.queryNames(new ObjectName("Q-MAN:*,package=org.apache.qpid.broker,class=queue"),null); - System.out.println(names.size()); - - for (ObjectName objectName : names) - { - try - { - InvocationResult result = (InvocationResult) connection.invoke(objectName,"spurgexyzhopethatitwontexists",new Object[]{1},new String[]{Integer.class.getName()}); - } catch (ReflectionException expected) - { - NoSuchMethodException exception = (NoSuchMethodException) expected.getCause(); - assertEquals("spurge",exception.getMessage()); - } - } - } -}
\ No newline at end of file |
