mulesoft-labs / mule-gradle-plugin

Plugin for building mule apps with the gradle build system.
Apache License 2.0
24 stars 14 forks source link

Junit test for flow using data-mapper fails #25

Closed sreejaptfa closed 9 years ago

sreejaptfa commented 9 years ago

Hi, Following is my build.gradle:

repositories {
    mavenCentral()
    maven { url "------------------" }  
    // for APIKit
    maven { url "http://repository.mulesoft.org/releases/" }

    // for Mule Enterprise Repository
    maven { 
        credentials {
            username "----------"
            password "------------"
        }
        url "https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/" 
    }
}

buildscript {
    dependencies {
        classpath group: 'org.mulesoft.build', name: 'mule-gradle-plugin', version: '1.1.0'
    }

    repositories {
        maven { url "http://repository.mulesoft.org/releases/" }
        // mavenLocal()
    }
}

apply plugin: 'mulestudio'
apply plugin: "project-report"
apply plugin: "eclipse"

eclipse {
    pathVariables 'GRADLE_USER_HOME': gradle.gradleUserHomeDir
}

mule.version = '3.4.1'

mule.muleEnterprise = true

mule.enterpriseRepoUsername = '----------'
mule.enterpriseRepoPassword = '--------------------'

mule.components {

    eeTransports += 'jdbc-ee'
}

dependencies {

    compile 'org.mule.modules:mule-module-apikit:1.4.2'

    testCompile "com.jayway.restassured:rest-assured:2.3.0"
    testCompile 'org.codehaus.groovy:groovy:2.2.1'
    testCompile 'org.codehaus.groovy:groovy-xml:2.2.1'
    testCompile 'org.codehaus.groovy:groovy-json:2.2.1'
//  testCompile 'com.mulesoft.muleesb.datamapper:mule-clover-plugins:3.4.1'
//  testCompile 'com.mulesoft.muleesb.modules:mule-module-data-mapper:3.4.1'
//  testCompile 'org.mule.tests:mule-tests-functional:3.4.1'
//  testCompile 'com.mulesoft.muleesb.datamapper:data-mapper-test:3.4.1'

//  testCompile group: 'com.cloveretl', name: 'cloveretl-engine', version: mule.version 

//  providedTestRuntime group: 'com.cloveretl', name: 'cloveretl-engine', version: mule.version, ext: 'zip'
//  testRuntime "org.mule.modules:mule-module-devkit-support:$mule.version"
    testRuntime "org.mule.modules:mule-module-ldap:1.1.4"
    testRuntime "xerces:xercesImpl:2.9.1"
    testRuntime "net.sf.saxon:saxon-dom:8.9.0.4-osgi"
    testRuntime "org.---------.mulesoft.ee:license-key:-----------:dev"
    testRuntime 'com.ibm:db2jcc_license_cu:1.2'
    testRuntime 'com.ibm:db2jcc:1.2'    
}

sourceSets {
    test {
        java {
            srcDirs = ["src/test/java"]
        }
        resources {
            // RAML and json schemas needed for APIKit.
            srcDirs = ["src/main/api"]
        }
    }
}

My unit tests fail when I use this build script. However, they pass when I run them on my AnypointStudio. Here is a part of my exception stack trace:

ERROR 2014-11-20 16:40:27,804 [connector.http.mule.default.receiver.02] org.jetel.component.ComponentFactory: Unknown lookup table: muleFlowLookup class: muleFlowLookup ERROR 2014-11-20 16:40:27,804 [connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:


Message : com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException: java.lang.RuntimeException: Unknown lookup table: muleFlowLookup class: muleFlowLookup (java.lang.RuntimeException). Message payload is of type: String

Code : MULE_ERROR-29999

Exception stack is:

  1. Unknown lookup table: muleFlowLookup class: muleFlowLookup (java.lang.RuntimeException) org.jetel.data.lookup.LookupTableFactory:116 (null)
  2. java.lang.RuntimeException: Unknown lookup table: muleFlowLookup class: muleFlowLookup (com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException) com.mulesoft.mule.module.datamapper.clover.impl.graphfactory.AbstractGraphFactory:61 (null)
  3. com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException: java.lang.RuntimeException: Unknown lookup table: muleFlowLookup class: muleFlowLookup (java.lang.RuntimeException) com.mulesoft.mule.module.datamapper.clover.impl.graphprovider.PoolGraphProvider:109 (null)
  4. com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException: java.lang.RuntimeException: Unknown lookup table: muleFlowLookup class: muleFlowLookup (java.lang.RuntimeException). Message payload is of type: String (org.mule.api.MessagingException)

    org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:35 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)

