Java Can';使用ejb3单元进行t测试
我从Ejb3Unit下载了示例项目,将其导入eclipse,并以JUnit Test->no errors的形式运行它 但是当我尝试测试我自己的实体类时,我总是得到一个OutOfMemoryErrorJava Can';使用ejb3单元进行t测试,java,testing,Java,Testing,我从Ejb3Unit下载了示例项目,将其导入eclipse,并以JUnit Test->no errors的形式运行它 但是当我尝试测试我自己的实体类时,我总是得到一个OutOfMemoryError @Entity @Table(name = "AUTOR") public class Author implements Serializable { private int id; private String name; private Date created; @Id @G
@Entity
@Table(name = "AUTOR")
public class Author implements Serializable {
private int id;
private String name;
private Date created;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "creation_timestamp", nullable = false)
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}
public class AuthorTest extends BaseEntityFixture<Author> {
public AuthorTest() {
super(Author.class);
}
}
@实体
@表(name=“AUTOR”)
公共类Author实现了可序列化{
私有int-id;
私有字符串名称;
创建私人日期;
@身份证
@生成值
公共int getId(){
返回id;
}
公共无效集合id(内部id){
this.id=id;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
@列(name=“creation\u timestamp”,nullable=false)
公共日期getCreated(){
创建回报;
}
创建公共作废集(创建日期){
this.created=created;
}
}
公共类AuthorTest扩展BaseEntityFixture{
公共作者(){
超级(作者类);
}
}
java.lang.OutOfMemoryError:java堆空间
位于java.util.Arrays.copyOf(Arrays.java:2882)
位于java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
位于java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572)
在java.lang.StringBuilder.append处(StringBuilder.java:203)
位于com.bm.datagen.utils.BaseRandomDataGenerator.getValueString(BaseRandomDataGenerator.java:109)
在com.bm.datagen.random.RandomStringGenerator.getValue(RandomStringGenerator.java:45)上
在com.bm.datagen.random.RandomStringGenerator.getValue(RandomStringGenerator.java:20)上
位于com.bm.datagen.DataGenerator.getNextValue(DataGenerator.java:127)
位于com.bm.creators.EntityInstanceCreator.createInstance(EntityInstanceCreator.java:91)
位于com.bm.creators.EntityBeanCreator.createBeanInstance(EntityBeanCreator.java:113)
在com.bm.testsuite.BaseEntityFixture.testWrite(BaseEntityFixture.java:182)上
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于junit.framework.TestCase.runTest(TestCase.java:154)
位于org.jmock.core.VerifyingTestCase.runBare(未知来源)
位于junit.framework.TestResult$1.protect(TestResult.java:106)
位于junit.framework.TestResult.runProtected(TestResult.java:124)
运行(TestResult.java:109)
运行(TestCase.java:118)
位于junit.framework.TestSuite.runTest(TestSuite.java:208)
运行(TestSuite.java:203)
位于org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
位于org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
我是否必须在任何属性文件中做一些更改,或者问题出在其他地方?增加eclipse的
-Xmx
配置值(例如在eclipse.ini
中)应该会有所帮助
有关详细信息,请参阅:
问题可能与ejb3unit用于自动测试实体bean的随机字符串的大小有关,请尝试更改@Column(length=…)
长度的默认值是255,这不是一个整批