Issue #23507 weld-integration now uses junit5 instead of junit4
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedBeanTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedBeanTest.java
index ae3fb17..79335db 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedBeanTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedBeanTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,14 +18,15 @@
package org.glassfish.cdi.transaction;
import java.util.concurrent.ConcurrentHashMap;
-import org.junit.Test;
+
+import org.easymock.EasyMockSupport;
+import org.junit.jupiter.api.Test;
import jakarta.enterprise.context.spi.Contextual;
import jakarta.enterprise.context.spi.CreationalContext;
-import static junit.framework.Assert.assertSame;
-import static org.easymock.EasyMock.*;
-import org.easymock.EasyMockSupport;
+import static org.easymock.EasyMock.expect;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
@@ -63,7 +65,7 @@
expect(contextual.create(creationalContext)).andReturn(localBean);
mockSupport.replayAll();
- TransactionScopedBean<T> transactionScopedBean = new TransactionScopedBean<T>(contextual, creationalContext,
+ TransactionScopedBean<T> transactionScopedBean = new TransactionScopedBean<>(contextual, creationalContext,
transactionScopedContext);
assertSame(localBean, transactionScopedBean.getContextualInstance());
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextExtensionTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextExtensionTest.java
index 949ac11..e981420 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextExtensionTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextExtensionTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,9 +18,14 @@
package org.glassfish.cdi.transaction;
import org.easymock.EasyMockSupport;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import jakarta.enterprise.inject.spi.*;
+import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
+import jakarta.enterprise.inject.spi.AnnotatedType;
+import jakarta.enterprise.inject.spi.Bean;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.enterprise.inject.spi.InjectionTarget;
+import jakarta.enterprise.inject.spi.InjectionTargetFactory;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
@@ -34,8 +40,8 @@
EasyMockSupport mockSupport = new EasyMockSupport();
AfterBeanDiscovery event = mockSupport.createMock(AfterBeanDiscovery.class);
BeanManager beanManager = mockSupport.createMock(BeanManager.class);
- AnnotatedType<TransactionScopedCDIEventHelperImpl> annotatedType = (AnnotatedType<TransactionScopedCDIEventHelperImpl>) mockSupport
- .createMock(AnnotatedType.class);
+ AnnotatedType<TransactionScopedCDIEventHelperImpl> annotatedType
+ = (AnnotatedType<TransactionScopedCDIEventHelperImpl>) mockSupport.createMock(AnnotatedType.class);
InjectionTargetFactory injectionTargetFactory = mockSupport.createMock(InjectionTargetFactory.class);
InjectionTarget injectionTarget = mockSupport.createMock(InjectionTarget.class);
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextImplTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextImplTest.java
index cc91b06..8f5abbc 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextImplTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionScopedContextImplTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,24 +17,31 @@
package org.glassfish.cdi.transaction;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.easymock.EasyMockSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import jakarta.enterprise.context.ContextNotActiveException;
import jakarta.enterprise.context.spi.Contextual;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.PassivationCapable;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import jakarta.transaction.Status;
import jakarta.transaction.TransactionScoped;
import jakarta.transaction.TransactionSynchronizationRegistry;
-import static junit.framework.Assert.*;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.same;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
@@ -46,7 +54,7 @@
private EasyMockSupport mockSupport = null;
private InitialContext initialContext = null;
- @Before
+ @BeforeEach
public void beforeTest() throws Exception {
mockSupport = new EasyMockSupport();
initialContext = mockSupport.createMock(InitialContext.class);
@@ -58,7 +66,7 @@
System.setProperty(Context.URL_PKG_PREFIXES, MyInitialContext.class.getPackage().getName());
}
- @After
+ @AfterEach
public void afterTest() throws Exception {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryProperty == null ? "" : initialContextFactoryProperty);
System.setProperty(Context.URL_PKG_PREFIXES, urlPkgPrefixes == null ? "" : urlPkgPrefixes);
@@ -173,14 +181,8 @@
setupMocksForInactiveTransaction(transactionSynchronizationRegistry);
mockSupport.replayAll();
- TransactionScopedContextImpl transactionScopedContext = new TransactionScopedContextImpl();
-
- try {
- transactionScopedContext.get(contextual, creationalContext);
- fail("Should have gotten a ContextNotActiveException.");
- } catch (ContextNotActiveException ignore) {
- }
-
+ final TransactionScopedContextImpl transactionScopedContext = new TransactionScopedContextImpl();
+ assertThrows(ContextNotActiveException.class, () -> transactionScopedContext.get(contextual, creationalContext));
mockSupport.verifyAll();
mockSupport.resetAll();
@@ -233,14 +235,8 @@
setupMocksForInactiveTransaction(transactionSynchronizationRegistry);
mockSupport.replayAll();
- transactionScopedContext = new TransactionScopedContextImpl();
-
- try {
- transactionScopedContext.get(contextual);
- fail("Should have gotten a ContextNotActiveException.");
- } catch (ContextNotActiveException ignore) {
- }
-
+ final TransactionScopedContextImpl transactionScopedContext2 = new TransactionScopedContextImpl();
+ assertThrows(ContextNotActiveException.class, () -> transactionScopedContext2.get(contextual));
mockSupport.verifyAll();
mockSupport.resetAll();
@@ -249,7 +245,7 @@
setupMocksForGetContextualInstance(transactionSynchronizationRegistry, contextual, transactionScopedBean, localBean);
mockSupport.replayAll();
- retrievedLocalBean = transactionScopedContext.get(contextual);
+ retrievedLocalBean = transactionScopedContext2.get(contextual);
assertSame(localBean, retrievedLocalBean);
mockSupport.verifyAll();
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionalAnnotationTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionalAnnotationTest.java
index 457f606..7709391 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionalAnnotationTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/cdi/transaction/TransactionalAnnotationTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,38 +17,39 @@
package org.glassfish.cdi.transaction;
-import junit.framework.TestCase;
-
-import jakarta.transaction.*;
import java.sql.SQLException;
import java.sql.SQLWarning;
+import org.junit.jupiter.api.Test;
+
+import jakarta.transaction.InvalidTransactionException;
+import jakarta.transaction.RollbackException;
+import jakarta.transaction.TransactionRequiredException;
+import jakarta.transaction.Transactional;
+import jakarta.transaction.TransactionalException;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
+
/**
* User: paulparkinson Date: 12/10/12 Time: 3:50 PM
*/
-public class TransactionalAnnotationTest extends TestCase {
+public class TransactionalAnnotationTest {
- public static void main(String args[]) throws Exception {
- TransactionalAnnotationTest transactionalAnnotationTest = new TransactionalAnnotationTest();
- transactionalAnnotationTest.testTransactionalInterceptorMANDATORY();
- transactionalAnnotationTest.testTransactionalInterceptorNEVER();
- transactionalAnnotationTest.testTransactionalInterceptorNOT_SUPPORTED();
- transactionalAnnotationTest.testTransactionalInterceptorREQUIRED();
- transactionalAnnotationTest.testTransactionalInterceptorREQUIRES_NEW();
- transactionalAnnotationTest.testTransactionalInterceptorSUPPORTS();
- }
-
+ @Test
public void testTransactionalInterceptorMANDATORY() throws Exception {
TransactionalInterceptorMandatory transactionalInterceptorMANDATORY = new TransactionalInterceptorMandatory();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorMANDATORY.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanMandatory.class.getMethod("foo", String.class), null);
try {
transactionalInterceptorMANDATORY.transactional(ctx);
fail("should have thrown TransactionRequiredException due to " + "transactionalInterceptorMANDATORY and no tx in place");
} catch (TransactionalException transactionalException) {
- assertTrue("transactionalException.getCause() instanceof TransactionRequiredException",
- transactionalException.getCause() instanceof TransactionRequiredException);
+ assertThat("transactionalException.getCause()", transactionalException.getCause(),
+ instanceOf(TransactionRequiredException.class));
}
transactionManager.begin();
transactionalInterceptorMANDATORY.transactional(ctx);
@@ -56,15 +58,15 @@
transactionalInterceptorMANDATORY.transactional(ctx);
fail("should have thrown TransactionRequiredException due to " + "transactionalInterceptorMANDATORY and no tx in place");
} catch (TransactionalException transactionalException) {
- assertTrue("transactionalException.getCause() instanceof TransactionRequiredException",
- transactionalException.getCause() instanceof TransactionRequiredException);
+ assertThat("transactionalException.getCause()", transactionalException.getCause(),
+ instanceOf(TransactionRequiredException.class));
}
}
public void testTransactionalInterceptorNEVER() throws Exception {
TransactionalInterceptorNever transactionalInterceptorNEVER = new TransactionalInterceptorNever();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorNEVER.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanNever.class.getMethod("foo", String.class), null);
transactionalInterceptorNEVER.transactional(ctx);
transactionManager.begin();
@@ -72,8 +74,8 @@
transactionalInterceptorNEVER.transactional(ctx);
fail("should have thrown InvalidTransactionException due to " + "TransactionalInterceptorNEVER and tx in place");
} catch (TransactionalException transactionalException) {
- assertTrue("transactionalException.getCause() instanceof InvalidTransactionException",
- transactionalException.getCause() instanceof InvalidTransactionException);
+ assertThat("transactionalException.getCause()", transactionalException.getCause(),
+ instanceOf(InvalidTransactionException.class));
} finally {
transactionManager.rollback();
}
@@ -82,7 +84,7 @@
public void testTransactionalInterceptorNOT_SUPPORTED() throws Exception {
TransactionalInterceptorNotSupported transactionalInterceptorNOT_SUPPORTED = new TransactionalInterceptorNotSupported();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorNOT_SUPPORTED.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanNotSupported.class.getMethod("foo", String.class), null);
transactionalInterceptorNOT_SUPPORTED.transactional(ctx);
}
@@ -90,7 +92,7 @@
public void testTransactionalInterceptorREQUIRED() throws Exception {
TransactionalInterceptorRequired transactionalInterceptorREQUIRED = new TransactionalInterceptorRequired();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorREQUIRED.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanRequired.class.getMethod("foo", String.class), null);
transactionalInterceptorREQUIRED.transactional(ctx);
transactionManager.begin();
@@ -102,7 +104,7 @@
public void testTransactionalInterceptorREQUIRES_NEW() throws Exception {
TransactionalInterceptorRequiresNew transactionalInterceptorREQUIRES_NEW = new TransactionalInterceptorRequiresNew();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorREQUIRES_NEW.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanRequiresNew.class.getMethod("foo", String.class), null);
transactionalInterceptorREQUIRES_NEW.transactional(ctx);
transactionManager.begin();
@@ -114,7 +116,7 @@
public void testTransactionalInterceptorSUPPORTS() throws Exception {
TransactionalInterceptorSupports transactionalInterceptorSUPPORTS = new TransactionalInterceptorSupports();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorSUPPORTS.setTestTransactionManager(transactionManager);
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
jakarta.interceptor.InvocationContext ctx = new InvocationContext(BeanSupports.class.getMethod("foo", String.class), null);
transactionalInterceptorSUPPORTS.transactional(ctx);
transactionManager.begin();
@@ -123,139 +125,115 @@
}
public void testSpecRollbackOnDontRollbackOnSample() throws Exception {
-
TransactionalInterceptorRequired transactionalInterceptorREQUIRED = new TransactionalInterceptorRequired();
jakarta.transaction.TransactionManager transactionManager = new TransactionManager();
- transactionalInterceptorREQUIRED.setTestTransactionManager(transactionManager);
- jakarta.interceptor.InvocationContext ctx = new InvocationContext(
+ TransactionalInterceptorBase.setTestTransactionManager(transactionManager);
+ {
+ jakarta.interceptor.InvocationContext ctx = new InvocationContext(
BeanSpecExampleOfRollbackDontRollback.class.getMethod("throwSQLException"), null) {
- @Override
- public Object getTarget() {
- return new BeanSpecExampleOfRollbackDontRollback();
- }
- @Override
- public Object proceed() throws Exception {
- throw new SQLException("test SQLException");
- }
- };
- transactionManager.begin();
- try {
- transactionalInterceptorREQUIRED.transactional(ctx);
- } catch (SQLException sqlex) {
+ @Override
+ public Object getTarget() {
+ return new BeanSpecExampleOfRollbackDontRollback();
+ }
+
+ @Override
+ public Object proceed() throws Exception {
+ throw new SQLException("test SQLException");
+ }
+ };
+ transactionManager.begin();
+ assertThrows(SQLException.class, () -> transactionalInterceptorREQUIRED.transactional(ctx));
+ assertThrows(RollbackException.class, transactionManager::commit);
}
- try {
+ {
+ // Now with a child of SQLException
+ InvocationContext ctx = new InvocationContext(
+ BeanSpecExampleOfRollbackDontRollback.class.getMethod("throwSQLException"), null) {
+
+ @Override
+ public Object getTarget() {
+ return new BeanSpecExampleOfRollbackDontRollback();
+ }
+
+ @Override
+ public Object proceed() throws Exception {
+ throw new SQLExceptionExtension();
+ }
+ };
+ transactionManager.begin();
+ assertThrows(SQLExceptionExtension.class, () -> transactionalInterceptorREQUIRED.transactional(ctx));
+ assertThrows(RollbackException.class, transactionManager::commit);
+ }
+ {
+
+ // now with a child of SQLException but one that is specified as dontRollback
+ InvocationContext ctx = new InvocationContext(
+ BeanSpecExampleOfRollbackDontRollback.class.getMethod("throwSQLWarning"), null) {
+
+ @Override
+ public Object proceed() throws Exception {
+ throw new SQLWarning("test SQLWarning");
+ }
+
+ @Override
+ public Object getTarget() {
+ return new BeanSpecExampleOfRollbackDontRollback();
+ }
+ };
+ transactionManager.begin();
+ assertThrows(SQLWarning.class, () -> transactionalInterceptorREQUIRED.transactional(ctx));
transactionManager.commit();
- fail("should have thrown RollbackException due to mark for rollback");
- } catch (RollbackException rbe) {
}
+ {
+ // now with a child of SQLWarning but one that is specified as rollback
+ // ie testing this
+ // @Transactional(
+ // rollbackOn = {SQLException.class, SQLWarningExtension.class},
+ // dontRollbackOn = {SQLWarning.class})
+ // where dontRollbackOn=SQLWarning overrides rollbackOn=SQLException,
+ // but rollbackOn=SQLWarningExtension overrides dontRollbackOn=SQLWarning
+ // ie...
+ // SQLException isAssignableFrom SQLWarning
+ // SQLWarning isAssignableFrom SQLWarningExtensionExtension
+ // SQLWarningExtensionExtension isAssignableFrom SQLWarningExtension
+ InvocationContext ctx = new InvocationContext(
+ BeanSpecExampleOfRollbackDontRollbackExtension.class.getMethod("throwSQLWarning"), null) {
- // Now with a child of SQLException
- ctx = new InvocationContext(BeanSpecExampleOfRollbackDontRollback.class.getMethod("throwSQLException"), null) {
- @Override
- public Object getTarget() {
- return new BeanSpecExampleOfRollbackDontRollback();
- }
+ @Override
+ public Object proceed() throws Exception {
+ throw new SQLWarningExtension();
+ }
- @Override
- public Object proceed() throws Exception {
- throw new SQLExceptionExtension();
- }
- };
- transactionManager.begin();
- try {
- transactionalInterceptorREQUIRED.transactional(ctx);
- } catch (SQLExceptionExtension sqlex) {
+ @Override
+ public Object getTarget() {
+ return new BeanSpecExampleOfRollbackDontRollbackExtension();
+ }
+ };
+ transactionManager.begin();
+ assertThrows(SQLWarningExtension.class, () -> transactionalInterceptorREQUIRED.transactional(ctx));
+ assertThrows(RollbackException.class, transactionManager::commit);
}
- try {
- transactionManager.commit();
- fail("should have thrown RollbackException due to mark for rollback");
- } catch (RollbackException rbe) {
+ {
+ // same as above test but with extension just to show continued inheritance...
+ InvocationContext ctx = new InvocationContext(
+ BeanSpecExampleOfRollbackDontRollbackExtension.class.getMethod("throwSQLWarning"), null) {
+
+ @Override
+ public Object proceed() throws Exception {
+ throw new SQLWarningExtensionExtension();
+ }
+
+ @Override
+ public Object getTarget() {
+ return new BeanSpecExampleOfRollbackDontRollbackExtension();
+ }
+
+ };
+ transactionManager.begin();
+ assertThrows(SQLWarningExtensionExtension.class, () -> transactionalInterceptorREQUIRED.transactional(ctx));
+ assertThrows(RollbackException.class, transactionManager::commit);
}
-
- // now with a child of SQLException but one that is specified as dontRollback
- ctx = new InvocationContext(BeanSpecExampleOfRollbackDontRollback.class.getMethod("throwSQLWarning"), null) {
- @Override
- public Object proceed() throws Exception {
- throw new SQLWarning("test SQLWarning");
- }
-
- @Override
- public Object getTarget() {
- return new BeanSpecExampleOfRollbackDontRollback();
- }
-
- };
- transactionManager.begin();
- try {
- transactionalInterceptorREQUIRED.transactional(ctx);
- } catch (SQLWarning sqlex) {
- }
- try {
- transactionManager.commit();
- } catch (Exception rbe) {
- fail("should not thrown Exception");
- }
-
- // now with a child of SQLWarning but one that is specified as rollback
- // ie testing this
- // @Transactional(
- // rollbackOn = {SQLException.class, SQLWarningExtension.class},
- // dontRollbackOn = {SQLWarning.class})
- // where dontRollbackOn=SQLWarning overrides rollbackOn=SQLException,
- // but rollbackOn=SQLWarningExtension overrides dontRollbackOn=SQLWarning
- // ie...
- // SQLException isAssignableFrom SQLWarning
- // SQLWarning isAssignableFrom SQLWarningExtensionExtension
- // SQLWarningExtensionExtension isAssignableFrom SQLWarningExtension
-
- ctx = new InvocationContext(BeanSpecExampleOfRollbackDontRollbackExtension.class.getMethod("throwSQLWarning"), null) {
- @Override
- public Object proceed() throws Exception {
- throw new SQLWarningExtension();
- }
-
- @Override
- public Object getTarget() {
- return new BeanSpecExampleOfRollbackDontRollbackExtension();
- }
-
- };
- transactionManager.begin();
- try {
- transactionalInterceptorREQUIRED.transactional(ctx);
- } catch (SQLWarningExtension sqlex) {
- }
- try {
- transactionManager.commit();
- fail("should have thrown RollbackException due to mark for rollback");
- } catch (RollbackException rbe) {
- }
-
- //same as above test but with extension just to show continued inheritance...
- ctx = new InvocationContext(BeanSpecExampleOfRollbackDontRollbackExtension.class.getMethod("throwSQLWarning"), null) {
- @Override
- public Object proceed() throws Exception {
- throw new SQLWarningExtensionExtension();
- }
-
- @Override
- public Object getTarget() {
- return new BeanSpecExampleOfRollbackDontRollbackExtension();
- }
-
- };
- transactionManager.begin();
- try {
- transactionalInterceptorREQUIRED.transactional(ctx);
- } catch (SQLWarningExtensionExtension sqlex) {
- }
- try {
- transactionManager.commit();
- fail("should have thrown RollbackException due to mark for rollback");
- } catch (RollbackException rbe) {
- }
-
}
class SQLExceptionExtension extends SQLException {
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/RootBeanDeploymentArchiveTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/RootBeanDeploymentArchiveTest.java
index f54dbfd..504f987 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/RootBeanDeploymentArchiveTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/RootBeanDeploymentArchiveTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,25 +18,29 @@
package org.glassfish.weld;
import com.sun.enterprise.deployment.EjbDescriptor;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.easymock.EasyMockSupport;
import org.glassfish.api.deployment.DeploymentContext;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.weld.connector.WeldUtils;
import org.jboss.weld.bootstrap.WeldBootstrap;
import org.jboss.weld.bootstrap.spi.BeanDiscoveryMode;
import org.jboss.weld.bootstrap.spi.BeansXml;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.*;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertSame;
-import static org.easymock.EasyMock.*;
-
-import org.easymock.EasyMockSupport;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.*;
-import org.junit.Ignore;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.expect;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldActivatorTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldActivatorTest.java
index b072337..62ad5dd 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldActivatorTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldActivatorTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,12 +17,14 @@
package org.glassfish.weld;
-import org.jboss.weld.bootstrap.api.SingletonProvider;
-import org.junit.Test;
-import static junit.framework.Assert.*;
-
import java.lang.reflect.Field;
+import org.jboss.weld.bootstrap.api.SingletonProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
*/
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldApplicationContainerTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldApplicationContainerTest.java
index 9b08896..cc6a63c 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldApplicationContainerTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldApplicationContainerTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,9 +17,11 @@
package org.glassfish.weld;
-import org.glassfish.api.deployment.ApplicationContext;
-import org.junit.Test;
-import static junit.framework.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContainerTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContainerTest.java
index 5d26434..b54e2dc 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContainerTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContainerTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,9 +17,9 @@
package org.glassfish.weld;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContextListenerTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContextListenerTest.java
index 54dcc1e..232c917 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContextListenerTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/WeldContextListenerTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,25 +17,31 @@
package org.glassfish.weld;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+
import org.apache.catalina.core.StandardContext;
import org.apache.jasper.runtime.JspApplicationContextImpl;
import org.easymock.EasyMockSupport;
-
-import static junit.framework.Assert.*;
-import static org.easymock.EasyMock.*;
-
import org.jboss.weld.module.web.el.WeldELContextListener;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import jakarta.el.ELResolver;
import jakarta.el.ExpressionFactory;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.jsp.JspApplicationContext;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:j.j.snyder@oracle.com">JJ Snyder</a>
@@ -119,13 +126,14 @@
}
private class LocalWeldContextListener extends WeldContextListener {
- private JspApplicationContext jspApplicationContext;
+ private final JspApplicationContext jspApplicationContext;
public LocalWeldContextListener(JspApplicationContext jspApplicationContext) {
super();
this.jspApplicationContext = jspApplicationContext;
}
+ @Override
protected JspApplicationContext getJspApplicationContext(ServletContextEvent servletContextEvent) {
return jspApplicationContext;
}
diff --git a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/services/TransactionServicesImplTest.java b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/services/TransactionServicesImplTest.java
index 9798559..c631139 100644
--- a/appserver/web/weld-integration/src/test/java/org/glassfish/weld/services/TransactionServicesImplTest.java
+++ b/appserver/web/weld-integration/src/test/java/org/glassfish/weld/services/TransactionServicesImplTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,15 +18,24 @@
package org.glassfish.weld.services;
import com.sun.enterprise.transaction.api.JavaEETransactionManager;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.junit.Test;
-
-import static junit.framework.Assert.*;
-import static org.easymock.EasyMock.*;
-
-import static jakarta.transaction.Status.*;
import org.easymock.EasyMockSupport;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.junit.jupiter.api.Test;
+
+import static jakarta.transaction.Status.STATUS_ACTIVE;
+import static jakarta.transaction.Status.STATUS_COMMITTED;
+import static jakarta.transaction.Status.STATUS_COMMITTING;
+import static jakarta.transaction.Status.STATUS_MARKED_ROLLBACK;
+import static jakarta.transaction.Status.STATUS_NO_TRANSACTION;
+import static jakarta.transaction.Status.STATUS_PREPARED;
+import static jakarta.transaction.Status.STATUS_PREPARING;
+import static jakarta.transaction.Status.STATUS_ROLLEDBACK;
+import static jakarta.transaction.Status.STATUS_ROLLING_BACK;
+import static jakarta.transaction.Status.STATUS_UNKNOWN;
+import static org.easymock.EasyMock.expect;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TransactionServicesImplTest {
@Test