Skip to content

Commit

Permalink
Upgrade to "TestNG Engine for the JUnit Platform" version 1.0.5
Browse files Browse the repository at this point in the history
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 junit-team/testng-engine#16
  • Loading branch information
sbrannen committed Jan 2, 2024
1 parent 7876db0 commit 6eed2b0
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion framework-platform/framework-platform.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -39,7 +39,7 @@
* @since 5.1
*/
@ContextConfiguration
public class AnnotationConfigTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
class AnnotationConfigTestNGSpringContextTests extends AbstractTestNGSpringContextTests {

@Autowired
Employee employee;
Expand All @@ -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");

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -54,7 +54,7 @@
* @since 3.1
*/
@ContextConfiguration
public class AnnotationConfigTransactionalTestNGSpringContextTests
class AnnotationConfigTransactionalTestNGSpringContextTests
extends AbstractTransactionalTestNGSpringContextTests {

private static final String JANE = "jane";
Expand Down Expand Up @@ -112,7 +112,7 @@ void afterClass() {

@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");

Expand All @@ -136,7 +136,7 @@ void setUp() throws Exception {
}

@Test
public void modifyTestDataWithinTransaction() {
void modifyTestDataWithinTransaction() {
assertThatTransaction().isActive();
assertAddPerson(JANE);
assertAddPerson(SUE);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -46,7 +46,7 @@
* @since 2.5
*/
@ContextConfiguration
public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
implements BeanNameAware, InitializingBean {

private static final String JANE = "jane";
Expand Down Expand Up @@ -150,7 +150,7 @@ void afterTransaction() {

@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.")
Expand All @@ -159,7 +159,7 @@ public void verifyBeanNameSet() {

@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.")
Expand All @@ -170,7 +170,7 @@ public void verifyApplicationContextSet() {

@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.")
Expand All @@ -179,7 +179,7 @@ public void verifyBeanInitialized() {

@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();
Expand All @@ -188,28 +188,28 @@ public void verifyAnnotationAutowiredFields() {

@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");
}

@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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -47,7 +47,7 @@
* @since 2.5
*/
@ContextConfiguration
public class DirtiesContextTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {
class DirtiesContextTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {

private ApplicationContext dirtiedApplicationContext;

Expand All @@ -64,13 +64,13 @@ private void performCommonAssertions() {

@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'.")
Expand All @@ -79,7 +79,7 @@ public void verifyContextWasDirtied() {
}

@Test(dependsOnMethods = { "verifyContextWasDirtied" })
public void verifyContextWasNotDirtied() {
void verifyContextWasNotDirtied() {
assertThat(this.applicationContext)
.as("The application context should NOT have been 'dirtied'.")
.isSameAs(this.dirtiedApplicationContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -32,16 +32,16 @@
* @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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -61,7 +61,7 @@ public void asyncPublication() throws InterruptedException {
}

@Test
public void asyncConsumption() {
void asyncConsumption() {
context.publishEvent(new CustomEvent("asyncConsumption"));

Awaitility.await().atMost(Durations.ONE_SECOND)
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -72,12 +72,12 @@ void beforeEach() {
}

@Test
public void test1() {
void test1() {
assertTestExpectations("test1");
}

@Test
public void test2() {
void test2() {
assertTestExpectations("test2");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,7 +38,7 @@
* @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";

Expand All @@ -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);
}
Expand All @@ -67,7 +67,7 @@ public void test2IncrementCount1() {
* 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);

Expand All @@ -76,7 +76,7 @@ public void test3IncrementCount2() {
}

@AfterMethod(alwaysRun = true)
public void synchronizePersistenceContext() {
void synchronizePersistenceContext() {
em.flush();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,7 +35,7 @@
@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 */

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,7 +35,7 @@
@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 */

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -36,7 +36,7 @@
*/
@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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,7 +38,7 @@
*/
@Test(suiteName = "Rollback for REQUIRES_NEW")
@Rollback
public class RollbackForRequiresNewEjbTxDaoTestNGTests extends CommitForRequiresNewEjbTxDaoTestNGTests {
class RollbackForRequiresNewEjbTxDaoTestNGTests extends CommitForRequiresNewEjbTxDaoTestNGTests {

/* test methods in superclass */

Expand Down
Loading

0 comments on commit 6eed2b0

Please sign in to comment.