[jboss-cvs] JBossAS SVN: r110803 - in projects/jboss-jca/trunk: adapters/src/test/resources and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 28 14:07:45 EST 2011
Author: jesper.pedersen
Date: 2011-02-28 14:07:44 -0500 (Mon, 28 Feb 2011)
New Revision: 110803
Added:
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2SecurityDomainTestCase.java
projects/jboss-jca/trunk/adapters/src/test/resources/h2-sd-ds.xml
Modified:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
Log:
Change getSubjectFactory() signature. Add security-domain test case
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2SecurityDomainTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2SecurityDomainTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2SecurityDomainTestCase.java 2011-02-28 19:07:44 UTC (rev 110803)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.adapters.jdbc.unit;
+
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
+
+import java.sql.Connection;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Test cases for getting a connection from the H2 database backed by a security domain
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class H2SecurityDomainTestCase
+{
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- GIVEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+ /**
+ * Define the deployment
+ * @return The deployment archive
+ * @throws Exception in case of errors
+ */
+ @Deployment
+ public static ResourceAdapterArchive createDeployment() throws Exception
+ {
+ String archiveName = "jdbc-local.rar";
+ ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcLocal(archiveName);
+ ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+ external.add(raa, "/");
+ external.addResource("h2-sd-ds.xml", "datasources-ds.xml");
+ return external;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- WHEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+ //
+ @Resource(mappedName = "java:/H2DS")
+ private DataSource ds;
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- THEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Basic
+ * @exception Throwable Thrown if case of an error
+ */
+ @Test
+ public void testBasic() throws Throwable
+ {
+ assertNotNull(ds);
+ Connection c = ds.getConnection();
+ assertNotNull(c);
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/resources/h2-sd-ds.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/resources/h2-sd-ds.xml (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/resources/h2-sd-ds.xml 2011-02-28 19:07:44 UTC (rev 110803)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+ <datasource jndi-name="java:/H2DS" pool-name="H2DS">
+ <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+ <driver-class>org.h2.Driver</driver-class>
+ <security>
+ <security-domain>DefaultSecurityDomain</security-domain>
+ </security>
+ </datasource>
+
+</datasources>
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-02-28 17:30:45 UTC (rev 110802)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-02-28 19:07:44 UTC (rev 110803)
@@ -1576,7 +1576,13 @@
}
}
- protected abstract SubjectFactory getSubjectFactory(String securityDomain);
+ /**
+ * Get a subject factory
+ * @param securityDomain The security domain
+ * @return The subject factory
+ * @exception DeployException Thrown if the security domain can't be resolved
+ */
+ protected abstract SubjectFactory getSubjectFactory(String securityDomain) throws DeployException;
/**
* Get management views for config property's
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java 2011-02-28 17:30:45 UTC (rev 110802)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java 2011-02-28 19:07:44 UTC (rev 110803)
@@ -472,17 +472,21 @@
}
@Override
- protected SubjectFactory getSubjectFactory(String securityDomain)
+ protected SubjectFactory getSubjectFactory(String securityDomain) throws DeployException
{
+ if (securityDomain == null)
+ throw new IllegalArgumentException("SecurityDomain is null");
+
+ if (securityDomain.trim().equals(""))
+ throw new IllegalArgumentException("SecurityDomain is empty");
+
try
{
- return kernel.getBean(securityDomain + "-subjectfactory", SubjectFactory.class);
+ return kernel.getBean(securityDomain, SubjectFactory.class);
}
- catch (Throwable e)
+ catch (Throwable t)
{
- log.error("Kernel loookup of securityDomain " + securityDomain + "got an error", e);
- return null;
+ throw new DeployException("Error during loookup of security domain: " + securityDomain, t);
}
-
}
}
More information about the jboss-cvs-commits
mailing list