AnsweredAssumed Answered

Spring workspace errors

Question asked by mickknutson on Oct 29, 2012
Latest reply on Oct 29, 2012 by frederikheremans1
I am trying to convert the Spring workspace to use Gradle to build and run tests.

Here is my gradle build.gradle:


apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
//apply plugin: 'project-report'

apply plugin: 'war'
apply plugin: 'jetty'


// group will translate to groupId during pom generation and deployment
group = 'com.comcast.oxygen.codewash'
version = "$VERSION_NUMBER"

sourceCompatibility = JAVA_SOURCE
targetCompatibility = JAVA_TARGET

ext {
    baseName = 'code-wash'
    description = 'Code Wash.'
    environment = 'development'
    config = ''

    // Code qa Scripts:
    coberturaScript = new File("$rootDir/script/cobertura.gradle").toURL().toString()
    pmdScript = new File("$rootDir/script/pmd.gradle").toURL().toString()
    codenarcScript = new File("$rootDir/script/codenarc.groovy").toURL().toString()

}

List common_dependencies = [
        "commons-beanutils:commons-beanutils:$commons_beanutilsVersion",
        "commons-beanutils:commons-beanutils-bean-collections:$commons_beanutilsVersion",
        "commons-codec:commons-codec:$commons_codecVersion",
        "commons-collections:commons-collections:$commons_collectionsVersion",
        "commons-dbcp:commons-dbcp:$commons_dbcpVersion",
        "commons-digester:commons-digester:$commons_digesterVersion",
        "org.apache.commons:commons-email:1.2",
        "commons-fileupload:commons-fileupload:$commons_fileuploadVersion",
        "commons-io:commons-io:$commons_ioVersion",
        "commons-lang:commons-lang:$commons_langVersion",
        "commons-logging:commons-logging:$commons_loggingVersion",
        //"commons-httpclient:commons-httpclient:$commons_httpclientVersion",
        "org.apache.httpcomponents:httpclient:$commons_httpclient4Version",
        "commons-pool:commons-pool:1.6",
        "commons-validator:commons-validator:$commons_validatorVersion",

        //"org.apache.ws.commons.schema:XmlSchema:$commons_xmlschemaVersion",

        "joda-time:joda-time:$jodaVersion",
        "com.google.guava:guava:$guavaVersion"
]

List spring_dependencies = [
        "org.springframework:spring-asm:$springVersion",
        "org.springframework:spring-aop:$springVersion",
        "org.springframework:spring-beans:$springVersion",
        "org.springframework:spring-context:$springVersion",
        "org.springframework:spring-context-support:$springVersion",
        "org.springframework:spring-core:$springVersion",
        "org.springframework:spring-expression:$springVersion",
        "org.springframework:spring-jdbc:$springVersion",
        "org.springframework:spring-orm:$springVersion",
        //"org.springframework:spring-jms:$springVersion",
        "org.springframework:spring-test:$springVersion",
        "org.springframework:spring-tx:$springVersion",

        "org.springframework:spring-web:$springVersion"
        //"org.springframework:spring-webmvc:$springVersion",
]


List testing_dependencies = [
        "junit:junit:$junitVersion",

        "org.mockito:mockito-all:$mockitoVersion",
        "org.powermock:powermock-core:$powermockVersion",
        "org.powermock:powermock-module-junit4:$powermockVersion",
        "org.powermock:powermock-module-junit4-common:$powermockVersion",
        "org.powermock:powermock-module-junit4-legacy:$powermockVersion",
        "org.powermock:powermock-api-mockito:$powermockVersion",
        "org.powermock:powermock-api-support:$powermockVersion",
        "org.powermock:powermock-classloading-base:$powermockVersion",
        "org.powermock:powermock-reflect:$powermockVersion",
        "org.javassist:javassist:$javassistVersion",

        "org.hamcrest:hamcrest-all:$hamcrestVersion"
]

configurations {

    compile {
        description = 'compile classpath'
        transitive = true
    }
    testCompile {
        transitive = true
    }

    // TO use, run: gradle cleanEclipse eclipse
    eclipse.classpath.downloadSources = true // defaults to 'false'
    eclipse.classpath.downloadJavadoc = true // defaults to 'true'
}

buildDir = 'target'

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'src/main/process']
        }
        resources {
            srcDirs = ['src/main/resources', 'src/main/process']
        }
    }
    test {
        runtimeClasspath = files(output.resourcesDir) + files(output.classesDir) + sourceSets.main.output + configurations.testRuntime
    }
}
sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir

