Skip to content

Commit

Permalink
appclient module refactor with Arquillian and Junit.
Browse files Browse the repository at this point in the history
Signed-off-by: Gurunandan Rao <[email protected]>
  • Loading branch information
gurunrao committed Nov 13, 2024
1 parent 7bba7b2 commit 394ec22
Show file tree
Hide file tree
Showing 29 changed files with 2,331 additions and 202 deletions.
85 changes: 85 additions & 0 deletions appclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
<name>APPCLIENT</name>
<description>APPCLIENT</description>

<properties>
<arquillian.junit>1.9.1.Final</arquillian.junit>
<jakarta.ee.version>11.0.0-SNAPSHOT</jakarta.ee.version>
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -69,6 +76,84 @@
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>libutil</artifactId>
<version>${jakarta.ee.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<version>${jakarta.ee.version}</version>
</dependency>
<dependency>
<groupId>jakarta.ejb</groupId>
<artifactId>jakarta.ejb-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}.arquillian</groupId>
<artifactId>arquillian-protocol-common</artifactId>
<version>${arquillian.jakarta.tck.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}.arquillian</groupId>
<artifactId>arquillian-protocol-javatest</artifactId>
<version>${arquillian.jakarta.tck.version}</version>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>3.1.4</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>${arquillian.junit}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-core</artifactId>
<version>${arquillian.junit}</version>
</dependency>
<dependency>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>arquillian-protocol-appclient</artifactId>
<version>${arquillian.jakarta.tck.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>arquillian-protocol-javatest</artifactId>
<version>${arquillian.jakarta.tck.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>tck-porting-lib</artifactId>
<version>${arquillian.jakarta.tck.version}</version>
</dependency>

<!-- Junit5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 394ec22

Please sign in to comment.