Segregate add'l long-running and performance tests

- Add TestGroup#LONG_RUNNING to distinguish from #PERFORMANCE, the
   former being tests that simply take a long time vs the latter being
   tests that are actually dependent on certain actions happening within
   a given time window and are thefore CPU-dependent.

Issue: SPR-9984
This commit is contained in:
Chris Beams
2013-01-03 12:14:17 +01:00
parent acd86a1fd7
commit 68e3b7773c
19 changed files with 217 additions and 58 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -16,11 +16,6 @@
package org.springframework.jdbc.config;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import javax.sql.DataSource;
import org.junit.Rule;
@@ -37,10 +32,16 @@ import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
/**
* @author Dave Syer
* @author Juergen Hoeller
* @author Chris Beams
*/
public class JdbcNamespaceIntegrationTests {
@@ -49,6 +50,8 @@ public class JdbcNamespaceIntegrationTests {
@Test
public void testCreateEmbeddedDatabase() throws Exception {
Assume.group(TestGroup.LONG_RUNNING);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/jdbc/config/jdbc-config.xml");
assertCorrectSetup(context, "dataSource", "h2DataSource", "derbyDataSource");
@@ -58,6 +61,8 @@ public class JdbcNamespaceIntegrationTests {
@Test
public void testCreateEmbeddedDatabaseAgain() throws Exception {
// If Derby isn't cleaned up properly this will fail...
Assume.group(TestGroup.LONG_RUNNING);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/jdbc/config/jdbc-config.xml");
assertCorrectSetup(context, "derbyDataSource");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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,6 +39,8 @@ import org.mockito.InOrder;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.IllegalTransactionStateException;
import org.springframework.transaction.PlatformTransactionManager;
@@ -845,6 +847,8 @@ public class DataSourceTransactionManagerTests {
}
private void doTestTransactionWithTimeout(int timeout) throws Exception {
Assume.group(TestGroup.PERFORMANCE);
PreparedStatement ps = mock(PreparedStatement.class);
given(con.getAutoCommit()).willReturn(true);
given(con.prepareStatement("some SQL statement")).willReturn(ps);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 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.
@@ -16,13 +16,15 @@
package org.springframework.jdbc.datasource.embedded;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.core.io.ClassRelativeResourceLoader;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.init.CannotReadScriptException;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Keith Donald
@@ -59,6 +61,8 @@ public class EmbeddedDatabaseBuilderTests {
@Test
public void testBuildDerby() {
Assume.group(TestGroup.LONG_RUNNING);
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass()));
EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.DERBY).addScript("db-schema-derby.sql").addScript("db-test-data.sql").build();
assertDatabaseCreatedAndShutdown(db);
@@ -81,4 +85,4 @@ public class EmbeddedDatabaseBuilderTests {
db.shutdown();
}
}
}