/tests/com/google/appengine/datanucleus/jdo/JDODataSourceConfigTest.java

http://datanucleus-appengine.googlecode.com/ · Java · 54 lines · 26 code · 10 blank · 18 comment · 0 complexity · e096dc8447bd4b849c0329f38e09edfc MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus.jdo;
  14. import junit.framework.TestCase;
  15. import org.datanucleus.api.jdo.JDOPersistenceManager;
  16. import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
  17. import com.google.appengine.datanucleus.DatastoreManager;
  18. import javax.jdo.JDOHelper;
  19. /**
  20. * @author Max Ross <maxr@google.com>
  21. */
  22. public class JDODataSourceConfigTest extends TestCase {
  23. public void testTransactionalPMF() {
  24. JDOPersistenceManagerFactory pmf =
  25. (JDOPersistenceManagerFactory) JDOHelper.getPersistenceManagerFactory("transactional");
  26. DatastoreManager storeMgr = (DatastoreManager) pmf.getNucleusContext().getStoreManager();
  27. JDOPersistenceManager pm = (JDOPersistenceManager) pmf.getPersistenceManager();
  28. assertTrue(storeMgr.connectionFactoryIsAutoCreateTransaction());
  29. pm.close();
  30. pmf.close();
  31. }
  32. public void testNonTransactionalPMF() {
  33. JDOPersistenceManagerFactory pmf =
  34. (JDOPersistenceManagerFactory) JDOHelper.getPersistenceManagerFactory("nontransactional");
  35. DatastoreManager storeMgr = (DatastoreManager) pmf.getNucleusContext().getStoreManager();
  36. JDOPersistenceManager pm = (JDOPersistenceManager) pmf.getPersistenceManager();
  37. assertFalse(storeMgr.connectionFactoryIsAutoCreateTransaction());
  38. pm.close();
  39. pmf.close();
  40. }
  41. }