使用Forge插件在现有Java EE项目上启用Arquillian

技术提示#34解释了如何创建可测试的Java EE 7应用程序。 如果要启动新的应用程序,这将很有用。 但是,如果您已经有一个应用程序并启用Arquillian怎么办?

这就是Forge和Forge-Arquillian附加组件派上用场的地方。 这就是我在javaee7-simple-sample中添加对Arquillian的支持的方式。

让我们看看已经完成了!

  1. 下载并安装Forge。 您可以在自己喜欢的位置下载ZIP并解压缩,也可以使用下面的命令为您完成:
    Downloads> curl http://forge.jboss.org/sh | sh% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
    100  2725    0  2725    0     0   4641      0 --:--:-- --:--:-- --:--:--  4642
    /usr/bin/java
    Downloading Forge
    ######################################################################## 100.0%
    Archive:  /Users/arungupta/.forge/forge_installer.zipcreating: /Users/arungupta/forge/forge-distribution-2.12.2.Final/creating: /Users/arungupta/forge/forge-distribution-2.12.2.Final/img/. . .If you have not yet seen the Forge built-in commands, you may either press TAB to see a list of the currently available commands, or get a more descriptive list by typing:$ command-listThen to get started - see the docs at
    http://forge.jboss.org/documentation 
    Consider installing Git and Maven 3.1+ (both optional)Restart Terminal to use forge.
  2. 克隆simple-javaee7-sample仓库 :
    git clone https://github.com/javaee-samples/javaee7-simple-sample.git
  3. 将目录更改为javaee7-simple-sample并启动Forge:
    javaee7-simple-sample> ~/tools/forge-distribution-2.12.2.Final/bin/forge
    Using Forge at /Users/arungupta/tools/forge-distribution-2.12.2.Final_____                    |  ___|__  _ __ __ _  ___ | |_ / _ \| `__/ _` |/ _ \  \\|  _| (_) | | | (_| |  __/  //|_|  \___/|_|  \__, |\___| |__/      JBoss Forge, version [ 2.12.2.Final ] - JBoss, by Red Hat, Inc. [ http://forge.jboss.org ]
  4. 安装Forge-Arquillian附加组件:
    [javaee7-simple-sample]$ addon-install-from-git --url https://github.com/forge/addon-arquillian.git
    ***INFO*** Installing Addon from Git 	[0/4] ...
    ***INFO*** Installing Addon from Git:Cloning repository in /var/folders/3v/syxsk5zx3yqd_8g9m206py_h0000gn/T/1416131293813-0 	[0/4] ...
    ***INFO*** Installing Addon from Git:Installing project into local repository 	[1/4] ...
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Arquillian Forge Addon 1.0.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] . . .Downloading: http://repo1.maven.org/maven2/org/jboss/forge/addon/maven-impl-projects/2.12.2.Final/maven-impl-projects-2.12.2.Final.pom
    Downloaded: http://repo1.maven.org/maven2/org/jboss/forge/addon/maven-impl-projects/2.12.2.Final/maven-impl-projects-2.12.2.Final.pom (4 KB at 16.9 KB/sec)
    ***SUCCESS*** Addon org.arquillian.forge:arquillian-addon,1.0.0-SNAPSHOT was installed successfully.
  5. 配置Arquillian附加组件并安装WildFly适配器:
    [javaee7-simple-sample]$ arquillian-setup --testFramework junit --containerAdapter wildfly-remote 
    Downloading: http://repo1.maven.org/maven2/org/wildfly/wildfly-arquillian-container-remote/maven-metadata.xml
    Downloaded: http://repo1.maven.org/maven2/org/wildfly/wildfly-arquillian-container-remote/maven-metadata.xml (702 B at 4.2 KB/sec)
    ***SUCCESS*** Arquillian setup complete
    ***SUCCESS*** Installed Arquillian 1.1.5.Final
    ***SUCCESS*** Installed junit
    ***SUCCESS*** Installed Arquillian Container WildFly Remote 8.x
    ***SUCCESS*** Installed Arquillian Container WildFly Remote 8.x dependencies

    适配器列表如下所示:

    glassfish-embedded-3.1       jetty-embedded-6.1           tomee-remote                 
    glassfish-managed-3.1        jetty-embedded-7             was-embedded-8               
    glassfish-remote-3.1         openejb-embedded-3.1         was-remote-7                 
    jbossas-embedded-6           openejb-embedded-4           was-remote-8                 
    jbossas-managed-4.2          openshift-express            weld-ee-embedded-1.1         
    jbossas-managed-5.1          openwebbeans-embedded-1      weld-se-embedded-1           
    jbossas-managed-6            tomcat-embedded-6            weld-se-embedded-1.1         
    jbossas-managed-7            tomcat-embedded-7            wildfly-managed              
    jbossas-remote-4.2           tomcat-managed-5.5           wildfly-remote               
    jbossas-remote-5             tomcat-managed-6             wls-remote-10.3              
    jbossas-remote-5.1           tomcat-managed-7             
    jbossas-remote-6             tomcat-remote-6

    这使您可以配置所选的容器。 这会将以下配置文件添加到您的“ pom.xml”中:

    arquillian-wildfly-remotemaven-surefire-plugin2.14.1arquillian-wildfly-remoteorg.wildflywildfly-arquillian-container-remote8.1.0.Finaltest

    该配置文件包括“ wildfly-arquillian-container-remote”依赖性,该依赖性使Arquillian可以与在远程“模式”下运行的WildFly连接。 默认主机为“ localhost”,端口为“ 8080”。 “ maven-surefire-plugin”将传递一个值为“ arquillian-wildfly-remote”的“ arquillian.launch”配置属性。 这与生成的“ arquillian.xml”中的“容器”限定符匹配。“ arquillian.xml”用于定义配置设置以定位容器或与容器通信。 在我们的情况下,WildFly在默认主机和端口上运行,因此无需更新此文件。 要注意的重要部分是“容器”限定符与“ arquillian.launch”限定符值匹配。

    这个文件。 有关此配置文件的更多详细信息, 请参见此处 。

  6. 在修复FORGE-2148之前,您还需要添加JAX-RS实现以及相应的JAXB提供程序。 该测试使用的是RESTEasy,因此需要添加以下内容:
    org.jboss.resteasyresteasy-client3.0.5.Finaltestorg.jboss.resteasyresteasy-jaxb-provider3.0.5.Finaltest

    可以在概要文件或项目范围的依赖项中添加它。

