I configured my project and wrote my test class for a multi-module project. A test for a business service call to an AS400 server is written with Arquillan, which gives me an InvalidEnvironnmentException
when I run the test.
package com.my.company.theproject.business.service.protect;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.my.company.theproject.common.dataaccess.PojoService;
import com.my.company.theproject.ServiceContext;
@RunWith(Arquillian.class)
public class SampleServiceTest
{
@Inject
@PojoService
SampleService service;
private ServiceContext context;
@Before
public void setUp()
throws Exception
{
context = new ServiceContext();
}
@Deployment
public static WebArchive createDeployment()
{
return ShrinkWrap
.create(WebArchive.class)
.addClasses(SampleService.class)
.addAsWebInfResource("META-INF/beans.xml", ArchivePaths.create("beans.xml"))
.addAsLibraries(
Maven.configureResolverViaPlugin().importRuntimeDependencies().resolve().withTransitivity().asFile());
}
@Test
public void test()
{
List<String> list = new ArrayList<String>();
list.add("AAA");
service.getStoredProcedureParameters(context, list);
fail("To be implemented");
}
}
I have written down the imports here, in case some were wrong (eg javax.inject.Inject ?).
The problem here is that Arquillian gives me this error at test runtime (first exception of the stack trace) :
java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive com.sopra.banking.packbanque.business.service.protect.SampleServiceTest.createDeployment()
At the end of the stack trace, I see this :
Caused by: java.lang.reflect.InvocationTargetException
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.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:177)
... 50 more
Caused by: org.jboss.shrinkwrap.resolver.api.maven.InvalidEnvironmentException: Configuration from environment requires that user has following properties set, however they were not detected in runtime environment:
maven.execution.pom-file
maven.execution.offline
maven.execution.user-settings
maven.execution.global-settings
maven.execution.active-profiles
You should enable ShrinkWrap Maven Resolver Plugin to get them set for you automatically if executing from Maven via adding following to your <build> section:
<plugin>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>propagate-execution-context</goal>
</goals>
</execution>
</executions>
</plugin>
at org.jboss.shrinkwrap.resolver.impl.maven.task.ConfigureSettingsFromPluginTask.execute(ConfigureSettingsFromPluginTask.java:71)
at org.jboss.shrinkwrap.resolver.impl.maven.ConfigurableMavenResolverSystemBaseImpl.configureViaPlugin(ConfigurableMavenResolverSystemBaseImpl.java:119)
at org.jboss.shrinkwrap.resolver.api.maven.Maven.configureResolverViaPlugin(Maven.java:77)
at org.jboss.shrinkwrap.resolver.api.maven.Maven.configureResolverViaPlugin(Maven.java:59)
at com.sopra.banking.packbanque.business.service.protect.SampleServiceTest.createDeployment(SampleServiceTest.java:74)
... 55 more
The problem is that this plugin declaration is already in my Maven pom.xml !
<build>
<plugins>
<plugin>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-maven-plugin</artifactId>
<version>2.2.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>propagate-execution-context</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
What is the problem here ?
I think the problem could be that you need to load the pom file first and then resolve as of now it dosent know that whene to resolve the dependencies from..
I am not sure but you can try this... :)
You can find everything about shrikwrap resolver here :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.