test {
    useJUnit()
    jvmArgs [COMPILER_ARGS]
    include '**/*Test.class'
    exclude '**/Old*Test.class'
    forkEvery        = 30
    maxParallelForks = Runtime.runtime.availableProcessors()
}

def localMavenRepo = new File("${System.properties['M2_REPO']}")
if (!localMavenRepo.exists()) {
    localMavenRepo = new File("${System.properties['user.home']}/.m2/repository")
}

repositories {
    maven { url localMavenRepo.toURL().toString() }
    mavenCentral()
    maven { url "https://maven.alfresco.com/nexus/content/repositories/activiti/"}
    maven { url "http://extensions.springframework.org/milestone"}
    maven { url "http://dtestownload.java.net/maven/2"}
    maven { url "http://maven.thebuzzmedia.com"}
}


dependencies {
    // Groovy library for groovy building!
    groovy "org.codehaus.groovy:groovy-all:$groovyVersion"

    compile common_dependencies
    compile spring_dependencies

    compile "cglib:cglib:$cglibVersion"
    compile "asm:asm:$asmVersion"
    compile "javax.activation:activation:$activationVersion"

    compile "aopalliance:aopalliance:$aopallianceVersion"
    compile "org.aspectj:aspectjrt:$aspectjVersion"
    compile "org.aspectj:aspectjweaver:$aspectjVersion"

    // Activiti
    compile "org.activiti:activiti-engine:5.10"
    compile "org.activiti:activiti-spring:5.10"

    // Vaadin
    compile "com.vaadin:vaadin:$vaadinVersion"
    compile "javax.validation:validation-api:1.0.0.GA"

    compile "com.thebuzzmedia:imgscalr-lib:3.1"

    // Database / ORM / JPA:
    compile "com.h2database:h2:$h2Version"
    compile "org.mybatis:mybatis:3.1.1"

    compile "javax.persistence:persistence-api:1.0.2"
    compile "org.apache.openjpa:openjpa:1.2.2"

    // Other resources needed:
    // TODO: Finde out why these are needed and omit ones that are not required.
    compile "javax.mail:mail:1.4.5"

    // Drools
    compile("org.drools:drools-compiler:$droolsVersion",
            "org.drools:drools-core:$droolsVersion",
            "org.drools:knowledge-api:$droolsVersion",
            "org.drools:knowledge-internal-api:$droolsVersion",
            "org.mvel:mvel2:2.1.0.drools16")

    compile "net.sourceforge.serp:serp:1.14.1"

    compile "org.antlr:stringtemplate:4.0.2"

    compile "org.eclipse.jdt.core.compiler:ecj:3.7.2"

    compile "org.livetribe:livetribe-jsr223:2.0.7"


    compile "org.objenesis:objenesis:1.2"
    compile "com.fasterxml.uuid:java-uuid-generator:3.1.3"

    compile "org.subethamail:subethasmtp-smtp:1.2"
    compile "org.subethamail:subethasmtp-wiser:1.2"


    // Use Logback NOT log4j or slf4j
    compile "ch.qos.logback:logback-classic:$logbackVersion",
            "ch.qos.logback:logback-core:$logbackVersion"

       compile("org.slf4j:slf4j-api:$slf4jVersion",
            "org.slf4j:log4j-over-slf4j:$slf4jVersion")

    // [testing Dependencies] ___________________________________________|
    //TODO: revert back to: testCompile testing_dependencies. Spring project uses Junit in its source.
    compile testing_dependencies

    testCompile "org.springframework:spring-test:$springVersion"

    testCompile "org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1"
    testCompile "org.apache.geronimo.specs:geronimo-jpa_3.0_spec:1.1.1"
    testCompile "org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1"


    providedCompile "javax.servlet:servlet-api:$servletVersion"

}


war {
    //from 'src/rootContent' // adds a file-set to the root of the archive
    //webInf { from 'src/additionalWebInf' } // adds a file-set to the WEB-INF dir.
    //classpath fileTree('additionalLibs') // adds a file-set to the WEB-INF/lib dir.
    //classpath configurations.moreLibs // adds a configuration to the WEB-INF/lib dir.
    //webXml = file('src/someWeb.xml') // copies a file to WEB-INF/web.xml
    archiveName = "${baseName}.war"
}



Here is my gradle.properties


VERSION_NUMBER: 1.0-SNAPSHOT

JAVA_SOURCE: 1.6
JAVA_TARGET: 1.6

COMPILER_ARGS: -Xlint:all -ea
TEST_COMPILER_ARGS: -Xmx512M -XX:MaxPermSize=256m -Xlint:all
activationVersion: 1.1.1
akkaVersion: 1.1.3
antVersion: 1.8.2
antlrVersion: 3.0ea8
aopallianceVersion: 1.0
asmVersion: 3.1
asm_allVersion: 3.3.1
aspectjVersion: 1.6.11

cglibVersion: 2.2

coberturaVersion = 1.9.4.1

codenarcVersion = 0.17

commons_beanutilsVersion: 1.8.2
commons_beanutils_collectionsVersion: 1.8.2
commons_cliVersion: 1.2
commons_codecVersion: 1.2
commons_collectionsVersion: 3.2
commons_dbcpVersion: 1.4
commons_digesterVersion: 2.0
commons_fileuploadVersion: 1.2

commons_httpclientVersion: 3.1
commons_httpclient4Version: 4.2.1
commons_ioVersion: 2.0.1
commons_langVersion: 2.6
commons_lang3Version: 3.0.1
commons_loggingVersion: 1.1.1
commons_managementVersion: 1.0
commons_mathVersion: 2.2
commons_poolVersion: 1.5.6
commons_validatorVersion: 1.3.1
commons_xmlschemaVersion: 1.4.7

cxfVersion: 2.4.2

cucumber_jvmVersion: 1.0.14

dashboardVersion: 12.2.2
#dbunitVersion: 2.4.8
diffutilsVersion: 1.2.1
dom4jVersion: 1.6.1
#dozerVersion: 5.3.2

droolsVersion: 5.4.0.Final

ehcacheVersion: 2.2.0
ehcacheSpringAnnotationsVersion: 1.1.3

gebVersion: 0.7.2
groovyVersion: 2.0.4
guavaVersion: 11.0.2

hamcrestVersion: 1.1
#htmlunitVersion: 2.9
h2Version: 1.3.168

#jaxbVersion: 2.2.2
jaxbVersion: 2.2.5
jacksonVersion: 1.8.1
javaeeVersion: 6.0
javassistVersion: 3.15.0-GA
jerseyVersion: 1.12
jettisonVersion: 1.1

#jettyVersion: 8.0.1.v20110908
jettyVersion: 7.4.2.v20110526
jodaVersion: 1.6.2
#jsr311Version: 1.1.1
junitVersion: 4.10

log4jVersion: 1.2.16
logbackVersion: 1.0.1
log4mongoVersion: 0.7.2

mockitoVersion: 1.9.0
mongoVersion: 2.6.5

openjpa: 1.2.2

picocontainerVersion: 2.14.1
powermockVersion: 1.4.11

servletVersion: 2.5
slf4jVersion: 1.6.1

#springVersion: 3.0.7.RELEASE
springVersion: 3.1.2.RELEASE

staxVersion: 1.0-2

urlrewritefilterVersion: 3.2.0

vaadinVersion: 6.8.4
velocityVersion: 1.7
velocityToolsVersion: 2.0
xmlbeansVersion: 2.3.0
xercesVersion: 2.9.1
xstreamVersion: 1.4.2

When I run the tests, I get the following error:

java.lang.AssertionError: DB NOT CLEAN: 
  ACT_RE_DEPLOYMENT: 1 record(s)   ACT_RE_PROCDEF: 2 record(s)   ACT_HI_TASKINST: 2 record(s)   ACT_HI_ACTINST: 5 record(s)   ACT_RU_TASK: 1 record(s)   ACT_RU_JOB: 1 record(s)   ACT_GE_BYTEARRAY: 5 record(s)   ACT_HI_PROCINST: 2 record(s)   ACT_RU_EXECUTION: 2 record(s)
   at org.junit.Assert.fail(Assert.java:93)
   at org.activiti.engine.impl.test.AbstractActivitiTestCase.assertAndEnsureCleanDb(AbstractActivitiTestCase.java:148)
   at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:106)
   at org.activiti.spring.impl.test.SpringActivitiTestCase.runBare(SpringActivitiTestCase.java:51)
   at junit.framework.TestResult$1.protect(TestResult.java:110)
   at junit.framework.TestResult.runProtected(TestResult.java:128)
   at junit.framework.TestResult.run(TestResult.java:113)
   at junit.framework.TestCase.run(TestCase.java:124)
   at junit.framework.TestSuite.runTest(TestSuite.java:243)
   at junit.framework.TestSuite.run(TestSuite.java:238)
   at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
   at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55)
   at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42)
   at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75)
   at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
   at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
   at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
   at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
   at $Proxy2.processTestClass(Unknown Source)
   at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
   at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
   at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30)
   at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53)
   at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31)
   at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167)
   at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277)
   at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299)
   at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120)
   at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116)
   at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
   at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
   at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
   at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)

Can anyone help me to understand how to fix this test?

Outcomes