Skip to content

Instantly share code, notes, and snippets.

@jmkgreen
Created April 26, 2013 07:12
Show Gist options
  • Save jmkgreen/5465489 to your computer and use it in GitHub Desktop.
Save jmkgreen/5465489 to your computer and use it in GitHub Desktop.
simple test of saving and loading 3m records with mongodb and morphia
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