Skip to content

Commit

Permalink
EJBCLIENT-476 Intermittent failure in SimpleInvocationTestCase (wildf…
Browse files Browse the repository at this point in the history
  • Loading branch information
chengfang committed Jun 27, 2023
1 parent 559ae64 commit f7f6f79
Showing 1 changed file with 14 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.jboss.ejb.client.test.common.Result;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -56,16 +55,19 @@ public class SimpleInvocationTestCase extends AbstractEJBClientTestCase {

/**
* Do any general setup here
* @throws Exception
* @throws Exception on errors
*/
@BeforeClass
public static void beforeClass() throws Exception {
// trigger the static init of the correct proeprties file - this also depends on running in forkMode=always
// trigger the static init of the correct properties file - this also depends on running in forkMode=always
JBossEJBProperties ejbProperties = JBossEJBProperties.fromClassPath(SimpleInvocationTestCase.class.getClassLoader(), PROPERTIES_FILE);
JBossEJBProperties.getContextManager().setGlobalDefault(ejbProperties);

// Launch callback if needed
ClassCallback.beforeClassCallback();

// reset DISCOVERY_ADDITIONAL_TIMEOUT system property for slower machines
System.setProperty("org.jboss.ejb.client.discovery.additional-node-timeout", "0");
}

/**
Expand Down Expand Up @@ -176,7 +178,7 @@ public void testInvocationWithURIAffinityNoFailover() {
gotNoSuchEJBException = true;
echoResult = null;
}
Assert.assertEquals("NoSuchEJBException was expected", true, gotNoSuchEJBException);
Assert.assertTrue("NoSuchEJBException was expected", gotNoSuchEJBException);

// redeploy the bean on the server
deployStateless(0);
Expand All @@ -191,7 +193,7 @@ public void testInvocationWithURIAffinityNoFailover() {
* SFSB session is created on that target, strong affinity = Node(node2), weakAffinity = NONE
*/
@Test
public void testSFSBDefaultProxyInitialization() {
public void testSFSBDefaultProxyInitialization() throws Exception {
logger.info("=== Testing SFSB default proxy initialization ===");

// undeploy the bean from host node1
Expand All @@ -204,13 +206,7 @@ public void testSFSBDefaultProxyInitialization() {

// create a proxy for SFSB, with a default value for strong affinity
final StatelessEJBLocator<Echo> statefulEJBLocator = StatelessEJBLocator.create(Echo.class, STATEFUL_IDENTIFIER, Affinity.NONE);
Echo proxy ;
try {
proxy = EJBClient.createSessionProxy(statefulEJBLocator);
} catch (Exception e) {
Assert.fail("Unexpected exception when creating session proxy: e = " + e.getMessage());
proxy = null;
}
Echo proxy = EJBClient.createSessionProxy(statefulEJBLocator);
Assert.assertNotNull("Received a null proxy", proxy);

// check affinity assignments
Expand All @@ -234,7 +230,7 @@ public void testSFSBDefaultProxyInitialization() {
* SFSB session is created on that target, strong affinity = Node(node2), weakAffinity = NONE
*/
@Test
public void testSFSBProgrammaticProxyInitialization() {
public void testSFSBProgrammaticProxyInitialization() throws Exception {
logger.info("=== Testing SFSB programmatic proxy initialization ===");

Affinity expectedStrongAffinity = new NodeAffinity("node2");
Expand All @@ -244,13 +240,7 @@ public void testSFSBProgrammaticProxyInitialization() {

// create a proxy for SFSB, with a NodeAffinity which points to node2
final StatelessEJBLocator<Echo> statefulEJBLocator = StatelessEJBLocator.create(Echo.class, STATEFUL_IDENTIFIER, expectedStrongAffinity);
Echo proxy ;
try {
proxy = EJBClient.createSessionProxy(statefulEJBLocator);
} catch (Exception e) {
Assert.fail("Unexpected exception when creating session proxy: e = " + e.getMessage());
proxy = null;
}
Echo proxy = EJBClient.createSessionProxy(statefulEJBLocator);
Assert.assertNotNull("Received a null proxy", proxy);

// check affinity assignments
Expand All @@ -271,21 +261,15 @@ public void testSFSBProgrammaticProxyInitialization() {
* the invocation occurs on node2
*/
@Test
public void testSFSBInvocationation() {
public void testSFSBInvocationation() throws Exception {
logger.info("=== Testing SFSB invocation ===");

Affinity expectedStrongAffinity = new NodeAffinity("node2");
// Affinity expectedWeakAffinity = Affinity.NONE;

// create a proxy for SFSB, with a NodeAffinity which points to node2
final StatelessEJBLocator<Echo> statefulEJBLocator = StatelessEJBLocator.create(Echo.class, STATEFUL_IDENTIFIER, expectedStrongAffinity);
Echo proxy ;
try {
proxy = EJBClient.createSessionProxy(statefulEJBLocator);
} catch (Exception e) {
Assert.fail("Unexpected exception when creating session proxy: e = " + e.getMessage());
proxy = null;
}
Echo proxy = EJBClient.createSessionProxy(statefulEJBLocator);
Assert.assertNotNull("Received a null proxy", proxy);

// invoke on the proxy
Expand Down Expand Up @@ -354,7 +338,7 @@ public void testSFSBInvocationationNoFailover() {
gotNoSuchEJBException = true;
echoResult = null;
}
Assert.assertEquals("NoSuchEJBException was expected", true, gotNoSuchEJBException);
Assert.assertTrue("NoSuchEJBException was expected", gotNoSuchEJBException);

// redeploy the bean on the server
deployStateful(0);
Expand Down Expand Up @@ -466,9 +450,7 @@ public void testSLSBInvocationWithFailedNode() {

// check the message contents and the target
Assert.assertEquals("Got an unexpected echo", echoResult.getValue(), message);
Assert.assertTrue("Got an unexpected node for invocation target", echoResult.getNode().equals(SERVER2_NAME));

deployStateless(0);
Assert.assertEquals("Got an unexpected node for invocation target", SERVER2_NAME, echoResult.getNode());
}

/**
Expand All @@ -483,11 +465,4 @@ public void afterTest() {
stopServer(i);
}
}

/**
* Do any general tear down here.
*/
@AfterClass
public static void afterClass() {
}
}

0 comments on commit f7f6f79

Please sign in to comment.