Skip to content

Commit

Permalink
Fix EJB 2.x Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brideck committed May 10, 2024
1 parent ffcd438 commit 0f87c64
Show file tree
Hide file tree
Showing 169 changed files with 2,678 additions and 432 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* Copyright (c) 2007, 2024 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
*/

/*
* $Id$
*/

package com.sun.ts.tests.common.testlogic.ejb.bb.argsemantics;

import java.util.Properties;

import com.sun.ts.lib.util.TSNamingContext;
import com.sun.ts.lib.util.TestUtil;
import com.sun.ts.tests.common.ejb.calleebeans.SimpleArgument;
import com.sun.ts.tests.common.ejb.calleebeans.StatefulCallee;
import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeHome;
import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeLocal;
import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeLocalHome;

public class TestLogic {

/*
* Names used for Callee beans lookups.
*/
public static final String prefix = "java:comp/env/";

public static final String statefulRemoteLookup = prefix
+ "ejb/StatefulCalleeRemote";

public static final String statefulLocalLookup = prefix
+ "ejb/StatefulCalleeLocal";

public static final String statefulBiRemoteLookup = prefix
+ "ejb/StatefulCalleeBothRemote";

public static final String statefulBiLocalLookup = prefix
+ "ejb/StatefulCalleeBothLocal";

/*
* Expected values for our custom argument.
*/
public static final int initialValue = 12;

public static final int modifiedValue = 24;

public static final int modifiedValue2 = 48;

private static StatefulCallee ssfCalleeBean = null;

private static StatefulCalleeLocal ssfCalleeLocalBean = null;

public static boolean testStatefulRemote(TSNamingContext nctx,
Properties props) {

return testStatefulRemote(statefulRemoteLookup, nctx, props);
}

public static boolean testStatefulLocal(TSNamingContext nctx,
Properties props) {

return testStatefulLocal(statefulLocalLookup, nctx, props);
}

public static boolean testStatefulBoth(TSNamingContext nctx,
Properties props) {

boolean pass;

pass = testStatefulRemote(statefulBiRemoteLookup, nctx, props);
pass &= testStatefulLocal(statefulBiLocalLookup, nctx, props);

return pass;
}

protected static boolean testStatefulRemote(String lookupName,
TSNamingContext nctx, Properties props) {

StatefulCalleeHome home;
ssfCalleeBean = null;
SimpleArgument arg;
boolean pass;

try {
arg = new SimpleArgument(initialValue);
TestUtil.logTrace("[TestLogic] Initial value is " + arg.getValue());

TestUtil.logTrace("[TestLogic] Looking up Callee " + lookupName + " ...");
home = (StatefulCalleeHome) nctx.lookup(lookupName,
StatefulCalleeHome.class);

ssfCalleeBean = home.create(props, arg);
TestUtil.logTrace("[TestLogic] Value after create is " + arg.getValue());

ssfCalleeBean.call(props, arg);
TestUtil.logTrace(
"[TestLogic] Value after business " + "method is " + arg.getValue());

pass = (arg.getValue() == initialValue);
if (!pass) {
TestUtil.logErr(
"[TestLogic] Argument has been " + "modified to " + arg.getValue());
}
} catch (Exception e) {
pass = false;
TestUtil.logErr("[TestLogic] Unexpected exception", e);
}

return pass;
}

protected static boolean testStatefulLocal(String lookupName,
TSNamingContext nctx, Properties props) {

StatefulCalleeLocalHome home;
ssfCalleeLocalBean = null;
SimpleArgument arg;
String msg;
boolean pass;

try {
arg = new SimpleArgument(initialValue);
TestUtil.logTrace("[TestLogic] Initial value is " + arg.getValue());

TestUtil.logTrace("[TestLogic] Looking up Callee " + lookupName + " ...");
home = (StatefulCalleeLocalHome) nctx.lookup(lookupName);

ssfCalleeLocalBean = home.create(props, arg);
TestUtil.logTrace("[TestLogic] Value after create is " + arg.getValue());
pass = (arg.getValue() == modifiedValue);
if (!pass) {
msg = "Expected Argument to be set to " + modifiedValue;
TestUtil.logErr("[TestLogic] " + msg);
throw new Exception(msg);
}

ssfCalleeLocalBean.call(props, arg);
TestUtil.logTrace(
"[TestLogic] Value after business " + "method is " + arg.getValue());

pass = (arg.getValue() == modifiedValue2);
if (!pass) {
TestUtil.logErr("[TestLogic] Expected argument to be " + "set to "
+ modifiedValue2);
}
} catch (Exception e) {
pass = false;
TestUtil.logErr("[TestLogic] Unexpected exception", e);
}

return pass;
}

public static void cleanUpStatefulBean() {
TestUtil.logTrace("cleanUpStatefulBean");
try {
if (ssfCalleeBean != null) {
TestUtil.logTrace("cleanUp Session Stateful Remote Callee Bean");
ssfCalleeBean.remove();
ssfCalleeBean = null;
}

if (ssfCalleeLocalBean != null) {
TestUtil.logTrace("cleanUp Session Stateful Local Callee Bean");
ssfCalleeLocalBean.remove();
ssfCalleeLocalBean = null;
}
} catch (Exception e) {
TestUtil.logErr(
"Exception caught trying to remove Stateful Session beans", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.sun.ts.lib.harness.RemoteStatus;
import com.sun.ts.lib.util.TestUtil;

import jakarta.ejb.EJBException;

public class EJBVehicle {
private EETest testObj;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.casesens;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class CaseBeanEJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2024 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
Expand Down Expand Up @@ -32,7 +32,7 @@
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
${ts.wrappers.classes.mdb.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.clientjar descriptor="ejb_depMdbQ_ejblink_casesens_client.xml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.casesensT;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class CaseBeanEJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2024 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
Expand Down Expand Up @@ -32,7 +32,7 @@
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
${ts.wrappers.classes.mdb.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.clientjar descriptor="ejb_depMdbT_ejblink_casesens_client.xml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.scope;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class ReferencedBean2EJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.scope;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class ReferencedBeanEJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2024 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
Expand Down Expand Up @@ -35,7 +35,7 @@
com/sun/ts/tests/ejb/ee/deploy/mdb/ejblink/scope/ReferencedBeanHome.class">
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.ejbjar descriptor="ejb_depMdbQ_ejblink_scope_jar1_ejb.xml"
Expand All @@ -44,7 +44,7 @@
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
${ts.wrappers.classes.mdb.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.clientjar descriptor="ejb_depMdbQ_ejblink_scope_client.xml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.scopeT;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class ReferencedBean2EJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024 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
Expand All @@ -19,7 +19,7 @@
*/
package com.sun.ts.tests.ejb.ee.deploy.mdb.ejblink.scopeT;

import com.sun.ts.tests.assembly.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.common.ReferencedBeanCode;
import com.sun.ts.tests.common.ejb.wrappers.StatelessWrapper;

public class ReferencedBeanEJB extends StatelessWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2024 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
Expand Down Expand Up @@ -35,7 +35,7 @@
com/sun/ts/tests/ejb/ee/deploy/mdb/ejblink/scopeT/ReferencedBeanHome.class">
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.ejbjar descriptor="ejb_depMdbT_ejblink_scope_jar1_ejb.xml"
Expand All @@ -44,7 +44,7 @@
<fileset dir="${class.dir}"
includes="${ts.wrappers.classes.stateless.ejb},
${ts.wrappers.classes.mdb.ejb},
com/sun/ts/tests/assembly/util/shared/ejbref/common/ReferencedBeanCode.class"/>
com/sun/ts/tests/ejb/ee/deploy/util/shared/ejbref/common/ReferencedBeanCode.class"/>
</ts.ejbjar>

<ts.clientjar descriptor="ejb_depMdbT_ejblink_scope_client.xml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.Properties;

import com.sun.ts.tests.assembly.util.shared.ejbref.single.TestCode;
import com.sun.ts.tests.ejb.ee.deploy.util.shared.ejbref.single.TestCode;
import com.sun.ts.tests.common.ejb.wrappers.MDBWrapper;

public class MsgBean extends MDBWrapper {
Expand Down
Loading

0 comments on commit 0f87c64

Please sign in to comment.