From d235eeae35430ff7924eb2de7c0ef48123f1a614 Mon Sep 17 00:00:00 2001 From: Gurunandan Rao Date: Thu, 10 Oct 2024 11:51:16 +0530 Subject: [PATCH] appclient module refactor with Arquillian and Junit. Signed-off-by: Gurunandan Rao --- appclient/pom.xml | 85 +++ .../appclient/deploy/compat9_10/Client.java | 9 +- .../deploy/ejblink/casesens/Client.java | 109 +++- .../appclient/deploy/ejblink/path/Client.java | 122 ++++- .../deploy/ejblink/single/Client.java | 93 +++- .../deploy/ejbref/casesens/Client.java | 75 ++- .../appclient/deploy/ejbref/scope/Client.java | 119 ++++- .../deploy/ejbref/single/Client.java | 81 ++- .../deploy/enventry/casesens/Client.java | 49 +- .../deploy/enventry/scope/Client.java | 67 ++- .../deploy/enventry/single/Client.java | 58 ++- .../metadatacomplete/testapp/DataStore.java | 25 + .../testapp/DataStoreBean.java | 30 ++ .../testapp/DataStoreRemote.java | 25 + .../testapp/TestAppClient.java | 336 ++++++++++++ .../metadatacomplete/testapp/TestBean.java | 39 ++ .../testapp/application-client.xml | 23 + .../metadatacomplete/testapp/application.xml | 27 + .../testapp/files/DataStoreBean.java.src | 31 ++ .../testapp/files/TestAppClient.java.src | 492 ++++++++++++++++++ .../testapp/files/TestBean.java.src | 53 ++ .../metadatacomplete/testapp/persistence.xml | 28 + .../testapp/sun-application-client.xml | 26 + .../deploy/resref/casesens/Client.java | 55 +- .../appclient/deploy/resref/scope/Client.java | 80 ++- .../deploy/resref/scope/TopicClient.java | 2 +- .../deploy/resref/single/Client.java | 388 ++++++++------ ...ngle_client.jar.sun-application-client.xml | 2 +- .../util/shared/ejbref/single/TestCode.java | 4 + .../com/sun/ts/lib/util/TSNamingContext.java | 30 +- 30 files changed, 2356 insertions(+), 207 deletions(-) create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStore.java create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreBean.java create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreRemote.java create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestAppClient.java create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestBean.java create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application-client.xml create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application.xml create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/DataStoreBean.java.src create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestAppClient.java.src create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestBean.java.src create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/persistence.xml create mode 100644 appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/sun-application-client.xml diff --git a/appclient/pom.xml b/appclient/pom.xml index fa2399afbb..9cd0ef3435 100644 --- a/appclient/pom.xml +++ b/appclient/pom.xml @@ -32,6 +32,13 @@ APPCLIENT APPCLIENT + + 1.9.1.Final + 11.0.0-SNAPSHOT + 5.9.1 + 17 + + ${project.groupId} @@ -69,6 +76,84 @@ jakarta.persistence jakarta.persistence-api + + ${project.groupId} + libutil + ${jakarta.ee.version} + + + ${project.groupId} + common + ${jakarta.ee.version} + + + jakarta.ejb + jakarta.ejb-api + + + ${project.groupId}.arquillian + arquillian-protocol-common + ${arquillian.jakarta.tck.version} + + + ${project.groupId}.arquillian + arquillian-protocol-javatest + ${arquillian.jakarta.tck.version} + + + jakarta.mail + jakarta.mail-api + + + jakarta.activation + jakarta.activation-api + + + org.jboss.shrinkwrap + shrinkwrap-api + 1.2.6 + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-depchain + 3.1.4 + pom + + + org.jboss.arquillian.junit5 + arquillian-junit5-container + ${arquillian.junit} + + + org.jboss.arquillian.junit5 + arquillian-junit5-core + ${arquillian.junit} + + + jakarta.tck.arquillian + arquillian-protocol-appclient + ${arquillian.jakarta.tck.version} + + + jakarta.tck.arquillian + arquillian-protocol-javatest + ${arquillian.jakarta.tck.version} + + + jakarta.tck.arquillian + tck-porting-lib + ${arquillian.jakarta.tck.version} + + + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-engine + diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/compat9_10/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/compat9_10/Client.java index bb3b663d05..f83c788050 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/compat9_10/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/compat9_10/Client.java @@ -22,11 +22,16 @@ import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private static final String prefix = "java:comp/env/ejb/"; @@ -48,7 +53,6 @@ public static void main(String[] args) { * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; */ public void setup(String[] args, Properties props) throws Exception { - try { this.props = props; nctx = new TSNamingContext(); @@ -76,6 +80,7 @@ public void setup(String[] args, Properties props) throws Exception { * Run the client and check we can call a business method on * the referenced bean at runtime. */ + @Test public void test910DD() throws Exception { TestBean bean = null; String beanName; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/casesens/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/casesens/Client.java index 494debeac0..697cd1386c 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/casesens/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/casesens/Client.java @@ -20,13 +20,37 @@ package com.sun.ts.tests.appclient.deploy.ejblink.casesens; +import java.io.File; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import javax.naming.Context; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; +import tck.arquillian.protocol.common.TargetVehicle; + + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private static final String prefix = "java:comp/env/ejb/"; @@ -50,6 +74,67 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("javatest") + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_casesens_client.jar"); + ejbClient.addPackages(true, Client.class.getPackage()); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_casesens_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_casesens_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejblink.casesens.Client" + "\n"), + "MANIFEST.MF"); + + + System.out.println(ejbClient.toString(true)); + JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_casesens_ejb.jar"); + ejb.addClasses(CaseBean.class, CaseBeanEJB.class); + ejb.addPackages(true, "com.sun.ts.tests.assembly.util.shared.ejbref.common"); + ejb.addPackages(true, "com.sun.ts.tests.common.ejb.wrappers"); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_casesens_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_casesens_ejb.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + System.out.println("##################################"); + + System.out.println(ejb.toString(true)); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejblink_casesens.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(ejb); + ear.as(ZipExporter.class).exportTo( + new File("/tmp/ejb.ear"), true); + + return ear; + }; /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -58,16 +143,15 @@ public static void main(String[] args) { * @class.testArgs: -ap tssql.stmt * */ - public void setup(String[] args, Properties props) throws Exception { - this.props = props; - - try { - nctx = new TSNamingContext(); - logMsg("[Client] Setup succeed (got naming context)."); - } catch (Exception e) { - throw new Exception("[Client] Setup failed:", e); - } - } + public void setup(String[] args, Properties props) throws Exception { + this.props = props; + try { + nctx = new TSNamingContext(); + logMsg("[Client] Setup succeed (got naming context)."); + } catch (Exception e) { + throw new Exception("[Client] Setup failed:", e); + } + } /** * @testName: testCaseSensitivity @@ -85,13 +169,14 @@ public void setup(String[] args, Properties props) throws Exception { * match the references specified in the DD (validates that * the EJB references were resolved correctly). */ + @Test public void testCaseSensitivity() throws Exception { CaseBean bean1 = null; CaseBean bean2 = null; String bean1Name; String bean2Name; boolean pass = false; - + try { TestUtil.logTrace("[Client] Looking up '" + bean1Lookup + "'..."); bean1 = (CaseBean) nctx.lookup(bean1Lookup, CaseBean.class); diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/path/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/path/Client.java index ccb6397b4f..4a78f77822 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/path/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/path/Client.java @@ -20,13 +20,32 @@ package com.sun.ts.tests.appclient.deploy.ejblink.path; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private static final String prefix = "java:comp/env/ejb/"; @@ -50,6 +69,87 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + + EnterpriseArchive ear = null; + try { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_path_client.jar"); + ejbClient.addPackages(true, "com.sun.ts.tests.appclient.deploy.ejblink.path"); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_path_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/casesens/appclient_dep_ejblink_path_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejblink.path.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejb1 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_path_jar1_ejb.jar"); + ejb1.addPackages(true, Client.class.getPackage()); + ejb1.addPackages(true, "com.sun.ts.tests.common.ejb.wrappers"); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/path/appclient_dep_ejblink_path_jar1_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb1.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/path/appclient_dep_ejblink_path_jar1_ejb.xml"); + + if (resURL != null) { + ejb1.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + + + JavaArchive ejb2 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_path_jar2_ejb.jar"); + ejb2.addPackages(true, Client.class.getPackage()); + ejb2.addPackages(true, "com.sun.ts.tests.common.ejb.wrappers"); + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/path/appclient_dep_ejblink_path_jar2_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb2.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/path/appclient_dep_ejblink_path_jar2_ejb.xml"); + + if (resURL != null) { + ejb2.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + + ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejblink_path.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(ejb1); + ear.addAsModule(ejb2); + }catch(Exception e) { + e.printStackTrace(); + } + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -58,16 +158,15 @@ public static void main(String[] args) { * @class.testArgs: -ap tssql.stmt * */ - public void setup(String[] args, Properties props) throws Exception { - this.props = props; - - try { - nctx = new TSNamingContext(); - logMsg("[Client] Setup succeed (got naming context)."); - } catch (Exception e) { - throw new Exception("Setup failed:", e); - } - } + public void setup(String[] args, Properties props) throws Exception { + this.props = props; + try { + nctx = new TSNamingContext(); + logMsg("[Client] Setup succeed (got naming context)."); + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } /** * @testName: testScope @@ -87,6 +186,7 @@ public void setup(String[] args, Properties props) throws Exception { * identities (as reported by the String env. entry) match the * ones specified in the DD. */ + @Test public void testScope() throws Exception { ReferencedBean bean1 = null; ReferencedBean2 bean2 = null; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/single/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/single/Client.java index e1b4578d61..5a473bdb0e 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/single/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejblink/single/Client.java @@ -20,14 +20,35 @@ package com.sun.ts.tests.appclient.deploy.ejblink.single; +import java.io.IOException; +import java.net.URL; +import java.util.Hashtable; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import javax.naming.Context; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; -import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.assembly.util.shared.ejbref.single.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { /* @@ -36,6 +57,69 @@ public class Client extends EETest { private TSNamingContext nctx = null; private Properties props = null; + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_single_client.jar"); + ejbClient.addClass(Client.class); + ejbClient.addPackages(true, Client.class.getPackage()); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + ejbClient.addPackages(true, "com.sun.ts.tests.assembly.util.refbean"); + ejbClient.addPackages(true, "com.sun.ts.tests.assembly.util.shared"); + ejbClient.addPackages(true, "com.sun.ts.tests.common.dao.coffee"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/single/appclient_dep_ejblink_singe_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/single/appclient_dep_ejblink_single_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejblink.single.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejblink_single_ejb.jar"); + ejb.addPackages(true, "com.sun.ts.tests.assembly.util.shared.ejbref.common"); + ejb.addPackages(true, "com.sun.ts.tests.assembly.util.refbean"); + ejb.addPackages(true, "com.sun.ts.tests.assembly.util.shared"); + ejb.addPackages(true, "com.sun.ts.tests.common.dao.coffee"); + + + + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/single/appclient_dep_ejblink_single_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejblink/single/appclient_dep_ejblink_single_ejb.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejblink_single.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(ejb); + return ear; + }; + public static void main(String[] args) { Client theTests = new Client(); @@ -60,6 +144,7 @@ public void setup(String[] args, Properties props) throws Exception { logMsg("[Client] Setup succeed (got naming context)."); } catch (Exception e) { + e.printStackTrace(); throw new Exception("Setup failed:", e); } } @@ -77,9 +162,10 @@ public void setup(String[] args, Properties props) throws Exception { * that the EJB reference was resolved consistently with the * DD. */ + @Test public void testStateless() throws Exception { boolean pass; - + try { pass = TestCode.testStatelessExternal(nctx, props); if (!pass) { @@ -102,6 +188,7 @@ public void testStateless() throws Exception { * found only in this particular bean: This is to check that * the EJB reference was resolved consistently with the DD. */ + @Test public void testStateful() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/casesens/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/casesens/Client.java index 25dd32fd84..f50ef97406 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/casesens/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/casesens/Client.java @@ -20,13 +20,30 @@ package com.sun.ts.tests.appclient.deploy.ejbref.casesens; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private static final String prefix = "java:comp/env/ejb/"; @@ -50,6 +67,61 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = true) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_casesens_client.jar"); + ejbClient.addPackages(true, Client.class.getPackage()); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_casesens_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_casesens_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejbref.casesens.Client" + "\n"), + "MANIFEST.MF"); + + JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_casesens_ejb.jar"); + ejb.addPackages(false, "com.sun.ts.tests.assembly.util.refbean"); + ejb.addPackages(false, "com.sun.ts.tests.assembly.util.shared.ejbref.common"); + ejb.addPackages(true, Client.class.getPackage()); + + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_casesens_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_casesens_ejb.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejbref_scope.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(ejb); + return ear; + }; + /** * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -84,6 +156,7 @@ public void setup(String[] args, Properties props) throws Exception { * are distinct and match the ones specified in the DD * (validates that the EJB reference are resolved correctly). */ + @Test public void testCaseSensitivity() throws Exception { ReferencedBean bean1 = null; ReferencedBean bean2 = null; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/scope/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/scope/Client.java index 7fa4796223..f0ea188696 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/scope/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/scope/Client.java @@ -20,13 +20,31 @@ package com.sun.ts.tests.appclient.deploy.ejbref.scope; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private static final String prefix = "java:comp/env/ejb/"; @@ -46,6 +64,86 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = true) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient1 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_scope_client.jar"); + ejbClient1.addPackages(true, Client.class.getPackage()); + ejbClient1.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_scope_client.xml"); + if (appClientUrl != null) { + ejbClient1.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_scope_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient1.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient1.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejbref.scope.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejbClient2 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_scope_client_another.jar"); + ejbClient2.addPackages(true, Client.class.getPackage()); + ejbClient2.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_scope_another_client.xml"); + if (appClientUrl != null) { + ejbClient2.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_scope_another_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient2.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient2.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejbref.scope.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_scope_ejb.jar"); + ejb.addPackages(false, "com.sun.ts.tests.assembly.util.refbean"); + ejb.addPackages(false, "com.sun.ts.tests.assembly.util.shared.ejbref.common"); + ejb.addPackages(true, "com.sun.ts.tests.common.dao.coffee"); + ejb.addPackages(true, "com.sun.ts.tests.common.ejb.wrappers"); + ejb.addClasses(ReferencedBean.class, ReferencedBeanEJB.class); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_scope_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/scope/appclient_dep_ejbref_scope_ejb.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejbref_scope.ear"); + ear.addAsModule(ejbClient1); + ear.addAsModule(ejbClient2); + ear.addAsModule(ejb); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -54,16 +152,16 @@ public static void main(String[] args) { * @class.testArgs: -ap tssql.stmt * */ - public void setup(String[] args, Properties props) throws Exception { - this.props = props; + public void setup(String[] args, Properties props) throws Exception { + this.props = props; - try { - nctx = new TSNamingContext(); - logMsg("[Client] Setup succeed (got naming context)."); - } catch (Exception e) { - throw new Exception("Setup failed:", e); - } - } + try { + nctx = new TSNamingContext(); + logMsg("[Client] Setup succeed (got naming context)."); + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } /** * @testName: testScope @@ -90,6 +188,7 @@ public void setup(String[] args, Properties props) throws Exception { * the application client DD (validates that this EJB * reference is resolved correctly). */ + @Test public void testScope() throws Exception { ReferencedBean bean = null; String beanName; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/single/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/single/Client.java index b1e12ea6e5..97ea106eef 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/single/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/ejbref/single/Client.java @@ -20,14 +20,32 @@ package com.sun.ts.tests.appclient.deploy.ejbref.single; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; -import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.assembly.util.shared.ejbref.single.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { /* @@ -42,6 +60,63 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = true) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_single_client.jar"); + ejbClient.addClasses(Client.class, TestCode.class); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + ejbClient.addPackages(true, "com.sun.ts.tests.assembly.util.refbean"); + ejbClient.addPackages(true, "com.sun.ts.tests.common.dao.coffee"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_single_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_single_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.ejbref.single.Client" + "\n"), + "MANIFEST.MF"); + + JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "appclient_dep_ejbref_single_ejb.jar"); + ejb.addPackages(false, "com.sun.ts.tests.assembly.util.refbean"); + ejb.addPackages(true, "com.sun.ts.tests.common.dao.coffee"); + ejb.addPackages(true, "/com.sun.ts.tests.common.ejb.wrappers"); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_single_ejb.jar.sun-ejb-jar.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/ejbref/single/appclient_dep_ejbref_single_ejb.xml"); + + if (resURL != null) { + ejb.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_ejbref_single.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(ejb); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -77,6 +152,7 @@ public void setup(String[] args, Properties props) throws Exception { * that the EJB reference was resolved consistently with the * DD. */ + @Test public void testStateless() throws Exception { boolean pass; @@ -102,6 +178,7 @@ public void testStateless() throws Exception { * found only this particular bean: This is to check that the * EJB reference was resolved consistently with the DD. */ + @Test public void testStateful() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/casesens/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/casesens/Client.java index b7193485d8..a97cd9e2f5 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/casesens/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/casesens/Client.java @@ -20,13 +20,30 @@ package com.sun.ts.tests.appclient.deploy.enventry.casesens; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.tests.assembly.util.shared.enventry.casesens.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private TSNamingContext nctx = null; @@ -38,6 +55,35 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_enventry_casesens_client.jar"); + ejbClient.addClasses(Client.class, TestCode.class); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/enventry/casesens/appclient_dep_enventry_casesens_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.enventry.casesens.Client" + "\n"), + "MANIFEST.MF"); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_enventry_casesens.ear"); + ear.addAsModule(ejbClient); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -65,6 +111,7 @@ public void setup(String[] args, Properties props) throws Exception { * environment entries. Check that their runtime values are * distinct and match the ones specified in the DD. */ + @Test public void testCaseSensitivity() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/scope/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/scope/Client.java index 3d4cf671c0..3dfa989538 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/scope/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/scope/Client.java @@ -20,13 +20,31 @@ package com.sun.ts.tests.appclient.deploy.enventry.scope; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.tests.assembly.util.shared.enventry.scope.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { /** Env. entry name for JNDI lookup */ @@ -44,6 +62,52 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient1 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_enventry_scope_another_client.jar"); + ejbClient1.addClasses(Client.class, TestCode.class); + ejbClient1.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "com/sun/ts/tests/appclient/deploy/enventry/scope/appclient_dep_enventry_scope_another_client.xml"); + if (appClientUrl != null) { + ejbClient1.addAsManifestResource(appClientUrl, "application-client.xml"); + } + + ejbClient1.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.enventry.scope.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejbClient2 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_enventry_scope_client.jar"); + ejbClient2.addClasses(Client.class, TestCode.class); + ejbClient2.addPackages(true, "com.sun.ts.lib.harness"); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/enventry/scope/appclient_dep_enventry_scope_client.xml"); + + if (resURL != null) { + ejbClient2.addAsManifestResource(resURL, "application-client.xml"); + } + + ejbClient2.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.enventry.scope.Client" + "\n"), + "MANIFEST.MF"); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_enventry_scope.ear"); + ear.addAsModule(ejbClient1); + ear.addAsModule(ejbClient2); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -76,6 +140,7 @@ public void setup(String[] args, Properties props) throws Exception { * entry correspond to the one declared in the Deployment * Descriptor. */ + @Test public void testScope() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/single/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/single/Client.java index 39c80605d2..e40336353b 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/single/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/enventry/single/Client.java @@ -20,13 +20,30 @@ package com.sun.ts.tests.appclient.deploy.enventry.single; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.tests.assembly.util.shared.enventry.single.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private TSNamingContext nctx = null; @@ -38,6 +55,36 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_enventry_single_client.jar"); + ejbClient.addPackages(true, Client.class.getPackage()); + ejbClient.addClasses(Client.class, TestCode.class); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/enventry/single/appclient_dep_enventry_single_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.enventry.single.Client" + "\n"), + "MANIFEST.MF"); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_enventry_single.ear"); + ear.addAsModule(ejbClient); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -64,6 +111,7 @@ public void setup(String[] args, Properties props) throws Exception { * its runtime value match the DD value. * */ + @Test public void testString() throws Exception { boolean pass; @@ -87,6 +135,7 @@ public void testString() throws Exception { * its runtime value match the DD value. * */ + @Test public void testBoolean() throws Exception { boolean pass; @@ -110,6 +159,7 @@ public void testBoolean() throws Exception { * its runtime value match the DD value. * */ + @Test public void testByte() throws Exception { boolean pass; @@ -133,6 +183,7 @@ public void testByte() throws Exception { * its runtime value match the DD value. * */ + @Test public void testShort() throws Exception { boolean pass; @@ -156,6 +207,7 @@ public void testShort() throws Exception { * its runtime value match the DD value. * */ + @Test public void testInteger() throws Exception { boolean pass; @@ -179,6 +231,7 @@ public void testInteger() throws Exception { * its runtime value match the DD value. * */ + @Test public void testLong() throws Exception { boolean pass; @@ -202,6 +255,7 @@ public void testLong() throws Exception { * its runtime value match the DD value. * */ + @Test public void testFloat() throws Exception { boolean pass; @@ -225,6 +279,7 @@ public void testFloat() throws Exception { * its runtime value match the DD value. * */ + @Test public void testDouble() throws Exception { boolean pass; Double value; @@ -249,6 +304,7 @@ public void testDouble() throws Exception { * check that their runtime value match their DD value. * */ + @Test public void testAll() throws Exception { try { logTrace("[Client] testAll() : starting..."); diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStore.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStore.java new file mode 100644 index 0000000000..d63bb912f4 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStore.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import jakarta.ejb.Local; + +@Local +public interface DataStore { + + public String getData(); +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreBean.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreBean.java new file mode 100644 index 0000000000..915de68e93 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreBean.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import jakarta.ejb.LocalBean; +import jakarta.ejb.Stateless; + +@Stateless +@LocalBean + +public class DataStoreBean implements DataStore, DataStoreRemote { + + public String getData() { + return "42"; + } +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreRemote.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreRemote.java new file mode 100644 index 0000000000..4ca9d5de6b --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/DataStoreRemote.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import jakarta.ejb.Remote; + +@Remote +public interface DataStoreRemote { + + public String getData(); +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestAppClient.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestAppClient.java new file mode 100644 index 0000000000..25ff95630b --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestAppClient.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * @(#)TestAppClient.java 1.11 07/20/2017 + */ +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import java.util.Properties; + +import javax.naming.InitialContext; + +import com.sun.ts.lib.harness.Status; +import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.util.TSNamingContext; + +import jakarta.annotation.Resource; +import jakarta.annotation.sql.DataSourceDefinition; +import jakarta.ejb.EJB; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.JMSConnectionFactoryDefinition; +import jakarta.jms.JMSDestinationDefinition; +import jakarta.jms.Queue; +import jakarta.mail.MailSessionDefinition; +import jakarta.mail.Session; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceUnit; + +@MailSessionDefinition(name = "java:comp/myMailSession", host = "smtp.gmail.com", transportProtocol = "smtps", properties = { + "mail.debug=true" }) +@DataSourceDefinition(name = "java:global/MyApp/MyDataSource", className = "oracle.jdbc.pool.OracleDataSource", url = "jdbc:oracle:thin:@localhost:1521:orcl", user = "TESTU", password = "TESTU") +@JMSConnectionFactoryDefinition(description = "Define ConnectionFactory JSPMyTestConnectionFactory", interfaceName = "jakarta.jms.ConnectionFactory", name = "java:global/JSPMyTestConnectionFactory", user = "j2ee", password = "j2ee") +@JMSDestinationDefinition(name = "java:app/jms/myappTopic", interfaceName = "jakarta.jms.Topic", destinationName = "MyPhysicalAppTopic") + +public class TestAppClient extends EETest { + + private InitialContext initialContext; + + private TSNamingContext nctx = null; + + private Properties props = null; + + @Resource(lookup = "java:comp/myMailSession") + private static Session session; + + @EJB + static DataStoreRemote dataStore; + + @Resource(lookup = "java:app/jms/TestConnectionFactory") + private static ConnectionFactory testFac; + + @Resource(lookup = "java:app/jms/TestQ") + private static Queue testQueue; + + @PersistenceUnit(unitName = "TEST-EM-APPCLIENT") + static EntityManagerFactory emf; + + /* + * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; + * generateSQL; + * + * @class.testArgs: -ap tssql.stmt + * + */ + public void setup(String[] args, Properties props) throws Fault { + this.props = props; + try { + nctx = new TSNamingContext(); + logMsg("[Client] Setup succeed (got naming context)."); + } catch (Exception e) { + throw new Fault("Setup failed:", e); + } + } + + public static void main(String[] args) { + TestAppClient theTests = new TestAppClient(); + Status s = theTests.run(args, System.out, System.err); + s.exit(); + } + + + /** + * @testName: testMailSession + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,Resource annotation should be ignored - as it is one + * of the annotations to which metadata-complete is + * applicable. + * + */ + public void testMailSession() throws Fault { + try { + Object sess = nctx.lookup("mail/Session"); + logMsg("sess" + sess); + if (null == sess) { + throw new Fault("lookup failed!"); + } + } catch (Exception e) { + throw new Fault("MailSession test failed: " + e, e); + } + } + + /** + * @testName: testMailSessionDefinition + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,MailSessionDefinition annotation should be ignored - + * as it is one of the annotations to which metadata-complete + * is applicable. + * + */ + public void testMailSessionDefinition() throws Fault { + try { + logMsg("session" + session); + logMsg("mail.debug:" + session.getProperty("mail.debug")); + if (null != session) { + throw new Fault("MailSessionDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("MailSessionDefinition test failed: " + e, e); + } + } + + /** + * @testName: testEJBAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,EJB + * annotation should be ignored - as it is one of the + * annotations to which metadata-complete is applicable. + * + */ + public void testEJBAnnotation() throws Fault { + try { + logMsg("datastore" + dataStore); + if (null != dataStore) { + throw new Fault("EJBAnnotation test failed!"); + } + } catch (Exception e) { + throw new Fault("EJBAnnotation test failed: " + e, e); + } + } + + /** + * @testName: testDataSourceDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,DataSourceDefinition annotation should be ignored - as + * it is one of the annotations to which metadat-complete is + * applicable. + * + */ + public void testDataSourceDefinitionAnnotation() throws Fault { + try { + Object dataSource = nctx.lookup("java:global/MyApp/MyDataSource"); + if (dataSource != null) { + throw new Fault("DataSourceDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("DataSourceDefinition test failed: " + e, e); + } + } + + /** + * @testName: testJMSConnectionFactoryDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,JMSConnectionFactoryDefinition annotation should be + * ignored - as it is one of the annotations to which + * metadata-complete is applicable. + * + */ + public void testJMSConnectionFactoryDefinitionAnnotation() throws Fault { + try { + Object connFactory = nctx + .lookup("java:global/JSPMyTestConnectionFactory"); + logMsg("connFactory" + connFactory); + if (connFactory != null) { + throw new Fault("JMSConnectionFactoryDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("JMSConnectionFactoryDefinition test failed: " + e, e); + } + } + + /** + * @testName: testJMSDestinationDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,JMSDestinationDefinition annotation should be ignored + * - as it is one of the annotations to which + * metadata-complete is applicable. + * + */ + public void testJMSDestinationDefinitionAnnotation() throws Fault { + try { + Object destination = nctx.lookup("java:app/jms/myappTopic"); + logMsg("destination" + destination); + if (destination != null) { + throw new Fault("JMSDestinationDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("JMSDestinationDefinition test failed: " + e, e); + } + } + + /** + * @testName: testConnectionFactoryDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,ConnectionFactoryDefinition annotation should be + * ignored - as it is one of the annotations to which + * metadata-complete is applicable. + * + */ + public void testConnectionFactoryDefinitionAnnotation() throws Fault { + try { + logMsg("testFac" + testFac); + if (testFac != null) { + throw new Fault("ConnectionFactoryDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("ConnectionFactoryDefinition test failed: " + e, e); + } + } + + /** + * @testName: testAdministeredObjectDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,AdministeredObjectDefinition annotation should be + * ignored - as it is one of the annotations to which + * metadata-complete is applicable. + * + */ + public void testAdministeredObjectDefinitionAnnotation() throws Fault { + try { + logMsg("testQueue" + testQueue); + if (testFac != null) { + throw new Fault("AdministeredObjectDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("AdministeredObjectDefinition test failed: " + e, e); + } + } + + /** + * @testName: testPersistenceUnitDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to + * true,PersistenceUnitDefinition annotation should be ignored + * - as it is one of the annotations to which + * metadata-complete is applicable. + * + */ + public void testPersistenceUnitDefinitionAnnotation() throws Fault { + try { + logMsg("emf" + emf); + if (emf != null) { + throw new Fault("PersistenceUnitDefinition test failed!"); + } + } catch (Exception e) { + throw new Fault("PersistenceUnitDefinition test failed: " + e, e); + } + } + + public void cleanup() throws Fault { + logMsg("[Client] cleanup()"); + } +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestBean.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestBean.java new file mode 100644 index 0000000000..8b672b1d3f --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/TestBean.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import jakarta.annotation.ManagedBean; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; + +@ManagedBean("mybean") +public class TestBean { + + public TestBean() { + System.out.println(">>>>>>>>>>>>> Test123 "); + } + + @PostConstruct + public void postConstruct() { + System.out.println(">>> TestBean:postConstruct()"); + } + + @PreDestroy + public void preDestroy() { + System.out.println(">>> TestBean:preDestroy()"); + } +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application-client.xml b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application-client.xml new file mode 100644 index 0000000000..cdc3abfdb9 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application-client.xml @@ -0,0 +1,23 @@ + + + + + testapp + + diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application.xml b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application.xml new file mode 100644 index 0000000000..4bc148e0b6 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/application.xml @@ -0,0 +1,27 @@ + + + + + + testApp_ejb.jar + + + testApp_client.jar + + diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/DataStoreBean.java.src b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/DataStoreBean.java.src new file mode 100644 index 0000000000..c3c5c1b0e3 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/DataStoreBean.java.src @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; +import jakarta.ejb.LocalBean; +import jakarta.ejb.Stateless; +import jakarta.resource.ConnectionFactoryDefinition; +import jakarta.resource.AdministeredObjectDefinition; + +@Stateless +@LocalBean + +public class DataStoreBean implements DataStore,DataStoreRemote{ + + public String getData() { + return "42"; + } +} \ No newline at end of file diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestAppClient.java.src b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestAppClient.java.src new file mode 100644 index 0000000000..35deac25dc --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestAppClient.java.src @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2017, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import java.io.PrintStream; +import jakarta.annotation.Resource; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.NamingEnumeration; +import javax.naming.NameClassPair; +import java.util.Properties; +import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.lib.util.TSNamingContext; +import com.sun.javatest.Status; +import jakarta.mail.Session; +import jakarta.mail.MailSessionDefinition; +import jakarta.ejb.EJB; +import jakarta.xml.ws.WebServiceRef; +import jakarta.annotation.sql.DataSourceDefinition; +import jakarta.jms.JMSConnectionFactoryDefinition; +import jakarta.jms.JMSDestinationDefinition; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.Queue; +import jakarta.persistence.PersistenceUnit; +import jakarta.persistence.EntityManagerFactory; + + +@MailSessionDefinition(name = "java:comp/myMailSession", + host = "smtp.gmail.com", + transportProtocol = "smtps", + properties = { + "mail.debug=true" +}) +@DataSourceDefinition(name="java:global/MyApp/MyDataSource", + className="@dbclassname@", + url="@dburl@", + user="@dbuser@", + password="@dbpassword@" + ) +@JMSConnectionFactoryDefinition( + description="Define ConnectionFactory JSPMyTestConnectionFactory", + interfaceName="jakarta.jms.ConnectionFactory", + name="java:global/JSPMyTestConnectionFactory", + user = "@user@", + password = "@password@" + ) +@JMSDestinationDefinition( + name = "java:app/jms/myappTopic", + interfaceName = "jakarta.jms.Topic", + destinationName = "MyPhysicalAppTopic" +) + +public class TestAppClient extends EETest +{ + private InitialContext initialContext; + private TSNamingContext nctx = null; + private Properties props = null; + @Resource(lookup="java:module/mybean") + private static TestBean bean; + @Resource(lookup="java:comp/myMailSession") + private static Session session; + @EJB + static DataStoreRemote dataStore; + @WebServiceRef(name="service/HelloService") + static HelloService service; + @Resource(lookup="java:app/jms/TestConnectionFactory") + private static ConnectionFactory testFac; + @Resource(lookup="java:app/jms/TestQ") + private static Queue testQueue; + @PersistenceUnit(unitName = "TEST-EM-APPCLIENT") + static EntityManagerFactory emf; + @Resource(lookup="java:global/MyApp/MyDataSource") + private static Object dataSource; + @Resource(lookup="java:global/JSPMyTestConnectionFactory") + private static Object connFactory; + @Resource(lookup="java:app/jms/myappTopic") + private static Object destination; + + + + private Object lookup(String jndiName) + throws NamingException + { + return this.initialContext.lookup(jndiName); + } + /* + * @class.setup_props: org.omg.CORBA.ORBClass; + * java.naming.factory.initial; + * generateSQL; + * + * @class.testArgs: -ap tssql.stmt + * + */ + public void setup(String[] args, Properties props) throws Fault { + this.props = props; + + try { + nctx = new TSNamingContext(); + logMsg("[Client] Setup succeed (got naming context)."); + } catch (Exception e) { + throw new Fault("Setup failed:", e); + } + } + + public static void main(String[] args) { + TestAppClient theTests = new TestAppClient(); + Status s = theTests.run(args, System.out, System.err); + s.exit(); + } + + /** + * @testName: testResourceLookup + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,ManagedBean annotation + * - should work as metadata-complete attribute is not applicable to it. + * + */ + public void testResourceLookup() throws Fault { + try { + + Object mybean = + nctx.lookup("java:module/mybean"); + logMsg("mybean"+mybean); + if(null == mybean){ + throw new Fault("lookup failed!"); + } + } + catch (Exception e) { + throw new Fault("lookup failed: " + e, e); + } + } + + /** + * @testName: testResourceAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,Resource annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testResourceAnnotation() throws Fault { + + try { + logMsg("bean"+bean); + if(null != bean){ + throw new Fault("ResourceAnnotation test failed!"); + } + + + } + catch (Exception e) { + throw new Fault("ResourceAnnotation test failed: " + e, e); + } + } + + /** + * @testName: testMailSession + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,Resource annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testMailSession() throws Fault { + + try { + + Object sess = + nctx.lookup("mail/Session"); + logMsg("sess"+sess); + if(null == sess){ + throw new Fault("lookup failed!"); + } + + } + catch (Exception e) { + throw new Fault("MailSession test failed: " + e, e); + } + } + + /** + * @testName: testMailSessionDefinition + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,MailSessionDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testMailSessionDefinition() throws Fault { + + try { + + //Session sess = + //(Session)nctx.lookup("java:comp/myMailSession"); + logMsg("session"+session); + //logMsg("mail.debug:"+session.getProperty("mail.debug")); + if(null != session){ + throw new Fault("MailSessionDefinition test failed!"); + } + + } + catch (Exception e) { + throw new Fault("MailSessionDefinition test failed: " + e, e); + } + } + + /** + * @testName: testEJBAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,EJB annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testEJBAnnotation() throws Fault { + + try { + + logMsg("datastore"+dataStore); + if(null != dataStore){ + throw new Fault("EJBAnnotation test failed!"); + } + + } + catch (Exception e) { + throw new Fault("EJBAnnotation test failed: " + e, e); + } + } + + /** + * @testName: testWebServiceRefAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,WebServiceRef annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testWebServiceRefAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + logMsg("service"+service); + if(null != service){ + throw new Fault("WebServiceRefAnnotation test failed!"); + } + + } + catch (Exception e) { + throw new Fault("WebServiceRefAnnotation test failed: " + e, e); + } + } + + /** + * @testName: testDataSourceDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,DataSourceDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testDataSourceDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + //Object dataSource = + //nctx.lookup("java:global/MyApp/MyDataSource"); + if(dataSource != null){ + throw new Fault("DataSourceDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("DataSourceDefinition test failed: " + e, e); + } + } + + /** + * @testName: testJMSConnectionFactoryDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,JMSConnectionFactoryDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testJMSConnectionFactoryDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + //Object connFactory = + //nctx.lookup("java:global/JSPMyTestConnectionFactory"); + logMsg("connFactory"+connFactory); + if(connFactory != null){ + throw new Fault("JMSConnectionFactoryDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("JMSConnectionFactoryDefinition test failed: " + e, e); + } + } + + /** + * @testName: testJMSDestinationDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,JMSDestinationDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testJMSDestinationDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + //Object destination = + //nctx.lookup("java:app/jms/myappTopic"); + logMsg("destination"+destination); + if(destination != null){ + throw new Fault("JMSDestinationDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("JMSDestinationDefinition test failed: " + e, e); + } + } + + /** + * @testName: testConnectionFactoryDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,ConnectionFactoryDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testConnectionFactoryDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + logMsg("testFac"+testFac); + if(testFac != null){ + throw new Fault("ConnectionFactoryDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("ConnectionFactoryDefinition test failed: " + e, e); + } + } + + /** + * @testName: testAdministeredObjectDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,AdministeredObjectDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testAdministeredObjectDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + logMsg("testQueue"+testQueue); + if(testFac != null){ + throw new Fault("AdministeredObjectDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("AdministeredObjectDefinition test failed: " + e, e); + } + } + + /** + * @testName: testPersistenceUnitDefinitionAnnotation + * + * @assertion_ids: JavaEE:SPEC:323 + * + * @test_Strategy: + * + * We check that: + * + * - When the meta-data complete attribute is set to true,PersistenceUnitDefinition annotation should be ignored + * - as it is one of the annotations to which metadat-complete is applicable. + * + */ + public void testPersistenceUnitDefinitionAnnotation() throws Fault { + + try { + + + //logMsg("datastore"+dataStore); + //logMsg("service"+service); + logMsg("emf"+emf); + if(emf != null){ + throw new Fault("PersistenceUnitDefinition test failed!"); + } + } + catch (Exception e) { + throw new Fault("PersistenceUnitDefinition test failed: " + e, e); + } + } + + + public void cleanup() throws Fault { + logMsg("[Client] cleanup()"); + } + + +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestBean.java.src b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestBean.java.src new file mode 100644 index 0000000000..92bdd4ffde --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/files/TestBean.java.src @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.appclient.deploy.metadatacomplete.testapp; + +import jakarta.annotation.ManagedBean; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.resource.ConnectionFactoryDefinition; +import jakarta.resource.AdministeredObjectDefinition; + +@ConnectionFactoryDefinition( + name = "java:app/jms/TestConnectionFactory", + description = "application scoped jms connector resource definition", + interfaceName = "jakarta.jms.ConnectionFactory", + resourceAdapter="@raname@" +) +@AdministeredObjectDefinition( + name = "java:app/jms/TestQ", + description = "application scoped AdminObjectDefinition", + interfaceName = "jakarta.jms.Queue", + className = "com.sun.messaging.Queue", + resourceAdapter="@raname@") +@ManagedBean("mybean") +public class TestBean { + + public TestBean() { + System.out.println("TestBean : Constructor"); + } + + @PostConstruct + public void postConstruct() { + System.out.println("TestBean : postConstruct"); + } + + @PreDestroy + public void preDestroy() { + System.out.println("TestBean : preDestroy"); + } +} diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/persistence.xml b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/persistence.xml new file mode 100644 index 0000000000..75b0cd9f91 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/persistence.xml @@ -0,0 +1,28 @@ + + + + + + jdbc/DB_no_tx + + diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/sun-application-client.xml b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/sun-application-client.xml new file mode 100644 index 0000000000..0f6e979542 --- /dev/null +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/metadatacomplete/testapp/sun-application-client.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/casesens/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/casesens/Client.java index dac9a6cde8..3413ecc395 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/casesens/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/casesens/Client.java @@ -20,14 +20,32 @@ package com.sun.ts.tests.appclient.deploy.resref.casesens; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.assembly.util.shared.resref.casesens.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private Properties props = null; @@ -39,6 +57,40 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_resref_casesens_client.jar"); + ejbClient.addClasses(Client.class, TestCode.class); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/casesens/appclient_dep_resref_casesens_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/casesens/appclient_dep_resref_casesens_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.resref.casesens.Client" + "\n"), + "MANIFEST.MF"); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_resref_casesens.ear"); + ear.addAsModule(ejbClient); + return ear; + }; + /** * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -71,6 +123,7 @@ public void setup(String[] args, Properties props) throws Exception { * This validates that the resource references were resolved * correctly. */ + @Test public void testCaseSensitivity() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/Client.java index 04508d859c..1b61f4274f 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/Client.java @@ -20,13 +20,31 @@ package com.sun.ts.tests.appclient.deploy.resref.scope; +import java.io.IOException; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.tests.assembly.util.shared.resref.scope.QueueCode; +import com.sun.ts.tests.assembly.util.shared.resref.scope.TopicCode; + +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { private TSNamingContext nctx = null; @@ -38,6 +56,65 @@ public static void main(String[] args) { Status s = theTests.run(args, System.out, System.err); s.exit(); } + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + JavaArchive ejbClient1 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_resref_scope_another_client.jar"); + ejbClient1.addPackages(true, Client.class.getPackage()); + ejbClient1.addPackages(true, "com.sun.ts.lib.harness"); + ejbClient1.addClasses(Client.class, QueueCode.class, TopicCode.class); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "com/sun/ts/tests/appclient/deploy/resref/scope/appclient_dep_resref_scope_another_client.xml"); + if (appClientUrl != null) { + ejbClient1.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/scope/appclient_dep_resref_scope_another_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient1.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient1.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.resref.scope.Client" + "\n"), + "MANIFEST.MF"); + + + JavaArchive ejbClient2 = ShrinkWrap.create(JavaArchive.class, "appclient_dep_resref_scope_client.jar"); + ejbClient2.addPackages(true, "com.sun.ts.lib.harness"); + ejbClient2.addClasses(Client.class, QueueCode.class); + + URL resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/scope/appclient_dep_resref_scope_client.xml"); + + if (resURL != null) { + ejbClient2.addAsManifestResource(resURL, "ejb-jar.xml"); + } + + resURL = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/scope/appclient_dep_resref_scope_client.jar.sun-application-client.xml"); + + if (resURL != null) { + ejbClient2.addAsManifestResource(resURL, "sun-ejb-jar.xml"); + } + + ejbClient2.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.resref.scope.Client" + "\n"), + "MANIFEST.MF"); + + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_resref_scope.ear"); + ear.addAsModule(ejbClient1); + ear.addAsModule(ejbClient2); + return ear; + }; + /* * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; @@ -78,6 +155,7 @@ public void setup(String[] args, Properties props) throws Exception { * manager connection factories reference. * */ + @Test public void testScope() throws Exception { boolean pass; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/TopicClient.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/TopicClient.java index 5d7b4d91eb..edc3132a12 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/TopicClient.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/scope/TopicClient.java @@ -22,8 +22,8 @@ import java.util.Properties; -import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.tests.assembly.util.shared.resref.scope.TopicCode; diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/Client.java b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/Client.java index 61a187188d..a16d818881 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/Client.java +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/Client.java @@ -20,168 +20,248 @@ package com.sun.ts.tests.appclient.deploy.resref.single; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.util.Properties; -import com.sun.ts.lib.harness.Status; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.OverProtocol; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.jboss.shrinkwrap.api.asset.StringAsset; import com.sun.ts.lib.harness.EETest; +import com.sun.ts.lib.harness.Status; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.assembly.util.shared.resref.single.appclient.TestCode; +import tck.arquillian.porting.lib.spi.TestArchiveProcessor; + +@ExtendWith(ArquillianExtension.class) public class Client extends EETest { - private Properties props = null; - - private TSNamingContext nctx = null; - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /** - * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; - * webServerHost; webServerPort; - */ - public void setup(String[] args, Properties props) throws Exception { - this.props = props; - - try { - nctx = new TSNamingContext(); - } catch (Exception e) { - throw new Exception("Setup failed:", e); - } - } - - /** - * @testName: testDatasource - * - * @assertion_ids: JavaEE:SPEC:10125 - * - * @test_Strategy: Package an application client declaring a resource - * reference for a javax.sql.Datasource. - * - * Check that: - We can deploy the application. - We can - * lookup the datasource. - We can use it to open a DB - * connection. - */ - public void testDatasource() throws Exception { - boolean pass; - - try { - pass = TestCode.testDatasource(nctx); - if (!pass) { - throw new Exception("Datasource res-ref test failed!"); - } - } catch (Exception e) { - TestUtil.logErr("[Client] Caught exception: " + e); - throw new Exception("Datasource res-ref test failed!", e); - } - } - - /** - * @testName: testURL - * - * @assertion_ids: JavaEE:SPEC:10125 - * - * @test_Strategy: Package an application client declaring a resource - * reference for a java.net.URL. - * - * Check that: - We can deploy the application. - We can - * lookup the URL. - We can use this URL factory to open a - * connection to a HTML page bundled in the application. - */ - public void testURL() throws Exception { - boolean pass; - - try { - pass = TestCode.testURL(nctx); - if (!pass) { - throw new Exception("URL res-ref test failed!"); - } - } catch (Exception e) { - TestUtil.logErr("[Client] Caught exception: " + e); - throw new Exception("URL res-ref test failed!", e); - } - } - - /** - * @testName: testQueue - * - * @assertion_ids: JavaEE:SPEC:10125 - * - * @test_Strategy: Package an application client declaring a resource - * reference for a jakarta.jms.QueueConnectionFactory. - * - * Check that: - We can deploy the application. - We can - * lookup the JMS Queue Connection Factory. - */ - public void testQueue() throws Exception { - boolean pass; - - try { - pass = TestCode.testQueue(nctx); - if (!pass) { - throw new Exception("Queue res-ref test failed!"); - } - } catch (Exception e) { - TestUtil.logErr("[Client] Caught exception: " + e); - throw new Exception("Queue res-ref test failed!", e); - } - } - - /** - * @testName: testTopic - * - * @assertion_ids: JavaEE:SPEC:10125 - * - * @test_Strategy: Package an application client declaring a resource - * reference for a jakarta.jms.TopicConnectionFactory. - * - * Check that: - We can deploy the application. - We can - * lookup the JMS Topic Connection Factory. - */ - public void testTopic() throws Exception { - boolean pass; - - try { - pass = TestCode.testTopic(nctx); - if (!pass) { - throw new Exception("Topic res-ref test failed!"); - } - } catch (Exception e) { - TestUtil.logErr("[Client] Caught exception: " + e); - throw new Exception("Topic res-ref test failed!", e); - } - } - - /** - * @testName: testAll - * - * @assertion_ids: JavaEE:SPEC:10125 - * - * @test_Strategy: Package an application client declaring a resource - * reference for all the standard resource manager connection - * factory types. - * - * Check that: - We can deploy the application. - We can - * lookup all the declared resource factories. - */ - public void testAll() throws Exception { - try { - testDatasource(); - testURL(); - testQueue(); - testTopic(); - } catch (Exception e) { - TestUtil.logErr("[Client] Caught exception: " + e); - throw new Exception("All res-ref test failed!", e); - } - } - - public void cleanup() { - logTrace("[Client] cleanup()"); - } + private Properties props = null; + + private TSNamingContext nctx = null; + + public static void main(String[] args) { + Client theTests = new Client(); + Status s = theTests.run(args, System.out, System.err); + s.exit(); + } + + + @TargetsContainer("tck-javatest") + @OverProtocol("javatest") + @Deployment(testable = false) + public static EnterpriseArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) + throws IOException { + + EnterpriseArchive ear = null; + + try { + + JavaArchive ejbClient = ShrinkWrap.create(JavaArchive.class, "appclient_dep_resref_single_client.jar"); + ejbClient.addPackages(true, Client.class.getPackage()); + ejbClient.addPackages(true, "com.sun.ts.lib.harness"); + ejbClient.addClasses(TestCode.class, Client.class); + + // The appclient-client descriptor + URL appClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.xml"); + if (appClientUrl != null) { + ejbClient.addAsManifestResource(appClientUrl, "application-client.xml"); + } + // The sun appclient-client descriptor + URL sunAppClientUrl = Client.class.getResource( + "/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.jar.sun-application-client.xml"); + if (sunAppClientUrl != null) { + ejbClient.addAsManifestResource(sunAppClientUrl, "sun-application-client.xml"); + } + + ejbClient.addAsManifestResource( + new StringAsset("Main-Class: " + "com.sun.ts.tests.appclient.deploy.resref.single.Client" + "\n"), + "MANIFEST.MF"); + WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "appclient_dep_resref_single_jsp_web.war"); + InputStream testJSP = Thread.currentThread().getContextClassLoader() + .getResourceAsStream("com/sun/ts/tests/appclient/deploy/resref/single/contentRoot/test.jsp"); + webArchive.add(new ByteArrayAsset(testJSP), "test.jsp"); + + // The jsp descriptor + URL jspUrl = Client.class.getResource("appclient_dep_resref_single_jsp_web.xml"); + if(jspUrl != null) { + webArchive.addAsWebInfResource(jspUrl, "web.xml"); + } + + ear = ShrinkWrap.create(EnterpriseArchive.class, "appclient_dep_resref_single.ear"); + ear.addAsModule(ejbClient); + ear.addAsModule(webArchive); + }catch(Exception e) { + e.printStackTrace(); + } + return ear; + }; + + /** + * @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial; + * webServerHost; webServerPort; + */ + public void setup(String[] args, Properties props) throws Exception { + this.props = props; + + try { + nctx = new TSNamingContext(); + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + /** + * @testName: testDatasource + * + * @assertion_ids: JavaEE:SPEC:10125 + * + * @test_Strategy: Package an application client declaring a resource reference + * for a javax.sql.Datasource. + * + * Check that: - We can deploy the application. - We can lookup + * the datasource. - We can use it to open a DB connection. + */ + @Test + public void testDatasource() throws Exception { + boolean pass; + + try { + pass = TestCode.testDatasource(nctx); + if (!pass) { + throw new Exception("Datasource res-ref test failed!"); + } + } catch (Exception e) { + e.printStackTrace(); + TestUtil.logErr("[Client] Caught exception: " + e); + throw new Exception("Datasource res-ref test failed!", e); + } + } + + /** + * @testName: testURL + * + * @assertion_ids: JavaEE:SPEC:10125 + * + * @test_Strategy: Package an application client declaring a resource reference + * for a java.net.URL. + * + * Check that: - We can deploy the application. - We can lookup + * the URL. - We can use this URL factory to open a connection + * to a HTML page bundled in the application. + */ + @Test + public void testURL() throws Exception { + boolean pass; + + try { + pass = TestCode.testURL(nctx); + if (!pass) { + throw new Exception("URL res-ref test failed!"); + } + } catch (Exception e) { + e.printStackTrace(); + TestUtil.logErr("[Client] Caught exception: " + e); + throw new Exception("URL res-ref test failed!", e); + } + } + + /** + * @testName: testQueue + * + * @assertion_ids: JavaEE:SPEC:10125 + * + * @test_Strategy: Package an application client declaring a resource reference + * for a jakarta.jms.QueueConnectionFactory. + * + * Check that: - We can deploy the application. - We can lookup + * the JMS Queue Connection Factory. + */ + @Test + public void testQueue() throws Exception { + boolean pass; + + try { + pass = TestCode.testQueue(nctx); + if (!pass) { + throw new Exception("Queue res-ref test failed!"); + } + } catch (Exception e) { + e.printStackTrace(); + TestUtil.logErr("[Client] Caught exception: " + e); + throw new Exception("Queue res-ref test failed!", e); + } + } + + /** + * @testName: testTopic + * + * @assertion_ids: JavaEE:SPEC:10125 + * + * @test_Strategy: Package an application client declaring a resource reference + * for a jakarta.jms.TopicConnectionFactory. + * + * Check that: - We can deploy the application. - We can lookup + * the JMS Topic Connection Factory. + */ + @Test + public void testTopic() throws Exception { + boolean pass; + + try { + pass = TestCode.testTopic(nctx); + if (!pass) { + throw new Exception("Topic res-ref test failed!"); + } + } catch (Exception e) { + e.printStackTrace(); + TestUtil.logErr("[Client] Caught exception: " + e); + throw new Exception("Topic res-ref test failed!", e); + } + } + + /** + * @testName: testAll + * + * @assertion_ids: JavaEE:SPEC:10125 + * + * @test_Strategy: Package an application client declaring a resource reference + * for all the standard resource manager connection factory + * types. + * + * Check that: - We can deploy the application. - We can lookup + * all the declared resource factories. + */ + @Test + public void testAll() throws Exception { + try { + testDatasource(); + testURL(); + testQueue(); + testTopic(); + } catch (Exception e) { + e.printStackTrace(); + TestUtil.logErr("[Client] Caught exception: " + e); + throw new Exception("All res-ref test failed!", e); + } + } + + public void cleanup() { + logTrace("[Client] cleanup()"); + } } diff --git a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.jar.sun-application-client.xml b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.jar.sun-application-client.xml index c8cd65d6f1..4ee43dfce1 100644 --- a/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.jar.sun-application-client.xml +++ b/appclient/src/main/java/com/sun/ts/tests/appclient/deploy/resref/single/appclient_dep_resref_single_client.jar.sun-application-client.xml @@ -33,7 +33,7 @@ url/URL - http://webServerHost:webServerPort/appclient_dep_resref_single_jsp_web/test.jsp + http://localhost:8080/appclient_dep_resref_single_jsp_web/test.jsp jms/myQueueConnectionFactory diff --git a/assembly/src/main/java/com/sun/ts/tests/assembly/util/shared/ejbref/single/TestCode.java b/assembly/src/main/java/com/sun/ts/tests/assembly/util/shared/ejbref/single/TestCode.java index 7ddc6e4af3..c6da6a23ff 100644 --- a/assembly/src/main/java/com/sun/ts/tests/assembly/util/shared/ejbref/single/TestCode.java +++ b/assembly/src/main/java/com/sun/ts/tests/assembly/util/shared/ejbref/single/TestCode.java @@ -62,6 +62,7 @@ public static boolean testStatelessInternal(TSNamingContext nctx, pass = bean.isTestStatelessInternal(); } catch (Exception e) { + e.printStackTrace(); TestUtil.logErr("TestBean: Caught exception: " + e, e); pass = false; } @@ -83,6 +84,7 @@ public static boolean testStatelessExternal(TSNamingContext nctx, pass = true; } catch (Exception e) { + e.printStackTrace(); TestUtil.logErr( "TestBean: Exception in " + "testStatelessExternal(): " + e, e); pass = false; @@ -101,6 +103,7 @@ public static boolean testStatefulInternal(TSNamingContext nctx, pass = ssfInternalBeanRef1.isTestStatefulInternal(); } catch (Exception e) { + e.printStackTrace(); TestUtil.logErr("Caught exception: " + e, e); pass = false; } @@ -118,6 +121,7 @@ public static boolean testStatefulExternal(TSNamingContext nctx, StatefulExternal.class); pass = ssfExternalBeanRef1.isTestStatefulExternal(); } catch (Exception e) { + e.printStackTrace(); TestUtil.logErr("TestBean: Got exception: " + e, e); pass = false; } diff --git a/libutil/src/main/java/com/sun/ts/lib/util/TSNamingContext.java b/libutil/src/main/java/com/sun/ts/lib/util/TSNamingContext.java index d2d7223a6e..f4da6c54dc 100644 --- a/libutil/src/main/java/com/sun/ts/lib/util/TSNamingContext.java +++ b/libutil/src/main/java/com/sun/ts/lib/util/TSNamingContext.java @@ -20,11 +20,12 @@ package com.sun.ts.lib.util; -import javax.naming.InitialContext; import java.io.Serializable; import java.util.*; import javax.naming.*; import javax.rmi.PortableRemoteObject; + + import java.util.Properties; /** @@ -53,7 +54,20 @@ public TSNamingContext(Properties pp) throws Exception { * performed. */ public Object lookup(String s, Class c) throws Exception { - Object o = lookup(s); + props = new Properties(); + + + props = new Properties(); + props.put("java.naming.factory.initial", + "com.sun.jndi.cosnaming.CNCtxFactory"); + InitialContext jndiContext = new InitialContext (props); + NamingEnumeration list = jndiContext.list(""); + while (list.hasMore()) { + System.out.println("############################################" +list.next().getName()); + } + + Object o = lookup(s); + return (c != null && c.isAssignableFrom(o.getClass())) ? c.cast(o):null; } @@ -64,11 +78,17 @@ public Object lookup(String s, Class c) throws Exception { * object name to lookup */ public Object lookup(String s) throws Exception { - if (props != null) { - return new InitialContext(props).lookup(s); + Object o = null; + try { + if (props != null) { + o = new InitialContext(props).lookup(s); } else { - return new InitialContext().lookup(s); + o = new InitialContext().lookup(s); } + }catch(Exception e){ + e.printStackTrace(); + } + return o; } }