Integration test problem

Hello ,

I have strange error when try to run integration test of my plugin:

FAILURE: Build failed with an exception.
  * What went wrong:
A problem occurred configuring project ':modules:eda-eventtypeeditor'.
> Cannot cast object 'task ':modules:eda-eventtypeeditor:eclipseFeatureProperties'' with class 'com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties_Decorated' to class 'com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties'
  * Try:
Run with --debug option to get more log output.
  * Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':modules:eda-eventtypeeditor'.
 at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
 at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
 at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:80)
 at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
 at org.gradle.integtests.fixtures.executer.InProcessGradleExecuter.doRun(InProcessGradleExecuter.java:175)
 at org.gradle.integtests.fixtures.executer.InProcessGradleExecuter.doRun(InProcessGradleExecuter.java:86)
 at org.gradle.integtests.fixtures.executer.AbstractGradleExecuter.run(AbstractGradleExecuter.java:539)
 at org.gradle.integtests.fixtures.executer.AbstractDelegatingGradleExecuter.doRun(AbstractDelegatingGradleExecuter.java:29)
 at com.softwareag.bas.core.plugins.BasInProcessGradleDistributionExecuter.doRun(BasInProcessGradleDistributionExecuter.java:50)
 at org.gradle.integtests.fixtures.executer.AbstractGradleExecuter.run(AbstractGradleExecuter.java:539)
 at com.softwareag.bas.l10n.itests.L10nIntegrationTest.buildL10nSampleGenerateP2WithClean(L10nIntegrationTest.java:144)
 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:606)
 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
 at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
 at org.testng.TestRunner.privateRun(TestRunner.java:758)
 at org.testng.TestRunner.run(TestRunner.java:613)
 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
 at org.testng.SuiteRunner.run(SuiteRunner.java:240)
 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1137)
 at org.testng.TestNG.runSuitesLocally(TestNG.java:1062)
 at org.testng.TestNG.run(TestNG.java:974)
 at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:112)
 at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:57)
 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:606)
 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 com.sun.proxy.$Proxy2.stop(Unknown Source)
 at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:115)
 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:606)
 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.hub.MessageHub$Handler.run(MessageHub.java:355)
 at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:744)
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'task ':modules:eda-eventtypeeditor:eclipseFeatureProperties'' with class 'com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties_Decorated' to class 'com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties'
 at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
 at com.softwareag.bas.l10n.plugins.L10NPlugin$_addJarFeatureLocalizationsRule_closure28.doCall(L10NPlugin.groovy:577)
 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:606)
 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
 at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
 at groovy.lang.Closure.call(Closure.java:412)
 at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:51)
 at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:82)
 at com.sun.proxy.$Proxy52.apply(Unknown Source)
 at org.gradle.api.internal.DefaultNamedDomainObjectCollection.applyRules(DefaultNamedDomainObjectCollection.java:236)
 at org.gradle.api.internal.DefaultNamedDomainObjectCollection.findByName(DefaultNamedDomainObjectCollection.java:158)
 at org.gradle.api.internal.tasks.DefaultTaskContainer.findByName(DefaultTaskContainer.java:227)
 at org.gradle.api.internal.tasks.DefaultTaskContainer.findByName(DefaultTaskContainer.java:36)
 at org.gradle.api.NamedDomainObjectCollection$findByName.call(Unknown Source)
 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
 at com.softwareag.bas.l10n.plugins.L10NPlugin$_configureL10nDefaults_closure30_closure58.doCall(L10NPlugin.groovy:666)
 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:606)
 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
 at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
 at groovy.lang.Closure.call(Closure.java:412)
 at groovy.lang.Closure.call(Closure.java:425)
 at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
 at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
 at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
 at org.gradle.api.DomainObjectCollection$all$0.call(Unknown Source)
 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
 at com.softwareag.bas.l10n.plugins.L10NPlugin$_configureL10nDefaults_closure30.doCall(L10NPlugin.groovy:658)
 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:606)
 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
 at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
 at groovy.lang.Closure.call(Closure.java:412)
 at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
 at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
 at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
 at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
 at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
 at com.sun.proxy.$Proxy22.afterEvaluate(Unknown Source)
 at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
 ... 58 more

This is the test :

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
  import static org.testng.Assert.*;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
  import org.gradle.BuildListener;
import org.gradle.BuildResult;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.initialization.Settings;
import org.gradle.api.invocation.Gradle;
import org.gradle.api.java.archives.Manifest;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.plugins.osgi.OsgiManifest;
import org.gradle.integtests.fixtures.executer.ExecutionResult;
import org.gradle.integtests.fixtures.executer.GradleDistribution;
import org.gradle.integtests.fixtures.executer.GradleExecuter;
import org.gradle.integtests.fixtures.executer.UnderDevelopmentGradleDistribution;
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider;
import org.testng.annotations.Test;
import org.testng.annotations.Parameters;
import org.testng.annotations.BeforeClass;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.custommonkey.xmlunit.XMLUnit;
import com.softwareag.bas.core.artifacts.leftovers.ReflectionUtil;
import com.softwareag.bas.core.plugins.BasInProcessGradleDistributionExecuter;
import org.gradle.integtests.fixtures.executer.*;
import org.gradle.integtests.fixtures.AbstractIntegrationSpec;
    public class L10nIntegrationTest implements BuildListener {
 private static final String INTEG_TEST_GRADLE_USER_HOME_PROP = "integTest.gradleUserHomeDir";
    protected GradleDistribution dist;
 protected BasInProcessGradleDistributionExecuter executer;
           protected final File l10nSampleDir;
 protected final File testWorkingDir;
 protected File gradleUserHomeDir;
 protected File gradleInitScript;
 protected final LogLevel logLevel;
 protected final String l10nFeatureModulePath;
 protected final String l10nBundleModulePath;
 protected final String l10nBundleDummyModulePath;
 protected final String l10nPlainJarModulePath;
    protected Gradle gradle;
      @Parameters({"l10nSampleDir", "l10nFeatureModule", "l10nBundleModule", "l10nPlainJarModule", "l10nBundleDummyModule", "testWorkingDir", "logLevel"})
 public L10nIntegrationTest(String l10nSampleDir, String l10nFeatureModule,
   String l10nBundleModule, String l10nPlainJarModule, String l10nBundleDummyModule, String testWorkingDir, String logLevel) {
  if (l10nSampleDir == null || l10nSampleDir.trim().length() == 0) {
   throw new IllegalArgumentException("Required parameter 'l10nSampleDir' is not valid/empty.");
  }
  this.l10nSampleDir = new File(l10nSampleDir);
      if (!this.l10nSampleDir.exists() || !this.l10nSampleDir.isDirectory()) {
   throw new IllegalArgumentException(
     String.format("Specified 'l10nSampleDir' does not exist or is not a directory: %s", this.l10nSampleDir.getAbsolutePath()));
  }
      this.l10nFeatureModulePath = l10nFeatureModule;
  this.l10nBundleModulePath = l10nBundleModule;
  this.l10nPlainJarModulePath = l10nPlainJarModule;
  this.l10nBundleDummyModulePath = l10nBundleDummyModule;
      this.testWorkingDir = new File(testWorkingDir);
      String gradleUserHomeProp = System.getProperty(INTEG_TEST_GRADLE_USER_HOME_PROP);
  assertNotNull(gradleUserHomeProp, String.format("Required '%s' system property is not set", INTEG_TEST_GRADLE_USER_HOME_PROP));
      //workaround - when executing this test from command line, we need to add 'worker-1' suffix
  //when executing this test via GradleDistributionExecuter, Gradle User home will already be set to subdirectory of standard Gradle user home
  gradleUserHomeDir = new File(gradleUserHomeProp);
  if (!gradleUserHomeDir.getName().equals("worker-1")) {
   gradleUserHomeDir = new File(gradleUserHomeDir, "worker-1");
  }
      System.out.println(String.format("Running %s using Gradle user home: %s", this.getClass().getSimpleName(), this.gradleUserHomeDir.getAbsolutePath()));
  gradleInitScript = new File(gradleUserHomeDir, "init.gradle");
  if (!gradleInitScript.exists()) {
   gradleInitScript = new File(gradleUserHomeDir.getParentFile(), "init.gradle");
  }
  System.out.println(String.format("Running %s using Gradle init script: %s", this.getClass().getSimpleName(), this.gradleInitScript.getAbsolutePath()));
      this.logLevel = LogLevel.valueOf(logLevel);
 }
    @BeforeClass
 public void setupGradleExecuter() {
  dist = new UnderDevelopmentGradleDistribution();
  executer = new BasInProcessGradleDistributionExecuter(dist, new TestNameTestDirectoryProvider());
        }
    private GradleExecuter withBaseSettings() {
  return executer
    .withBuildListener(this)
    .withGradleUserHomeDir(gradleUserHomeDir)
    .usingInitScript(gradleInitScript)
    .inDirectory(testWorkingDir)
    .withEagerClassLoaderCreationCheckDisabled()
    .withDeprecationChecksDisabled();
  }
    /**
  * Build a p2 repository out of the l10n sample's feature module
  *
   * This should deliver the 'noLocale' message resources and merge them into the main
  * feature/bundle artifacts
  */
 @Test(groups = { "generateP2" })
 public void buildL10nSampleGenerateP2WithClean() {
  ExecutionResult result =
withBaseSettings()
   .usingProjectDirectory(l10nSampleDir)
   .withArguments("clean", l10nFeatureModulePath + ":generateP2", logLevel == LogLevel.DEBUG ? "-d" : "-i", "-S")
   .run();
      result.assertTasksExecuted(
    l10nFeatureModulePath + ":clean",
    l10nBundleModulePath
+ ":clean",
     l10nPlainJarModulePath
+ ":clean",
     l10nBundleDummyModulePath
+ ":clean",
     l10nFeatureModulePath + ":compileJava",
     l10nFeatureModulePath + ":processLocalizationResources",
     l10nFeatureModulePath + ":processResources",
     l10nFeatureModulePath + ":classes",
     l10nFeatureModulePath + ":setup",
     l10nFeatureModulePath + ":jar",
     l10nBundleModulePath
+ ":compileJava",
     l10nBundleModulePath
+ ":processLocalizationResources",
     l10nBundleModulePath
+ ":processResources",
     l10nBundleModulePath
+ ":classes",
     l10nBundleModulePath
+ ":setup",
     l10nBundleModulePath
+ ":jar",
     l10nFeatureModulePath + ":eclipseFeature",
     l10nFeatureModulePath + ":processEclipseFeatureLocalizationResources",
     l10nFeatureModulePath + ":eclipseFeatureProperties",
     l10nFeatureModulePath + ":jarEclipseFeature",
     l10nFeatureModulePath + ":generateP2"
    );
 }

And this is custom executer impl class:

public class BasInProcessGradleDistributionExecuter extends GradleContextualExecuter {
 protected BuildListener listener;
    public BasInProcessGradleDistributionExecuter(GradleDistribution distribution, TestDirectoryProvider testDirectoryProvider) {
  super(distribution, testDirectoryProvider);
 }
    private final ActionBroadcast<GradleExecuter> beforeExecute = new ActionBroadcast<GradleExecuter>();
   private void fireBeforeExecute() {
        beforeExecute.execute(this);
    }
    @Override
    protected ExecutionResult doRun() {
     //fireBeforeExecute();
     DefaultGradleLauncherFactory factory = (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
                  if (listener != null) {
         factory.addListener(listener);
                   }
        try {
                    return super.doRun();
        } finally {
         if (listener != null) {
             factory.removeListener(listener);
         }
        }
    }
      @Override
    protected ExecutionFailure doRunWithFailure() {
     DefaultGradleLauncherFactory factory = (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
            if (listener != null) {
   factory.addListener(listener);
  }
  try {
   return super.doRunWithFailure();
  } finally {
   if (listener != null) {
    factory.removeListener(listener);
   }
  }
 }
       public GradleExecuter withBuildListener(BuildListener listener) {
     this.listener = listener;
     return this;
    }
          public BuildListener getBuildListener() {
     return listener;
    }
          public GradleExecuter reset() {
     super.reset();
     this.listener = null;
     return this;
    }
}

Can someone give me more information about this:>

Cannot cast object ‘task ‘:modules:eda-eventtypeeditor:eclipseFeatureProperties’’ with class ‘com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties_Decorated’ to class ‘com.softwareag.bas.core.tasks.eclipse.GenerateEclipseFeatureProperties’ ,

I am a little bit confused.

Regards,

Slavi

I

Is there anyone who can help ?

A quick search of the gradle sources finds this https://github.com/gradle/gradle/search?q=_Decorated&ref=cmdform

If I was to take an educated guess, I’d guess it’s a classloader issue where

GenerateEclipseFeatureProperties_Decorated.class.classloader != GenerateEclipseFeatureProperties.class.classloader

Thanks , i will check it !

Ok i understand that GenerateEclipseFeatureProperties_Decorated.class.classloader != GenerateEclipseFeatureProperties.class.classloader but why is it ? And how can do some workaround for that issue ?