现在,您可以进行测试了!

下载WildFly 8.1并解压缩。 以以下方式启动服务器:

./bin/standalone.sh

运行测试:

javaee7-simple-sample> mvn test
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ helloworld ---
[INFO] Surefire report directory: /Users/arungupta/workspaces/javaee7-simple-sample/target/surefire-reports-------------------------------------------------------T E S T S
-------------------------------------------------------
Running org.javaee7.sample.PersonTest
Nov 16, 2014 1:53:57 PM org.xnio.Xnio 
INFO: XNIO version 3.2.0.Beta4
Nov 16, 2014 1:53:57 PM org.xnio.nio.NioXnio 
INFO: XNIO NIO Implementation Version 3.2.0.Beta4
Nov 16, 2014 1:53:57 PM org.jboss.remoting3.EndpointImpl 
INFO: JBoss Remoting version (unknown)
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.963 secResults :Tests run: 2, Failures: 0, Errors: 0, Skipped: 0[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.403 s
[INFO] Finished at: 2014-11-16T13:53:59+02:00
[INFO] Final Memory: 17M/309M
[INFO] ------------------------------------------------------------------------

现在,您已经使用Arquillian启用了现有项目!

在此处提交任何问题 。

请享用!

翻译自: https://www.javacodegeeks.com/2014/11/enable-arquillian-on-an-existing-java-ee-project-using-forge-addon.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/361492.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HDOJ1166 敌兵布阵【线段树】

Problem : 1166 ( 敌兵布阵 ) Judge Status : AcceptedRunId : 5862942 Language : GCC Author : qq1203456195 #include <stdio.h> #define lson l,m,rt<<1 #define rson m1,r,rt<<1|1 #define maxn 55555 int sum[maxn<<2]; void PushUp(i…

欧拉回路

欧拉回路与欧拉路径 欧拉回路 不重复地结果每条边的回路欧拉路径 不重复地几个每条边地路径欧拉图 存在欧拉回路地图半欧拉图 存在欧拉路径地图在数学中为简单的图的一笔画完问题&#xff0c;但在有向图里&#xff0c;可以应用到单词接龙判断 判断是否存在欧拉回路 无向图有向图…

jQuery文档就绪

很多jQuery代码都有如下片段: $(document).ready(function(){//代码 })作用就是等文档结构加载完成后再去执行function中的代码&#xff0c;功能类似于window.onload事件。 代码实例如下: <!DOCTYPE html> <html> <head> <meta charset"utf-8"…

使用Java EE 7,WildFly和Docker进行连续部署–(第1部分)

此博客是开始一个新的hanginar&#xff08;G 结伴旅游 webi NAR&#xff09;&#xff0c;将突出解决方案&#xff0c;框架&#xff0c;应用服务器&#xff0c;工具&#xff0c;部署和更多的内容集中在Java EE的系列。 这些不是通常的会议风格独白演示&#xff0c;而是交互式ha…

URAL 1013 K-based Numbers. Version 3

URAL_1013 和URAL_1009的思路是一样的&#xff0c;只不过需要高精度&#xff0c;所以就直接用java写了。具体的一些思路可以参考我的URAL_1009的题解&#xff1a;http://www.cnblogs.com/staginner/archive/2012/05/01/2477513.html。 如果N再大一点的话&#xff0c;也可以用二…

爬取w3c课程—Urllib库使用

爬虫原理 浏览器获取网页内容的步骤&#xff1a;浏览器提交请求、下载网页代码、解析成页面&#xff0c;爬虫要做的就是&#xff1a; 模拟浏览器发送请求&#xff1a;通过HTTP库向目标站点发起请求Request&#xff0c;请求可以包含额外的header等信息&#xff0c;等待服务器响应…

关于SSL证书配置、升级的一些问题总结

SSL会成为网站、APP、小程序&#xff08;小程序已经强制使用https&#xff09;等项目的标配。关于SSL证书安装使用的问题今天总结下&#xff0c;以备用。 环境配置&#xff1a;windows server 2008 R2和IIS7.0 1、 安装SSL证书的环境 (温馨提示&#xff1a;安装证书前请先备份…

如何为JBoss Developer Studio 8设置集成和SOA工具

最新的JBoss Developer Studio&#xff08;JBDS&#xff09;的发布带来了有关如何开始使用尚未安装的各种JBoss Integration和BPM产品工具集的问题。 在本系列文章中&#xff0c;我们将为您概述如何安装每套工具并说明它们支持哪些产品。 这将有助于您在着手进行下一个JBoss集…

YUM常用命令介绍

1.列出所有可更新的软件清单命令&#xff1a;yum check-update 2.安装所有更新软件命令&#xff1a;yum update 3.仅安装指定的软件命令&#xff1a;yum install <package_name> 4.仅更新指定的软件命令&#xff1a;yum update <package_name> 5.列出所有可安裝的软…

WildFly 8的Camel子系统集成了Java EE –入门

就在三天前&#xff0c;围绕Thomas Diesler&#xff08; tdiesler &#xff09;的团队发布了WildFly-Camel子系统的2.0.0.CR1版本&#xff0c;它允许您将Camel Routes添加为WildFly配置的一部分。 路由可以部署为JavaEE应用程序的一部分。 JavaEE组件可以访问Camel Core API和各…

jQuery中国各个省份地图分部代码

jQuery中国各个省份地图分部代码 在线演示本地下载更多专业前端知识&#xff0c;请上 【猿2048】www.mk2048.com

封装axios的接口请求数据方法

lib文件夹中http.js文件的内容 包含了数据请求&#xff0c;路由的拦截&#xff0c;同时向外界暴露的是一个方法&#xff0c;方法内有三个参数&#xff0c;分别为请求的方式&#xff0c;地址&#xff0c;数据 1 import axios from axios;2 import qs from qs;3 4 const serverax…

Spring Boot Actuator:自定义端点,其顶部具有MVC层

Spring Boot Actuator端点允许您监视应用程序并与之交互。 Spring Boot包含许多内置端点&#xff0c;您也可以添加自己的端点。 添加自定义端点就像创建一个从org.springframework.boot.actuate.endpoint.AbstractEndpoint扩展的类一样容易。 但是Spring Boot Actuator也提供了…

jQuery自适应倒计时插件

jQuery自适应倒计时插件 在线演示本地下载更多专业前端知识&#xff0c;请上 【猿2048】www.mk2048.com

Linux三大共享文件的方法

1. Samba Samba 用于Linux 和windows之间的共享&#xff0c;ubuntu里面默认没有安装samba 在安装好samba之后&#xff0c;就用开始配置samba服务: Samba服务器主要配置文件为/etc/samba/smb.conf&#xff0c;并且可以将NetBIOS名与主机的对应关系写在/etc/samba /lmhosts文件中…

Unity3D实践系列03,使用Visual Studio编写脚本与调试

在Unity3D中&#xff0c;只有把脚本赋予Scene中的GameObject&#xff0c;脚本才会得以执行。 添加Camera类型的GameObject。 Unity3D默认使用"MonoDevelop"编辑器&#xff0c;这里&#xff0c;我想使用Visual Studio作为编辑器。 依次点击"Edit","Pre…

纯CSS3文字Loading动画特效

纯CSS3文字Loading动画特效是一款个性的loading文字加载动画。 在线演示本地下载更多专业前端知识&#xff0c;请上 【猿2048】www.mk2048.com

所有OSGi套件的通用CXF请求拦截器

几个月以来&#xff0c;我一直在研究Apache CXF&#xff0c;Karaf和Felix&#xff0c;我发现所有这些捆绑技术都非常有趣。 在处理一些用例时&#xff0c;我陷入一种情况&#xff0c;即我只需要一个Interceptor即可在发送到Karaf应用程序下部署的任何捆绑包的每个HTTP请求上执行…

通过init-connect + binlog 实现MySQL审计功能

背景&#xff1a; 假设这么一个情况&#xff0c;你是某公司mysql-DBA&#xff0c;某日突然公司数据库中的所有被人为删了。 尽管有数据备份&#xff0c;但是因服务停止而造成的损失上千万&#xff0c;现在公司需要查出那个做删除操作的人。 但是拥有数据库操作权限的人很多&…

AngularJS中ui-router全攻略

首先是angular-ui-router的基本用法。■ 如何引用依赖angular-ui-router angular.module(app,["ui.router"]).config(function($stateProvider){$stateProvider.state(stateName, stateCofig);}) ■ $stateProvider.state(stateName, stateConfig)stateName是string类…