Skip to content

Commit

Permalink
JBIDE-7532 Fix hibernate tools junit tests
Browse files Browse the repository at this point in the history
git-svn-id: https://anonsvn.jboss.org/repos/hibernate/tools/trunk@20862 1b8cb986-b30d-0410-93ca-fae66ebed9b2
  • Loading branch information
maxandersen committed Nov 11, 2010
1 parent 5d1d2ab commit f35978e
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 154 deletions.
185 changes: 185 additions & 0 deletions lib/testlibs/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
hibernate.lib=hibernate3.jar
hibernate.ignorecheck=true

ant.lib=ant-1.6.5.jar
ant.version=1.6.5
ant.name=Ant core
ant.when=buildtime

ant-antlr.lib=ant-antlr-1.6.5.jar
ant-antlr.version=1.6.5
ant-antlr.name=Ant antlr support
ant-antlr.when=buildtime

ant-junit.lib=ant-junit-1.6.5.jar
ant-junit.version=1.6.5
ant-junit.name=Ant junit support
ant-junit.when=buildtime

ant-launcher.lib=ant-launcher-1.6.5.jar
ant-launcher.version=1.6.5
ant-launcher.name=Ant launcher
ant-launcher.when=buildtime

ant-swing.lib=ant-swing-1.6.5.jar
ant-swing.version=1.6.5
ant-swing.name=Ant swing support
ant-swing.when=buildtime

junit.lib=junit-3.8.1.jar
junit.version=3.8.1
junit.name=JUnit test framework
junit.when=buildtime

checkstyle.lib=checkstyle-all.jar
checkstyle.name=Checkstyle
checkstyle.when=buildtime

cleanimports.lib=cleanimports.jar
cleanimports.name=cleanimports
cleanimports.when=buildtime
hibernate.version=3.0
hibernate.name=Hibernate core
hibernate.when=runtime, required

versioncheck.lib=versioncheck.jar
versioncheck.version=1.0
versioncheck.name=version checker
versioncheck.when=buildtime

syndiag.lib=syndiag2.jar
syndiag.version=2.0
syndiag.name=antlr to bnf image generator
syndiag.when=buildtime

javassist.lib=javassist.jar
javassist.version=3.4
javassist.name=Javassist bytecode generator
javassist.when=runtime, required if using 'javassist' bytecode provider

cglib.lib=cglib-2.1.3.jar
cglib.version=2.1.3
cglib.name=CGLIB bytecode generator
cglib.when=runtime, required if using 'cglib' bytecode provider

asm.lib=asm.jar
asm.name=ASM bytecode library
asm.when=runtime, required if using 'cglib' bytecode provider

asm-attrs.lib=asm-attrs.jar
asm-attrs.name=ASM bytecode library
asm-attrs.when=runtime, required if using 'cglib' bytecode provider

commons-collections.lib=commons-collections-2.1.1.jar
commons-collections.version=2.1.1
commons-collections.name=Commons Collections
commons-collections.when=runtime, required

commons-logging.lib=commons-logging-1.0.4.jar
commons-logging.version=1.0.4
commons-logging.name=Commons Logging
commons-logging.when=runtime, required

antlr.lib=antlr-2.7.6.jar
antlr.version=2.7.6
antlr.name=ANother Tool for Language Recognition
antlr.when=runtime, required

## xml/xslt handling

dom4j.lib=dom4j-1.6.1.jar
dom4j.version=1.6.1
dom4j.name=XML configuration & mapping parser
dom4j.when=runtime, required

jaxen.lib=jaxen-1.1-beta-7.jar
jaxen.version=1.1-beta-7
jaxen.name=Jaxen - universal java xpath engine
jaxen.when=runtime, required if you want to deserialize a Configuration to improve startup performance

xerces.lib=xerces-2.6.2.jar
xerces.version=2.6.2
xerces.name=SAX parser
xerces.when=runtime, required for JDK < 1.4

xml-apis.lib=xml-apis.jar
xml-apis.name=Standard JAXP API
xml-apis.when=runtime, some SAX parser is required

## j2ee related

