java ee6.0api_针对Java EE 6 API进行测试

我写了一个除了JAX-RS和包括Java EE 6 API作为Maven依赖。

javax

javaee-api

6.0

provided

然后我有一个小测试用例:

@Test

public void testIsWriteable() {

class SpecialViewable extends Viewable {

public SpecialViewable() {

super("test");

}

}

FreeMarkerViewProcessor processor = new FreeMarkerViewProcessor(null);

assertTrue(processor.isWriteable(SpecialViewable.class, null, null,

MediaType.WILDCARD_TYPE));

}

但我得到一个错误:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ws/rs/core/MediaType

...

如果我将Jersey包括为JAX-RS实现而不是Java EE API,一切都很好。

感谢BalusC的提示我知道我猜到了:Java EE 6只是一个没有方法主体的API:

From the java.net blog

You can compile you code with this

jar, but of course you cannnot run

your application with it since it

contains only the Java EE 5 APIs and

does not contain any method bodies. If

you try to run, you would get this

exception:

Exception in thread “main”

java.lang.ClassFormatError: Absent

Code attribute in method that is not

native or abstract in class file

javax/mail/Session

In order to execute a Java EE 5

application, you’ll still need a Java

EE 5 container, like for example the

GlassFish application server.

我试图添加Jersy与测试范围,但它没有工作。

javax

javaee-api

6.0

provided

com.sun.jersey

jersey-server

${jersey-version}

test

如何测试仅依赖于官方Java EE API的软件?

提供程序(Jersey)需要放在pom.xml中的API(javeee-api)之前。

com.sun.jersey

jersey-server

${jersey-version}

test

javax

javaee-api

6.0

provided

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值