Author: djencks Date: Wed Nov 17 00:33:37 2004 New Revision: 76104 Added: geronimo/trunk/modules/connector-builder/src/test-data/data/dup-admin-object-name.xml geronimo/trunk/modules/connector-builder/src/test-data/data/dup-connectionfactoryinstance-name.xml geronimo/trunk/modules/connector-builder/src/test-data/data/dup-resourceadapter-name.xml geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java Modified: geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd Log: GERONIMO-374 Added uniqueness constraints for resourceadapter-name, connectionfactory name, and admin object message-destination-name
Modified: geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd ============================================================================== --- geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd (original) +++ geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd Wed Nov 17 00:33:37 2004 @@ -54,6 +54,42 @@ </xsd:documentation> </xsd:annotation> + <xsd:unique name="resourceadapter-instance-name-uniqueness"> + <xsd:annotation> + <xsd:documentation> + + The resourceadapter-instance element must have a unique name. + + </xsd:documentation> + </xsd:annotation> + <xsd:selector xpath="ger:resourceadapter/ger:resourceadapter-instance"/> + <xsd:field xpath="ger:resourceadapter-name"/> + </xsd:unique> + + <xsd:unique name="connectiondefinition-instance-name-uniqueness"> + <xsd:annotation> + <xsd:documentation> + + The connectiondefinition-instance element must have a unique name. + + </xsd:documentation> + </xsd:annotation> + <xsd:selector xpath="ger:resourceadapter/ger:outbound-resourceadapter/ger:connection-definition/ger:connectiondefinition-instance"/> + <xsd:field xpath="ger:name"/> + </xsd:unique> + + <xsd:unique name="admin-object-instance-name-uniqueness"> + <xsd:annotation> + <xsd:documentation> + + The admin-object-instance element must have a unique name. + + </xsd:documentation> + </xsd:annotation> + <xsd:selector xpath="ger:adminobject/ger:adminobject-instance"/> + <xsd:field xpath="ger:message-destination-name"/> + </xsd:unique> + </xsd:element> @@ -414,7 +450,8 @@ <xsd:sequence> <xsd:element name="resourceadapter-instance" type="ger:resourceadapter-instanceType" - minOccurs="0"/> + minOccurs="0"> + </xsd:element> <xsd:element name="outbound-resourceadapter" type="ger:outbound-resourceadapterType" minOccurs="0"> Added: geronimo/trunk/modules/connector-builder/src/test-data/data/dup-admin-object-name.xml ============================================================================== --- (empty file) +++ geronimo/trunk/modules/connector-builder/src/test-data/data/dup-admin-object-name.xml Wed Nov 17 00:33:37 2004 @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2004 The Apache Software Foundation + + Licensed 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. +--> + +<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" version="1.5" + configId="org/apache/geronimo/j2ee/deployment/test" + parentId="org/apache/geronimo/Server"> + + <resourceadapter> + <resourceadapter-instance> + <resourceadapter-name>testRA</resourceadapter-name> + <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting> + <workmanager-name>DefaultWorkManager</workmanager-name> + </resourceadapter-instance> + </resourceadapter> + + <adminobject> + <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface> + <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class> + <adminobject-instance> + <message-destination-name>tweedledee</message-destination-name> + <config-property-setting name="Tweedle">Dee-value</config-property-setting> + </adminobject-instance> + <adminobject-instance> + <message-destination-name>tweedledum</message-destination-name> + <config-property-setting name="Tweedle">Dum-value</config-property-setting> + </adminobject-instance> + </adminobject> + <adminobject> + <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface> + <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class> + <adminobject-instance> + <message-destination-name>tweedledee</message-destination-name> + <config-property-setting name="Tweedle">Dee-value</config-property-setting> + </adminobject-instance> + <adminobject-instance> + <message-destination-name>tweedledum</message-destination-name> + <config-property-setting name="Tweedle">Dum-value</config-property-setting> + </adminobject-instance> + </adminobject> + + +</connector> Added: geronimo/trunk/modules/connector-builder/src/test-data/data/dup-connectionfactoryinstance-name.xml ============================================================================== --- (empty file) +++ geronimo/trunk/modules/connector-builder/src/test-data/data/dup-connectionfactoryinstance-name.xml Wed Nov 17 00:33:37 2004 @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2004 The Apache Software Foundation + + Licensed 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. +--> + +<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" version="1.5" + configId="org/apache/geronimo/j2ee/deployment/test" + parentId="org/apache/geronimo/Server"> + + <resourceadapter> + <resourceadapter-instance> + <resourceadapter-name>testRA1</resourceadapter-name> + <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting> + <workmanager-name>DefaultWorkManager</workmanager-name> + </resourceadapter-instance> + <outbound-resourceadapter> + <connection-definition> + <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface> + <connectiondefinition-instance> + <name>FirstTestOutboundConnectionFactory</name> + <config-property-setting name="OutboundStringProperty1">newvalue1</config-property-setting> + <config-property-setting name="OutboundStringProperty3">newvalue2</config-property-setting> + <connectionmanager> + <realm-bridge>TargetRealm</realm-bridge> + <xa-transaction> + <transaction-caching/> + </xa-transaction> + <partitioned-pool> + <max-size>10</max-size> + <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds> + <match-one/> + <partition-by-subject/> + </partitioned-pool> + </connectionmanager> + <global-jndi-name>connectionfactories/testcf</global-jndi-name> + <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface> + </connectiondefinition-instance> + </connection-definition> + </outbound-resourceadapter> + </resourceadapter> + <resourceadapter> + <resourceadapter-instance> + <resourceadapter-name>testRA2</resourceadapter-name> + <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting> + <workmanager-name>DefaultWorkManager</workmanager-name> + </resourceadapter-instance> + <outbound-resourceadapter> + <connection-definition> + <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface> + <connectiondefinition-instance> + <name>FirstTestOutboundConnectionFactory</name> + <config-property-setting name="OutboundStringProperty1">newvalue1</config-property-setting> + <config-property-setting name="OutboundStringProperty3">newvalue2</config-property-setting> + <connectionmanager> + <realm-bridge>TargetRealm</realm-bridge> + <xa-transaction> + <transaction-caching/> + </xa-transaction> + <partitioned-pool> + <max-size>10</max-size> + <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds> + <match-one/> + <partition-by-subject/> + </partitioned-pool> + </connectionmanager> + <global-jndi-name>connectionfactories/testcf</global-jndi-name> + <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface> + </connectiondefinition-instance> + </connection-definition> + </outbound-resourceadapter> + </resourceadapter> + + +</connector> Added: geronimo/trunk/modules/connector-builder/src/test-data/data/dup-resourceadapter-name.xml ============================================================================== --- (empty file) +++ geronimo/trunk/modules/connector-builder/src/test-data/data/dup-resourceadapter-name.xml Wed Nov 17 00:33:37 2004 @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2004 The Apache Software Foundation + + Licensed 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. +--> + +<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" version="1.5" + configId="org/apache/geronimo/j2ee/deployment/test" + parentId="org/apache/geronimo/Server"> + + <resourceadapter> + <resourceadapter-instance> + <resourceadapter-name>testRA</resourceadapter-name> + <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting> + <workmanager-name>DefaultWorkManager</workmanager-name> + </resourceadapter-instance> + </resourceadapter> + <resourceadapter> + <resourceadapter-instance> + <resourceadapter-name>testRA</resourceadapter-name> + <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting> + <workmanager-name>DefaultWorkManager</workmanager-name> + </resourceadapter-instance> + </resourceadapter> + + +</connector> Added: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java ============================================================================== --- (empty file) +++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java Wed Nov 17 00:33:37 2004 @@ -0,0 +1,68 @@ +package org.apache.geronimo.connector.deployment; + +import java.io.File; + +import junit.framework.TestCase; +import org.apache.geronimo.schema.SchemaConversionUtils; +import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; +import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlObject; + +/** + */ +public class PlanParsingTest extends TestCase { + + File basedir = new File(System.getProperty("basedir", ".")); + + public void testResourceAdapterNameUniqueness() throws Exception { + File resourcePlan = new File(basedir, "src/test-data/data/dup-resourceadapter-name.xml"); + assertTrue(resourcePlan.exists()); + + XmlObject plan = SchemaConversionUtils.parse(resourcePlan.toURL()); + GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type); + if (doc == null) { + doc = (GerConnectorDocument) plan; + } + try { + SchemaConversionUtils.validateDD(doc); + fail("dup resource adapter name is invalid"); + } catch (XmlException e) { + //expected + } + } + + public void testConnectionFactoryNameUniqueness() throws Exception { + File resourcePlan = new File(basedir, "src/test-data/data/dup-connectionfactoryinstance-name.xml"); + assertTrue(resourcePlan.exists()); + + XmlObject plan = SchemaConversionUtils.parse(resourcePlan.toURL()); + GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type); + if (doc == null) { + doc = (GerConnectorDocument) plan; + } + try { + SchemaConversionUtils.validateDD(doc); + fail("dup connection factory name is invalid"); + } catch (XmlException e) { + //expected + } + } + + public void testAdminObjectNameUniqueness() throws Exception { + File resourcePlan = new File(basedir, "src/test-data/data/dup-admin-object-name.xml"); + assertTrue(resourcePlan.exists()); + + XmlObject plan = SchemaConversionUtils.parse(resourcePlan.toURL()); + GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type); + if (doc == null) { + doc = (GerConnectorDocument) plan; + } + try { + SchemaConversionUtils.validateDD(doc); + fail("dup admin object name is invalid"); + } catch (XmlException e) { + //expected + } + } + +}