[prev in list] [next in list] [prev in thread] [next in thread]
List: openejb-cvs
Subject: [openejb-scm] [2586] branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment:
From: dain () codehaus ! org
Date: 2006-03-28 0:13:48
Message-ID: 20060328001348.30006.qmail () codehaus ! org
[Download RAW message or body]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li { font-family: verdana,arial,helvetica,sans-serif; \
font-size: 10pt; } #msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: \
6px; } #msg ul, pre { overflow: auto; }
#patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<title>[2586] branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment: \
Reenabled and fixed EJBQLTest</title> </head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2586</dd>
<dt>Author</dt> <dd>dain</dd>
<dt>Date</dt> <dd>2006-03-27 19:13:43 -0500 (Mon, 27 Mar 2006)</dd>
</dl>
<h3>Log Message</h3>
<pre>Reenabled and fixed EJBQLTest</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentDepl \
oymentHelperjava">branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java</a></li>
<li><a href="#branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentent \
itycmpejbqlEJBQLTestjava">branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/ejbql/EJBQLTest.java</a></li>
<li><a href="#branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentsls \
bBasicStatelessContainerTestjava">branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/slsb/BasicStatelessContainerTest.java</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymententi \
tycmpSerializableDataSourcejava">branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/SerializableDataSource.java</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentKern \
elHelperjava">branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentDeploymentHelperjava"></a>
<div class="modfile"><h4>Modified: \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java \
(2585 => 2586)</h4> <pre class="diff">
<span class="info">--- \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java 2006-03-27 \
00:56:03 UTC (rev 2585)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java 2006-03-28 \
00:13:43 UTC (rev 2586) </span><span class="lines">@@ -112,7 +112,6 @@
</span><span class="cx"> * @version $Revision$ $Date$
</span><span class="cx"> */
</span><span class="cx"> public class DeploymentHelper extends TestCase {
</span><del>-
</del><span class="cx"> public static final Environment DEFAULT_ENVIRONMENT = new \
Environment(); </span><span class="cx"> public static final Environment \
ENVIRONMENT = new Environment(); </span><span class="cx">
</span><span class="lines">@@ -135,6 +134,7 @@
</span><span class="cx">
</span><span class="cx"> protected Kernel kernel;
</span><span class="cx"> public AbstractName ctcName;
</span><ins>+ public AbstractName tmName;
</ins><span class="cx"> public AbstractName tcmName;
</span><span class="cx"> public AbstractName txTimerName;
</span><span class="cx"> public AbstractName nonTxTimerName;
</span><span class="lines">@@ -150,6 +150,7 @@
</span><span class="cx"> protected final AbstractName CONTAINER_NAME = new \
AbstractName(testConfigurationArtifact, Collections.singletonMap("ejb", \
"Mock")); </span><span class="cx">
</span><span class="cx"> protected void setUp() throws Exception {
</span><ins>+ super.setUp();
</ins><span class="cx"> \
defaultEnvironment.getProperties().put(NameFactory.JSR77_BASE_NAME_PROPERTY, \
BASE_NAME); </span><span class="cx"> cl = this.getClass().getClassLoader();
</span><span class="cx"> kernel = \
KernelFactory.newInstance().createKernel("test"); </span><span \
class="lines">@@ -181,11 +182,12 @@ </span><span class="cx"> \
xidFactory.setAttribute("tmId", "tmId".getBytes()); </span><span \
class="cx"> </span><span class="cx"> GBeanData tm = \
bootstrap.addGBean("TransactionManager", \
TransactionManagerImplGBean.GBEAN_INFO); </span><ins>+ tmName = \
tm.getAbstractName(); </ins><span class="cx"> \
tm.setReferencePattern("XidFactory", xidFactory.getAbstractName()); \
</span><span class="cx"> \
tm.setAttribute("defaultTransactionTimeoutSeconds", new Integer(10)); \
</span><span class="cx"> </span><span class="cx"> GBeanData tcm = \
bootstrap.addGBean("TransactionContextManager", \
TransactionContextManagerGBean.GBEAN_INFO); </span><del>- \
tcm.setReferencePattern("TransactionManager", tm.getAbstractName()); \
</del><ins>+ tcm.setReferencePattern("TransactionManager", tmName); \
</ins><span class="cx"> tcmName = tcm.getAbstractName(); </span><span \
class="cx"> ctcName = \
bootstrap.addGBean("ConnectionTrackingCoordinator", \
ConnectionTrackingCoordinatorGBean.GBEAN_INFO).getAbstractName(); </span><span \
class="cx"> </span><span class="lines">@@ -256,17 +258,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>- private AbstractName createConnectionObjectName(Artifact artifact) {
- AbstractName jcaResourceName = createJCAResourceName(artifact);
- AbstractName jcaConnectionFactoryName = \
naming.createChildName(jcaResourceName, "DefaultDatasource", \
NameFactory.JCA_CONNECTION_FACTORY);
- return naming.createChildName(jcaConnectionFactoryName, \
"DefaultDatasource", \
NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
- }
</del><span class="cx"> private AbstractName \
createJCAResourceAdapterName(Artifact artifact) { </span><span class="cx"> \
AbstractName jcaResourceName = createJCAResourceName(artifact); </span><span \
class="cx"> return naming.createChildName(jcaResourceName, \
"MockRA", NameFactory.JCA_RESOURCE_ADAPTER); </span><span class="cx"> }
</span><span class="cx">
</span><del>- private AbstractName createJCAResourceName(Artifact artifact) {
</del><ins>+ protected AbstractName createJCAResourceName(Artifact artifact) {
</ins><span class="cx"> AbstractName moduleName = \
createResourceAdapterModuleName(artifact); </span><span class="cx"> \
AbstractName resourceAdapterName = naming.createChildName(moduleName, \
artifact.toString(), NameFactory.RESOURCE_ADAPTER); </span><span class="cx"> \
AbstractName jcaResourceName = naming.createChildName(resourceAdapterName, \
artifact.toString(), NameFactory.JCA_RESOURCE); </span><span class="lines">@@ -281,6 \
+278,7 @@ </span><span class="cx">
</span><span class="cx"> protected void tearDown() throws Exception {
</span><span class="cx"> kernel.shutdown();
</span><ins>+ super.tearDown();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> public static class MockConfigStore implements \
ConfigurationStore { </span><span class="lines">@@ -396,7 +394,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- /////////////////////////////
</del><span class="cx"> public static AbstractNameQuery createEjbNameQuery(String \
name, String j2eeType, String ejbModule) { </span><span class="cx"> Map \
properties = new LinkedHashMap(); </span><span class="cx"> \
properties.put("name", name); </span><span class="lines">@@ -404,5 +401,4 \
@@ </span><span class="cx"> properties.put("EJBModule", ejbModule);
</span><span class="cx"> return new AbstractNameQuery(null, properties);
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> }
</span></pre></div>
<a id="branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentKernelHelperjava"></a>
<div class="delfile"><h4>Deleted: \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java \
(2585 => 2586)</h4> <pre class="diff">
<span class="info">--- \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java 2006-03-27 \
00:56:03 UTC (rev 2585)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java 2006-03-28 \
00:13:43 UTC (rev 2586) </span><span class="lines">@@ -1,143 +0,0 @@
</span><del>-/**
- *
- * Copyright 2003-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.
- */
-package org.openejb.deployment;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationData;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.KernelConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
-import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.repository.Environment;
-
-/**
- * @version $Rev$ $Date$
- */
-public class KernelHelper {
- //TODO configId delete this, some disabled tests still use it.
- public static final Environment DEFAULT_ENVIRONMENT = new Environment();
- public static final Environment ENVIRONMENT = new Environment();
-
- static {
- Artifact defaultConfigId = \
Artifact.create("geronimo/server/1/car");
- DEFAULT_ENVIRONMENT.setConfigId(defaultConfigId);
- Artifact configId = Artifact.create("test/test/1/car");
- ENVIRONMENT.setConfigId(configId);
- }
-
-
-
- public static class MockConfigStore implements ConfigurationStore {
- private static final Map locations = new HashMap();
-
- public MockConfigStore() {
- }
-
- public void install(ConfigurationData configurationData) throws IOException, \
InvalidConfigException {
- }
-
- public void uninstall(Artifact configID) throws NoSuchConfigException, \
IOException {
- }
-
- public GBeanData loadConfiguration(Artifact configId) throws \
NoSuchConfigException, IOException, InvalidConfigException {
- AbstractName configurationObjectName = \
Configuration.getConfigurationAbstractName(configId);
- GBeanData configData = new GBeanData(configurationObjectName, \
Configuration.GBEAN_INFO);
- Environment environment = new Environment();
- environment.setConfigId(configId);
- environment.getProperties().put(NameFactory.JSR77_BASE_NAME_PROPERTY, \
"geronimo.test:J2EEServer=geronimo");
- configData.setAttribute("environment", environment);
- configData.setAttribute("gBeanState", NO_OBJECTS_OS);
- configData.setAttribute("moduleType", \
ConfigurationModuleType.CAR);
-
- return configData;
- }
-
- public boolean containsConfiguration(Artifact configID) {
- return true;
- }
-
- public String getObjectName() {
- return null;
- }
-
- public List listConfigurations() {
- return null;
- }
-
- public File createNewConfigurationDir(Artifact configId) {
- try {
- File file = DeploymentUtil.createTempDir();
- locations.put(configId, file);
- return file;
- } catch (IOException e) {
- return null;
- }
- }
-
- public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, \
MalformedURLException {
- File file = (File) locations.get(configId);
- if (file == null) {
-// throw new NoSuchConfigException("nothing for configid " \
+ configId);
- return new File("foo").toURL();
- }
- return new URL(file.toURL(), uri.toString());
- }
-
- public final static GBeanInfo GBEAN_INFO;
-
- private static final byte[] NO_OBJECTS_OS;
-
- static {
- GBeanInfoBuilder infoBuilder = \
GBeanInfoBuilder.createStatic(MockConfigStore.class, \
NameFactory.CONFIGURATION_STORE);
- infoBuilder.addInterface(ConfigurationStore.class);
- GBEAN_INFO = infoBuilder.getBeanInfo();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.flush();
- NO_OBJECTS_OS = baos.toByteArray();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
</del></pre></div>
<a id="branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymententitycmpSerializableDataSourcejava"></a>
<div class="addfile"><h4>Added: \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/SerializableDataSource.java \
(2585 => 2586)</h4> <pre class="diff">
<span class="info">--- \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/SerializableDataSource.java 2006-03-27 \
00:56:03 UTC (rev 2585)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/SerializableDataSource.java 2006-03-28 \
00:13:43 UTC (rev 2586) </span><span class="lines">@@ -0,0 +1,104 @@
</span><ins>+/**
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ * statements and notices. Redistributions must also contain a
+ * copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. The name "OpenEJB" must not be used to endorse or promote
+ * products derived from this Software without prior written
+ * permission of The OpenEJB Group. For written permission,
+ * please contact info@openejb.org.
+ *
+ * 4. Products derived from this Software may not be called "OpenEJB"
+ * nor may "OpenEJB" appear in their names without prior written
+ * permission of The OpenEJB Group. OpenEJB is a registered
+ * trademark of The OpenEJB Group.
+ *
+ * 5. Due credit should be given to the OpenEJB Project
+ * (http://openejb.org/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
+ *
+ * $Id: file,v 1.1 2005/02/18 23:22:00 user Exp $
+ */
+package org.openejb.deployment.entity.cmp;
+
+import java.io.Serializable;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.ArrayList;
+import javax.sql.DataSource;
+
+/**
+ * DO NOT USE THIS FOR A REAL DATA SOURCE!!!!!!
+ * @version $Revision$ $Date$
+ */
+public class SerializableDataSource implements DataSource, Serializable {
+ private static final long serialVersionUID = 4066474294074568165L;
+ private static final List dataSources = new ArrayList();
+
+ private transient final DataSource dataSource;
+ private final int index;
+
+ public SerializableDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ synchronized (dataSources) {
+ index = dataSources.size();
+ dataSources.add(dataSource);
+ }
+ }
+
+ public Connection getConnection() throws SQLException {
+ return dataSource.getConnection();
+ }
+
+ public Connection getConnection(String username, String password) throws \
SQLException { + return dataSource.getConnection(username, password);
+ }
+
+ public PrintWriter getLogWriter() throws SQLException {
+ return dataSource.getLogWriter();
+ }
+
+ public void setLogWriter(PrintWriter out) throws SQLException {
+ dataSource.setLogWriter(out);
+ }
+
+ public void setLoginTimeout(int seconds) throws SQLException {
+ dataSource.setLoginTimeout(seconds);
+ }
+
+ public int getLoginTimeout() throws SQLException {
+ return dataSource.getLoginTimeout();
+ }
+
+ protected Object readResolve() {
+ synchronized (dataSources) {
+ DataSource dataSource = (DataSource) dataSources.get(index);
+ return new SerializableDataSource(dataSource);
+ }
+ }
+}
</ins></pre></div>
<a id="branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymententitycmpejbqlEJBQLTestjava"></a>
<div class="modfile"><h4>Modified: \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/ejbql/EJBQLTest.java \
(2585 => 2586)</h4> <pre class="diff">
<span class="info">--- \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/ejbql/EJBQLTest.java 2006-03-27 \
00:56:03 UTC (rev 2585)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/ejbql/EJBQLTest.java 2006-03-28 \
00:13:43 UTC (rev 2586) </span><span class="lines">@@ -52,41 +52,40 @@
</span><span class="cx"> import java.sql.Connection;
</span><span class="cx"> import java.sql.SQLException;
</span><span class="cx"> import java.sql.Statement;
</span><ins>+import java.util.Collections;
</ins><span class="cx"> import java.util.HashMap;
</span><span class="cx"> import java.util.HashSet;
</span><del>-import java.util.Set;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
</del><span class="cx"> import javax.sql.DataSource;
</span><span class="cx"> import javax.transaction.TransactionManager;
</span><span class="cx">
</span><del>-import junit.framework.TestCase;
-
</del><span class="cx"> import org.apache.geronimo.deployment.util.DeploymentUtil;
</span><del>-import org.apache.geronimo.gbean.GBeanData;
</del><span class="cx"> import org.apache.geronimo.gbean.AbstractName;
</span><span class="cx"> import org.apache.geronimo.gbean.AbstractNameQuery;
</span><ins>+import org.apache.geronimo.gbean.GBeanData;
</ins><span class="cx"> import org.apache.geronimo.j2ee.deployment.EARContext;
</span><del>-import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
-import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
</del><span class="cx"> import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
</span><del>-import org.apache.geronimo.kernel.Kernel;
</del><span class="cx"> import \
org.apache.geronimo.kernel.config.ConfigurationModuleType; </span><del>-import \
org.apache.geronimo.kernel.jmx.JMXUtil; </del><ins>+import \
org.apache.geronimo.kernel.config.ConfigurationData; +import \
org.apache.geronimo.kernel.config.ConfigurationManager; +import \
org.apache.geronimo.kernel.config.ConfigurationUtil; +import \
org.apache.geronimo.kernel.config.Configuration; +import \
org.apache.geronimo.kernel.repository.Environment; </ins><span class="cx"> import \
org.apache.geronimo.kernel.repository.Repository; </span><ins>+import \
org.apache.geronimo.kernel.repository.Artifact; +import \
org.apache.geronimo.kernel.repository.Dependency; +import \
org.apache.geronimo.kernel.repository.ImportType; </ins><span class="cx"> import \
org.apache.geronimo.xbeans.j2ee.EjbJarDocument; </span><span class="cx"> import \
org.apache.geronimo.xbeans.j2ee.EjbJarType; </span><span class="cx"> import \
org.apache.xmlbeans.XmlObject; </span><span class="cx"> import \
org.axiondb.jdbc.AxionDataSource; </span><del>-import org.openejb.ContainerIndex;
</del><ins>+import org.openejb.entity.cmp.CMPEJBContainer;
</ins><span class="cx"> import org.openejb.deployment.CMPContainerBuilder;
</span><span class="cx"> import org.openejb.deployment.CMPEntityBuilderTestUtil;
</span><span class="cx"> import org.openejb.deployment.DeploymentHelper;
</span><span class="cx"> import org.openejb.deployment.MockConnectionProxyFactory;
</span><span class="cx"> import org.openejb.deployment.OpenEJBModuleBuilder;
</span><span class="cx"> import org.openejb.deployment.Schemata;
</span><del>-//import org.openejb.deployment.KernelHelper;
</del><ins>+import org.openejb.deployment.entity.cmp.SerializableDataSource;
</ins><span class="cx"> import org.openejb.deployment.pkgen.TranQLPKGenBuilder;
</span><span class="cx"> import org.openejb.dispatch.InterfaceMethodSignature;
</span><span class="cx"> import org.openejb.transaction.TransactionPolicySource;
</span><span class="lines">@@ -103,198 +102,173 @@
</span><span class="cx"> /**
</span><span class="cx"> * @version $Revision$ $Date$
</span><span class="cx"> */
</span><del>-public class EJBQLTest extends TestCase {
- public void testNothing() {}
-// private static final File basedir = new \
File(System.getProperty("basedir", \
System.getProperty("user.dir")));
-// private static final String j2eeDomainName = "openejb.server";
-// private static final String j2eeServerName = "TestOpenEJBServer";
-// private static final J2eeContext j2eeContext = new \
J2eeContextImpl(j2eeDomainName, j2eeServerName, NameFactory.NULL, \
NameFactory.EJB_MODULE, "MockModule", "testapp", \
NameFactory.J2EE_MODULE);
-// protected static final AbstractName CI_NAME = \
JMXUtil.getAbstractName("openejb.server:role=ContainerIndex");
-// protected static final AbstractName C_NAME_A;
-//
-// static {
-// try {
-// C_NAME_A = NameFactory.getEjbComponentName(null, null, null, null, \
"A", NameFactory.ENTITY_BEAN, j2eeContext);
-// } catch (MalformedAbstractNameException e) {
-// throw new AssertionError(e);
-// }
-// }
-//
-// private Repository repository = null;
-// private Kernel kernel;
-// private DataSource ds;
-// private EJBSchema ejbSchema;
-// private SQLSchema sqlSchema;
-// private GlobalSchema cacheSchema;
-// private AHome aHome;
-// private ALocalHome aLocalHome;
-// private TransactionManager tm;
-//
-// public void testHomeFindTest() throws Exception {
-// ARemote a = aHome.findTest("test");
-// assertEquals(new Integer(1), a.getField1());
-// }
-//
-// public void testLocalHomeFindTest() throws Exception {
-// ALocal a = aLocalHome.findTest("test");
-// assertEquals(new Integer(1), a.getField1());
-// }
-//
-// public void testSelectTest() throws Exception {
-// ALocal a = aLocalHome.selectTest("test");
-// assertEquals(new Integer(1), a.getField1());
-// }
-//
-// private void buildDBSchema(Connection c) throws Exception {
-// Statement s = c.createStatement();
-// try {
-// s.execute("DROP TABLE A");
-// } catch (SQLException e) {
-// // ignore
-// }
-//
-// s.execute("CREATE TABLE A(A1 INTEGER, A2 VARCHAR(50))");
-//
-// s.execute("INSERT INTO A(A1, A2) VALUES(1, 'test')");
-// s.close();
-// c.close();
-// }
-//
-// private String getEjbJarDD() {
-// return "src/test-cmp/ejb-ql/ejb-jar.xml";
-// }
-//
-// private String getOpenEjbJarDD() {
-// return "src/test-cmp/ejb-ql/openejb-jar.xml";
-// }
-//
-// protected void setUp() throws Exception {
-// ds = new AxionDataSource("jdbc:axiondb:testdb");
-//
-// Connection c = ds.getConnection("root", null);
-// buildDBSchema(c);
-//
-// kernel = DeploymentHelper.setUpKernelWithTransactionManager();
-// DeploymentHelper.setUpTimer(kernel);
-//
-// tm = (TransactionManager) \
kernel.getProxyManager().createProxy(DeploymentHelper.TRANSACTIONMANAGER_NAME, \
TransactionManager.class);
-// TransactionManagerDelegate tmDelegate = new TransactionManagerDelegate();
-//
-// tmDelegate.setTransactionManager(tm);
-//
-// File ejbJarFile = new File(basedir, getEjbJarDD());
-// File openejbJarFile = new File(basedir, getOpenEjbJarDD());
-// EjbJarType ejbJarType = ((EjbJarDocument) \
XmlObject.Factory.parse(ejbJarFile)).getEjbJar();
-// OpenejbOpenejbJarType openejbJarType = ((OpenejbOpenejbJarDocument) \
XmlObject.Factory.parse(openejbJarFile)).getOpenejbJar();
-//
-// OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(null, null, \
null, null);
-// CMPEntityBuilderTestUtil builder = new \
CMPEntityBuilderTestUtil(moduleBuilder);
-// TranQLPKGenBuilder pkGen = new TranQLPKGenBuilder();
-// File tempDir = DeploymentUtil.createTempDir();
-//
-// try {
-// EARContext earContext = new EARContext(tempDir,
-// KernelHelper.ENVIRONMENT,
-// ConfigurationModuleType.EJB,
-// kernel.getNaming(),
-// repository,
-// configurationStore,
-// serverName,
-// NameFactory.NULL,
-// null,
-// null,
-// null,
-// null,
-// null,
-// null);
-//
-// ClassLoader cl = Thread.currentThread().getContextClassLoader();
-// Schemata schemata = builder.buildCMPSchema(earContext, j2eeContext, \
ejbJarType, openejbJarType, cl, pkGen, ds);
-//
-// ejbSchema = schemata.getEjbSchema();
-// sqlSchema = schemata.getSqlSchema();
-// cacheSchema = schemata.getGlobalSchema();
-//
-// GBeanData containerIndex = new GBeanData(ContainerIndex.GBEAN_INFO);
-// Set patterns = new HashSet();
-// patterns.add(C_NAME_A);
-// containerIndex.setReferencePatterns("EJBContainers", \
patterns);
-// start(CI_NAME, containerIndex);
-//
-// AbstractName connectionProxyFactoryAbstractName = \
NameFactory.getComponentName(null, null, null, NameFactory.JCA_RESOURCE, \
"jcamodule", "testcf", NameFactory.JCA_CONNECTION_FACTORY, \
j2eeContext);
-// GBeanData connectionProxyFactoryGBean = new \
GBeanData(connectionProxyFactoryAbstractName, \
MockConnectionProxyFactory.GBEAN_INFO);
-// kernel.loadGBean(connectionProxyFactoryGBean, \
this.getClass().getClassLoader());
-// kernel.startGBean(connectionProxyFactoryAbstractName);
-//
-// FrontEndCacheDelegate cacheDelegate = new FrontEndCacheDelegate();
-// setUpContainer(ejbSchema.getEJB("A"), ABean.class, \
AHome.class, ARemote.class, ALocalHome.class, ALocal.class, C_NAME_A, tmDelegate, \
cacheDelegate);
-//
-// aLocalHome = (ALocalHome) kernel.getAttribute(C_NAME_A, \
"ejbLocalHome");
-// aHome = (AHome) kernel.getAttribute(C_NAME_A, "ejbHome");
-// } finally {
-// DeploymentUtil.recursiveDelete(tempDir);
-// }
-// }
-//
-//
-// private void setUpContainer(EJB ejb, Class beanClass, Class homeClass, Class \
remoteClass, Class localHomeClass, Class localClass, AbstractName containerName, \
TransactionManagerDelegate tmDelegate, FrontEndCacheDelegate cacheDelegate) throws \
Exception {
-// CMPContainerBuilder builder = new CMPContainerBuilder();
-// builder.setClassLoader(this.getClass().getClassLoader());
-// builder.setContainerId(containerName.toURI().toString());
-// builder.setEJBName(ejb.getName());
-// builder.setBeanClassName(beanClass.getName());
-// builder.setHomeInterfaceName(homeClass.getName());
-// builder.setLocalHomeInterfaceName(localHomeClass.getName());
-// builder.setRemoteInterfaceName(remoteClass.getName());
-// builder.setLocalInterfaceName(localHomeClass.getName());
-// builder.setPrimaryKeyClassName(ejb.getPrimaryKeyClass().getName());
-//
-// builder.setJndiNames(new String[0]);
-// builder.setLocalJndiNames(new String[0]);
-// builder.setUnshareableResources(new HashSet());
-// builder.setTransactionPolicySource(new TransactionPolicySource() {
-// public TransactionPolicyType getTransactionPolicy(String methodIntf, \
InterfaceMethodSignature signature) {
-// return TransactionPolicyType.Required;
-// }
-// });
-//
-// builder.setEJBSchema(ejbSchema);
-// builder.setSQLSchema(sqlSchema);
-// builder.setGlobalSchema(cacheSchema);
-// builder.setComponentContext(new HashMap());
-// builder.setTransactionManagerDelegate(tmDelegate);
-// builder.setFrontEndCacheDelegate(cacheDelegate);
-//
-// GBeanData container = builder.createConfiguration(containerName,
-// new \
AbstractNameQuery(DeploymentHelper.TRANSACTIONCONTEXTMANAGER_NAME),
-// new \
AbstractNameQuery(DeploymentHelper.TRACKEDCONNECTIONASSOCIATOR_NAME),
-// null);
-//
-// container.setReferencePattern("Timer", \
DeploymentHelper.TRANSACTIONALTIMER_NAME);
-// start(containerName, container);
-// }
-//
-// protected void tearDown() throws Exception {
-// kernel.getProxyManager().destroyProxy(tm);
-// kernel.shutdown();
-// java.sql.Connection c = ds.getConnection();
-// c.createStatement().execute("SHUTDOWN");
-// }
-//
-// private void start(AbstractName name, GBeanData instance) throws Exception {
-// instance.setAbstractName(name);
-// kernel.loadGBean(instance, this.getClass().getClassLoader());
-// kernel.startGBean(name);
-// }
-//
-// protected class EJBClass {
-// public EJBClass(Class bean, Class home, Class local) {
-// this.bean = bean;
-// this.home = home;
-// this.local = local;
-// };
-// public Class bean;
-// public Class home;
-// public Class local;
-// }
</del><ins>+public class EJBQLTest extends DeploymentHelper {
+ private static final File basedir = new \
File(System.getProperty("basedir", \
System.getProperty("user.dir"))); +
+ private Repository repository = null;
+ private DataSource ds;
+ private EJBSchema ejbSchema;
+ private SQLSchema sqlSchema;
+ private GlobalSchema cacheSchema;
+ private AHome aHome;
+ private ALocalHome aLocalHome;
+ private TransactionManager tm;
+ private AbstractName moduleName = \
naming.createRootName(testConfigurationArtifact, "MockModule", \
NameFactory.EJB_MODULE); + private AbstractName containerA = \
naming.createChildName(moduleName, "A", NameFactory.ENTITY_BEAN); +
+ public void testHomeFindTest() throws Exception {
+ ARemote a = aHome.findTest("test");
+ assertEquals(new Integer(1), a.getField1());
+ }
+
+ public void testLocalHomeFindTest() throws Exception {
+ ALocal a = aLocalHome.findTest("test");
+ assertEquals(new Integer(1), a.getField1());
+ }
+
+ public void testSelectTest() throws Exception {
+ ALocal a = aLocalHome.selectTest("test");
+ assertEquals(new Integer(1), a.getField1());
+ }
+
+ private void buildDBSchema(Connection c) throws Exception {
+ Statement s = c.createStatement();
+ try {
+ s.execute("DROP TABLE A");
+ } catch (SQLException e) {
+ // ignore
+ }
+
+ s.execute("CREATE TABLE A(A1 INTEGER, A2 VARCHAR(50))");
+
+ s.execute("INSERT INTO A(A1, A2) VALUES(1, 'test')");
+ s.close();
+ c.close();
+ }
+
+ private String getEjbJarDD() {
+ return "src/test-cmp/ejb-ql/ejb-jar.xml";
+ }
+
+ private String getOpenEjbJarDD() {
+ return "src/test-cmp/ejb-ql/openejb-jar.xml";
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ds = new SerializableDataSource(new \
AxionDataSource("jdbc:axiondb:testdb")); +
+ Connection c = ds.getConnection("root", null);
+ buildDBSchema(c);
+
+ tm = (TransactionManager) kernel.getProxyManager().createProxy(tmName, \
TransactionManager.class); + TransactionManagerDelegate tmDelegate = new \
TransactionManagerDelegate(); +
+ tmDelegate.setTransactionManager(tm);
+
+ File ejbJarFile = new File(basedir, getEjbJarDD());
+ File openejbJarFile = new File(basedir, getOpenEjbJarDD());
+ EjbJarType ejbJarType = ((EjbJarDocument) \
XmlObject.Factory.parse(ejbJarFile)).getEjbJar(); + OpenejbOpenejbJarType \
openejbJarType = ((OpenejbOpenejbJarDocument) \
XmlObject.Factory.parse(openejbJarFile)).getOpenejbJar(); +
+ OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(null, null, \
null, null); + CMPEntityBuilderTestUtil builder = new \
CMPEntityBuilderTestUtil(moduleBuilder); + TranQLPKGenBuilder pkGen = new \
TranQLPKGenBuilder(); + File tempDir = DeploymentUtil.createTempDir();
+
+ try {
+ EARContext earContext = new EARContext(tempDir,
+ new Environment(testConfigurationArtifact),
+ ConfigurationModuleType.EJB,
+ kernel.getNaming(),
+ Collections.singleton(repository),
+ Collections.singleton(configStore),
+ new AbstractNameQuery(serverName),
+ moduleName,
+ new AbstractNameQuery(tcmName),
+ new AbstractNameQuery(ctcName),
+ new AbstractNameQuery(txTimerName),
+ new AbstractNameQuery(nonTxTimerName),
+ null,
+ null);
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Schemata schemata = builder.buildCMPSchema(earContext, moduleName, \
ejbJarType, openejbJarType, cl, pkGen, ds); +
+ ejbSchema = schemata.getEjbSchema();
+ sqlSchema = schemata.getSqlSchema();
+ cacheSchema = schemata.getGlobalSchema();
+
+ AbstractName connectionProxyFactoryAbstractName = \
naming.createChildName(createJCAResourceName(testConfigurationArtifact), \
"testcf", NameFactory.JCA_RESOURCE_ADAPTER); +// \
NameFactory.getComponentName(null, null, null, NameFactory.JCA_RESOURCE, \
"jcamodule", "testcf", NameFactory.JCA_CONNECTION_FACTORY, \
j2eeContext); + GBeanData connectionProxyFactoryGBean = new \
GBeanData(connectionProxyFactoryAbstractName, MockConnectionProxyFactory.GBEAN_INFO); \
+ kernel.loadGBean(connectionProxyFactoryGBean, \
this.getClass().getClassLoader()); + \
kernel.startGBean(connectionProxyFactoryAbstractName); +
+ FrontEndCacheDelegate cacheDelegate = new FrontEndCacheDelegate();
+ setUpContainer(ejbSchema.getEJB("A"), ABean.class, \
AHome.class, ARemote.class, ALocalHome.class, ALocal.class, containerA, tmDelegate, \
cacheDelegate); +
+ aLocalHome = (ALocalHome) kernel.getAttribute(containerA, \
"ejbLocalHome"); + aHome = (AHome) \
kernel.getAttribute(containerA, "ejbHome"); + } finally {
+ DeploymentUtil.recursiveDelete(tempDir);
+ }
+ }
+
+
+ private void setUpContainer(EJB ejb, Class beanClass, Class homeClass, Class \
remoteClass, Class localHomeClass, Class localClass, AbstractName containerName, \
TransactionManagerDelegate tmDelegate, FrontEndCacheDelegate cacheDelegate) throws \
Exception { + CMPContainerBuilder builder = new CMPContainerBuilder();
+ builder.setClassLoader(this.getClass().getClassLoader());
+ builder.setContainerId(containerName.toURI().toString());
+ builder.setEJBName(ejb.getName());
+ builder.setBeanClassName(beanClass.getName());
+ builder.setHomeInterfaceName(homeClass.getName());
+ builder.setLocalHomeInterfaceName(localHomeClass.getName());
+ builder.setRemoteInterfaceName(remoteClass.getName());
+ builder.setLocalInterfaceName(localClass.getName());
+ builder.setPrimaryKeyClassName(ejb.getPrimaryKeyClass().getName());
+
+ builder.setJndiNames(new String[0]);
+ builder.setLocalJndiNames(new String[0]);
+ builder.setUnshareableResources(new HashSet());
+ builder.setTransactionPolicySource(new TransactionPolicySource() {
+ public TransactionPolicyType getTransactionPolicy(String methodIntf, \
InterfaceMethodSignature signature) { + return \
TransactionPolicyType.Required; + }
+ });
+
+ builder.setEJBSchema(ejbSchema);
+ builder.setSQLSchema(sqlSchema);
+ builder.setGlobalSchema(cacheSchema);
+ builder.setComponentContext(new HashMap());
+ builder.setTransactionManagerDelegate(tmDelegate);
+ builder.setFrontEndCacheDelegate(cacheDelegate);
+
+ GBeanData container = new GBeanData(containerA, CMPEJBContainer.GBEAN_INFO);
+ container = builder.createConfiguration(new AbstractNameQuery(tcmName),
+ new AbstractNameQuery(ctcName),
+ null,
+ container);
+
+ container.setReferencePattern("Timer", txTimerName);
+ container.setAbstractName(containerA);
+
+ // Wrap the GBeanData in a configuration
+ ConfigurationData config = new ConfigurationData(new \
Artifact("some", "test", "42", "car"), \
kernel.getNaming()); + config.getEnvironment().addDependency(new \
Dependency(baseId, ImportType.ALL)); + config.addGBean(container);
+
+ // Start the configuration
+ ConfigurationManager configurationManager = \
ConfigurationUtil.getConfigurationManager(kernel); + Configuration \
configuration = configurationManager.loadConfiguration(config); + \
configurationManager.startConfiguration(configuration); + }
+
+ protected void tearDown() throws Exception {
+ kernel.getProxyManager().destroyProxy(tm);
+ kernel.shutdown();
+ java.sql.Connection c = ds.getConnection();
+ c.createStatement().execute("SHUTDOWN");
+ super.tearDown();
+ }
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></pre></div>
<a id="branchesv2_1openejb2modulesopenejbbuildersrctestorgopenejbdeploymentslsbBasicStatelessContainerTestjava"></a>
<div class="modfile"><h4>Modified: \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/slsb/BasicStatelessContainerTest.java \
(2585 => 2586)</h4> <pre class="diff">
<span class="info">--- \
branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/slsb/BasicStatelessContainerTest.java 2006-03-27 \
00:56:03 UTC (rev 2585)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/slsb/BasicStatelessContainerTest.java 2006-03-28 \
00:13:43 UTC (rev 2586) </span><span class="lines">@@ -50,7 +50,6 @@
</span><span class="cx"> import java.util.HashMap;
</span><span class="cx"> import java.util.HashSet;
</span><span class="cx">
</span><del>-import org.apache.geronimo.gbean.AbstractName;
</del><span class="cx"> import org.apache.geronimo.gbean.AbstractNameQuery;
</span><span class="cx"> import org.apache.geronimo.gbean.GBeanData;
</span><span class="cx"> import org.apache.geronimo.kernel.repository.Artifact;
</span><span class="lines">@@ -179,18 +178,23 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx"> builder.setComponentContext(new HashMap());
</span><ins>+
+ // Generate the GBeanData
</ins><span class="cx"> GBeanData container = new GBeanData(CONTAINER_NAME, \
GenericEJBContainer.GBEAN_INFO); </span><del>- \
builder.createConfiguration( </del><ins>+ builder.createConfiguration(
</ins><span class="cx"> new AbstractNameQuery(tcmName),
</span><span class="cx"> new AbstractNameQuery(ctcName),
</span><del>- null, container);
-
- //start the ejb container
</del><ins>+ null,
+ container);
</ins><span class="cx"> container.setReferencePattern("Timer", \
txTimerName); </span><span class="cx"> \
container.setAbstractName(CONTAINER_NAME); </span><ins>+
+ // Wrap the GBeanData in a configuration
</ins><span class="cx"> ConfigurationData config = new ConfigurationData(new \
Artifact("some", "test", "42", "car"), \
kernel.getNaming()); </span><span class="cx"> \
config.getEnvironment().addDependency(new Dependency(baseId, ImportType.ALL)); \
</span><span class="cx"> config.addGBean(container); </span><ins>+
+ // Start the configuration
</ins><span class="cx"> ConfigurationManager configurationManager = \
ConfigurationUtil.getConfigurationManager(kernel); </span><span class="cx"> \
Configuration configuration = configurationManager.loadConfiguration(config); \
</span><span class="cx"> \
configurationManager.startConfiguration(configuration); </span></pre>
</div>
</div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic