Skip to content

Commit

Permalink
Merge pull request #971 from alwin-joseph/ejblitejsf-tests-ejb32
Browse files Browse the repository at this point in the history
Address ejblitejsf test failures in ejb32 - part1
  • Loading branch information
scottmarlow committed May 12, 2022
2 parents 0e01403 + 5583db5 commit 572fe6d
Show file tree
Hide file tree
Showing 37 changed files with 4,079 additions and 20 deletions.
45 changes: 38 additions & 7 deletions install/jakartaee/other/vehicle.properties
Expand Up @@ -185,13 +185,44 @@ com/sun/ts/tests/ejb30/bb/session/stateful/timeout = ejblitejsp
com/sun/ts/tests/ejb30/bb/session/stateful/concurrency = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp

com/sun/ts/tests/ejb32/lite = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/basic/xa = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/interceptor/lifecycle = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/interceptor/aroundtimeout/singleton/annotated = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/service = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/tx = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/lifecycle = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/txnonpersistent = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/basic/concurrency/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/basic/concurrency/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/basic/sharing/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/basic/sharing/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/basic/xa/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/basic/xa/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/interceptor/lifecycle/singleton/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/interceptor/lifecycle/singleton/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/interceptor/aroundtimeout/singleton/annotated/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/interceptor/aroundtimeout/singleton/annotated/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/interceptor/aroundtimeout/singleton/dual/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/interceptor/aroundtimeout/singleton/dual/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/interceptor/business/singleton/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/interceptor/business/singleton/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/interceptor/business/stateless/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/interceptor/business/stateless/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/descriptor/stateless/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/schedule/descriptor/stateless/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/expire/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/schedule/expire/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/expression/annotated/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/schedule/expression/annotated/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/expression/descriptor/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/schedule/expression/descriptor/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/service/singleton/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/service/singleton/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/service/stateless/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/service/stateless/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/tx/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/tx/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/tz/Client.java = ejbembed ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/tz/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/txnonpersistent/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/txnonpersistent/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/schedule/lifecycle/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp
com/sun/ts/tests/ejb32/lite/timer/schedule/lifecycle/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/lite/timer/timerconfig/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp ejbembed
com/sun/ts/tests/ejb32/lite/timer/timerconfig/JsfClient.java = ejblitejsf
com/sun/ts/tests/ejb32/timer = ejbliteservlet

com/sun/ts/tests/jaxm = ejb servlet jsp appclient
Expand Down
164 changes: 164 additions & 0 deletions src/com/sun/ts/tests/ejb30/timer/common/JsfClientBase.java
@@ -0,0 +1,164 @@
/*
* Copyright (c) 2022 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.ejb30.timer.common;

import java.util.Collections;
import java.util.List;
import java.util.Properties;

import com.sun.ts.lib.util.TestUtil;
import com.sun.ts.tests.ejb30.common.helper.Helper;
import com.sun.ts.tests.ejb30.common.lite.EJBLiteJsfClientBase;

import jakarta.ejb.EJB;

public class JsfClientBase extends EJBLiteJsfClientBase {
protected static final long WAIT_FOR_TIMEOUT_STATUS = 60000; // millis

protected static final long WAIT_FOR_NO_TIMEOUT_STATUS = 60000; // millis

protected static final int NUM_OF_RECURRING_RECORDS = 3;

protected static final long POLL_INTERVAL = 1000; // millis

protected static final long DEFAULT_DURATION = 100L; // time out after these
// millisec

protected static final long DEFAULT_INTERVAL = 100L;

@EJB(beanName = "TimeoutStatusBean")
protected TimeoutStatusBean statusSingleton;

@Override
public void setup(String[] args, Properties p) {
super.setup(args, p);
if (needToRemoveStatusAndRecords()) {
// NOTE: this method only clears records for the timer whose name is
// the same as the current test name. If the test method creates
// timers with different names, these timer records will not be cleared.
// In that case, individual test methods need to take care of it.
removeStatusAndRecords();
}
}

protected boolean needToRemoveStatusAndRecords() {
return true;
}

protected void passIfNoTimeout(long... waitMillis) {
passIfNoTimeout(getTestName(), waitMillis);
}

protected void passIfNoTimeout(String timerName, long... waitMillis) {
long waitFor = WAIT_FOR_NO_TIMEOUT_STATUS;
if (waitMillis.length != 0) {
waitFor = waitMillis[0];
}
Boolean status = pollTimeoutStatus(timerName, waitFor, false);
assertEquals("Timeout status must not be set.", null, status);
assertEquals("Timeout result must not be set.", 0,
statusSingleton.getRecords(timerName).size());
}

protected void passIfTimeout(long... waitMillis) {
passIfTimeout(getTestName(), waitMillis);
}

// Usually timerName is the same as getTestName(). This method is used
// when they are different.
protected void passIfTimeout(String timerName, long... waitMillis) {
long waitFor = WAIT_FOR_TIMEOUT_STATUS;
if (waitMillis.length != 0) {
waitFor = waitMillis[0];
}
Boolean status = pollTimeoutStatus(timerName, waitFor, false);
appendReason(statusSingleton.getRecords(timerName));
assertEquals("Check timeout status", Boolean.TRUE, status);
}

protected void passIfTimeoutOnce(long... waitMillis) {
passIfTimeoutOnce(getTestName(), waitMillis);
}

protected void passIfTimeoutOnce(String timerName, long... waitMillis) {
passIfTimeout(timerName, waitMillis);
// wait again to see if there is any subsequent expiration.
long waitFor = (waitMillis.length != 0) ? waitMillis[0]
: WAIT_FOR_TIMEOUT_STATUS;
TestUtil.sleepMsec((int) waitFor);
assertEquals("Check num of expirations", 1,
statusSingleton.getRecords(timerName).size());
}

// for recurring timers with interval
protected void passIfRecurringTimeout(long... waitMillis) {
passIfRecurringTimeout(getTestName(), waitMillis);
}

// for recurring timers with interval
protected void passIfRecurringTimeout(String timerName, long... waitMillis) {
long waitFor = WAIT_FOR_TIMEOUT_STATUS * NUM_OF_RECURRING_RECORDS;
if (waitMillis.length != 0) {
waitFor = waitMillis[0];
}
Boolean status = pollTimeoutStatus(timerName, waitFor, true);
List<String> records = statusSingleton.getRecords(timerName);
appendReason(records);
assertEquals("Check timeout status", Boolean.TRUE, status);
assertGreaterThan("Check num of timeout records", records.size(),
NUM_OF_RECURRING_RECORDS - 1);
}

private Boolean pollTimeoutStatus(String timerName, long waitMillis,
boolean recurringTimer) {
long end = System.currentTimeMillis() + waitMillis;
Boolean status = null;
List<String> records = Collections.emptyList();
if (recurringTimer) {
while (records.size() < NUM_OF_RECURRING_RECORDS
&& System.currentTimeMillis() < end) {
TestUtil.sleepMsec((int) POLL_INTERVAL);
records = statusSingleton.getRecords(timerName);
}
status = statusSingleton.getStatus(timerName);
if (records.size() < NUM_OF_RECURRING_RECORDS) {
Helper.getLogger()
.fine("Polling recurring Timeout records timed out after "
+ waitMillis + " millis for timerName " + timerName);
}
} else {
while (status == null && System.currentTimeMillis() < end) {
TestUtil.sleepMsec((int) POLL_INTERVAL);
status = statusSingleton.getStatus(timerName);
}
if (status == null) {
Helper.getLogger().fine("Polling Timeout status timed out after "
+ waitMillis + " millis for timerName " + timerName);
}
}
return status;
}

protected void removeStatusAndRecords(String... timerName) {
String tn = (timerName.length == 0) ? getTestName() : timerName[0];
statusSingleton.removeStatus(tn);
statusSingleton.removeRecords(tn);
}
}
5 changes: 3 additions & 2 deletions src/com/sun/ts/tests/ejb30/timer/common/build-import.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2022 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 @@ -26,7 +26,8 @@
com/sun/ts/tests/ejb30/timer/common/ScheduleValues.class,
com/sun/ts/tests/ejb30/timer/common/TimerBeanBase.class,
com/sun/ts/tests/ejb30/timer/common/TimerBeanBaseWithoutTimeOutMethod.class,
com/sun/ts/tests/ejb30/timer/common/ClientBase.class"/>
com/sun/ts/tests/ejb30/timer/common/ClientBase.class,
com/sun/ts/tests/ejb30/timer/common/JsfClientBase.class"/>

<target name="package">
<ts.vehicles name="${app.name}" buildleveloverride="2"
Expand Down

0 comments on commit 572fe6d

Please sign in to comment.