/tests/com/google/appengine/datanucleus/jdo/JDOStorageVersionTest.java
Java | 60 lines | 34 code | 7 blank | 19 comment | 0 complexity | 3391a13effc616fa7e1a5fbb75128834 MD5 | raw file
1/* 2 * Copyright (C) 2010 Google Inc 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.google.appengine.datanucleus.jdo; 17 18import java.util.Map; 19 20import javax.jdo.JDOFatalUserException; 21import javax.jdo.JDOHelper; 22 23import com.google.appengine.datanucleus.DatastoreManager; 24import com.google.appengine.datanucleus.StorageVersion; 25import com.google.appengine.datanucleus.Utils; 26 27/** 28 * @author Max Ross <max.ross@gmail.com> 29 */ 30public class JDOStorageVersionTest extends JDOTestCase { 31 32 public void testDefaultStorageVersion() { 33 DatastoreManager storeMgr = (DatastoreManager) getExecutionContext().getStoreManager(); 34 assertEquals(StorageVersion.READ_OWNED_CHILD_KEYS_FROM_PARENTS, storeMgr.getStorageVersion()); 35 } 36 37 public void testNonDefaultStorageVersion() { 38 pm.close(); 39 pmf.close(); 40 Map<String, String> props = Utils.newHashMap(); 41 props.put(StorageVersion.STORAGE_VERSION_PROPERTY, StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN.name()); 42 pmf = JDOHelper.getPersistenceManagerFactory(props, getPersistenceManagerFactoryName().name()); 43 pm = pmf.getPersistenceManager(); 44 DatastoreManager storeMgr = (DatastoreManager) getExecutionContext().getStoreManager(); 45 assertEquals(StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN, storeMgr.getStorageVersion()); 46 } 47 48 public void testUnknownStorageVersion() { 49 pm.close(); 50 pmf.close(); 51 Map<String, String> props = Utils.newHashMap(); 52 props.put(StorageVersion.STORAGE_VERSION_PROPERTY, "does not exist"); 53 try { 54 pmf = JDOHelper.getPersistenceManagerFactory(props, getPersistenceManagerFactoryName().name()); 55 } catch (JDOFatalUserException e) { 56 // good 57 assertTrue(e.getCause().getMessage().startsWith("'does not exist'")); 58 } 59 } 60}