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

http://datanucleus-appengine.googlecode.com/ · Java · 44 lines · 21 code · 5 blank · 18 comment · 0 complexity · ac99e544627f53504e2f81c717779428 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 com.google.appengine.api.datastore.Entity;
  15. import com.google.appengine.datanucleus.Utils;
  16. import com.google.appengine.datanucleus.test.jdo.HasMultiValuePropsJDO;
  17. /**
  18. * @author Max Ross <maxr@google.com>
  19. */
  20. public class JDOMakeTransientTest extends JDOTestCase {
  21. public void testListAccessibleOutsideTxn() {
  22. switchDatasource(PersistenceManagerFactoryName.nontransactional);
  23. Entity e = new Entity(HasMultiValuePropsJDO.class.getSimpleName());
  24. e.setProperty("strList", Utils.newArrayList("a", "b", "c"));
  25. e.setProperty("str", "yar");
  26. ds.put(e);
  27. beginTxn();
  28. HasMultiValuePropsJDO pojo = pm.getObjectById(HasMultiValuePropsJDO.class, e.getKey().getId());
  29. pojo.setStr("yip");
  30. pojo.getStrList();
  31. commitTxn();
  32. assertEquals("yip", pojo.getStr());
  33. assertEquals(3, pojo.getStrList().size());
  34. pm = pmf.getPersistenceManager();
  35. }
  36. }