[appengine-java] Testing with JDO

2010-10-22 Thread Daniel Blasco
Hi, I'm using GAE 1.3.5 and JUnit 4.

I want to test a GAE App which uses JDO. Firstly I read the "HowTo" in
the GAE official site:
http://code.google.com/appengine/docs/java/tools/localunittesting.html
But there is no clues.

In this page http://blog.appenginefan.com/2009/05/jdo-and-unit-tests.html
I found some instructions but, obselete I guess.

Some instructions please?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Testing with JDO

2010-10-25 Thread Daniel Blasco
Thank you Didier.

This is my BaseTest.java and works perfect now:

package ...;

import static org.junit.Assert.assertEquals;

import java.util.Date;
import java.util.List;

import javax.jdo.PersistenceManager;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.declaraciones.PMF;
import com.declaraciones.shared.Declaracion.EstadoDeclaracion;
import com.declaraciones.shared.Movimiento;
import
com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import
com.google.appengine.tools.development.testing.LocalServiceTestHelper;

public class BaseTest {
private final LocalServiceTestHelper dsHelper = new
LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
private final PersistenceManager pm = PMF.getPersistenceManager();

@Before
public void setUp() {
System.out.println("Entering @Before for BaseTest");
dsHelper.setUp();
}

@After
public void tearDown() {
System.out.println("Entering @After for BaseTest");
this.dsHelper.tearDown();
}

// run this test twice to prove we're not leaking any state across
tests
@SuppressWarnings("unchecked")
private void doTest() {
String query = "select from " + Movimiento.class.getName();
assertEquals(0, ((List)
pm.newQuery(query).execute()).size());
Movimiento m1 = new Movimiento();
pm.makePersistent(m1);
assertEquals(1, ((List)
pm.newQuery(query).execute()).size());
Movimiento m2 = new Movimiento();
pm.makePersistent(m2);
assertEquals(2, ((List)
pm.newQuery(query).execute()).size());
}

@Test
public void testInsert1() {
doTest();
}

@Test
public void testInsert2() {
doTest();
}

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.