Permalink
Browse files

consolidate src/test and src/matrix

  • Loading branch information...
1 parent 77d83b8 commit 0196ad20f8943cab90fd8d35d2349b247aab6695 @sebersole sebersole committed Jun 7, 2012
Showing 1,944 changed files with 578 additions and 659 deletions.
@@ -31,7 +31,6 @@ import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
-import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.testing.Test
import org.hibernate.build.gradle.testing.database.DatabaseProfile
import org.hibernate.build.gradle.testing.database.DatabaseProfilePlugin
@@ -43,7 +42,7 @@ import static org.gradle.api.plugins.JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME
/**
* TODO : 1) add a base configuration of common attribute across all matrix node tasks (convention)
- * TODO: 2) somehow allow applying just a single database to a project (non matrix testing).
+ * TODO : 2) somehow allow applying just a single database to a project (non matrix testing).
*
* @author Steve Ebersole
* @author Strong Liu
@@ -54,14 +53,13 @@ public class MatrixTestingPlugin implements Plugin<Project> {
public static final String MATRIX_COMPILE_CONFIG_NAME = "matrixCompile";
public static final String MATRIX_RUNTIME_CONFIG_NAME = "matrixRuntime";
public static final String MATRIX_TASK_NAME = "matrix";
- public static final String MATRIX_SOURCE_SET_NAME = "matrix";
- public static final String SKIP_UNIT_TEST = "hibernate-matrix-skip-unittest";
private Project project;
+ private SourceSet testSourceSet;
+
private Configuration matrixCompileConfig;
private Configuration matrixRuntimeConfig;
private Task matrixTask;
- private SourceSet matrixSourceSet;
// currently, only the build jdk is supported
private Jdk theJdk = new Jdk();
@@ -78,23 +76,16 @@ public class MatrixTestingPlugin implements Plugin<Project> {
matrixCompileConfig = prepareCompileConfiguration();
matrixRuntimeConfig = prepareRuntimeConfiguration();
- matrixSourceSet = prepareSourceSet();
+ testSourceSet = project.convention.getPlugin( JavaPluginConvention ).sourceSets
+ .getByName( SourceSet.TEST_SOURCE_SET_NAME );
matrixTask = prepareGroupingTask();
for ( MatrixNode matrixNode: matrixNodes ) {
Task matrixNodeTask = prepareNodeTask( matrixNode );
matrixTask.dependsOn( matrixNodeTask );
}
-
- if ( ! shouldSkipMatrixTestsAgainstDefaultDb() ) {
- createTestTaskForMatrixSourceSet();
- }
}
- private boolean shouldSkipMatrixTestsAgainstDefaultDb() {
- return "true".equals( project.properties[SKIP_UNIT_TEST] ) || "true".equals( System.properties[SKIP_UNIT_TEST] );
- }
-
private List<MatrixNode> locateMatrixNodes() {
List<MatrixNode> matrixNodes = new ArrayList<MatrixNode>();
Iterable<DatabaseProfile> profiles = project.rootProject.plugins[DatabaseProfilePlugin].databaseProfiles;
@@ -127,24 +118,6 @@ public class MatrixTestingPlugin implements Plugin<Project> {
.extendsFrom( project.configurations.getByName( TEST_RUNTIME_CONFIGURATION_NAME ) );
}
-
- private SourceSet prepareSourceSet() {
- final SourceSetContainer sourceSets = project.convention.getPlugin( JavaPluginConvention ).sourceSets;
- SourceSet sourceSet = sourceSets.findByName( MATRIX_SOURCE_SET_NAME );
- if ( sourceSet == null ) {
- sourceSet = sourceSets.add( MATRIX_SOURCE_SET_NAME );
- }
- final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); //sourceSets.main
- final SourceSet unitTestSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); //sourceSets.test
- sourceSet.compileClasspath = mainSourceSet.output + unitTestSourceSet.output + matrixCompileConfig
- sourceSet.runtimeClasspath = sourceSet.output + mainSourceSet.output + unitTestSourceSet.output + matrixRuntimeConfig
- sourceSet.output.classesDir = new File(unitTestSourceSet.output.classesDir.parentFile, "matrix")
- sourceSet.resources {
- setSrcDirs(['src/matrix/java', 'src/matrix/resources'])
- }
- return sourceSet;
- }
-
private Task prepareGroupingTask() {
Task matrixTask = project.tasks.add( MATRIX_TASK_NAME );
matrixTask.group = "Verification"
@@ -169,60 +142,18 @@ public class MatrixTestingPlugin implements Plugin<Project> {
log.debug( "Adding Matrix Testing task $taskName" );
final Test nodeTask = project.tasks.add( taskName, Test );
nodeTask.description = "Runs the matrix against ${node.name}"
- nodeTask.classpath = node.databaseProfile.testingRuntimeConfiguration + matrixSourceSet.runtimeClasspath
- nodeTask.testClassesDir = matrixSourceSet.output.classesDir
+ nodeTask.classpath = node.databaseProfile.testingRuntimeConfiguration + testSourceSet.runtimeClasspath
+ nodeTask.testClassesDir = testSourceSet.output.classesDir
nodeTask.ignoreFailures = true
nodeTask.workingDir = node.baseOutputDirectory
nodeTask.testReportDir = new File(node.baseOutputDirectory, "reports")
nodeTask.testResultsDir = new File(node.baseOutputDirectory, "results")
- nodeTask.dependsOn( project.tasks.getByName( matrixSourceSet.classesTaskName ) );
+ nodeTask.dependsOn( project.tasks.getByName( testSourceSet.classesTaskName ) );
nodeTask.systemProperties = node.databaseAllocation.properties
nodeTask.systemProperties['hibernate.test.validatefailureexpected'] = true
nodeTask.jvmArgs = ['-Xms1024M', '-Xmx1024M']//, '-XX:MaxPermSize=512M', '-Xss4096k', '-Xverify:none', '-XX:+UseFastAccessorMethods', '-XX:+DisableExplicitGC']
nodeTask.maxHeapSize = "1024M"
return nodeTask;
}
-
- /**
- * we need create a Test task which runs tests in matrix and also use resources in test.resources
- */
- private void createTestTaskForMatrixSourceSet() {
- final Test test = project.tasks.test
- final Test matrixUnitTask = project.tasks.add("matrixUnitTest", Test)
- matrixUnitTask.description = "Run matrix sources as unit test"
- matrixUnitTask.classpath = matrixSourceSet.runtimeClasspath
- matrixUnitTask.testClassesDir = matrixSourceSet.output.classesDir
-
- matrixUnitTask.workingDir = test.workingDir
- matrixUnitTask.testReportDir = test.testReportDir
- matrixUnitTask.testResultsDir = test.testResultsDir
- matrixUnitTask.systemProperties = test.systemProperties
- test.dependsOn matrixUnitTask
- def sourceSets = project.convention.getPlugin(JavaPluginConvention).sourceSets
- project.tasks.getByName("processMatrixResources").doLast({
- project.copy {
- from(sourceSets.test.java.srcDirs) {
- include '**/*.properties'
- include '**/*.xml'
- }
- into matrixSourceSet.output.classesDir
- }
- project.copy {
- from(sourceSets.test.resources.srcDirs) {
- include '**/*.properties'
- include '**/*.xml'
- }
- into matrixSourceSet.output.classesDir
- }
- project.copy {
- from(matrixSourceSet.java.srcDirs) {
- include '**/*.properties'
- include '**/*.xml'
- }
- into matrixSourceSet.output.classesDir
- }
- })
-
- }
}
@@ -32,21 +32,11 @@ dependencies {
testRuntime( libraries.javassist )
}
-compileMatrixJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
manifest.mainAttributes(
'Main-Class': 'org.hibernate.Version'
)
-sourceSets {
- matrix {
- java {
- srcDir 'src/matrix/java'
- }
- resources {
- srcDir 'src/matrix/resources'
- }
- }
-}
+
sourceSets.main {
jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" )
java.srcDir jaxbTargetDir
@@ -61,8 +51,6 @@ sourceSets.test.resources {
idea {
module {
sourceDirs += file( '$buildDir/generated-src/antlr/main' )
- testSourceDirs += file( 'src/matrix/java')
- testSourceDirs += file( 'src/matrix/resources')
}
}
@@ -1,82 +1,82 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.cascade;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Test;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-
-
-public class CascadeToEmbeddedManyToOneTest extends BaseCoreFunctionalTestCase {
-
- @Test
- public void testPersistCascadeToSetOfEmbedded() {
- Session sess = openSession();
- try {
- final Transaction trx = sess.beginTransaction();
- try {
- final Set<PersonPair> setOfPairs = new HashSet<PersonPair>();
- setOfPairs.add(new PersonPair(new Person("PERSON NAME 1"), new Person("PERSON NAME 2")));
- sess.persist( new CodedPairSetHolder( "CODE", setOfPairs ) );
- sess.flush();
- } finally {
- trx.rollback();
- }
- } finally {
- sess.close();
- }
- }
-
- @Test
- public void testPersistCascadeToEmbedded() {
- Session sess = openSession();
- try {
- final Transaction trx = sess.beginTransaction();
- try {
- PersonPair personPair = new PersonPair(new Person("PERSON NAME 1"), new Person("PERSON NAME 2"));
- sess.persist( new CodedPairHolder( "CODE", personPair ) );
- sess.flush();
- } finally {
- trx.rollback();
- }
- } finally {
- sess.close();
- }
- }
-
- @Override
- protected Class[] getAnnotatedClasses() {
- return new Class[]{
- CodedPairSetHolder.class,
- CodedPairHolder.class,
- Person.class,
- PersonPair.class
- };
- }
-}
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.cascade;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+
+public class CascadeToEmbeddedManyToOneTest extends BaseCoreFunctionalTestCase {
+
+ @Test
+ public void testPersistCascadeToSetOfEmbedded() {
+ Session sess = openSession();
+ try {
+ final Transaction trx = sess.beginTransaction();
+ try {
+ final Set<PersonPair> setOfPairs = new HashSet<PersonPair>();
+ setOfPairs.add(new PersonPair(new Person("PERSON NAME 1"), new Person("PERSON NAME 2")));
+ sess.persist( new CodedPairSetHolder( "CODE", setOfPairs ) );
+ sess.flush();
+ } finally {
+ trx.rollback();
+ }
+ } finally {
+ sess.close();
+ }
+ }
+
+ @Test
+ public void testPersistCascadeToEmbedded() {
+ Session sess = openSession();
+ try {
+ final Transaction trx = sess.beginTransaction();
+ try {
+ PersonPair personPair = new PersonPair(new Person("PERSON NAME 1"), new Person("PERSON NAME 2"));
+ sess.persist( new CodedPairHolder( "CODE", personPair ) );
+ sess.flush();
+ } finally {
+ trx.rollback();
+ }
+ } finally {
+ sess.close();
+ }
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[]{
+ CodedPairSetHolder.class,
+ CodedPairHolder.class,
+ Person.class,
+ PersonPair.class
+ };
+ }
+}
Oops, something went wrong.

0 comments on commit 0196ad2

Please sign in to comment.