jta.lib=jta.jar
jta.name=Standard JTA API
jta.when=runtime, required for standalone operation (outside application server)

jaas.lib=jaas.jar
jaas.name=Standard JAAS API
jaas.when=runtime, optional (required by JCA)

log4j.lib=log4j-1.2.11.jar
log4j.version=1.2.11
log4j.name=Log4j Library
log4j.when=runtime, optional

## Treecache

jboss-cache.lib=jboss-cache.jar
jboss-cache.version=1.2.2 alpha
jboss-cache.name=TreeCache clustered cache
jboss-cache.when=runtime, optional

concurrent.lib=concurrent-1.3.2.jar
concurrent.version=1.3.2
concurrent.when=runtime, optional (required by TreeCache)

jboss-common.lib=jboss-common.jar
jboss-common.when=runtime, optional (required by TreeCache)

jboss-jmx.lib=jboss-jmx.jar
jboss-jmx.when=runtime, optional (required by TreeCache)

jboss-system.lib=jboss-system.jar
jboss-system.when=runtime, optional (required by TreeCache)

## Replication

jgroups.lib=jgroups-2.2.8.jar
jgroups.version=2.2.8
jgroups.name=JGroups multicast library
jgroups.when=runtime, optional (required by replicated caches)

## cache providers

ehcache.lib=ehcache-1.2.3.jar
ehcache.version=1.2.3
ehcache.name=EHCache cache
ehcache.when=runtime, optional (required if no other cache provider is set)

oscache.lib=oscache-2.1.jar
oscache.version=2.1
oscache.name=OpenSymphony OSCache
oscache.when=runtime, optional

swarmcache.lib=swarmcache-1.0rc2.jar
swarmcache.version=1.0rc2
swarmcache.name=runtime, optional
swarmcache.when=runtime, optional

## connection pool

c3p0.lib=c3p0-0.9.1.jar
c3p0.version=0.9.1
c3p0.name=C3P0 JDBC connection pool
c3p0.when=runtime, optional (needed if using c3p0 as the connection pooling library)

proxool.lib=proxool-0.8.3.jar
proxool.version=0.8.3
proxool.name=Proxool JDBC connection pool
proxool.when=runtime, optional (needed if using proxool as the connection pooling library)


jacc.lib=jacc-1_0-fr.jar
jacc.version=1.0-fr
jacc.name=JACC Library
jacc.when=runtime, optional

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-test-source</id>
Expand Down
51 changes: 39 additions & 12 deletions src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import junit.framework.TestSuite;

import org.apache.tools.ant.BuildException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.Session;
import org.hibernate.tool.test.TestHelper;