Root Exception stack trace: java.lang.RuntimeException: Unknown lookup table: muleFlowLookup class: muleFlowLookup at org.jetel.data.lookup.LookupTableFactory.getLookupTableClass(LookupTableFactory.java:116) at org.jetel.data.lookup.LookupTableFactory.createLookupTable(LookupTableFactory.java:140) at org.jetel.data.lookup.LookupTableFactory.createLookupTable(LookupTableFactory.java:213)


Could you please look into this and help us with this?

juancavallotti commented 9 years ago

Hello,

Within your build script you're doing many things that are automatically done by the gradle plugin, you would need to remove things like:

repositories {
    mavenCentral()
    maven { url "------------------" }  
    // for APIKit
    maven { url "http://repository.mulesoft.org/releases/" }

    // for Mule Enterprise Repository
    maven { 
        credentials {
            username "----------"
            password "------------"
        }
        url "https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/" 
    }
}

And many of your dependencies as well are not the same version as the mule runtime bundles.

Also the 'mulestudio' plugin inherits from eclipse so I don't see any need for explicitly applying it.

Apart from that, the particular issue is that the mappings directory (which normally has the lookup tables and the grf files) might not be part of your test runtime.

Please check that.

yellowcola commented 9 years ago

Hi @juancavallotti

We found out this issue is caused by "mule-clover-plugins" missing in "cloveretl-engine-3.4.1.zip". Is this plugins supposed to be part of cloveretl engine?

-Karl

juancavallotti commented 9 years ago

Hello @yellowcola

Unfortunately DataMapper unit tests suffered some differences in 3.4.0 and 3.4.1, I would suggest that you build using the target version 3.4.2 onwards (it should be able to deploy in a 3.4.1 server without issues).

yellowcola commented 9 years ago

Hi @juancavallotti

I'm still seeing the same error after changing to 3.4.2.

The build downloads mule-clover-plugins-3.4.2.jar now, but the problem is Clover Etl doesn't seem to recognize "com.mulesoft.datamapper.lookup.MuleFlowLookupTable" as "muleFlowLookup".

I feel we still need a way to unzip the mule-clover-plugins.zip into the classpath. It has both the .jar and plugin.xml that defines "muleFlowLookup"

Let me know, Karl

juancavallotti commented 9 years ago

Hello @yellowcola the clover plugins actually do get unzipped and if they weren't your unit test would fail at an earlier stage. My question is, if you run this app on mule, would the mapping work?

yellowcola commented 9 years ago

Hi @juancavallotti

The mapping is working when we run it on both Anypoint Studio and Standalone.

Where is unzipped mule-clover-plugins being placed? When we unzip it and place it under "\build\classes\test\", it's working. (I made a little workaround in the fork: https://github.com/yellowcola/mule-gradle-plugin/blob/master/src/main/groovy/com/mulesoft/build/dependency/UnpackCloverTask.groovy#L55)

Let me know, Karl

juancavallotti commented 9 years ago

@yellowcola Can you please attach the GRF file and the sample input so I can build the junit test case?

yellowcola commented 9 years ago

@juancavallotti Can I upload it on the enterprise support site?

juancavallotti commented 9 years ago

@yellowcola I'd prefer keeping this outside support, maybe you can generate a small datamapper that reproduces the issue?

yellowcola commented 9 years ago

@juancavallotti I created a sample project to reproduce the issue. You can find it in https://github.com/yellowcola/muleflowlookupbuildissue

The .grf file is https://github.com/yellowcola/muleflowlookupbuildissue/blob/master/mappings/json_to_map.grf

Sample input is { "a":"test_value_a", "b":"test_value_b" }

You can also try to build it, but you provide the license and ee credential.

Let me know if you run into issue.

juancavallotti commented 9 years ago

@yellowcola Ok, I've identified the issue and will apply a fix, the fix is targeted for the next bugfix release.

yellowcola commented 9 years ago

@juancavallotti Thanks!

yellowcola commented 9 years ago

@juancavallotti Do you have any suggested workaround for now?

juancavallotti commented 9 years ago

@yellowcola you can build the latest version of the plugin until we release 1.1.1