Lusk116
Lusk116

Reputation: 1030

Can't test with Ejb3Unit

I downloaded the sample project from Ejb3Unit, imported it into eclipse and run it as JUnit Test -> no errors.

BUT when I try to test my own entity class I always get an OutOfMemoryError!

@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);
}   
}

java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572) at java.lang.StringBuilder.append(StringBuilder.java:203) at com.bm.datagen.utils.BaseRandomDataGenerator.getValueString(BaseRandomDataGenerator.java:109) at com.bm.datagen.random.RandomStringGenerator.getValue(RandomStringGenerator.java:45) at com.bm.datagen.random.RandomStringGenerator.getValue(RandomStringGenerator.java:20) at com.bm.datagen.DataGenerator.getNextValue(DataGenerator.java:127) at com.bm.creators.EntityInstanceCreator.createInstance(EntityInstanceCreator.java:91) at com.bm.creators.EntityBeanCreator.createBeanInstance(EntityBeanCreator.java:113) at com.bm.testsuite.BaseEntityFixture.testWrite(BaseEntityFixture.java:182) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:154) at org.jmock.core.VerifyingTestCase.runBare(Unknown Source) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

do I have to do some changes in any properties file or is the problem anywhere else?

Upvotes: 1

Views: 331

Answers (1)

Allen Parslow
Allen Parslow

Reputation: 209

Increasing eclipse's -Xmx configuration value (e.g. in eclipse.ini) should help.

For more information, see:

http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F

The issue could be related to size of random strings ejb3unit uses to automatically test your entity bean, try changing @Column(length = ...).

The default value for length is 255, which isn't a whole lot.

Upvotes: 2

Related Questions