Created
April 26, 2013 07:12
-
-
Save jmkgreen/5465489 to your computer and use it in GitHub Desktop.
simple test of saving and loading 3m records with mongodb and morphia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.jmkgreen.morphia; | |
import com.github.jmkgreen.morphia.annotations.Entity; | |
import com.github.jmkgreen.morphia.annotations.Id; | |
import org.bson.types.ObjectId; | |
import org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import java.util.Date; | |
import java.util.List; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: jamesgreen | |
* Date: 26/04/2013 | |
* Time: 07:17 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class TestThreeMillion extends TestBase { | |
@Entity | |
public static class Person { | |
@Id | |
private ObjectId id; | |
private String fName, lName; | |
private Date birth; | |
} | |
@Before | |
public void before() { | |
map(); | |
} | |
@Test | |
public void testThreeMillionReturned() { | |
for (int i = 0; i < 3000000; i++) { | |
ads.insert(create()); | |
} | |
List<Person> found = ads.find(Person.class).asList(); | |
Assert.assertNotNull(found); | |
Assert.assertEquals(3000000, found.size()); | |
} | |
protected void map() { | |
this.morphia.map(Person.class); | |
} | |
protected Person create() { | |
Person p = new Person(); | |
p.fName = "Foo"; | |
p.lName = "Bar"; | |
p.birth = new Date(); | |
return p; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment