ç°å¢
ãã£ããã¨
Mavenããã¸ã§ã¯ãã®ä½æ
archetypeã§webapp-javaee7ãé¸ãã§ããã¸ã§ã¯ããä½ãã
ãã¹ã対象ã¯ã©ã¹ã®ä½æ
Getting Started · Arquillian Guidesã®ã³ããã ãã©Javaã®ããã¼ã®ã¯ã©ã¹ãã¤ããã
package arquilliantutorial; import java.io.PrintStream; public class Greeter { public void greet(PrintStream to, String name) { to.println(createGreeting(name)); } public String createGreeting(String name) { return "Hello, " + name + "!"; } }
ãã¹ãã³ã¼ãã®ä½æ
ãããã»ã¼ã³ããã1ã¤ã®ãã¹ããæåãã¦ããã1ã¤ã¯å¤±æããã
package arquilliantutorial; import static org.junit.Assert.fail; import javax.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class GreeterTest { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(Greeter.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Inject Greeter greeter; @Test public void testGreet() { Assert.assertEquals("Hello, Earthling!", greeter.createGreeting("Earthling")); greeter.greet(System.out, "Earthling"); } @Test public void testCreateGreeting() { fail("Not yet implemented"); } }
pom.xmlã«dependency追å
javaee-web-abiã¯ç½®ãã¦ããã¨ãã¦ã
- Arquillian API
- Arquillian-JUnitã¤ã³ãã°ã¬ã¼ã·ã§ã³
- Embedded GlassFishã³ã³ããã¢ããã¿
- Embedded GlassFish All-In-One
ã®ä¾åæ§ã追å ããã
ä¸è¨ã¯embeddedã®å ´åã
<dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.0.0.Final</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <version>1.0.0.Final</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-glassfish-embedded-3.1</artifactId> <version>1.0.0.CR4</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish.main.extras</groupId> <artifactId>glassfish-embedded-all</artifactId> <version>4.0</version> <scope>provided</scope> </dependency> </dependencies>
ä¸è¨ã¯remoteã®å ´åã
arquillian-glassfish-embedded ã arquillian-glassfish-remote ã«ãããglassfish-embedded-allã¯è¦ããªãã使ãåããå ´åãprofileã§åæ¿ãããããã
<dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.0.0.Final</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <version>1.0.0.Final</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-glassfish-remote-3.1</artifactId> <version>1.0.0.CR4</version> <scope>test</scope> </dependency> </dependencies>
ã¯ã¾ãã©ãã
java.lang.NoSuchMethodError: org.jboss.shrinkwrap.descriptor.api.DescriptorImporter.fromString(Ljava/lang/String;)Lorg/jboss/shrinkwrap/descriptor/api/Descriptor;
ã¨ã©ã¼ãã°ã¯ãããªæãã
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160) (ä¸ç¥) Caused by: java.lang.NoSuchMethodError: org.jboss.shrinkwrap.descriptor.api.DescriptorImporter.fromString(Ljava/lang/String;)Lorg/jboss/shrinkwrap/descriptor/api/Descriptor; at org.jboss.arquillian.config.impl.extension.ConfigurationSysPropResolver.resolveSystemProperties(ConfigurationSysPropResolver.java:55) (ä¸ç¥)
Mavenã®Dependency Hierarchyãä¸æããã£ã¦ããªãããã«çºçãããArquillian APIã¨Embedded GlassFishã³ã³ããã¢ããã¿ã®ãã¼ã¸ã§ã³ãåã¿ãã£ã¦ããªãã¨ãã®ã¨ã©ã¼ãåºãã2013/10/8ç¾å¨ãArquillian APIã®ææ°ãã¼ã¸ã§ã³ã¯1.1.1.Finalãªãã ãã©GlassFishã³ã³ããã¢ããã¿1.0.0.CR4ã¯ã½ã¬ã«å¯¾å¿ãã¦ããªãã®ã ã¨æãããããã ããGlassFishã³ã³ããã¢ããã¿3.1ã§ãGlassFish4ã§åãã®ã§ãä¸å¿åé¡ã¯ç¡ããåèâArquillian Container GlassFish 1.0.0.CR4 Released · Arquillian Blog
java.lang.NoClassDefFoundError: org/glassfish/embeddable/GlassFishException
ã¨ã©ã¼ãã°ã¯ãããªæãã
java.lang.RuntimeException: Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor see cause. at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170) (ä¸ç¥) Caused by: java.lang.NoClassDefFoundError: org/glassfish/embeddable/GlassFishException at java.lang.Class.getDeclaredConstructors0(Native Method) (ä¸ç¥)
glassfish-embedded-allãç¡ãã¨ãããªãã
Could not connect to DAS on: http://localhost:4848
remoteã®å ´åãGlassFishãèµ·åãã¦ããªãã¨ãããªæãã®ã¨ã©ã¼ã«ãªãã
10 08, 2013 8:18:47 åå¾ org.jboss.arquillian.container.glassfish.CommonGlassFishManager start é大: Could not connect to DAS on: http://localhost:4848 | Connection refused: connect