나는 다음과 같은 방법으로 내장 된 글래스 피쉬를 사용했습니다 :글래스 피시 내장 +를 받는다는 cobertura 플러그인
이public static void createContainer() throws IOException {
File target = new File("target/classes");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(EJBContainer.MODULES, target);
properties.put("org.glassfish.ejb.embedded.glassfish.installation.root",
"/opt/glassfish3/glassfish");
container = EJBContainer.createEJBContainer(properties);
context = container.getContext();
}
@AfterSuite(alwaysRun = true)
public static void closeContainer() throws NamingException {
// close container
}
// I use this method to lookup
public static <T> T lookupBy(Class<T> type) {
try {
return (T) context.lookup("java:global/classes/" + type.getSimpleName());
} catch (NamingException ex) {
throw new RuntimeException(ex);
}
}
문제는 내장 된 글래스 피쉬는 "목표/수업"의 클래스를 사용하여 받는다는 cobertura이 사용한다는 것입니다 "목표/생성 -classes/cobertura "라고합니다. 그런 다음 테스트를 처음 실행하면 ok이지만 두 번째로 cobertura가 실행될 때 java.lang.RuntimeException : javax.naming.NamingException이 발생합니다 (cobertura가 "target/generated-classes/cobertura" "글래스 피시는"목표/클래스 "에서 작업 중).
이 문제를 해결할 수있는 아이디어가 있습니까 ???