diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index f94f190a1f..1b1d220f9c 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -265,9 +265,9 @@ See the https://github.com/wildfly/quickstart/blob/11.x/pom.xml#L155[WildFly par ** CDI should be used as the programming model ** Avoid using a `web.xml` file if possible. Use a `faces-config.xml` to activate JSF if needed. -** Any tests should use Arquillian. +** Any tests should use JUnit. -* If the quickstart persists to a database, you must use a unique datasource JNDI name and connection URL for the application and for any Arquillian tests that it provides. Do not use the JNDI name `java:jboss/datasources/ExampleDS`. Failure to use unique names can result in a `DuplicateServiceException` when more than one quickstart is deployed to the same server. +* If the quickstart persists to a database, you must use a unique datasource JNDI name and connection URL for the application and for any tests that it provides. Do not use the JNDI name `java:jboss/datasources/ExampleDS`. Failure to use unique names can result in a `DuplicateServiceException` when more than one quickstart is deployed to the same server. * Be sure to test the quickstart in {JBDSProductName}, which strictly enforces Jakarta EE coding rules! diff --git a/guide/KitchensinkQuickstart.asciidoc b/guide/KitchensinkQuickstart.asciidoc index e04c31dbcc..fbdcb8e12c 100644 --- a/guide/KitchensinkQuickstart.asciidoc +++ b/guide/KitchensinkQuickstart.asciidoc @@ -1,4 +1,4 @@ -CDI + JSF + EJB + JTA + Bean Validation + JAX-RS + Arquillian: Kitchensink quickstart +CDI + JSF + EJB + JTA + Bean Validation + JAX-RS : Kitchensink quickstart ===================================================================================== :Author: Pete Muir @@ -67,7 +67,7 @@ image:gfx/Eclipse_KitchenSink_Deploy_3.jpg[] The kitchensink quickstart in depth ----------------------------------- -The kitchensink application shows off a number of Jakarta EE technologies such as CDI, JSF, EJB, JTA, JAX-RS and Arquillian. It does this by providing a member registration database, available via JSF and JAX-RS. +The kitchensink application shows off a number of Jakarta EE technologies such as CDI, JSF, EJB, JTA, JAX-RS. It does this by providing a member registration database, available via JSF and JAX-RS. As usual, let's start by looking at the necessary deployment descriptors. By now, we're very used to seeing `beans.xml` and `faces-config.xml` in `WEB-INF/` (which can be found in the `src/main/webapp` directory). Notice that, once again, we don't need a `web.xml`. There are two configuration files in `WEB-INF/classes/META-INF` (which can be found in the `src/main/resources` directory) — `persistence.xml`, which sets up JPA, and `import.sql` which Hibernate, the JPA provider in JBoss WildFly, will use to load the initial users into the application when the application starts. We discussed both of these files in detail in <>, and these are largely the same. @@ -700,397 +700,5 @@ public class MemberResourceRESTService { <11> The object is then passed to the `MemberRegistration` service to be persisted <12> We then handle any remaining issues with validating the object, which are raised when the object is persisted - -Arquillian -~~~~~~~~~~ - -If you've been following along with the Test Driven Development craze of the past few years, you're probably getting a bit nervous by now, wondering how on earth you are going to test your application. Lucky for you, the Arquillian project is here to help! - -Arquillian provides all the boiler plate for running your test inside JBoss WildFly, allowing you to concentrate on testing your application. In order to do that, it utilizes Shrinkwrap, a fluent API for defining packaging, to create an archive to deploy. We'll go through the testcase, and how you configure Arquillian in just a moment, but first let's run the test. - -Before we start, we need to let Arquillian know the path to our server. Open up `src/test/resources/arquillian.xml`, uncomment the `` elements, and set the `jbossHome` property to the path to the server: - -image:gfx/eclipse_arquillian_0.png[] - -Now, make sure the server is not running (so that the instance started for running the test does not interfere), and then run the tests from the command line by typing: - - mvn clean test -Parq-managed - -You should see the server start up, a `test.war` deployed, test executed, and then the results displayed to you on the console: - ------------------------------------------------------------------------- -$ > mvn clean test -Parq-managed - - -[INFO] Scanning for projects... -[INFO] -[INFO] ------------------------------------------------------------------------ -[INFO] Building WildFly Quickstarts: Kitchensink 7.0.0-SNAPSHOT -[INFO] ------------------------------------------------------------------------ -[INFO] -[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ wildfly-kitchensink --- -[INFO] Deleting /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target -[INFO] -[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ wildfly-kitchensink --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -[INFO] Copying 2 resources -[INFO] -[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ wildfly-kitchensink --- -[INFO] Compiling 6 source files to /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/classes -[INFO] -[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ wildfly-kitchensink --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -[INFO] Copying 1 resource -[INFO] -[INFO] --- maven-compiler-plugin:2.3.1:testCompile (default-testCompile) @ wildfly-kitchensink --- -[INFO] Compiling 1 source file to /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/test-classes -[INFO] -[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ wildfly-kitchensink --- -[INFO] Surefire report directory: /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/surefire-reports - -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest -Jun 25, 2011 7:17:49 PM org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator getActivatedConfiguration -INFO: Could not read active container configuration: null -log4j:WARN No appenders could be found for logger (org.jboss.remoting). -log4j:WARN Please initialize the log4j system properly. -Jun 25, 2011 7:17:54 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal -INFO: Starting container with: [java, -Djboss.home.dir=/Users/pmuir/development/jboss, -Dorg.jboss.boot.log.file=/Users/pmuir/development/jboss/standalone/log/boot.log, -Dlogging.configuration=file:/Users/pmuir/development/jboss/standalone/configuration/logging.properties, -jar, /Users/pmuir/development/jboss/jboss-modules.jar, -mp, /Users/pmuir/development/jboss/modules, -logmodule, org.jboss.logmanager, -jaxpmodule, javax.xml.jaxp-provider, org.jboss.as.standalone, -server-config, standalone.xml] -19:17:55,107 INFO [org.jboss.modules] JBoss Modules version 1.0.0.CR4 -19:17:55,329 INFO [org.jboss.msc] JBoss MSC version 1.0.0.CR2 -19:17:55,386 INFO [org.jboss.as] JBoss WildFly.0.0.Beta4-SNAPSHOT "(TBD)" starting -19:17:56,159 INFO [org.jboss.as] creating http management service using network interface (management) port (9990) securePort (-1) -19:17:56,181 INFO [org.jboss.as.logging] Removing bootstrap log handlers -19:17:56,189 INFO [org.jboss.as.naming] (Controller Boot Thread) Activating Naming Subsystem -19:17:56,203 INFO [org.jboss.as.naming] (MSC service thread 1-4) Starting Naming Service -19:17:56,269 INFO [org.jboss.as.security] (Controller Boot Thread) Activating Security Subsystem -19:17:56,305 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 3.2.0.Beta2 -19:17:56,317 INFO [org.xnio] (MSC service thread 1-1) XNIO Version 3.0.0.Beta3 -19:17:56,331 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.0.0.Beta3 -19:17:56,522 INFO [org.jboss.as.connector.subsystems.datasources] (Controller Boot Thread) Deploying JDBC-compliant driver class org.h2.Driver (version 1.2) -19:17:56,572 INFO [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-7) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java -19:17:56,627 INFO [org.jboss.as.remoting] (MSC service thread 1-3) Listening on /127.0.0.1:9999 -19:17:56,641 INFO [org.jboss.as.jmx.JMXConnectorService] (MSC service thread 1-2) Starting remote JMX connector -19:17:56,705 INFO [org.jboss.as.ee] (Controller Boot Thread) Activating EE subsystem -19:17:56,761 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080 -19:17:56,793 INFO [org.jboss.as.connector] (MSC service thread 1-3) Starting JCA Subsystem (JBoss IronJacamar 1.0.0.CR2) -19:17:56,837 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) Bound data source [java:jboss/datasources/ExampleDS] -19:17:57,335 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "arquillian-service" -19:17:57,348 INFO [org.jboss.as.deployment] (MSC service thread 1-7) Started FileSystemDeploymentService for directory /Users/pmuir/development/jboss/standalone/deployments -19:17:57,693 INFO [org.jboss.as] (Controller Boot Thread) JBoss WildFly.0.0.Beta4-SNAPSHOT "(TBD)" started in 2806ms - Started 111 of 138 services (27 services are passive or on-demand) -19:18:00,596 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) Stopped deployment arquillian-service in 8ms -19:18:01,394 INFO [org.jboss.as.server.deployment] (pool-2-thread-7) Content added at location /Users/pmuir/development/jboss/standalone/data/content/0a/9e20b7bc978fd2778b89c7c06e4d3e1f308dfe/content -19:18:01,403 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) Starting deployment of "arquillian-service" -19:18:01,650 INFO [org.jboss.as.server.deployment] (pool-2-thread-6) Content added at location /Users/pmuir/development/jboss/standalone/data/content/94/8324ab8f5a693c67fa57b59323304d3947bbf6/content -19:18:01,659 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) Starting deployment of "test.war" -19:18:01,741 INFO [org.jboss.jpa] (MSC service thread 1-7) read persistence.xml for primary -19:18:01,764 INFO [org.jboss.weld] (MSC service thread 1-3) Processing CDI deployment: test.war -19:18:01,774 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named MemberRegistration in deployment unit deployment "test.war" are as follows: - - java:global/test/MemberRegistration!org.jboss.as.quickstarts.kitchensink.controller.MemberRegistration - java:app/test/MemberRegistration!org.jboss.as.quickstarts.kitchensink.controller.MemberRegistration - java:module/MemberRegistration!org.jboss.as.quickstarts.kitchensink.controller.MemberRegistration - java:global/test/MemberRegistration - java:app/test/MemberRegistration - java:module/MemberRegistration - -19:18:01,908 INFO [org.jboss.weld] (MSC service thread 1-5) Starting Services for CDI deployment: test.war -19:18:02,131 INFO [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900 1.1.1 (Final) -19:18:02,169 INFO [org.jboss.weld] (MSC service thread 1-2) Starting weld service -19:18:02,174 INFO [org.jboss.as.arquillian] (MSC service thread 1-3) Arquillian deployment detected: ArquillianConfig[service=jboss.arquillian.config."test.war",unit=test.war,tests=[org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest]] -19:18:02,179 INFO [org.jboss.jpa] (MSC service thread 1-6) starting Persistence Unit Service 'test.war#primary' -19:18:02,322 INFO [org.hibernate.annotations.common.Version] (MSC service thread 1-6) Hibernate Commons Annotations 3.2.0.Final -19:18:02,328 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00412:Hibernate [WORKING] -19:18:02,330 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00206:hibernate.properties not found -19:18:02,332 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00021:Bytecode provider name : javassist -19:18:02,354 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-6) HHH00204:Processing PersistenceUnitInfo [ - name: primary - ...] -19:18:02,400 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-6) HHH00194:Package not found or wo package-info.java: org.jboss.as.quickstarts.kitchensink.test -19:18:02,400 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-6) HHH00194:Package not found or wo package-info.java: org.jboss.as.quickstarts.kitchensink.controller -19:18:02,401 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-6) HHH00194:Package not found or wo package-info.java: org.jboss.as.quickstarts.kitchensink.util -19:18:02,401 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-6) HHH00194:Package not found or wo package-info.java: org.jboss.as.quickstarts.kitchensink.model -19:18:02,592 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-6) HHH00130:Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider -19:18:02,852 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-6) HHH00400:Using dialect: org.hibernate.dialect.H2Dialect -19:18:02,858 WARN [org.hibernate.dialect.H2Dialect] (MSC service thread 1-6) HHH00431:Unable to determine H2 database version, certain features may not work -19:18:02,862 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-6) HHH00423:Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 -19:18:02,870 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-6) HHH00268:Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory -19:18:02,874 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-6) HHH00397:Using ASTQueryTranslatorFactory -19:18:02,911 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-6) Hibernate Validator 4.1.0.Final -19:18:02,917 INFO [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-6) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. -19:18:03,079 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-6) HHH00227:Running hbm2ddl schema export -19:18:03,093 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-6) HHH00230:Schema export complete -19:18:03,217 INFO [org.jboss.web] (MSC service thread 1-5) registering web context: /test -19:18:03,407 WARN [org.jboss.weld.Bean] (RMI TCP Connection(3)-127.0.0.1) WELD-000018 Executing producer field or method [method] @Produces public org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest.produceLog(InjectionPoint) on incomplete declaring bean Managed Bean [class org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest] with qualifiers [@Any @Default] due to circular injection -19:18:03,427 WARN [org.jboss.weld.Bean] (RMI TCP Connection(3)-127.0.0.1) WELD-000018 Executing producer field or method [method] @Produces public org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest.produceLog(InjectionPoint) on incomplete declaring bean Managed Bean [class org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest] with qualifiers [@Any @Default] due to circular injection -19:18:03,450 WARN [org.jboss.as.ejb3.component.EJBComponent] (RMI TCP Connection(3)-127.0.0.1) EJBTHREE-2120: deprecated getTransactionAttributeType method called (dev problem) -19:18:03,459 INFO [org.jboss.as.quickstarts.kitchensink.controller.MemberRegistration] (RMI TCP Connection(3)-127.0.0.1) Registering Jane Doe -19:18:03,616 INFO [org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest] (RMI TCP Connection(3)-127.0.0.1) Jane Doe was persisted with id 1 -19:18:03,686 INFO [org.jboss.jpa] (MSC service thread 1-1) stopping Persistence Unit Service 'test.war#primary' -19:18:03,687 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1) HHH00227:Running hbm2ddl schema export -19:18:03,690 INFO [org.jboss.weld] (MSC service thread 1-3) Stopping weld service -19:18:03,692 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1) HHH00230:Schema export complete -19:18:03,704 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) Stopped deployment test.war in 52ms -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.859 sec - -Results : - -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 22.305s -[INFO] Finished at: Sat Jun 25 19:18:04 BST 2011 -[INFO] Final Memory: 17M/125M -[INFO] ------------------------------------------------------------------------ - ------------------------------------------------------------------------- - -As you can see, that didn't take too long (approximately 15s), and is great for running in your QA environment, but if you running locally, you might prefer to connect to a running server. To do that, start up JBoss WildFly (as described in <>. Now, run your test, but use the `arq-wildfly-remote` profile: - - mvn clean test -Parq-remote - ------------------------------------------------------------------------- -$ > mvn clean test -Parq-remote - - -[INFO] Scanning for projects... -[INFO] -[INFO] ------------------------------------------------------------------------ -[INFO] Building WildFly Quickstarts: Kitchensink 7.0.0-SNAPSHOT -[INFO] ------------------------------------------------------------------------ -[INFO] -[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ wildfly-kitchensink --- -[INFO] Deleting /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target -[INFO] -[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ wildfly-kitchensink --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -[INFO] Copying 2 resources -[INFO] -[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ wildfly-kitchensink --- -[INFO] Compiling 6 source files to /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/classes -[INFO] -[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ wildfly-kitchensink --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -[INFO] Copying 1 resource -[INFO] -[INFO] --- maven-compiler-plugin:2.3.1:testCompile (default-testCompile) @ wildfly-kitchensink --- -[INFO] Compiling 1 source file to /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/test-classes -[INFO] -[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ wildfly-kitchensink --- -[INFO] Surefire report directory: /Users/pmuir/workspace/wildfly-docs/quickstarts/kitchensink/target/surefire-reports - ------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.jboss.as.quickstarts.kitchensink.test.MemberRegistrationTest -Jun 25, 2011 7:22:28 PM org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator getActivatedConfiguration -INFO: Could not read active container configuration: null -log4j:WARN No appenders could be found for logger (org.jboss.as.arquillian.container.MBeanServerConnectionProvider). -log4j:WARN Please initialize the log4j system properly. -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.13 sec - -Results : - -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 10.474s -[INFO] Finished at: Sat Jun 25 19:22:33 BST 2011 -[INFO] Final Memory: 17M/125M -[INFO] ------------------------------------------------------------------------ -$ > ------------------------------------------------------------------------- - - -[IMPORTANT] -======================================================================== -Arquillian defines two modes, _managed_ and _remote_ . The _managed_ -mode will take care of starting and stopping the server for you, whilst -the _remote_ mode connects to an already running server. -======================================================================== - -This time you can see the test didn't start the server (if you check the instance you started, you will see the application was deployed there), and the test ran a lot faster (approximately 4s). - -We can also run the test from Eclipse, in both managed and remote modes. First, we'll run in in managed mode. In order to set up the correct dependencies on your classpath, right click on the project, and select Properties : - -image:gfx/eclipse_arquillian_1.png[] - -Now, locate the Maven panel: - -image:gfx/eclipse_arquillian_2.png[] - -And activate the `arq-managed` profile: - -image:gfx/eclipse_arquillian_3.png[] - -Finally, hit _Ok_, and then confirm you want to update the project configuration: - -image:gfx/eclipse_arquillian_4.png[] - -Once the project has built, locate the `MemberRegistrationTest` in `src/test/java`, right click on the test, and choose _Run As -> JUnit Test...`_: - -image:gfx/eclipse_arquillian_12.png[] - -You should see the server start in the Eclipse Console, the test be deployed, and finally the JUnit View pop up with the result (a pass of course!). - -We can also run the test in an already running instance of Eclipse. Simply change the active profile to `arq-remote`: - -image:gfx/eclipse_arquillian_11.png[] - -Now, make sure the server is running, right click on the test case and choose _Run As -> JUnit Test..._: - -image:gfx/eclipse_arquillian_12.png[] - -Again, you'll see the test run in the server, and the JUnit View pop up, with the test passing. - -So far so good, the test is running in both Eclipse and from the command line. But what does the test look like? - -.src/test/java/org/jboss/as/quickstarts/kitchensink/test/MemberRegistrationTest.java -[source,java] ------------------------------------------------------------------------- -@RunWith(Arquillian.class) // <1> -public class MemberRegistrationTest { - @Deployment // <2> - public static Archive createTestArchive() { - return ShrinkWrap.create(WebArchive.class, "test.war") - .addClasses(Member.class, - MemberRegistration.class, - Resources.class) // <3> - .addAsResource("META-INF/test-persistence.xml", - "META-INF/persistence.xml") // <4> - .addAsWebInfResource(EmptyAsset.INSTANCE, - "beans.xml") // <5> - // Deploy our test datasource - .addAsWebInfResource("test-ds.xml"); // <6> - } - - @Inject // <7> - MemberRegistration memberRegistration; - - @Inject - Logger log; - - @Test - public void testRegister() throws Exception { // <8> - Member newMember = new Member(); - newMember.setName("Jane Doe"); - newMember.setEmail("jane@mailinator.com"); - newMember.setPhoneNumber("2125551234"); - memberRegistration.register(newMember); - assertNotNull(newMember.getId()); - log.info(newMember.getName() + - " was persisted with id " + - newMember.getId()); - } - -} ------------------------------------------------------------------------- -<1> `@RunWith(Arquillian.class)` tells JUnit to hand control over to Arquillian when executing tests -<2> The `@Deployment` annotation identifies the `createTestArchive()` static method to Arquillian as the one to use to determine which resources and classes to deploy -<3> We add just the classes needed for the test, no more -<4> We also add persistence.xml as our test is going to use the database -<5> Of course, we must add beans.xml to enable CDI -<6> Finally, we add a test datasource, so that test data doesn't overwrite production data -<7> Arquillian allows us to inject beans into the test case -<8> The test method works as you would expect - creates a new member, registers them, and then verifies that the member was created - -As you can see, Arquillian has lived up to the promise - the test case is focused on _what_ to test (the `@Deployment` method) and _how_ to test (the `@Test` method). It's also worth noting that this isn't a simplistic unit test - this is a fully fledged integration test that uses the database. - -Now, let's look at how we configure Arquillian. First of all, let's take a look at `arquillian.xml` in `src/test/resources`. - - -.src/test/resources/META-INF/arquillian.xml -[source,xml] ------------------------------------------------------------------------- - - - - <1> - - - - - <2> - - - - - - /path/to/wildfly - - - - ------------------------------------------------------------------------- -<1> Arquillian deploys the test war, and doesn't write it to disk. For debugging, it can be very useful to see exactly what is in your war, so Arquillian allows you to export the war when the tests runs -<2> Arquillian currently needs configuring to use the Servlet protocol to connect to the server - -Now, we need to look at how we select between containers in the `pom.xml`: - -.pom.xml -[source,xml] ------------------------------------------------------------------------- - - - - - arq-wildfly-managed <1> - - - org.jboss.as - <2> - wildfly-arquillian-container-managed - - test - - - - - - - - arq-wildfly-remote - - - org.jboss.as - <3> - wildfly-arquillian-container-remote - - test - - - ------------------------------------------------------------------------- -<1> The profile needs an id so we can activate from Eclipse or the command line -<2> Arquillian decides which container to use depending on your classpath. Here we define the managed container -<3> Arquillian decides which container to use depending on your classpath. Here we define the remote container - -And that's it! As you can see Arquillian delivers simple and true testing. You can concentrate on writing your test functionality, and run your tests in the same environment in which you will run your application. - - -[TIP] -======================================================================== -Arquillian also offers other containers, allowing you to run your tests -against Weld Embedded (super fast, but your enterprise services are -mocked), GlassFish, and more -======================================================================== - That concludes our tour of the kitchensink quickstart. If you would like to use this project as a basis for your own application, you can of course copy this application sources and modify it. diff --git a/guide/gfx/eclipse_arquillian_0.png b/guide/gfx/eclipse_arquillian_0.png deleted file mode 100644 index 18bdbc3a8a..0000000000 Binary files a/guide/gfx/eclipse_arquillian_0.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_1.png b/guide/gfx/eclipse_arquillian_1.png deleted file mode 100644 index 17c9c3e51f..0000000000 Binary files a/guide/gfx/eclipse_arquillian_1.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_11.png b/guide/gfx/eclipse_arquillian_11.png deleted file mode 100644 index f32571ac09..0000000000 Binary files a/guide/gfx/eclipse_arquillian_11.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_12.png b/guide/gfx/eclipse_arquillian_12.png deleted file mode 100644 index 039c2b79d4..0000000000 Binary files a/guide/gfx/eclipse_arquillian_12.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_2.png b/guide/gfx/eclipse_arquillian_2.png deleted file mode 100644 index 3d0c1300fd..0000000000 Binary files a/guide/gfx/eclipse_arquillian_2.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_3.png b/guide/gfx/eclipse_arquillian_3.png deleted file mode 100644 index 8870552c27..0000000000 Binary files a/guide/gfx/eclipse_arquillian_3.png and /dev/null differ diff --git a/guide/gfx/eclipse_arquillian_4.png b/guide/gfx/eclipse_arquillian_4.png deleted file mode 100644 index f2d56c6658..0000000000 Binary files a/guide/gfx/eclipse_arquillian_4.png and /dev/null differ diff --git a/kitchensink/pom.xml b/kitchensink/pom.xml index 77b1b27115..208ce1242f 100644 --- a/kitchensink/pom.xml +++ b/kitchensink/pom.xml @@ -185,21 +185,6 @@ provided - - - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - - org.jboss.arquillian.protocol - arquillian-protocol-servlet-jakarta - test - - org.jboss.logging diff --git a/microprofile-config/pom.xml b/microprofile-config/pom.xml index b9b4380d38..eaaf82e1b1 100644 --- a/microprofile-config/pom.xml +++ b/microprofile-config/pom.xml @@ -130,23 +130,6 @@ test jar - - org.jboss.arquillian.container - arquillian-container-test-spi - test - jar - - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - - org.wildfly.arquillian - wildfly-arquillian-container-managed - test - org.jboss.resteasy resteasy-client diff --git a/microprofile-config/src/test/java/org/wildfly/quickstarts/microprofile/config/MicroProfileConfigIT.java b/microprofile-config/src/test/java/org/wildfly/quickstarts/microprofile/config/MicroProfileConfigIT.java deleted file mode 100644 index 888a6fc1ae..0000000000 --- a/microprofile-config/src/test/java/org/wildfly/quickstarts/microprofile/config/MicroProfileConfigIT.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.wildfly.quickstarts.microprofile.config; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.container.test.api.RunAsClient; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.arquillian.test.api.ArquillianResource; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.wildfly.quickstarts.microprofile.config.custom.CustomPropertiesFileProvider; - -import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.ClientBuilder; -import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.Response; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -/** - * Simple tests for MicroProfile Config quickstart. Arquillian deploys an WAR archive to the application server, which - * contains several endpoints exposing injected configuration values and verifies that they are correctly invoked. - * - * @author Martin Stefanko - * - */ -@RunWith(Arquillian.class) -@RunAsClient -public class MicroProfileConfigIT { - - @ArquillianResource - private URL deploymentURL; - - private Client client; - - @Before - public void before() throws MalformedURLException { - client = ClientBuilder.newClient(); - } - - @After - public void after() { - if (client != null) { - client.close(); - } - } - - /** - * Constructs a deployment archive - * - * @return the deployment archive - */ - @Deployment - public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class) - .addPackages(true, ConfigResource.class.getPackage()) - .addAsResource("META-INF/microprofile-config.properties") - .addAsResource("META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource") - .addAsResource("META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider") - .addAsResource("META-INF/services/org.eclipse.microprofile.config.spi.Converter") - // enable CDI - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - } - - /** - * Tests that /config/value returns the value configured in microprofile-config.properties - */ - @Test - public void testConfigPropertiesValue() { - Response response = client - .target(deploymentURL.toString()) - .path("/config/value") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("MyPropertyFileConfigValue", response.readEntity(String.class)); - - response.close(); - } - - /** - * Tests that /config/required returns the default value from the `ConfigProperty` annotations - */ - @Test - public void testDefaultValue() { - Response response = client - .target(deploymentURL.toString()) - .path("/config/required") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("Default required prop value", response.readEntity(String.class)); - - response.close(); - } - - /** - * Tests that /config/optional returns the orElse value hard coded in the resource - */ - @Test - public void testOptionalValue() { - Response response = client - .target(deploymentURL.toString()) - .path("/config/optional") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("no optional value provided, use this as the default", response.readEntity(String.class)); - - response.close(); - } - - /** - * Tests that /config/all-props retuns an array containins string `config.prop` (as it is a configured property) - */ - @Test - public void testConfigObjectAllProps() { - Response response = client - .target(deploymentURL.toString()) - .path("/config/all-props") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertTrue(response.readEntity(String.class).contains("config.prop")); - - response.close(); - } - - /** - * Tests that /custom-config/value returns the value from the custom config source deployed with the application - */ - @Test - public void testConfigSourceValue() { - Response response = client - .target(deploymentURL.toString()) - .path("/custom-config/value") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("MyCustomValue", response.readEntity(String.class)); - - response.close(); - } - - /** - * Tests that /custom-config/reloaded-value returns: - * - 200 on first invocation and the default value `default` is returned (custom.properties file does not exist) - * - create `custom.properties` file in the `JBOSS_HOME` directory with the content - * `custom.provided.prop=FileSystemCustomConfigValue` and verify that /custom-config/reloaded-value returns - * `FileSystemCustomConfigValue` - * - change the value of `custom.provided.prop` in the `custom.properties` file and verify that it is returned - * from /custom-config/reloaded-value - */ - @Test - public void testConfigSourceReloadedValue() throws IOException { - Path customPropertiesPath = Paths.get(CustomPropertiesFileProvider.getJBossHome() + "/custom.properties"); - Files.deleteIfExists(customPropertiesPath); - - WebTarget target = client - .target(deploymentURL.toString()) - .path("/custom-config/reloaded-value"); - - Response response = target.request().get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("default", response.readEntity(String.class)); - response.close(); - - Files.write(customPropertiesPath, "custom.provided.prop=FileSystemCustomConfigValue".getBytes()); - - response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("FileSystemCustomConfigValue", response.readEntity(String.class)); - response.close(); - - Files.write(customPropertiesPath, "custom.provided.prop=ChangedValue".getBytes()); - - response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ChangedValue", response.readEntity(String.class)); - response.close(); - - Files.delete(customPropertiesPath); - } - - /** - * Tests that /converter/value returns the value from the custom converted object - */ - @Test - public void testConverterValue() { - Response response = client - .target(deploymentURL.toString()) - .path("/converter/value") - .request() - .get(); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("MyCustomConverterValue", response.readEntity(String.class)); - - response.close(); - } -} diff --git a/microprofile-fault-tolerance/pom.xml b/microprofile-fault-tolerance/pom.xml index 1aa2320f6a..f362cd3ed1 100644 --- a/microprofile-fault-tolerance/pom.xml +++ b/microprofile-fault-tolerance/pom.xml @@ -165,18 +165,6 @@ junit test - - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - org.wildfly.arquillian - wildfly-arquillian-common - test - org.jboss.resteasy resteasy-client diff --git a/microprofile-health/pom.xml b/microprofile-health/pom.xml index 41a61d78ee..7fa3ab0ff6 100644 --- a/microprofile-health/pom.xml +++ b/microprofile-health/pom.xml @@ -139,9 +139,9 @@ test - org.wildfly.arquillian - wildfly-arquillian-common - test + org.wildfly.core + wildfly-cli + client diff --git a/microprofile-health/src/test/java/org/wildfly/quickstarts/microprofile/health/MicroProfileHealthIT.java b/microprofile-health/src/test/java/org/wildfly/quickstarts/microprofile/health/MicroProfileHealthIT.java index 54e713e1c1..6eaa3e5eda 100644 --- a/microprofile-health/src/test/java/org/wildfly/quickstarts/microprofile/health/MicroProfileHealthIT.java +++ b/microprofile-health/src/test/java/org/wildfly/quickstarts/microprofile/health/MicroProfileHealthIT.java @@ -32,8 +32,7 @@ import java.util.Optional; /** - * Simple tests for MicroProfile Health quickstart. Arquillian deploys an JAR archive to the application server, which - * contains several health checks and verifies that they are correctly invoked. + * Simple tests for MicroProfile Health quickstart. * * @author Martin Stefanko * diff --git a/microprofile-reactive-messaging-kafka/pom.xml b/microprofile-reactive-messaging-kafka/pom.xml index 0e85c58216..105dab870d 100644 --- a/microprofile-reactive-messaging-kafka/pom.xml +++ b/microprofile-reactive-messaging-kafka/pom.xml @@ -201,11 +201,6 @@ - - org.wildfly.arquillian - wildfly-arquillian-common - test - org.eclipse.microprofile.rest.client microprofile-rest-client-api diff --git a/remote-helloworld-mdb/src/test/resources/arquillian.xml b/remote-helloworld-mdb/src/test/resources/arquillian.xml deleted file mode 100644 index f20100c13e..0000000000 --- a/remote-helloworld-mdb/src/test/resources/arquillian.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/shared-doc/attributes.adoc b/shared-doc/attributes.adoc index a032d67521..4adf2dc369 100644 --- a/shared-doc/attributes.adoc +++ b/shared-doc/attributes.adoc @@ -149,7 +149,6 @@ endif::[] :useEclipseDeployEARDocUrl: {guidesBaseUrl}USE_JBDS.adoc#deploy_and_undeploy_a_quickstart_ear_project :useProductHomeDocUrl: {guidesBaseUrl}USE_OF_{jbossHomeName}.adoc#use_of_product_home_and_jboss_home_variables :configureMavenDocUrl: {guidesBaseUrl}CONFIGURE_MAVEN_JBOSS_EAP.adoc#configure_maven_to_build_and_deploy_the_quickstarts -:arquillianTestsDocUrl: {guidesBaseUrl}RUN_ARQUILLIAN_TESTS.adoc#run_the_arquillian_tests :addUserDocUrl: {guidesBaseUrl}CREATE_USERS.adoc#create_users_required_by_the_quickstarts :addApplicationUserDocUrl: {guidesBaseUrl}CREATE_USERS.adoc#add_an_application_user :addManagementUserDocUrl: {guidesBaseUrl}CREATE_USERS.adoc#add_an_management_user diff --git a/shared-doc/run-arquillian-functional-tests-remote.adoc b/shared-doc/run-arquillian-functional-tests-remote.adoc deleted file mode 100644 index c9bfbba246..0000000000 --- a/shared-doc/run-arquillian-functional-tests-remote.adoc +++ /dev/null @@ -1,37 +0,0 @@ -[[run_the_arquillian_functional_tests-remote]] -= Run the Arquillian Functional Tests -//****************************************************************************** -// Include this template if your quickstart provides standard Arquillian -// functional tests. -//****************************************************************************** - -This quickstart provides Arquillian functional tests. They are located under the `src/tests/` directory. Functional tests verify that your application behaves correctly from the user's point of view and simulate clicking around the web page as a normal user would do. - -Follow these steps to run the functional tests. - -ifdef::standalone-server-type[] -. xref:start_the_eap_standalone_server[Start the {productName} server] as described above. - -endif::[] - -ifdef::managed-domain-type[] -. xref:start_the_eap_managed_domain[Start the {productName} server] as described above. -endif::[] - -ifdef::standalone-server-type,managed-domain-type[] -. Type the following command to run the `verify` goal with the `arq-remote` profile activated. -endif::[] -ifndef::standalone-server-type,managed-domain-type[] -. You need to start the provisioned server or the bootable jar server, as previously described. -. Type the following command to run the `verify` goal with the `arq-remote` profile activated. -endif::[] - -[source,options="nowrap"] ----- -$ mvn verify -Parq-remote ----- - -[NOTE] -==== -You may also use the environment variable `SERVER_HOST` or the system property `server.host` to define the target host of the tests. -==== diff --git a/shared-doc/run-arquillian-functional-tests.adoc b/shared-doc/run-arquillian-functional-tests.adoc deleted file mode 100644 index 59f54675e4..0000000000 --- a/shared-doc/run-arquillian-functional-tests.adoc +++ /dev/null @@ -1,42 +0,0 @@ -[[run_the_arquillian_functional_tests]] -= Run the Arquillian Functional Tests -//****************************************************************************** -// Include this template if your quickstart provides standard Arquillian -// functional tests. -//****************************************************************************** - -This quickstart provides Arquillian functional tests. They are located under the `functional-tests/` directory. Functional tests verify that your application behaves correctly from the user's point of view and simulate clicking around the web page as a normal user would do. - -NOTE: The Arquillian functional tests deploy the application, so make sure you undeploy the quickstart before you begin. - -Follow these steps to run the functional tests. - -ifdef::standalone-server-type[] -. xref:start_the_eap_standalone_server[Start the {productName} server] as described above. -endif::[] - -ifdef::managed-domain-type[] -. xref:start_the_eap_managed_domain[Start the {productName} server] as described above. -endif::[] - -. Build the quickstart archive. -.. Open a terminal and navigate to the root directory of this quickstart. -.. Build the quickstart archive using the following command: -+ -[source,options="nowrap"] ----- -$ mvn clean package ----- -. Navigate to the `functional-tests/` directory in this quickstart. - -. Type the following command to run the `verify` goal with the `arq-remote` profile activated. -+ -[source,options="nowrap"] ----- -$ mvn clean verify -Parq-remote ----- - -[NOTE] -==== -You can also let Arquillian manage the {productName} server by using the `arq-managed` profile, meaning the tests will start the server for you. This profile requires that you provide Arquillian with the location of the {productName} server, either by setting the `JBOSS_HOME` environment variable, or by setting the `jbossHome` property in the `arquillian.xml` file. For more information, see link:{arquillianTestsDocUrl}[Run the Arquillian Tests]. -==== diff --git a/shared-doc/run-arquillian-tests.adoc b/shared-doc/run-arquillian-tests.adoc deleted file mode 100644 index 37216a677c..0000000000 --- a/shared-doc/run-arquillian-tests.adoc +++ /dev/null @@ -1,48 +0,0 @@ -[[run_the_arquillian_tests]] -= Run the Arquillian Tests -//****************************************************************************** -// Include this template if your quickstart provides standard Arquillian tests. -//****************************************************************************** - -This quickstart provides Arquillian tests. By default, these tests are configured to be skipped since Arquillian tests require the use of a container. - -NOTE: The Arquillian tests deploy the application, so make sure you undeploy the quickstart before you begin. - -ifdef::arq-prerequisities[] -== Arquillian Tests prerequisities - -{arq-prerequisities} -endif::[] - -Follow these steps to run the tests. - -ifdef::standalone-server-type[] -. xref:start_the_eap_standalone_server[Start the {productName} server] as described above. -endif::[] - -ifdef::managed-domain-type[] -. xref:start_the_eap_managed_domain[Start the {productName} server] as described above. -endif::[] - -. Open a terminal and navigate to the root directory of this quickstart. -. Type the following command to run the `verify` goal with the `arq-remote` profile activated. -+ -[source,options="nowrap"] ----- -$ mvn clean verify -Parq-remote ----- -ifdef::arquillianTestResults[] -You should see the following results: -+ -[source,subs=attributes+,options="nowrap"] ----- -Results : - -{arquillianTestResults} ----- -endif::[] - -[NOTE] -==== -You can also let Arquillian manage the {productName} server by using the `arq-managed` profile, meaning the tests will start the server for you. This profile requires that you provide Arquillian with the location of the {productName} server, either by setting the `JBOSS_HOME` environment variable, or by setting the `jbossHome` property in the `arquillian.xml` file. For more information, see link:{arquillianTestsDocUrl}[Run the Arquillian Tests]. -==== diff --git a/shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc b/shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc index 5272595257..b99e67ab08 100644 --- a/shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc +++ b/shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc @@ -11,7 +11,7 @@ This quickstart is not supported in {JBDSProductName}. endif::jbds-not-supported[] ifndef::jbds-not-supported[] -You can also start the server and deploy the quickstarts or run the Arquillian tests in {JBDSProductName} or from Eclipse using JBoss tools. For general information about how to import a quickstart, add a {productName} server, and build and deploy a quickstart, see link:{useEclipseUrl}[Use {JBDSProductName} or Eclipse to Run the Quickstarts]. +You can also start the server and deploy the quickstarts, or run any tests in {JBDSProductName} or from Eclipse using JBoss tools. For general information about how to import a quickstart, add a {productName} server, and build and deploy a quickstart, see link:{useEclipseUrl}[Use {JBDSProductName} or Eclipse to Run the Quickstarts]. endif::jbds-not-supported[] // Add additional instructions specific to running this quickstart in an IDE here. diff --git a/spring-resteasy/pom.xml b/spring-resteasy/pom.xml index 7c64f07020..169e65800f 100644 --- a/spring-resteasy/pom.xml +++ b/spring-resteasy/pom.xml @@ -190,18 +190,6 @@ httpclient test - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-depchain - 2.2.7 - pom - test - diff --git a/spring-resteasy/src/test/resources/arquillian.xml b/spring-resteasy/src/test/resources/arquillian.xml deleted file mode 100644 index a96b377684..0000000000 --- a/spring-resteasy/src/test/resources/arquillian.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -