loading ...
loading...

2006-09-08 | 对EJB3进行单元测试需要注意的问题

分享
标签: EJB3  单元测试 

曾经想尝试着写一下,失败,今天在jboss的EJB3论坛上有人问到同样的问题,解决方案如下:

Create a jndi.properties file, place it in the classpath (usually in the base directory of the jar file), with these contents:

Code:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces	



Of course, replace locahost with your host name if you are attempting remote access.

或者采用HashMap:

Hashtable<String, String> props= new Hashtable<String, String>(); 
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost:1099" );
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces" );
Context ctx = new InitialContext( props );
只不过对于依赖注入还没有更好的方案,等jboss的ejb3最新实现出来再看看	

分享 分享 |  评论 (0) |  阅读 (?)  |  固定链接 |  类别 (Java) |  发表于 10:08
搜狐博客温馨提示:警惕博客留言诈骗, 搜狐博客管理员的正确地址为http://admin.blog.sohu.com, 其他都是冒牌。搜狐博客官方不会要求参加活动的各位博友缴纳任何的手续费用。请勿轻信留言、评论中的中奖信息,更不要拨打陌生电话及向陌生帐户汇款,谨防受骗!识别更多网络骗术,请 点击查看详情
您还未登录,只能匿名发表评论。或者您可以 登录 后发表。
 
  一个单亲妈妈的心愿:治好7岁儿子的白血病
表  情:
加载中...
回复通知: 同时用小纸条通知对方该回复