試圖建立一個JPA + EJB測試這些指令後: http://ctpjava.blogspot.fi/2009/10/unit-testing-ejbs-and-jpa-with.htmlJPA + EJB測試與嵌入的GlassFish v3的
似乎是我似乎無法得到完全正確一些問題。 首先,我得到這個錯誤(這我能解決,但它仍然需要修復):
SEVERE: EJB6004:Specified application server installation location [C:\Users\<userName>\.m2\repository\org\glassfish\extras\glassfish-embedded-all\domains\domain1] does not exist.
發現這個網站,這給(更正確?)屬性來設置: http://docs.oracle.com/cd/E18930_01/html/821-2424/gjlde.html
而且修改了我的測試設置,以這樣的:
import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
...
@BeforeClass
public static void createContainer() {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(EJBContainer.MODULES, new File("target/classes"));
properties.put("installation.root", "./src/test/glassfish");
properties.put("configuration.file", "./src/test/glassfish/domains/domain1/config/domain.xml");
container = EJBContainer.createEJBContainer(properties);
ctx = container.getContext();
}
而且在pom.xml中我有一個似乎是需要這種如下:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.9.1.0</version>
<scope>test</scope>
</dependency>
<!-- Must be before java-ee -->
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
錯誤指向到用戶目錄,我能得到通過建立必要的東西,有通過這個(並獲得過去的這一點),但是這不是一個合適的地方,因爲一切都必須通過SVN可用。
根據後者的鏈接我想我有正確的屬性設置,但這些似乎被忽略。也許我錯過了一些明顯的東西?