From 91c9f544b1d8127b308f5cf884d91f0c39c0c483 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 3 Jul 2009 09:57:19 +0000 Subject: [PATCH] [SPR-5889] Renaming TestNG tests from *Tests_ back to *Tests, but keeping @org.junit.Ignore to exclude them from the JUnit test run. --- ...ransactionalTestNGSpringContextTests.java} | 33 +++++-------------- ...ransactionalTestNGSpringContextTests.java} | 17 +++++----- 2 files changed, 16 insertions(+), 34 deletions(-) rename org.springframework.test/src/test/java/org/springframework/test/context/testng/{ConcreteTransactionalTestNGSpringContextTests_.java => ConcreteTransactionalTestNGSpringContextTests.java} (82%) rename org.springframework.test/src/test/java/org/springframework/test/context/testng/{DirtiesContextTransactionalTestNGSpringContextTests_.java => DirtiesContextTransactionalTestNGSpringContextTests.java} (83%) diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests_.java b/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java similarity index 82% rename from org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests_.java rename to org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java index 79ad50ce16..30125a76a8 100644 --- a/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests_.java +++ b/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 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. @@ -26,7 +26,6 @@ import static org.testng.Assert.assertTrue; import javax.annotation.Resource; import javax.sql.DataSource; -import org.junit.Ignore; import org.springframework.beans.Employee; import org.springframework.beans.Pet; import org.springframework.beans.factory.BeanNameAware; @@ -48,35 +47,25 @@ import org.testng.annotations.Test; /** * Combined unit test for {@link AbstractTestNGSpringContextTests} and * {@link AbstractTransactionalTestNGSpringContextTests}. - * + * * @author Sam Brannen * @since 2.5 */ -@Ignore // renamed to Tests_ to avoid being picked up by junit. Spring Build support for TestNG is pending. +@org.junit.Ignore("TestNG tests should not be run by JUnit") @ContextConfiguration -public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTransactionalTestNGSpringContextTests +public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests implements BeanNameAware, InitializingBean { - // ------------------------------------------------------------------------| - // --- CONSTANTS ----------------------------------------------------------| - // ------------------------------------------------------------------------| - private static final String BOB = "bob"; private static final String JANE = "jane"; private static final String SUE = "sue"; private static final String YODA = "yoda"; - // ------------------------------------------------------------------------| - // --- STATIC VARIABLES ---------------------------------------------------| - // ------------------------------------------------------------------------| - private static int numSetUpCalls = 0; private static int numSetUpCallsInTransaction = 0; private static int numTearDownCalls = 0; private static int numTearDownCallsInTransaction = 0; - // ------------------------------------------------------------------------| - // --- INSTANCE VARIABLES -------------------------------------------------| // ------------------------------------------------------------------------| private boolean beanInitialized = false; @@ -97,8 +86,6 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran protected String bar; - // ------------------------------------------------------------------------| - // --- STATIC METHODS -----------------------------------------------------| // ------------------------------------------------------------------------| private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) { @@ -126,8 +113,6 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name); } - // ------------------------------------------------------------------------| - // --- INSTANCE METHODS ---------------------------------------------------| // ------------------------------------------------------------------------| public void afterPropertiesSet() throws Exception { @@ -152,7 +137,7 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran private void assertNumRowsInPersonTable(int expectedNumRows, String testState) { assertEquals(countRowsInPersonTable(this.simpleJdbcTemplate), expectedNumRows, - "Verifying the number of rows in the person table (" + testState + ")."); + "Verifying the number of rows in the person table (" + testState + ")."); } private void assertAddPerson(final String name) { @@ -182,7 +167,7 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran public void verifyApplicationContextSet() { assertInTransaction(false); assertNotNull(super.applicationContext, - "The application context should have been set due to ApplicationContextAware semantics."); + "The application context should have been set due to ApplicationContextAware semantics."); Employee employeeBean = (Employee) super.applicationContext.getBean("employee"); assertEquals(employeeBean.getName(), "John Smith", "Verifying employee's name."); } @@ -192,7 +177,7 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran public void verifyBeanInitialized() { assertInTransaction(false); assertTrue(this.beanInitialized, - "This test instance should have been initialized due to InitializingBean semantics."); + "This test instance should have been initialized due to InitializingBean semantics."); } @Test @@ -200,7 +185,7 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran public void verifyBeanNameSet() { assertInTransaction(false); assertEquals(this.beanName, getClass().getName(), - "The bean name of this test instance should have been set due to BeanNameAware semantics."); + "The bean name of this test instance should have been set due to BeanNameAware semantics."); } @Test @@ -275,8 +260,6 @@ public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTran } - // ------------------------------------------------------------------------| - // --- TYPES --------------------------------------------------------------| // ------------------------------------------------------------------------| public static class DatabaseSetup { diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests_.java b/org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests.java similarity index 83% rename from org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests_.java rename to org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests.java index b30e0c74ef..be78b46759 100644 --- a/org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests_.java +++ b/org.springframework.test/src/test/java/org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 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. @@ -21,7 +21,6 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotSame; import static org.testng.Assert.assertSame; -import org.junit.Ignore; import org.springframework.context.ApplicationContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -44,13 +43,13 @@ import org.testng.annotations.Test; * individual tests. DirtiesContextTransactionalTestNGSpringContextTests * therefore verifies the expected behavior and correct semantics. *

- * + * * @author Sam Brannen * @since 2.5 */ -@Ignore // renamed to Tests_ to avoid being picked up by junit. Spring Build support for TestNG is pending. +@org.junit.Ignore("TestNG tests should not be run by JUnit") @ContextConfiguration -public class DirtiesContextTransactionalTestNGSpringContextTests_ extends AbstractTransactionalTestNGSpringContextTests { +public class DirtiesContextTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests { private ApplicationContext dirtiedApplicationContext; @@ -58,9 +57,9 @@ public class DirtiesContextTransactionalTestNGSpringContextTests_ extends Abstra private void performCommonAssertions() { assertInTransaction(true); assertNotNull(super.applicationContext, - "The application context should have been set due to ApplicationContextAware semantics."); + "The application context should have been set due to ApplicationContextAware semantics."); assertNotNull(super.simpleJdbcTemplate, - "The SimpleJdbcTemplate should have been created in setDataSource() via DI for the DataSource."); + "The SimpleJdbcTemplate should have been created in setDataSource() via DI for the DataSource."); } @Test @@ -74,13 +73,13 @@ public class DirtiesContextTransactionalTestNGSpringContextTests_ extends Abstra public void verifyContextWasDirtied() { performCommonAssertions(); assertNotSame(super.applicationContext, this.dirtiedApplicationContext, - "The application context should have been 'dirtied'."); + "The application context should have been 'dirtied'."); this.dirtiedApplicationContext = super.applicationContext; } @Test(dependsOnMethods = { "verifyContextWasDirtied" }) public void verifyContextWasNotDirtied() { assertSame(this.applicationContext, this.dirtiedApplicationContext, - "The application context should NOT have been 'dirtied'."); + "The application context should NOT have been 'dirtied'."); } }