Your JDO config is not related to LocalServiceTestHelper or
LocalDatastoreServiceTestConfig.  If you create your PersistenceManager in
the typical way after you create a LocalServiceTestHelper with a
LocalDatastoreServiceTestConfig and then call helper.setUp() you should be
all set.

Max

2010/4/26 Marcos Vinícius Soares <[email protected]>

> I just wanted an instance of PersistenceManager to use in unit tests and I
> was able to setup it up. I'm not sure how to get it through
> LocalDatastoreServiceTestConfig. Anyway, it is working now as per the code I
> sent earlier.
>
> Thanks
>
>>
> On Mon, Apr 26, 2010 at 1:33 PM, Max Ross (Google) <
> [email protected] <maxr%[email protected]>> wrote:
>
>> What aspect of the local datastore are you trying to configure that isn't
>> covered by LocalDatastoreServiceTestConfig()? I don't think you should have
>> to configure the ApiProxyLocal or the LocalServerEnvironment directly.
>>
>>
>> On Sun, Apr 25, 2010 at 3:40 PM, mvsoares <[email protected]> wrote:
>>
>>> Indeed, ApiProxyLocalImpl is not public anymore in newer versions of
>>> google app engine.
>>>
>>> Find below one solution to the problem:
>>>
>>> import java.io.File;
>>> import java.util.Properties;
>>>
>>> import javax.jdo.JDOHelper;
>>> import javax.jdo.PersistenceManager;
>>> import javax.jdo.PersistenceManagerFactory;
>>>
>>> import junit.framework.TestCase;
>>>
>>> import com.google.appengine.api.datastore.dev.LocalDatastoreService;
>>> import com.google.appengine.tools.development.ApiProxyLocal;
>>> import com.google.appengine.tools.development.ApiProxyLocalFactory;
>>> import com.google.appengine.tools.development.LocalServerEnvironment;
>>> import
>>> com.google.appengine.tools.development.testing.LocalServiceTestHelper;
>>> import
>>> com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig;
>>> import com.google.apphosting.api.ApiProxy;
>>>
>>> public class BaseTest extends TestCase {
>>>
>>>        private final LocalServiceTestHelper helper =
>>>        new LocalServiceTestHelper(new LocalTaskQueueTestConfig());
>>>
>>>        protected PersistenceManagerFactory pmf;
>>>        protected PersistenceManager pm;
>>>
>>>        @Override
>>>    public void tearDown() {
>>>        helper.tearDown();
>>>    }
>>>
>>>        @Override
>>>        public void setUp() throws Exception {
>>>                super.setUp();
>>>                helper.setUp();
>>>                Properties newProperties = new Properties();
>>>
>>>  newProperties.put("javax.jdo.PersistenceManagerFactoryClass",
>>>                                "org.datanucleus.store.appengine.jdo."
>>>                                                +
>>> "DatastoreJDOPersistenceManagerFactory");
>>>                newProperties.put("javax.jdo.option.ConnectionURL",
>>> "appengine");
>>>                newProperties.put("javax.jdo.option.NontransactionalRead",
>>> "true");
>>>
>>>  newProperties.put("javax.jdo.option.NontransactionalWrite", "true");
>>>                newProperties.put("javax.jdo.option.RetainValues",
>>> "true");
>>>
>>>  newProperties.put("datanucleus.appengine.autoCreateDatastoreTxns",
>>>                                "true");
>>>
>>>  newProperties.put("datanucleus.appengine.autoCreateDatastoreTxns",
>>>                                "true");
>>>                pmf =
>>> JDOHelper.getPersistenceManagerFactory(newProperties);
>>>                pm = pmf.getPersistenceManager();
>>>                ApiProxyLocalFactory factory = new ApiProxyLocalFactory();
>>>                ApiProxyLocal proxy = factory.create(new
>>> LocalServerEnvironment() {
>>>                                        public void waitForServerToStart()
>>>                                                        throws
>>> InterruptedException {
>>>                                        }
>>>                                        public int getPort() {
>>>                                                return 0;
>>>                                        }
>>>                                        public File getAppDir() {
>>>                                                return new File(".");
>>>                                        }
>>>                                        public String getAddress() {
>>>                                                return null;
>>>                                        }
>>>                                });
>>>                proxy.setProperty(
>>> //
>>>  LocalDatastoreService.BACKING_STORE_PROPERTY,
>>>                                LocalDatastoreService.NO_STORAGE_PROPERTY,
>>>                                Boolean.TRUE.toString());
>>>                ApiProxy.setDelegate(proxy);
>>>         }
>>>
>>> }
>>>
>>> --
>>> 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
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-appengine-java%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>>
>>  --
>> 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
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-appengine-java%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> 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
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to