From 726655af50b6747b8c87ed023aa7911c2b4fe2ed Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Jun 2012 12:52:24 +0200 Subject: [PATCH] Fix outdated Javadoc in the TestContext framework Fixed outdated Javadoc regarding support for 'annotated classes' in the TestContext Framework. --- .../AbstractJUnit4SpringContextTests.java | 28 +++++++++---------- ...TransactionalJUnit4SpringContextTests.java | 23 ++++++--------- .../AbstractTestNGSpringContextTests.java | 28 +++++++++---------- ...TransactionalTestNGSpringContextTests.java | 19 +++++-------- ...TransactionalTestNGSpringContextTests.java | 7 ++--- 5 files changed, 45 insertions(+), 60 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java index 69916d321df..19806cd1632 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java @@ -18,7 +18,9 @@ package org.springframework.test.context.junit4; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.junit.runner.RunWith; + import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.ContextConfiguration; @@ -29,30 +31,26 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution import org.springframework.test.context.support.DirtiesContextTestExecutionListener; /** - *

* Abstract base test class which integrates the Spring TestContext * Framework with explicit {@link ApplicationContext} testing support in a * JUnit 4.5+ environment. - *

- *

- * Concrete subclasses should typically declare a class-level + * + *

Concrete subclasses should typically declare a class-level * {@link ContextConfiguration @ContextConfiguration} annotation to - * configure the {@link ApplicationContext application context} - * {@link ContextConfiguration#locations() resource locations}. - * If your test does not need to load an application context, you may choose - * to omit the {@link ContextConfiguration @ContextConfiguration} declaration - * and to configure the appropriate - * {@link org.springframework.test.context.TestExecutionListener TestExecutionListeners} - * manually. - *

- *

- * Note: this class serves only as a convenience for extension. If you do not + * configure the {@link ApplicationContext application context} {@link + * ContextConfiguration#locations() resource locations} or {@link + * ContextConfiguration#classes() annotated classes}. If your test does not + * need to load an application context, you may choose to omit the {@link + * ContextConfiguration @ContextConfiguration} declaration and to configure + * the appropriate {@link org.springframework.test.context.TestExecutionListener + * TestExecutionListeners} manually. + * + *

Note: this class serves only as a convenience for extension. If you do not * wish for your test classes to be tied to a Spring-specific class hierarchy, * you may configure your own custom test classes by using * {@link SpringJUnit4ClassRunner}, {@link ContextConfiguration * @ContextConfiguration}, {@link TestExecutionListeners * @TestExecutionListeners}, etc. - *

* * @author Sam Brannen * @since 2.5 diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java index 541ffd241ab..f0d2782790f 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java @@ -32,33 +32,28 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; /** - *

* Abstract {@link Transactional transactional} extension of * {@link AbstractJUnit4SpringContextTests} which adds convenience functionality * for JDBC access. Expects a {@link DataSource} bean and a * {@link PlatformTransactionManager} bean to be defined in the Spring * {@link ApplicationContext application context}. - *

- *

- * This class exposes a {@link SimpleJdbcTemplate} and provides an easy way to - * {@link #countRowsInTable(String) count the number of rows in a table} , - * {@link #deleteFromTables(String...) delete from the database} , and + * + *

This class exposes a {@link SimpleJdbcTemplate} and provides an easy way + * to {@link #countRowsInTable(String) count the number of rows in a table}, + * {@link #deleteFromTables(String...) delete from tables}, and * {@link #executeSqlScript(String, boolean) execute SQL scripts} within a * transaction. - *

- *

- * Concrete subclasses must fulfill the same requirements outlined in + * + *

Concrete subclasses must fulfill the same requirements outlined in * {@link AbstractJUnit4SpringContextTests}. - *

- *

- * Note: this class serves only as a convenience for extension. If you do not + * + *

Note: this class serves only as a convenience for extension. If you do not * wish for your test classes to be tied to a Spring-specific class hierarchy, * you may configure your own custom test classes by using * {@link SpringJUnit4ClassRunner}, {@link ContextConfiguration * @ContextConfiguration}, {@link TestExecutionListeners * @TestExecutionListeners}, {@link Transactional @Transactional}, * etc. - *

* * @author Sam Brannen * @author Juergen Hoeller @@ -76,9 +71,9 @@ import org.springframework.transaction.annotation.Transactional; * @see org.springframework.test.jdbc.SimpleJdbcTestUtils * @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests */ -@SuppressWarnings("deprecation") @TestExecutionListeners(TransactionalTestExecutionListener.class) @Transactional +@SuppressWarnings("deprecation") public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests { /** diff --git a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java index 91192c50f0c..7f002792f1b 100644 --- a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.ContextConfiguration; @@ -29,6 +30,7 @@ import org.springframework.test.context.TestContextManager; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.support.DirtiesContextTestExecutionListener; + import org.testng.IHookCallBack; import org.testng.IHookable; import org.testng.ITestResult; @@ -38,27 +40,23 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; /** - *

- * Abstract base test class which integrates the - * Spring TestContext Framework with explicit - * {@link ApplicationContext} testing support in a TestNG + * Abstract base test class which integrates the Spring TestContext Framework + * with explicit {@link ApplicationContext} testing support in a TestNG * environment. - *

- *

- * Concrete subclasses: - *

+ * + *

Concrete subclasses: *

* * @author Sam Brannen diff --git a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java index 8c0736c0ea4..b560a6fdf07 100644 --- a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java @@ -31,24 +31,20 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; /** - *

* Abstract {@link Transactional transactional} extension of * {@link AbstractTestNGSpringContextTests} which adds convenience functionality * for JDBC access. Expects a {@link DataSource} bean and a * {@link PlatformTransactionManager} bean to be defined in the Spring * {@link ApplicationContext application context}. - *

- *

- * This class exposes a {@link SimpleJdbcTemplate} and provides an easy way to - * {@link #countRowsInTable(String) count the number of rows in a table} , - * {@link #deleteFromTables(String...) delete from the database} , and + * + *

This class exposes a {@link SimpleJdbcTemplate} and provides an easy way + * to {@link #countRowsInTable(String) count the number of rows in a table}, + * {@link #deleteFromTables(String...) delete from tables}, and * {@link #executeSqlScript(String, boolean) execute SQL scripts} within a * transaction. - *

- *

- * Concrete subclasses must fulfill the same requirements outlined in + * + *

Concrete subclasses must fulfill the same requirements outlined in * {@link AbstractTestNGSpringContextTests}. - *

* * @author Sam Brannen * @author Juergen Hoeller @@ -64,9 +60,9 @@ import org.springframework.transaction.annotation.Transactional; * @see org.springframework.test.jdbc.SimpleJdbcTestUtils * @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests */ -@SuppressWarnings("deprecation") @TestExecutionListeners(TransactionalTestExecutionListener.class) @Transactional +@SuppressWarnings("deprecation") public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests { /** @@ -125,7 +121,6 @@ public abstract class AbstractTransactionalTestNGSpringContextTests extends Abst * and continueOnError was false */ protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException { - Resource resource = this.applicationContext.getResource(sqlResourcePath); SimpleJdbcTestUtils.executeSqlScript(this.simpleJdbcTemplate, new EncodedResource(resource, this.sqlScriptEncoding), continueOnError); diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java index c8bc3811eb5..dfabc22d7d7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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,7 +32,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.test.annotation.NotTransactional; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; import org.springframework.transaction.PlatformTransactionManager; @@ -48,13 +47,13 @@ import org.testng.annotations.Test; * classes with TestNG-based tests. * *

Configuration will be loaded from - * {@link AnnotationConfigTransactionalTestNGSpringContextTestsConfig}. + * {@link AnnotationConfigTransactionalTestNGSpringContextTests.ContextConfiguration}. * * @author Sam Brannen * @since 3.1 */ @SuppressWarnings("deprecation") -@ContextConfiguration(loader = AnnotationConfigContextLoader.class) +@ContextConfiguration public class AnnotationConfigTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests {