Upgrade to "TestNG Engine for the JUnit Platform" version 1.0.5

Thanks to a bug fix in 1.0.5, test methods in TestNG test classes can
finally be package private as was always the case with TestNG itself.

See https://github.com/junit-team/testng-engine/issues/16
This commit is contained in:
Sam Brannen 2024-01-02 15:39:55 +01:00
parent 7876db03c6
commit 6eed2b0aee
16 changed files with 74 additions and 74 deletions

View File

@ -131,7 +131,7 @@ dependencies {
api("org.hsqldb:hsqldb:2.7.2")
api("org.javamoney:moneta:1.4.2")
api("org.jruby:jruby:9.4.5.0")
api("org.junit.support:testng-engine:1.0.4")
api("org.junit.support:testng-engine:1.0.5")
api("org.mozilla:rhino:1.7.14")
api("org.ogce:xpp3:1.1.6")
api("org.python:jython-standalone:2.7.3")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 5.1
*/
@ContextConfiguration
public class AnnotationConfigTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
class AnnotationConfigTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
@Autowired
Employee employee;
@ -48,7 +48,7 @@ public class AnnotationConfigTestNGSpringContextTests extends AbstractTestNGSpri
Pet pet;
@Test
public void autowiringFromConfigClass() {
void autowiringFromConfigClass() {
assertThat(employee).as("The employee should have been autowired.").isNotNull();
assertThat(employee.getName()).isEqualTo("John Smith");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ import static org.springframework.transaction.support.TransactionSynchronization
* @since 3.1
*/
@ContextConfiguration
public class AnnotationConfigTransactionalTestNGSpringContextTests
class AnnotationConfigTransactionalTestNGSpringContextTests
extends AbstractTransactionalTestNGSpringContextTests {
private static final String JANE = "jane";
@ -112,7 +112,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void autowiringFromConfigClass() {
void autowiringFromConfigClass() {
assertThat(employee).as("The employee should have been autowired.").isNotNull();
assertThat(employee.getName()).isEqualTo("John Smith");
@ -136,7 +136,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests
}
@Test
public void modifyTestDataWithinTransaction() {
void modifyTestDataWithinTransaction() {
assertThatTransaction().isActive();
assertAddPerson(JANE);
assertAddPerson(SUE);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ import static org.springframework.transaction.support.TransactionSynchronization
* @since 2.5
*/
@ContextConfiguration
public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
implements BeanNameAware, InitializingBean {
private static final String JANE = "jane";
@ -150,7 +150,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyBeanNameSet() {
void verifyBeanNameSet() {
assertThatTransaction().isNotActive();
assertThat(this.beanName)
.as("The bean name of this test instance should have been set to the fully qualified class name due to BeanNameAware semantics.")
@ -159,7 +159,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyApplicationContextSet() {
void verifyApplicationContextSet() {
assertThatTransaction().isNotActive();
assertThat(super.applicationContext)
.as("The application context should have been set due to ApplicationContextAware semantics.")
@ -170,7 +170,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyBeanInitialized() {
void verifyBeanInitialized() {
assertThatTransaction().isNotActive();
assertThat(beanInitialized)
.as("This test instance should have been initialized due to InitializingBean semantics.")
@ -179,7 +179,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyAnnotationAutowiredFields() {
void verifyAnnotationAutowiredFields() {
assertThatTransaction().isNotActive();
assertThat(nonrequiredLong).as("The nonrequiredLong field should NOT have been autowired.").isNull();
assertThat(pet).as("The pet field should have been autowired.").isNotNull();
@ -188,7 +188,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyAnnotationAutowiredMethods() {
void verifyAnnotationAutowiredMethods() {
assertThatTransaction().isNotActive();
assertThat(employee).as("The setEmployee() method should have been autowired.").isNotNull();
assertThat(employee.getName()).as("employee's name.").isEqualTo("John Smith");
@ -196,20 +196,20 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyResourceAnnotationInjectedFields() {
void verifyResourceAnnotationInjectedFields() {
assertThatTransaction().isNotActive();
assertThat(foo).as("The foo field should have been injected via @Resource.").isEqualTo("Foo");
}
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void verifyResourceAnnotationInjectedMethods() {
void verifyResourceAnnotationInjectedMethods() {
assertThatTransaction().isNotActive();
assertThat(bar).as("The setBar() method should have been injected via @Resource.").isEqualTo("Bar");
}
@Test
public void modifyTestDataWithinTransaction() {
void modifyTestDataWithinTransaction() {
assertThatTransaction().isActive();
assertAddPerson(JANE);
assertAddPerson(SUE);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
* @since 2.5
*/
@ContextConfiguration
public class DirtiesContextTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {
class DirtiesContextTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {
private ApplicationContext dirtiedApplicationContext;
@ -64,13 +64,13 @@ public class DirtiesContextTransactionalTestNGSpringContextTests extends Abstrac
@Test
@DirtiesContext
public void dirtyContext() {
void dirtyContext() {
performCommonAssertions();
this.dirtiedApplicationContext = super.applicationContext;
}
@Test(dependsOnMethods = { "dirtyContext" })
public void verifyContextWasDirtied() {
void verifyContextWasDirtied() {
performCommonAssertions();
assertThat(super.applicationContext)
.as("The application context should have been 'dirtied'.")
@ -79,7 +79,7 @@ public class DirtiesContextTransactionalTestNGSpringContextTests extends Abstrac
}
@Test(dependsOnMethods = { "verifyContextWasDirtied" })
public void verifyContextWasNotDirtied() {
void verifyContextWasNotDirtied() {
assertThat(this.applicationContext)
.as("The application context should NOT have been 'dirtied'.")
.isSameAs(this.dirtiedApplicationContext);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,16 +32,16 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
* @since 3.0
*/
@ContextConfiguration
public class TimedTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {
class TimedTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {
@Test
public void testWithoutTimeout() {
void testWithoutTimeout() {
assertThatTransaction().isActive();
}
// TODO Enable TestNG test with timeout once we have a solution.
@Test(timeOut = 10000, enabled = false)
public void testWithTimeout() {
void testWithTimeout() {
assertThatTransaction().isActive();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ class TestNGApplicationEventsAsyncIntegrationTests extends AbstractTestNGSpringC
@Test
public void asyncPublication() throws InterruptedException {
void asyncPublication() throws InterruptedException {
Thread t = new Thread(() -> context.publishEvent(new CustomEvent("asyncPublication")));
t.start();
t.join();
@ -61,7 +61,7 @@ class TestNGApplicationEventsAsyncIntegrationTests extends AbstractTestNGSpringC
}
@Test
public void asyncConsumption() {
void asyncConsumption() {
context.publishEvent(new CustomEvent("asyncConsumption"));
Awaitility.await().atMost(Durations.ONE_SECOND)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -72,12 +72,12 @@ class TestNGApplicationEventsIntegrationTests extends AbstractTestNGSpringContex
}
@Test
public void test1() {
void test1() {
assertTestExpectations("test1");
}
@Test
public void test2() {
void test2() {
assertTestExpectations("test2");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.0.1
*/
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public abstract class AbstractEjbTxDaoTestNGTests extends AbstractTransactionalTestNGSpringContextTests {
abstract class AbstractEjbTxDaoTestNGTests extends AbstractTransactionalTestNGSpringContextTests {
protected static final String TEST_NAME = "test-name";
@ -50,13 +50,13 @@ public abstract class AbstractEjbTxDaoTestNGTests extends AbstractTransactionalT
@Test
public void test1InitialState() {
void test1InitialState() {
int count = dao.getCount(TEST_NAME);
assertThat(count).as("New TestEntity should have count=0.").isEqualTo(0);
}
@Test(dependsOnMethods = "test1InitialState")
public void test2IncrementCount1() {
void test2IncrementCount1() {
int count = dao.incrementCount(TEST_NAME);
assertThat(count).as("Expected count=1 after first increment.").isEqualTo(1);
}
@ -67,7 +67,7 @@ public abstract class AbstractEjbTxDaoTestNGTests extends AbstractTransactionalT
* expected that the previous increment has been persisted in the database.
*/
@Test(dependsOnMethods = "test2IncrementCount1")
public void test3IncrementCount2() {
void test3IncrementCount2() {
int count = dao.getCount(TEST_NAME);
assertThat(count).as("Expected count=1 after test2IncrementCount1().").isEqualTo(1);
@ -76,7 +76,7 @@ public abstract class AbstractEjbTxDaoTestNGTests extends AbstractTransactionalT
}
@AfterMethod(alwaysRun = true)
public void synchronizePersistenceContext() {
void synchronizePersistenceContext() {
em.flush();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ import org.springframework.test.context.transaction.ejb.dao.RequiredEjbTxTestEnt
@Test(suiteName = "Commit for REQUIRED")
@ContextConfiguration("/org/springframework/test/context/transaction/ejb/required-tx-config.xml")
@Commit
public class CommitForRequiredEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
class CommitForRequiredEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
/* test methods in superclass */

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ import org.springframework.test.context.transaction.ejb.dao.RequiresNewEjbTxTest
@Test(suiteName = "Commit for REQUIRES_NEW")
@ContextConfiguration("/org/springframework/test/context/transaction/ejb/requires-new-tx-config.xml")
@Commit
public class CommitForRequiresNewEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
class CommitForRequiresNewEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
/* test methods in superclass */

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@Test(suiteName = "Rollback for REQUIRED")
@Rollback
public class RollbackForRequiredEjbTxDaoTestNGTests extends CommitForRequiredEjbTxDaoTestNGTests {
class RollbackForRequiredEjbTxDaoTestNGTests extends CommitForRequiredEjbTxDaoTestNGTests {
/**
* Overrides parent implementation in order to change expectations to align with
@ -46,7 +46,7 @@ public class RollbackForRequiredEjbTxDaoTestNGTests extends CommitForRequiredEjb
*/
@Test(dependsOnMethods = "test2IncrementCount1")
@Override
public void test3IncrementCount2() {
void test3IncrementCount2() {
int count = dao.getCount(TEST_NAME);
// Expecting count=0 after test2IncrementCount1() since REQUIRED transactions
// participate in the existing transaction (if present), which in this case is the

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi
*/
@Test(suiteName = "Rollback for REQUIRES_NEW")
@Rollback
public class RollbackForRequiresNewEjbTxDaoTestNGTests extends CommitForRequiresNewEjbTxDaoTestNGTests {
class RollbackForRequiresNewEjbTxDaoTestNGTests extends CommitForRequiresNewEjbTxDaoTestNGTests {
/* test methods in superclass */

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -53,7 +53,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
* @since 4.1
*/
@ContextConfiguration
public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSpringContextTests {
class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSpringContextTests {
private String methodName;
@ -65,13 +65,13 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
}
@BeforeTransaction
public void beforeTransaction() {
void beforeTransaction() {
deleteFromTables("user");
executeSqlScript("classpath:/org/springframework/test/context/jdbc/data.sql", false);
}
@AfterTransaction
public void afterTransaction() {
void afterTransaction() {
switch (this.methodName) {
case "commitTxAndStartNewTx", "commitTxButDoNotStartNewTx" -> assertUsers("Dogbert");
case "rollbackTxAndStartNewTx", "rollbackTxButDoNotStartNewTx", "startTxWithExistingTransaction" ->
@ -83,47 +83,47 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void isActiveWithNonExistentTransactionContext() {
void isActiveWithNonExistentTransactionContext() {
assertThat(TestTransaction.isActive()).isFalse();
}
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void flagForRollbackWithNonExistentTransactionContext() {
void flagForRollbackWithNonExistentTransactionContext() {
TestTransaction.flagForRollback();
}
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void flagForCommitWithNonExistentTransactionContext() {
void flagForCommitWithNonExistentTransactionContext() {
TestTransaction.flagForCommit();
}
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void isFlaggedForRollbackWithNonExistentTransactionContext() {
void isFlaggedForRollbackWithNonExistentTransactionContext() {
TestTransaction.isFlaggedForRollback();
}
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void startTxWithNonExistentTransactionContext() {
void startTxWithNonExistentTransactionContext() {
TestTransaction.start();
}
@Test(expectedExceptions = IllegalStateException.class)
public void startTxWithExistingTransaction() {
void startTxWithExistingTransaction() {
TestTransaction.start();
}
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void endTxWithNonExistentTransactionContext() {
void endTxWithNonExistentTransactionContext() {
TestTransaction.end();
}
@Test
public void commitTxAndStartNewTx() {
void commitTxAndStartNewTx() {
assertThatTransaction().isActive();
assertThat(TestTransaction.isActive()).isTrue();
assertUsers("Dilbert");
@ -147,7 +147,7 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
}
@Test
public void commitTxButDoNotStartNewTx() {
void commitTxButDoNotStartNewTx() {
assertThatTransaction().isActive();
assertThat(TestTransaction.isActive()).isTrue();
assertUsers("Dilbert");
@ -167,7 +167,7 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
}
@Test
public void rollbackTxAndStartNewTx() {
void rollbackTxAndStartNewTx() {
assertThatTransaction().isActive();
assertThat(TestTransaction.isActive()).isTrue();
assertUsers("Dilbert");
@ -192,7 +192,7 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
}
@Test
public void rollbackTxButDoNotStartNewTx() {
void rollbackTxButDoNotStartNewTx() {
assertThatTransaction().isActive();
assertThat(TestTransaction.isActive()).isTrue();
assertUsers("Dilbert");
@ -209,7 +209,7 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
@Test
@Commit
public void rollbackTxAndStartNewTxWithDefaultCommitSemantics() {
void rollbackTxAndStartNewTxWithDefaultCommitSemantics() {
assertThatTransaction().isActive();
assertThat(TestTransaction.isActive()).isTrue();
assertUsers("Dilbert");
@ -251,12 +251,12 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
static class Config {
@Bean
public PlatformTransactionManager transactionManager() {
PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
@Bean
public DataSource dataSource() {
DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration
@WebAppConfiguration
public class ServletTestExecutionListenerTestNGIntegrationTests extends AbstractTestNGSpringContextTests {
class ServletTestExecutionListenerTestNGIntegrationTests extends AbstractTestNGSpringContextTests {
@Configuration
static class Config {
@ -57,7 +57,7 @@ public class ServletTestExecutionListenerTestNGIntegrationTests extends Abstract
* @see #ensureMocksAreReinjectedBetweenTests_2
*/
@Test
public void ensureMocksAreReinjectedBetweenTests_1() {
void ensureMocksAreReinjectedBetweenTests_1() {
assertInjectedServletRequestEqualsRequestInRequestContextHolder();
}
@ -67,7 +67,7 @@ public class ServletTestExecutionListenerTestNGIntegrationTests extends Abstract
* @see #ensureMocksAreReinjectedBetweenTests_1
*/
@Test
public void ensureMocksAreReinjectedBetweenTests_2() {
void ensureMocksAreReinjectedBetweenTests_2() {
assertInjectedServletRequestEqualsRequestInRequestContextHolder();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration
@WebAppConfiguration
public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTests implements ServletContextAware {
class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTests implements ServletContextAware {
@Configuration
static class Config {
@ -88,7 +88,7 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
}
@Test
public void basicWacFeatures() throws Exception {
void basicWacFeatures() throws Exception {
assertThat(wac.getServletContext()).as("ServletContext should be set in the WAC.").isNotNull();
assertThat(servletContext).as("ServletContext should have been set via ServletContextAware.").isNotNull();
@ -113,7 +113,7 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
}
@Test
public void fooEnigmaAutowired() {
void fooEnigmaAutowired() {
assertThat(foo).isEqualTo("enigma");
}