You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2008/10/20 20:23:42 UTC
svn commit: r706357 [9/13] - in
/geronimo/server/trunk/plugins/connector-1_6: ./ client-transaction-1_6/
client-transaction-1_6/src/ client-transaction-1_6/src/main/
client-transaction-1_6/src/main/history/
client-transaction-1_6/src/main/plan/ client-...
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml Mon Oct 20 11:23:36 2008
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config"
+ >
+
+ <xb:namespace uri="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
+ <xb:package>org.apache.geronimo.xbeans.geronimo</xb:package>
+ <xb:prefix>Ger</xb:prefix>
+ </xb:namespace>
+
+
+</xb:config>
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsdconfig/xmlconfig.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,584 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
+
+import javax.naming.Reference;
+import javax.sql.DataSource;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.service.GBeanBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.j2ee.deployment.ActivationSpecInfoLocator;
+import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.EditableConfigurationManager;
+import org.apache.geronimo.kernel.config.EditableKernelConfigurationManager;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.mock.MockConfigStore;
+import org.apache.geronimo.kernel.mock.MockRepository;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManagerGBean;
+
+/**
+ * @version $Rev:385232 $ $Date$
+ */
+public class ConnectorModuleBuilderTest extends TestSupport {
+
+ private boolean defaultXATransactionCaching = true;
+ private boolean defaultXAThreadCaching = false;
+ private int defaultMaxSize = 10;
+ private int defaultMinSize = 0;
+ private int defaultBlockingTimeoutMilliseconds = 5000;
+ private int defaultidleTimeoutMinutes = 15;
+ private String defaultWorkManagerName = "DefaultWorkManager";
+ private Environment defaultEnvironment;
+ private ConfigurationStore configurationStore = new MockConfigStore();
+ private MockRepository repository;
+
+ private ActivationSpecInfoLocator activationSpecInfoLocator = new ActivationSpecInfoLocator() {
+
+ public Reference createResourceRef(AbstractNameQuery containerId, Class iface, Configuration configuration) {
+ return null;
+ }
+
+ public Reference createAdminObjectRef(AbstractNameQuery containerId, Class iface, Configuration configuration) {
+ return null;
+ }
+
+ public GBeanData locateActivationSpecInfo(AbstractNameQuery nameQuery, String messageListenerInterface, Configuration configuration) {
+ return null;
+ }
+ };
+
+ private Kernel kernel;
+ private EditableConfigurationManager configurationManager;
+ private static final Naming naming = new Jsr77Naming();
+ private static final Artifact bootId = new Artifact("test", "test", "42", "car");
+
+ private static final AbstractNameQuery connectionTrackerName = new AbstractNameQuery(null, Collections.singletonMap("name", "ConnectionTracker"));
+ private AbstractName serverName;
+ private static final AbstractNameQuery transactionManagerName = new AbstractNameQuery(null, Collections.singletonMap("name", "TransactionManager"));
+
+
+ public void testBuildEar() throws Exception {
+ JarFile rarFile = null;
+ try {
+ rarFile = DeploymentUtil.createJarFile(new File(BASEDIR, "target/test-ear-noger.ear"));
+ GBeanBuilder serviceBuilder = new GBeanBuilder(null, null);
+// EARConfigBuilder configBuilder = new EARConfigBuilder(defaultEnvironment, transactionContextManagerName, connectionTrackerName, null, null, null, new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()), null, null, ejbReferenceBuilder, null,
+ EARConfigBuilder configBuilder = new EARConfigBuilder(defaultEnvironment,
+ transactionManagerName,
+ connectionTrackerName,
+ null,
+ new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()),
+ Collections.singleton(repository),
+ null,
+ null,
+ new ConnectorModuleBuilder(defaultEnvironment, defaultMaxSize, defaultMinSize, defaultBlockingTimeoutMilliseconds, defaultidleTimeoutMinutes, defaultXATransactionCaching, defaultXAThreadCaching, defaultWorkManagerName, Collections.singleton(serviceBuilder)),
+ activationSpecInfoLocator,
+ null,
+ null,
+ serviceBuilder,
+ null,
+ kernel.getNaming(),
+ null);
+ configBuilder.doStart();
+ ConfigurationData configData = null;
+ DeploymentContext context = null;
+ ArtifactManager artifactManager = new DefaultArtifactManager();
+ ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(repository), null);
+
+ try {
+ File planFile = new File(BASEDIR, "src/test/resources/data/external-application-plan.xml");
+ ModuleIDBuilder idBuilder = new ModuleIDBuilder();
+ Object plan = configBuilder.getDeploymentPlan(planFile, rarFile, idBuilder);
+ context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan, rarFile, idBuilder), plan, rarFile, Collections.singleton(configurationStore), artifactResolver, configurationStore);
+
+ // add the a j2ee server so the application context reference can be resolved
+ context.addGBean("geronimo", J2EEServerImpl.GBEAN_INFO);
+
+ configData = context.getConfigurationData();
+ } finally {
+ if (context != null) {
+ context.close();
+ }
+ if (configData != null) {
+ DeploymentUtil.recursiveDelete(configData.getConfigurationDir());
+ }
+ }
+ configBuilder.doStop();
+ } finally {
+ DeploymentUtil.close(rarFile);
+
+ }
+ }
+
+ public void testBuildUnpackedModule() throws Exception {
+ InstallAction action = new InstallAction() {
+ public File getRARFile() {
+ return new File(BASEDIR, "target/test-rar-10");
+ }
+ };
+ executeTestBuildModule(action, false);
+ }
+
+ public void testBuildUnpackedAltSpecDDModule() throws Exception {
+ InstallAction action = new InstallAction() {
+ public File getVendorDD() {
+ return new File(BASEDIR, "target/test-rar-10/META-INF/geronimo-ra.xml");
+ }
+
+ public URL getSpecDD() throws MalformedURLException {
+ return new File(BASEDIR, "target/test-rar-10/dummy.xml").toURL();
+ }
+
+ public File getRARFile() {
+ return new File(BASEDIR, "target/test-rar-10");
+ }
+ };
+ try {
+ executeTestBuildModule(action, false);
+ fail("Spec alt-dd does not exist.");
+ } catch (DeploymentException e) {
+ }
+ }
+
+ public void testBuildUnpackedAltVendorDDModule() throws Exception {
+ InstallAction action = new InstallAction() {
+ public File getVendorDD() {
+ // this file does not exist, one expects a DeploymentException.
+ return new File(BASEDIR, "target/test-rar-10/dummy.xml");
+ }
+
+ public URL getSpecDD() throws MalformedURLException {
+ return new File(BASEDIR, "target/test-rar-10/META-INF/ra.xml").toURL();
+ }
+
+ public File getRARFile() {
+ return new File(BASEDIR, "target/test-rar-10");
+ }
+ };
+ try {
+ executeTestBuildModule(action, false);
+ fail("Vendor alt-dd does not exist.");
+ } catch (DeploymentException e) {
+ }
+ }
+
+ public void testBuildUnpackedAltSpecVendorDDModule() throws Exception {
+ InstallAction action = new InstallAction() {
+ public File getVendorDD() {
+ // this file exists
+ return new File(BASEDIR, "target/test-rar-10/META-INF/geronimo-ra.xml");
+ }
+
+ public URL getSpecDD() throws MalformedURLException {
+ return new File(BASEDIR, "target/test-rar-10/META-INF/ra.xml").toURL();
+ }
+
+ public File getRARFile() {
+ return new File(BASEDIR, "target/test-rar-10");
+ }
+ };
+ executeTestBuildModule(action, false);
+ }
+
+ public void testBuildPackedModule() throws Exception {
+ InstallAction action = new InstallAction() {
+ public File getRARFile() {
+ return new File(BASEDIR, "target/test-rar-10.rar");
+ }
+ };
+ executeTestBuildModule(action, false);
+ }
+
+ //1.5 tests
+ public void testBuildUnpackedModule15() throws Exception {
+ InstallAction action = new InstallAction() {
+ private File rarFile = new File(BASEDIR, "target/test-rar-15");
+
+ public File getRARFile() {
+ return rarFile;
+ }
+
+ };
+ executeTestBuildModule(action, true);
+ }
+
+
+ public void testBuildPackedModule15() throws Exception {
+ InstallAction action = new InstallAction() {
+ private File rarFile = new File(BASEDIR, "target/test-rar-15.rar");
+
+ public File getRARFile() {
+ return rarFile;
+ }
+
+ };
+ executeTestBuildModule(action, true);
+ }
+
+ public void testBuildPackedModule15LocalTx() throws Exception {
+ InstallAction action = new InstallAction() {
+ private File rarFile = new File(BASEDIR, "target/test-rar-15-localtx.rar");
+
+ public File getRARFile() {
+ return rarFile;
+ }
+
+ };
+ try {
+ executeTestBuildModule(action, true);
+ fail("transaction setting mismatch not detected");
+ } catch (DeploymentException e) {
+
+ }
+ }
+
+ public void testBuildPackedModule15NoTx() throws Exception {
+ InstallAction action = new InstallAction() {
+ private File rarFile = new File(BASEDIR, "target/test-rar-15-notx.rar");
+
+ public File getRARFile() {
+ return rarFile;
+ }
+
+ };
+ try {
+ executeTestBuildModule(action, true);
+ fail("transaction setting mismatch not detected");
+ } catch (DeploymentException e) {
+
+ }
+ }
+
+
+ private void executeTestBuildModule(InstallAction action, boolean is15) throws Exception {
+ String resourceAdapterName = "testRA";
+
+ try {
+ ConnectorModuleBuilder moduleBuilder = new ConnectorModuleBuilder(defaultEnvironment, defaultMaxSize, defaultMinSize, defaultBlockingTimeoutMilliseconds, defaultidleTimeoutMinutes, defaultXATransactionCaching, defaultXAThreadCaching, defaultWorkManagerName, Collections.singleton(new GBeanBuilder(null, null)));
+ File rarFile = action.getRARFile();
+
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = new URLClassLoader(new URL[]{rarFile.toURL()}, oldCl);
+
+ Thread.currentThread().setContextClassLoader(cl);
+
+ JarFile rarJarFile = DeploymentUtil.createJarFile(rarFile);
+ AbstractName earName = null;
+ String moduleName = "geronimo/test-ear/1.0/car";
+ Module module = moduleBuilder.createModule(action.getVendorDD(), rarJarFile, moduleName, action.getSpecDD(), null, null, earName, naming, new ModuleIDBuilder());
+ if (module == null) {
+ throw new DeploymentException("Was not a connector module");
+ }
+ assertEquals(moduleName, module.getEnvironment().getConfigId().toString());
+
+ File tempDir = null;
+ try {
+ tempDir = DeploymentUtil.createTempDir();
+ EARContext earContext = new EARContext(tempDir,
+ null,
+ module.getEnvironment(),
+ module.getType(),
+ naming,
+ configurationManager,
+ Collections.EMPTY_SET,
+ new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()),
+ module.getModuleName(), //hardcode standalone here.
+ transactionManagerName,
+ connectionTrackerName,
+ null
+ );
+
+ action.install(moduleBuilder, earContext, module, configurationStore);
+ earContext.getClassLoader();
+ moduleBuilder.initContext(earContext, module, cl);
+ moduleBuilder.addGBeans(earContext, module, cl, Collections.singleton(repository));
+
+ ConfigurationData configurationData = earContext.getConfigurationData();
+ AbstractName moduleAbstractName = earContext.getModuleName();
+ earContext.close();
+
+ verifyDeployment(configurationData, oldCl, moduleAbstractName, resourceAdapterName, is15, moduleName);
+ } finally {
+ module.close();
+ DeploymentUtil.recursiveDelete(tempDir);
+ }
+ } finally {
+ kernel.shutdown();
+ }
+ }
+
+ private void verifyDeployment(ConfigurationData configurationData, ClassLoader cl, AbstractName moduleAbstractName, String resourceAdapterName, boolean is15, String moduleName) throws Exception {
+ DataSource ds = null;
+ try {
+
+ Artifact configurationId = configurationData.getId();
+
+ // load the configuration
+ configurationManager.loadConfiguration(configurationData);
+ Configuration configuration = configurationManager.getConfiguration(configurationId);
+ configurationManager.startConfiguration(configurationId);
+ Set<AbstractName> gb = configuration.getGBeans().keySet();
+ for (AbstractName name : gb) {
+ if (State.RUNNING_INDEX != kernel.getGBeanState(name)) {
+ log.debug("Not running: " + name);
+ }
+ }
+
+ assertRunning(kernel, moduleAbstractName);
+ AbstractName resourceAdapterjsr77Name = naming.createChildName(moduleAbstractName, moduleName, NameFactory.RESOURCE_ADAPTER);
+ assertRunning(kernel, resourceAdapterjsr77Name);
+ AbstractName jcaResourcejsr77Name = naming.createChildName(resourceAdapterjsr77Name, moduleName, NameFactory.JCA_RESOURCE);
+ assertRunning(kernel, jcaResourcejsr77Name);
+
+ //1.5 only
+ if (is15) {
+ Map activationSpecInfoMap = (Map) kernel.getAttribute(moduleAbstractName, "activationSpecInfoMap");
+ assertEquals(1, activationSpecInfoMap.size());
+ GBeanData activationSpecInfo = (GBeanData) activationSpecInfoMap.get("javax.jms.MessageListener");
+ assertNotNull(activationSpecInfo);
+ GBeanInfo activationSpecGBeanInfo = activationSpecInfo.getGBeanInfo();
+ List attributes1 = activationSpecGBeanInfo.getPersistentAttributes();
+ assertEquals(2, attributes1.size());
+
+ Map adminObjectInfoMap = (Map) kernel.getAttribute(moduleAbstractName, "adminObjectInfoMap");
+ assertEquals(1, adminObjectInfoMap.size());
+ GBeanData adminObjectInfo = (GBeanData) adminObjectInfoMap.get("org.apache.geronimo.connector.mock.MockAdminObject");
+ assertNotNull(adminObjectInfo);
+ GBeanInfo adminObjectGBeanInfo = adminObjectInfo.getGBeanInfo();
+ List attributes2 = adminObjectGBeanInfo.getPersistentAttributes();
+ assertEquals(3, attributes2.size());
+
+ // ResourceAdapter
+ AbstractName resourceAdapterObjectName = naming.createChildName(jcaResourcejsr77Name, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER);
+
+ assertRunning(kernel, resourceAdapterObjectName);
+ assertAttributeValue(kernel, resourceAdapterObjectName, "RAStringProperty", "NewStringValue");
+
+ //both, except 1.0 has only one mcf type
+ Map managedConnectionFactoryInfoMap = (Map) kernel.getAttribute(moduleAbstractName, "managedConnectionFactoryInfoMap");
+ assertEquals(2, managedConnectionFactoryInfoMap.size());
+ GBeanData managedConnectionFactoryInfo = (GBeanData) managedConnectionFactoryInfoMap.get("javax.resource.cci.ConnectionFactory");
+ assertNotNull(managedConnectionFactoryInfo);
+ GBeanInfo managedConnectionFactoryGBeanInfo = managedConnectionFactoryInfo.getGBeanInfo();
+ List attributes3 = managedConnectionFactoryGBeanInfo.getPersistentAttributes();
+ assertEquals(11, attributes3.size());
+ }
+
+ // FirstTestOutboundConnectionFactory
+ AbstractName firstOutCF = naming.createChildName(jcaResourcejsr77Name, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY);
+ assertRunning(kernel, firstOutCF);
+
+ AbstractName firstOutMCF = naming.createChildName(firstOutCF, "FirstTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
+ assertRunning(kernel, firstOutMCF);
+ assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty1", "newvalue1");
+ assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty2", "originalvalue2");
+ assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty3", "newvalue2");
+
+ AbstractName firstConnectionManagerFactory = naming.createChildName(firstOutMCF, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER);
+ assertRunning(kernel, firstConnectionManagerFactory);
+
+ // SecondTestOutboundConnectionFactory
+ AbstractName secondOutCF = naming.createChildName(jcaResourcejsr77Name, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY);
+ assertRunning(kernel, secondOutCF);
+
+ AbstractName secondOutMCF = naming.createChildName(secondOutCF, "SecondTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
+ assertRunning(kernel, secondOutMCF);
+
+ AbstractName secondConnectionManagerFactory = naming.createChildName(secondOutMCF, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER);
+ assertRunning(kernel, secondConnectionManagerFactory);
+
+ // ThirdTestOutboundConnectionFactory
+ AbstractName thirdOutCF = naming.createChildName(jcaResourcejsr77Name, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY);
+ assertRunning(kernel, thirdOutCF);
+
+ AbstractName thirdOutMCF = naming.createChildName(thirdOutCF, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
+ assertRunning(kernel, thirdOutMCF);
+
+ AbstractName thirdConnectionManagerFactory = naming.createChildName(thirdOutMCF, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER);
+ assertRunning(kernel, thirdConnectionManagerFactory);
+
+ // 1.5 only
+ // Admin objects
+ //
+
+ if (is15) {
+ AbstractName tweedledeeAdminObject = naming.createChildName(jcaResourcejsr77Name, "tweedledee", NameFactory.JCA_ADMIN_OBJECT);
+ assertRunning(kernel, tweedledeeAdminObject);
+
+ AbstractName tweedledumAdminObject = naming.createChildName(jcaResourcejsr77Name, "tweedledum", NameFactory.JCA_ADMIN_OBJECT);
+ assertRunning(kernel, tweedledumAdminObject);
+ }
+
+
+ configurationManager.stopConfiguration(configurationId);
+ configurationManager.unloadConfiguration(configurationId);
+ } finally {
+ if (ds != null) {
+ Connection connection = ds.getConnection();
+ try {
+ Statement statement = connection.createStatement();
+ try {
+ statement.execute("SHUTDOWN");
+ } finally {
+ statement.close();
+ }
+ } finally {
+ connection.close();
+ }
+ }
+
+ if (kernel != null) {
+ kernel.shutdown();
+ }
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ private void assertAttributeValue(Kernel kernel, AbstractName name, String attributeName, String attributeValue) throws Exception {
+ Object value = kernel.getAttribute(name, attributeName);
+ assertEquals(attributeValue, value);
+ }
+
+ private void assertRunning(Kernel kernel, AbstractName name) throws Exception {
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(name));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ kernel = KernelFactory.newInstance().createKernel("test");
+ kernel.boot();
+
+ ConfigurationData bootstrap = new ConfigurationData(bootId, naming);
+
+// GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
+//
+// GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
+// artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+//
+// GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", EditableKernelConfigurationManager.GBEAN_INFO);
+// configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+// configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
+// bootstrap.addGBean(configurationManagerData);
+ bootstrap.addGBean("ServerInfo", BasicServerInfo.GBEAN_INFO).setAttribute("baseDirectory", ".");
+
+ AbstractName repositoryName = bootstrap.addGBean("Repository", MockRepository.GBEAN_INFO).getAbstractName();
+
+ AbstractName configStoreName = bootstrap.addGBean("MockConfigurationStore", MockConfigStore.GBEAN_INFO).getAbstractName();
+
+ GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
+
+ GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
+ artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+
+ GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", EditableKernelConfigurationManager.GBEAN_INFO);
+ configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+ configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
+ configurationManagerData.setReferencePattern("Stores", configStoreName);
+ configurationManagerData.setReferencePattern("Repositories", repositoryName);
+ bootstrap.addGBean(configurationManagerData);
+
+ GBeanData serverData = bootstrap.addGBean("geronimo", J2EEServerImpl.GBEAN_INFO);
+ serverName = serverData.getAbstractName();
+ bootstrap.addGBean(serverData);
+
+
+ // add fake TransactionManager so refs will resolve
+ GBeanData tm = bootstrap.addGBean("TransactionManager", GeronimoTransactionManagerGBean.GBEAN_INFO);
+ tm.setAttribute("defaultTransactionTimeoutSeconds", 10);
+
+ ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
+
+ repository = (MockRepository) kernel.getGBean(repositoryName);
+ Set<Artifact> repo = repository.getRepo();
+ repo.add(Artifact.create("org.apache.geronimo.tests/test/1/car"));
+ repo.add(bootId);
+
+
+ configurationManager = ConfigurationUtil.getEditableConfigurationManager(kernel);
+// configurationManager.getConfiguration(bootstrap.getId());
+ ConfigurationStore configStore = (ConfigurationStore) kernel.getGBean(configStoreName);
+ configStore.install(bootstrap);
+
+ defaultEnvironment = new Environment();
+ defaultEnvironment.addDependency(bootstrap.getId(), ImportType.ALL);
+
+ }
+
+ protected void tearDown() throws Exception {
+ kernel.shutdown();
+ super.tearDown();
+ }
+
+ private abstract class InstallAction {
+ public File getVendorDD() {
+ return null;
+ }
+
+ public URL getSpecDD() throws MalformedURLException {
+ return null;
+ }
+
+ public abstract File getRARFile();
+
+ public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module, ConfigurationStore configurationStore) throws Exception {
+ moduleBuilder.installModule(module.getModuleFile(), earContext, module, Collections.singleton(configurationStore), configurationStore, Collections.singleton(repository));
+ }
+ }
+
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,175 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.connector.AdminObjectWrapperGBean;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.j2ee.deployment.ConnectorModule;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.mock.MockConfigurationManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Rev:390932 $ $Date$
+ */
+public class MessageDestinationTest extends TestCase {
+
+ private static final Naming naming = new Jsr77Naming();
+ Configuration configuration;
+ AbstractName baseName;
+ AdminObjectRefBuilder adminObjectRefBuilder = new AdminObjectRefBuilder(null, new String[] {SchemaConversionUtils.J2EE_NAMESPACE});
+ Module module;
+
+ Map componentContext = new HashMap();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Artifact id = new Artifact("test", "test", "", "car");
+ module = new ConnectorModule(false, new AbstractName(id, Collections.singletonMap("name", "test")), null, null, "foo", null, null, null, null);
+ ConfigurationManager configurationManager = new MockConfigurationManager();
+ EARContext earContext = new EARContext(new File("foo"),
+ null,
+ new Environment(new Artifact("foo", "bar", "1.0", "car")),
+ ConfigurationModuleType.EAR,
+ naming,
+ configurationManager,
+ (Collection) null,
+ null,
+ null,
+ null,
+ null,
+ null);
+ module.setEarContext(earContext);
+ module.setRootEarContext(earContext);
+ configuration = earContext.getConfiguration();
+ baseName = naming.createRootName(configuration.getId(), "testRoot", NameFactory.RESOURCE_ADAPTER_MODULE);
+ }
+
+ private static final String SPECDD1 = "<tmp xmlns=\"http://java.sun.com/xml/ns/j2ee\">" +
+ "<message-destination><message-destination-name>d1</message-destination-name></message-destination>" +
+ "<message-destination><message-destination-name>d2</message-destination-name></message-destination>" +
+ "<message-destination-ref>" +
+ " <message-destination-ref-name>n1</message-destination-ref-name>" +
+ " <message-destination-type>java.lang.Object</message-destination-type>" +
+ " <message-destination-usage>Consumes</message-destination-usage>" +
+ " <message-destination-link>d1</message-destination-link>" +
+ "</message-destination-ref>" +
+ "<message-destination-ref>" +
+ " <message-destination-ref-name>n2</message-destination-ref-name>" +
+ " <message-destination-type>java.lang.Object</message-destination-type>" +
+ " <message-destination-usage>Consumes</message-destination-usage>" +
+ " <message-destination-link>d2</message-destination-link>" +
+ "</message-destination-ref>" +
+ "</tmp>";
+
+ private static final String PLAN1 = "<tmp xmlns=\"http://geronimo.apache.org/xml/ns/naming-1.2\">" +
+ "<message-destination>" +
+ " <message-destination-name>d1</message-destination-name>" +
+ " <admin-object-link>l1</admin-object-link>" +
+ "</message-destination>" +
+ "<message-destination>" +
+ " <message-destination-name>d2</message-destination-name>" +
+ " <admin-object-link>l2</admin-object-link>" +
+ "</message-destination>" +
+ "</tmp>";
+
+ public void testMessageDestinations() throws Exception {
+ XmlObject specDD = parse(SPECDD1);
+ XmlObject plan = parse(PLAN1);
+ adminObjectRefBuilder.initContext(specDD, plan, module);
+ AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
+ AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
+ configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.GBEAN_INFO));
+ configuration.addGBean(new GBeanData(n2, AdminObjectWrapperGBean.GBEAN_INFO));
+ adminObjectRefBuilder.buildNaming(specDD, plan, module, componentContext);
+ assertEquals(2, NamingBuilder.JNDI_KEY.get(componentContext).size());
+ }
+
+ private static final String PLAN2 = "<tmp xmlns=\"http://geronimo.apache.org/xml/ns/naming-1.2\">" +
+ "<message-destination>" +
+ " <message-destination-name>d1</message-destination-name>" +
+ " <admin-object-module>testRoot</admin-object-module>" +
+ " <admin-object-link>l1</admin-object-link>" +
+ "</message-destination>" +
+ "<message-destination>" +
+ " <message-destination-name>d2</message-destination-name>" +
+ " <admin-object-module>testRoot</admin-object-module>" +
+ " <admin-object-link>l2</admin-object-link>" +
+ "</message-destination>" +
+ "</tmp>";
+ public void testMessageDestinationsWithModule() throws Exception {
+ XmlObject specDD = parse(SPECDD1);
+ XmlObject plan = parse(PLAN2);
+ adminObjectRefBuilder.initContext(specDD, plan, module);
+ AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
+ AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
+ configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.GBEAN_INFO));
+ configuration.addGBean(new GBeanData(n2, AdminObjectWrapperGBean.GBEAN_INFO));
+ adminObjectRefBuilder.buildNaming(specDD, plan, module, componentContext);
+ assertEquals(2, NamingBuilder.JNDI_KEY.get(componentContext).size());
+ }
+
+ private static final String SPECDD2 = "<tmp xmlns=\"http://java.sun.com/xml/ns/j2ee\">" +
+ "</tmp>";
+
+
+ public void testMessageDestinationsMatch() throws Exception {
+ XmlObject specDD = parse(SPECDD2);
+ XmlObject plan = parse(PLAN1);
+ try {
+ adminObjectRefBuilder.initContext(specDD, plan, module);
+ fail("tried to register a GerMessageDestination witout a MessageDestination and it succeeded");
+ } catch (DeploymentException e) {
+
+ }
+ }
+
+ private XmlObject parse(String xmlString) throws XmlException {
+ XmlObject xmlObject = XmlObject.Factory.parse(xmlString);
+ XmlCursor xmlCursor = xmlObject.newCursor();
+ try {
+ xmlCursor.toFirstChild();
+ return xmlCursor.getObject();
+ } finally {
+ xmlCursor.dispose();
+ }
+ }
+
+}
+
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,82 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.net.URL;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Enumeration;
+
+import javax.enterprise.deploy.model.DeployableObject;
+import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.model.DDBean;
+import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
+import javax.enterprise.deploy.shared.ModuleType;
+
+import org.apache.geronimo.deployment.tools.DDBeanRootImpl;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ *
+ * */
+public class MockRARDeployable implements DeployableObject {
+
+ private DDBeanRoot root;
+
+ public MockRARDeployable(URL dd) throws DDBeanCreateException {
+ root = new DDBeanRootImpl(this, dd);
+ }
+
+ public ModuleType getType() {
+ return ModuleType.RAR;
+ }
+
+ public DDBeanRoot getDDBeanRoot() {
+ return root;
+ }
+
+ public DDBean[] getChildBean(String xpath) {
+ return root.getChildBean(xpath);
+ }
+
+ public String[] getText(String xpath) {
+ return root.getText(xpath);
+ }
+
+ public Class getClassFromScope(String className) {
+ return null;
+ }
+
+ public String getModuleDTDVersion() {
+ return null;
+ }
+
+ public DDBeanRoot getDDBeanRoot(String filename) throws FileNotFoundException, DDBeanCreateException {
+ return null;
+ }
+
+ public Enumeration entries() {
+ return null;
+ }
+
+ public InputStream getEntry(String name) {
+ return null;
+ }
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MockRARDeployable.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,119 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
+import org.apache.geronimo.xbeans.geronimo.GerConnectorType;
+import org.apache.geronimo.xbeans.j2ee.ConnectorDocument;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ */
+public class PlanParsingTest extends TestSupport {
+ private final static QName CONNECTOR_QNAME = GerConnectorDocument.type.getDocumentElementName();
+ private ClassLoader classLoader = this.getClass().getClassLoader();
+
+ public void testLoadGeronimoDeploymentDescriptor10() throws Exception {
+ URL srcXml = classLoader.getResource("connector_1_0/geronimo-ra.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument connectorDocument = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ GerConnectorType connector = (GerConnectorType) SchemaConversionUtils.fixGeronimoSchema(connectorDocument, CONNECTOR_QNAME, GerConnectorType.type);
+ XmlBeansUtil.validateDD(connector);
+ assertEquals(1, connectorDocument.getConnector().getResourceadapterArray().length);
+ }
+
+ public void testLoadJ2eeDeploymentDescriptor() throws Exception {
+ URL srcXml = classLoader.getResource("connector_1_5/ra.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ ConnectorDocument connectorDocument = (ConnectorDocument) plan.changeType(ConnectorDocument.type);
+ assertNotNull(connectorDocument.getConnector().getResourceadapter());
+ XmlBeansUtil.validateDD(connectorDocument);
+ }
+
+ public void testLoadGeronimoDeploymentDescriptor15() throws Exception {
+ URL srcXml = classLoader.getResource("connector_1_5/geronimo-ra.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument connectorDocument = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ GerConnectorType connector = (GerConnectorType) SchemaConversionUtils.fixGeronimoSchema(connectorDocument, CONNECTOR_QNAME, GerConnectorType.type);
+ assertEquals(1, connector.getResourceadapterArray().length);
+ }
+
+ public void testResourceAdapterNameUniqueness() throws Exception {
+ URL srcXml = classLoader.getResource("data/dup-resourceadapter-name.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ if (doc == null) {
+ doc = (GerConnectorDocument) plan;
+ }
+ try {
+ XmlBeansUtil.validateDD(doc);
+ fail("dup resource adapter name is invalid");
+ } catch (XmlException e) {
+ //expected
+ }
+ }
+
+ public void testConnectionFactoryNameUniqueness() throws Exception {
+ URL srcXml = classLoader.getResource("data/dup-connectionfactoryinstance-name.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ if (doc == null) {
+ doc = (GerConnectorDocument) plan;
+ }
+ try {
+ XmlBeansUtil.validateDD(doc);
+ fail("dup connection factory name is invalid");
+ } catch (XmlException e) {
+ //expected
+ }
+ }
+
+ public void testAdminObjectNameUniqueness() throws Exception {
+ URL srcXml = classLoader.getResource("data/dup-admin-object-name.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ if (doc == null) {
+ doc = (GerConnectorDocument) plan;
+ }
+ try {
+ XmlBeansUtil.validateDD(doc);
+ fail("dup admin object name is invalid");
+ } catch (XmlException e) {
+ //expected
+ }
+ }
+
+ public void testRectifyPlan() throws Exception {
+ URL srcXml = classLoader.getResource("data/old-schema-plan.xml");
+ XmlObject plan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+ GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+ if (doc == null) {
+ doc = (GerConnectorDocument) plan;
+ }
+ GerConnectorType gerConnector = doc.getConnector();
+ ConnectorPlanRectifier.rectifyPlan(gerConnector);
+ gerConnector = (GerConnectorType) SchemaConversionUtils.fixGeronimoSchema(gerConnector, CONNECTOR_QNAME, GerConnectorType.type);
+ }
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/PlanParsingTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,120 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.model.DDBean;
+import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.spi.DConfigBeanRoot;
+import javax.enterprise.deploy.spi.DeploymentConfiguration;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+import org.apache.geronimo.connector.deployment.dconfigbean.ConfigPropertySettings;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConnectionDefinitionDConfigBean;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConnectionDefinitionInstance;
+import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
+import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ *
+ * */
+public class RAR_1_0DConfigBeanTest extends TestSupport {
+ private URL j2eeDD;
+ XmlOptions xmlOptions;
+ private List errors;
+
+ public void testNothing() {}
+
+ public void XtestDConfigBeans() throws Exception {
+ MockRARDeployable deployable = new MockRARDeployable(j2eeDD);
+ DDBeanRoot ddroot = deployable.getDDBeanRoot();
+ DeploymentConfiguration rarConfiguration = new RARConfigurer().createConfiguration(deployable);
+ DConfigBeanRoot root = rarConfiguration.getDConfigBeanRoot(ddroot);
+ assertNotNull(root);
+
+ //outbound
+ DDBean[] connectionDefinitiondds = ddroot.getChildBean(root.getXpaths()[0]);
+ assertEquals(1, connectionDefinitiondds.length);
+ ConnectionDefinitionDConfigBean connectionDefinitionDConfigBean = (ConnectionDefinitionDConfigBean)root.getDConfigBean(connectionDefinitiondds[0]);
+ assertNotNull(connectionDefinitionDConfigBean);
+ ConnectionDefinitionInstance connectionDefinitionInstance1 = new ConnectionDefinitionInstance();
+ connectionDefinitionDConfigBean.setConnectionDefinitionInstance(new ConnectionDefinitionInstance[] {connectionDefinitionInstance1});
+ DDBean[] connectionDefinitionConfigPropDDs = connectionDefinitiondds[0].getChildBean("config-property");
+ assertEquals(4, connectionDefinitionConfigPropDDs.length);
+ ConfigPropertySettings connectionDefinitionSetting1 = connectionDefinitionInstance1.getConfigProperty()[0];
+ connectionDefinitionSetting1.setConfigPropertyValue("TestCDValue1");
+ //connection manager properties
+// connectionDefinitionInstance1.setBlockingTimeout(3000);
+
+ //check the results
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ rarConfiguration.save(baos);
+ baos.flush();
+ byte[] bytes = baos.toByteArray();
+ baos.close();
+ InputStream is = new ByteArrayInputStream(bytes);
+ GerConnectorDocument gcDoc = GerConnectorDocument.Factory.parse(is);
+ GerResourceadapterType ra = gcDoc.getConnector().getResourceadapterArray()[0];
+
+ //connection definition
+ GerConnectionDefinitionType connectionDefinitionType = ra.getOutboundResourceadapter().getConnectionDefinitionArray(0);
+ GerConnectiondefinitionInstanceType connectiondefinitionInstanceType = connectionDefinitionType.getConnectiondefinitionInstanceArray(0);
+ assertEquals("TestCDValue1", connectiondefinitionInstanceType.getConfigPropertySettingArray(0).getStringValue());
+ //connection manager
+ GerConnectionmanagerType connectionmanagerType = connectiondefinitionInstanceType.getConnectionmanager();
+// assertEquals(3000, connectionmanagerType.getBlockingTimeout().intValue());
+
+ //and read back into dconfigbeans
+ rarConfiguration.restore(new ByteArrayInputStream(bytes));
+
+ //outbound
+ connectionDefinitionDConfigBean = (ConnectionDefinitionDConfigBean)root.getDConfigBean(connectionDefinitiondds[0]);
+ assertNotNull(connectionDefinitionDConfigBean);
+ ConnectionDefinitionInstance[] connectionDefinitionInstances = connectionDefinitionDConfigBean.getConnectionDefinitionInstance();
+ connectionDefinitionSetting1 = connectionDefinitionInstances[0].getConfigProperty()[0];
+ assertEquals("TestCDValue1", connectionDefinitionSetting1.getConfigPropertyValue());
+ //connection manager
+// assertEquals(3000, connectionDefinitionInstances[0].getBlockingTimeout());
+
+ }
+
+ protected void XsetUp() throws Exception {
+ File docDir = new File(BASEDIR, "src/test/data/connector_1_0");
+ j2eeDD = new File(docDir, "ra.xml").toURL();
+ xmlOptions = new XmlOptions();
+ xmlOptions.setLoadLineNumbers();
+ errors = new ArrayList();
+ xmlOptions.setErrorListener(errors);
+ }
+
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,189 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.model.DDBean;
+import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.spi.DConfigBeanRoot;
+import javax.enterprise.deploy.spi.DeploymentConfiguration;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.connector.deployment.dconfigbean.AdminObjectDConfigBean;
+import org.apache.geronimo.connector.deployment.dconfigbean.AdminObjectInstance;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConfigPropertySettingDConfigBean;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConfigPropertySettings;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConnectionDefinitionDConfigBean;
+import org.apache.geronimo.connector.deployment.dconfigbean.ConnectionDefinitionInstance;
+import org.apache.geronimo.connector.deployment.dconfigbean.ResourceAdapterDConfigBean;
+import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
+import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType;
+import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
+import org.apache.geronimo.xbeans.geronimo.GerResourceadapterInstanceType;
+import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ *
+ * */
+public class RAR_1_5DConfigBeanTest extends TestCase {
+ public void testNothing() {}
+ /* In the process of replacing the Connector 1.5 DConfigBeans
+ private static final File basedir = new File(System.getProperty("basedir", System.getProperty("user.dir")));
+ private URL j2eeDD;
+ XmlOptions xmlOptions;
+ private List errors;
+
+
+ public void testDConfigBeans() throws Exception {
+ MockRARDeployable deployable = new MockRARDeployable(j2eeDD);
+ DDBeanRoot ddroot = deployable.getDDBeanRoot();
+ DeploymentConfiguration rarConfiguration = new RARConfigurer().createConfiguration(deployable);
+ DConfigBeanRoot root = rarConfiguration.getDConfigBeanRoot(ddroot);
+ assertNotNull(root);
+
+ //resource adapter
+ DDBean resourceAdapterdd = ddroot.getChildBean(root.getXpaths()[0])[0];
+ ResourceAdapterDConfigBean resourceAdapterDConfigBean = (ResourceAdapterDConfigBean) root.getDConfigBean(resourceAdapterdd);
+ assertNotNull(resourceAdapterDConfigBean);
+ resourceAdapterDConfigBean.setResourceAdapterName("TestRAName");
+ DDBean[] resourceAdapterProperties = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[0]);
+ assertEquals(1, resourceAdapterProperties.length);
+ ConfigPropertySettingDConfigBean resourceAdapterSetting = (ConfigPropertySettingDConfigBean)resourceAdapterDConfigBean.getDConfigBean(resourceAdapterProperties[0]);
+ assertNotNull(resourceAdapterSetting);
+ assertEquals("StringValue", resourceAdapterSetting.getConfigPropertyValue());
+ resourceAdapterSetting.setConfigPropertyValue("TestRAValue");
+
+// //admin objects
+// DDBean[] adminObjectdds = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[2]);
+// assertEquals(1, adminObjectdds.length);
+// AdminObjectDConfigBean adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
+// assertNotNull(adminObjectDConfigBean);
+// AdminObjectInstance adminObjectInstance1 = new AdminObjectInstance();
+// adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance1});
+// ConfigPropertySettings adminObjectSetting1 = adminObjectInstance1.getConfigProperty()[0];
+// adminObjectSetting1.setConfigPropertyValue("TestAOValue1");
+//
+// //add a second admin object in first position
+// AdminObjectInstance adminObjectInstance2 = new AdminObjectInstance();
+// adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance2, adminObjectInstance1});
+// ConfigPropertySettings adminObjectSetting2 = adminObjectInstance2.getConfigProperty()[0];
+// adminObjectSetting2.setConfigPropertyValue("TestAOValue2");
+
+ //outbound
+ DDBean[] connectionDefinitiondds = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[1]);
+ assertEquals(2, connectionDefinitiondds.length);
+ ConnectionDefinitionDConfigBean connectionDefinitionDConfigBean = (ConnectionDefinitionDConfigBean)resourceAdapterDConfigBean.getDConfigBean(connectionDefinitiondds[0]);
+ assertNotNull(connectionDefinitionDConfigBean);
+ ConnectionDefinitionInstance connectionDefinitionInstance1 = new ConnectionDefinitionInstance();
+ connectionDefinitionDConfigBean.setConnectionDefinitionInstance(new ConnectionDefinitionInstance[] {connectionDefinitionInstance1});
+ DDBean[] connectionDefinitionConfigPropDDs = connectionDefinitiondds[0].getChildBean("config-property");
+ assertEquals(4, connectionDefinitionConfigPropDDs.length);
+ ConfigPropertySettings connectionDefinitionSetting1 = connectionDefinitionInstance1.getConfigProperty()[0];
+ connectionDefinitionSetting1.setConfigPropertyValue("TestCDValue1");
+ //connection manager properties
+// connectionDefinitionInstance1.setBlockingTimeout(3000);
+
+ //check the results
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ rarConfiguration.save(baos);
+ baos.flush();
+ byte[] bytes = baos.toByteArray();
+ baos.close();
+ InputStream is = new ByteArrayInputStream(bytes);
+ GerConnectorDocument gcDoc = GerConnectorDocument.Factory.parse(is);
+ GerResourceadapterType ra = gcDoc.getConnector().getResourceadapterArray()[0];
+ GerResourceadapterInstanceType rai = ra.getResourceadapterInstance();
+ assertEquals("TestRAName", rai.getResourceadapterName());
+ GerConfigPropertySettingType rasetting = rai.getConfigPropertySettingArray(0);
+ assertEquals("TestRAValue", rasetting.getStringValue());
+
+ //admin object
+// GerAdminobjectType adminobjectType1 = ra.getAdminobjectArray(0);
+// GerAdminobjectInstanceType adminobjectInstanceType2 = adminobjectType1.getAdminobjectInstanceArray(0);
+// assertEquals("TestAOValue1", adminobjectInstanceType2.getConfigPropertySettingArray(0).getStringValue());
+// GerAdminobjectInstanceType adminobjectInstanceType1 = adminobjectType1.getAdminobjectInstanceArray(1);
+// assertEquals("TestAOValue2", adminobjectInstanceType1.getConfigPropertySettingArray(0).getStringValue());
+
+ //connection definition
+ GerConnectionDefinitionType connectionDefinitionType = ra.getOutboundResourceadapter().getConnectionDefinitionArray(0);
+ GerConnectiondefinitionInstanceType connectiondefinitionInstanceType = connectionDefinitionType.getConnectiondefinitionInstanceArray(0);
+ assertEquals("TestCDValue1", connectiondefinitionInstanceType.getConfigPropertySettingArray(0).getStringValue());
+ //connection manager
+ GerConnectionmanagerType connectionmanagerType = connectiondefinitionInstanceType.getConnectionmanager();
+// assertEquals(3000, connectionmanagerType.getBlockingTimeout().intValue());
+
+ //and read back into dconfigbeans
+ rarConfiguration.restore(new ByteArrayInputStream(bytes));
+ //resource adapter
+ resourceAdapterDConfigBean = (ResourceAdapterDConfigBean) root.getDConfigBean(resourceAdapterdd);
+ assertNotNull(resourceAdapterDConfigBean);
+ assertEquals("TestRAName", resourceAdapterDConfigBean.getResourceAdapterName());
+ resourceAdapterSetting = (ConfigPropertySettingDConfigBean)resourceAdapterDConfigBean.getDConfigBean(resourceAdapterProperties[0]);
+ assertNotNull(resourceAdapterSetting);
+ assertEquals("TestRAValue", resourceAdapterSetting.getConfigPropertyValue());
+
+// //admin objects
+// adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
+// assertNotNull(adminObjectDConfigBean);
+// AdminObjectInstance[] adminObjectInstances = adminObjectDConfigBean.getAdminObjectInstance();
+// assertEquals(2, adminObjectInstances.length);
+// adminObjectSetting1 = adminObjectInstances[1].getConfigProperty()[0];
+// assertEquals("TestAOValue2", adminObjectSetting1.getConfigPropertyValue());
+//
+// //second admin object is in first position ..not any longer:-(((
+// adminObjectSetting2 = adminObjectInstances[0].getConfigProperty()[0];
+// assertEquals("TestAOValue1", adminObjectSetting2.getConfigPropertyValue());
+
+ //outbound
+ connectionDefinitionDConfigBean = (ConnectionDefinitionDConfigBean)resourceAdapterDConfigBean.getDConfigBean(connectionDefinitiondds[0]);
+ assertNotNull(connectionDefinitionDConfigBean);
+ ConnectionDefinitionInstance[] connectionDefinitionInstances = connectionDefinitionDConfigBean.getConnectionDefinitionInstance();
+ connectionDefinitionSetting1 = connectionDefinitionInstances[0].getConfigProperty()[0];
+ assertEquals("TestCDValue1", connectionDefinitionSetting1.getConfigPropertyValue());
+ //connection manager
+// assertEquals(3000, connectionDefinitionInstances[0].getBlockingTimeout());
+
+ }
+
+
+
+ protected void setUp() throws Exception {
+ File docDir = new File(basedir, "src/test-data/connector_1_5");
+ j2eeDD = new File(docDir, "ra.xml").toURL();
+ xmlOptions = new XmlOptions();
+ xmlOptions.setLoadLineNumbers();
+ errors = new ArrayList();
+ xmlOptions.setErrorListener(errors);
+ }
+*/
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,67 @@
+/**
+ * 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.geronimo.connector.deployment;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * ejb 1.1 dtd appears to be a subset of ejb 2.0 dtd so the same xsl should
+ * work for both.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SchemaConversionTest extends XmlBeansTestSupport {
+ private ClassLoader classLoader = this.getClass().getClassLoader();
+
+ public void testConnector10ToConnector15Transform() throws Exception {
+ URL srcXml = classLoader.getResource("j2ee_1_3dtd/ra-10.xml");
+ URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ra-15.xml");
+ XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+ XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+ XmlBeansUtil.validateDD(expected);
+ xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject);
+ List problems = new ArrayList();
+ boolean ok = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences: " + problems, ok);
+ //make sure trying to convert twice has no bad effects
+ XmlCursor cursor2 = xmlObject.newCursor();
+ try {
+ String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
+ String version = "1.4";
+ assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
+ } finally {
+ cursor2.dispose();
+ }
+ boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences after reconverting to schema: " + problems, ok2);
+ //do the whole transform twice...
+ xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject);
+ boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences after reconverting to application schema: " + problems, ok3);
+ }
+
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,93 @@
+/**
+ * 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.geronimo.connector.deployment.annotation;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+
+import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
+import org.apache.geronimo.connector.deployment.ResourceRefBuilder;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.geronimo.xbeans.javaee.WebAppDocument;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xbean.finder.ClassFinder;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ * Testcases for each of the various AnnotationHelper class
+ */
+public class AnnotationHelperTest extends XmlBeansTestSupport {
+
+ private Class[] classes = {ResourceAnnotationTest.class};
+
+ private ClassFinder classFinder = new ClassFinder(classes);
+ private ClassLoader classLoader = this.getClass().getClassLoader();
+ private XmlOptions options = new XmlOptions();
+
+ public void testResourceAnnotationHelper() throws Exception {
+
+ //-------------------------------------------------
+ // Ensure annotations are discovered correctly
+ //-------------------------------------------------
+ List<Class> annotatedClasses = classFinder.findAnnotatedClasses(Resources.class);
+ assertNotNull(annotatedClasses);
+ assertEquals(1, annotatedClasses.size());
+ assertTrue(annotatedClasses.contains(ResourceAnnotationTest.class));
+
+ List<Method> annotatedMethods = classFinder.findAnnotatedMethods(Resource.class);
+ assertNotNull(annotatedMethods);
+ assertEquals(2, annotatedMethods.size());
+ assertTrue(annotatedMethods.contains(ResourceAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod1", new Class[]{String.class})));
+ assertTrue(annotatedMethods.contains(ResourceAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod2", new Class[]{String.class})));
+
+ List<Field> annotatedFields = classFinder.findAnnotatedFields(Resource.class);
+ assertNotNull(annotatedFields);
+ assertEquals(2, annotatedFields.size());
+ assertTrue(annotatedFields.contains(ResourceAnnotationTest.class.getDeclaredField("annotatedField1")));
+ assertTrue(annotatedFields.contains(ResourceAnnotationTest.class.getDeclaredField("annotatedField2")));
+
+ //-------------------------------------------------
+ // Ensure annotations are processed correctly
+ //-------------------------------------------------
+ //
+ // 1. resource-ref
+ //
+ URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
+ XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
+ WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
+ WebAppType webApp = webAppDoc.getWebApp();
+ AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
+ ResourceAnnotationHelper.processAnnotations(annotatedWebApp, classFinder, ResourceRefBuilder.ResourceRefProcessor.INSTANCE);
+ URL expectedXML = classLoader.getResource("annotation/resource-ref-expected.xml");
+ XmlObject expected = XmlObject.Factory.parse(expectedXML);
+ log.debug("[@Resource <resource-ref> Source XML] " + '\n' + webApp.toString() + '\n');
+ log.debug("[@Resource <resource-ref> Expected XML]" + '\n' + expected.toString() + '\n');
+ List problems = new ArrayList();
+ boolean ok = compareXmlObjects(webApp, expected, problems);
+ assertTrue("Differences: " + problems, ok);
+ }
+}
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java?rev=706357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java Mon Oct 20 11:23:36 2008
@@ -0,0 +1,70 @@
+/**
+ * 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.geronimo.connector.deployment.annotation;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+
+@Resources ({
+ @Resource(name = "Resource1", // 2. env-entry
+ type = java.lang.String.class,
+ authenticationType = Resource.AuthenticationType.APPLICATION,
+ shareable = true,
+ description = "description1",
+ mappedName = "mappedName1"),
+ @Resource(name = "Resource2", // 3. service-ref
+ type = javax.xml.ws.Service.class,
+ authenticationType = Resource.AuthenticationType.APPLICATION)
+ })
+public class ResourceAnnotationTest {
+
+ @Resource(name = "Resource3",
+ type = java.lang.Object.class,
+ authenticationType = Resource.AuthenticationType.CONTAINER,
+ shareable = true,
+ mappedName = "mappedName3")
+ boolean annotatedField1;
+
+ @Resource(name = "Resource4",
+ type = javax.xml.ws.Service.class, // 3. service-ref
+ shareable = false,
+ description = "description4",
+ mappedName = "mappedName4")
+ String annotatedField2;
+
+ //------------------------------------------------------------------------------------------
+ // Method name (for setter-based injection) must follow JavaBeans conventions:
+ // -- Must start with "set"
+ // -- Have one parameter
+ // -- Return void
+ //------------------------------------------------------------------------------------------
+ @Resource(name = "Resource5", // 1. resource-ref
+ type = javax.sql.DataSource.class,
+ authenticationType = Resource.AuthenticationType.CONTAINER,
+ description = "description5",
+ mappedName = "mappedName5")
+ public void setAnnotatedMethod1(String string) {
+ }
+
+ @Resource // 2. env-entry
+ public void setAnnotatedMethod2(String string) {
+ }
+
+}