/**
Expand All @@ -28,16 +25,30 @@ public AntHibernateToolTest(String name) {
}

protected void tearDown() throws Exception {
executeTarget("cleanup");
System.out.println(getLog());
cleanup();
super.tearDown();
}

protected void setUp() throws Exception {
super.setUp();
configureProject("src/testsupport/anttest-build.xml");
executeTarget( "cleanup" );
}

private void cleanup(){
executeTarget("afterCfg2hbm");
boolean removed = false;
do{
try {
executeTarget("removeDirs");
removed = true;
} catch (BuildException be){
//Unable to delete file ...\testdb\hsqldb.log
//if isn't removed calls
//User SA not fount for all the next tests.
}
} while (!removed);
}

public void testHbm2DDLLogic() {
cleanupOutputDir();
File baseDir = new File(project.getProperty("build.dir"), "topdown");
Expand All @@ -54,6 +65,7 @@ public void testHbm2DDLLogic() {
// allow to test creation of script file + delimiter
// + non execution (test will fail if executed because of crappy delimiter)
executeTarget("testScriptCreation");
assertTrue(getLog(), checkLogWithoutExceptions());

assertTrue(onlyCreate.exists());
assertTrue(onlyDrop.exists());
Expand All @@ -78,7 +90,6 @@ public void testHbm2DDLLogic() {
onlyDrop.delete();
dropAndCreate.delete();
update.delete();

}

public void testHbm2DDLUpdateExecution() {
Expand All @@ -94,6 +105,7 @@ public void testHbm2DDLUpdateExecution() {


executeTarget("testantcfgUpdateExecuted");
assertTrue(getLog(), checkLogWithoutExceptions());

assertTrue(update1.exists());
assertTrue(update2.exists());
Expand All @@ -120,6 +132,7 @@ public void testHbm2DDLExportExecution() {


executeTarget("testantcfgExportExecuted");
assertTrue(getLog(), checkLogWithoutExceptions());

assertTrue(export.exists());
assertTrue(update.exists());
Expand All @@ -135,10 +148,12 @@ public void testHbm2DDLExportExecution() {

public void testJDBCConfiguration() {
executeTarget("testantjdbccfg");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testAnnotationConfigurationFailureExpected() {
executeTarget("testantannotationcfg");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testEJB3ConfigurationFailureExpected() {
Expand All @@ -150,20 +165,20 @@ public void testEJB3ConfigurationFailureExpected() {
assertEquals(null, TestHelper.findFirstString("drop", ejb3));

assertTrue(getLog().indexOf("<ejb3configuration> is deprecated")>0);

}

public void testJPABogusPUnit() {
try {
executeTarget("jpa-bogusunit");
executeTarget("jpa-boguspunit");
fail("Bogus unit accepted");
} catch(BuildException be) {
// should happen
assertTrue(getLog(), getLog().contains("Persistence unit not found: 'shouldnotbethere'"));
}
}

public void testJPAPUnit() {
executeTarget("jpa-punit");
executeTarget("jpa-punit");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testJPAPropertyOveridesPUnit() {
Expand All @@ -178,18 +193,22 @@ public void testJPAPropertyOveridesPUnit() {

public void testHbm2JavaConfiguration() {
executeTarget("testanthbm2java");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testHbm2JavaEJB3Configuration() {
executeTarget("testantejb3hbm2java");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testCfg2HbmNoError() {
executeTarget("testantcfg2hbm1");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testCfg2HbmWithCustomReverseNamingStrategy() {
executeTarget("testantcfg2hbm2");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testCfg2HbmWithInvalidReverseNamingStrategy() {
Expand All @@ -200,23 +219,28 @@ public void testCfg2HbmWithInvalidReverseNamingStrategy() {

public void testCfg2HbmWithPackageName() {
executeTarget("testantcfg2hbm4");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testCfg2HbmWithPackageNameAndReverseNamingStrategy() {
executeTarget("testantcfg2hbm5");
assertTrue(getLog(), checkLogWithoutExceptions());
}


public void testJDBCConfigWithRevEngXml() {
executeTarget("testantjdbccfgoverrides");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testProperties() {
executeTarget("testproperties");
executeTarget("testproperties");
assertTrue(getLog(), checkLogWithoutExceptions());
}

public void testGenericExport() {
executeTarget("testgeneric");
assertTrue(getLog(), checkLogWithoutExceptions());

property = project.getProperty("build.dir");
assertTrue(new File(property, "generic").exists());
Expand Down Expand Up @@ -259,6 +283,7 @@ public void testException() {

public void testQuery() {
executeTarget("testquery");
assertTrue(getLog(), checkLogWithoutExceptions());

File baseDir = new File(project.getProperty("build.dir"), "querytest");

Expand All @@ -268,6 +293,7 @@ public void testQuery() {

public void testHbmLint() {
executeTarget("testhbmlint");
assertTrue(getLog(), checkLogWithoutExceptions());

File baseDir = new File(project.getProperty("build.dir"), "linttest");

Expand All @@ -283,6 +309,7 @@ public void testNoConfig() {
}

}

public static Test suite() {
return new TestSuite(AntHibernateToolTest.class);
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/org/hibernate/tool/ant/BuildFileTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ protected void expectLogContaining(String target, String log) {
protected String getLog() {
return logBuffer.toString();
}

/**
* Checks the log for Exceptions
*/
protected boolean checkLogWithoutExceptions(){
return !(getLog().contains("Exception"));
}

/**
* Assert that the given message has been logged with a priority
Expand Down
Loading

0 comments on commit f35978e

Please sign in to comment.