/tests/com/google/appengine/datanucleus/jpa/JPAOneToManySetTest.java
Java | 220 lines | 187 code | 13 blank | 20 comment | 0 complexity | a827e538cb8b7c644f520bba202350b9 MD5 | raw file
1/********************************************************************** 2Copyright (c) 2009 Google Inc. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15**********************************************************************/ 16package com.google.appengine.datanucleus.jpa; 17 18import com.google.appengine.datanucleus.test.jpa.BidirectionalChildLongPkSetJPA; 19import com.google.appengine.datanucleus.test.jpa.BidirectionalChildSetJPA; 20import com.google.appengine.datanucleus.test.jpa.BidirectionalChildUnencodedStringPkSetJPA; 21import com.google.appengine.datanucleus.test.jpa.HasOneToManyKeyPkSetJPA; 22import com.google.appengine.datanucleus.test.jpa.HasOneToManyLongPkSetJPA; 23import com.google.appengine.datanucleus.test.jpa.HasOneToManySetJPA; 24import com.google.appengine.datanucleus.test.jpa.HasOneToManyUnencodedStringPkSetJPA; 25 26/** 27 * @author Max Ross <maxr@google.com> 28 */ 29public class JPAOneToManySetTest extends JPAOneToManyTestCase { 30 31 public void testInsert_NewParentAndChild() throws Exception { 32 testInsert_NewParentAndChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 33 TXN_START_END); 34 } 35 36 public void testInsert_NewParentAndChild_NoTxn() throws Exception { 37 testInsert_NewParentAndChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 38 NEW_EM_START_END); 39 } 40 41 public void testInsert_ExistingParentNewChild() throws Exception { 42 testInsert_ExistingParentNewChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 43 TXN_START_END); 44 } 45 46 public void testInsert_ExistingParentNewChild_NoTxn() throws Exception { 47 testInsert_ExistingParentNewChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 48 NEW_EM_START_END); 49 } 50 51 public void testUpdate_UpdateChildWithMerge() throws Exception { 52 testUpdate_UpdateChildWithMerge(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 53 TXN_START_END); 54 } 55 public void testUpdate_UpdateChildWithMerge_NoTxn() throws Exception { 56 testUpdate_UpdateChildWithMerge(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 57 NEW_EM_START_END); 58 } 59 60 public void testUpdate_UpdateChild() throws Exception { 61 testUpdate_UpdateChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 62 TXN_START_END); 63 } 64 public void testUpdate_UpdateChild_NoTxn() throws Exception { 65 testUpdate_UpdateChild(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 66 NEW_EM_START_END); 67 } 68 69 public void testUpdate_NullOutChildren() throws Exception { 70 testUpdate_NullOutChildren(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 71 TXN_START_END); 72 } 73 public void testUpdate_NullOutChildren_NoTxn() throws Exception { 74 testUpdate_NullOutChildren(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 75 NEW_EM_START_END); 76 } 77 public void testUpdate_ClearOutChildren() throws Exception { 78 testUpdate_ClearOutChildren(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 79 TXN_START_END); 80 } 81 public void testUpdate_ClearOutChildren_NoTxn() throws Exception { 82 testUpdate_ClearOutChildren(new BidirectionalChildSetJPA(), new HasOneToManySetJPA(), 83 NEW_EM_START_END); 84 } 85 public void testFind() throws Exception { 86 testFind(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, TXN_START_END); 87 } 88 public void testFind_NoTxn() throws Exception { 89 testFind(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, NEW_EM_START_END); 90 } 91 public void testQuery() throws Exception { 92 testQuery(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, TXN_START_END); 93 } 94 public void testQuery_NoTxn() throws Exception { 95 testQuery(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, NEW_EM_START_END); 96 } 97 public void testChildFetchedLazily() throws Exception { 98 testChildFetchedLazily(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class); 99 } 100 public void testDeleteParentDeletesChild() throws Exception { 101 testDeleteParentDeletesChild(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, 102 TXN_START_END); 103 } 104 public void testDeleteParentDeletesChild_NoTxn() throws Exception { 105 testDeleteParentDeletesChild(HasOneToManySetJPA.class, BidirectionalChildSetJPA.class, 106 NEW_EM_START_END); 107 } 108 public void testRemoveObject() throws Exception { 109 testRemoveObject(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(nextNamedKey()), 110 new BidirectionalChildSetJPA(nextNamedKey()), TXN_START_END); 111 } 112 public void testRemoveObject_NoTxn() throws Exception { 113 testRemoveObject(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(nextNamedKey()), 114 new BidirectionalChildSetJPA(nextNamedKey()), NEW_EM_START_END); 115 } 116 public void testChangeParent() throws Exception { 117 testChangeParent(new HasOneToManySetJPA(), new HasOneToManySetJPA(), TXN_START_END); 118 } 119 public void testChangeParent_NoTxn() throws Exception { 120 testChangeParent(new HasOneToManySetJPA(), new HasOneToManySetJPA(), NEW_EM_START_END); 121 } 122 public void testNewParentNewChild_NamedKeyOnChild() throws Exception { 123 testNewParentNewChild_NamedKeyOnChild(new HasOneToManySetJPA(), TXN_START_END); 124 } 125 public void testNewParentNewChild_NamedKeyOnChild_NoTxn() throws Exception { 126 testNewParentNewChild_NamedKeyOnChild(new HasOneToManySetJPA(), NEW_EM_START_END); 127 } 128 public void testAddAlreadyPersistedChildToParent_NoTxnSameEm() { 129 testAddAlreadyPersistedChildToParent_NoTxnSameEm(new HasOneToManySetJPA()); 130 } 131 public void testAddAlreadyPersistedChildToParent_NoTxnDifferentEm() { 132 testAddAlreadyPersistedChildToParent_NoTxnDifferentEm(new HasOneToManySetJPA()); 133 } 134 public void testFetchOfOneToManyParentWithKeyPk() throws Exception { 135 testFetchOfOneToManyParentWithKeyPk(new HasOneToManyKeyPkSetJPA(), TXN_START_END); 136 } 137 public void testFetchOfOneToManyParentWithKeyPk_NoTxn() throws Exception { 138 testFetchOfOneToManyParentWithKeyPk(new HasOneToManyKeyPkSetJPA(), NEW_EM_START_END); 139 } 140 public void testFetchOfOneToManyParentWithLongPk() throws Exception { 141 testFetchOfOneToManyParentWithLongPk(new HasOneToManyLongPkSetJPA(), TXN_START_END); 142 } 143 public void testFetchOfOneToManyParentWithLongPk_NoTxn() throws Exception { 144 testFetchOfOneToManyParentWithLongPk(new HasOneToManyLongPkSetJPA(), NEW_EM_START_END); 145 } 146 public void testFetchOfOneToManyParentWithUnencodedStringPk() throws Exception { 147 testFetchOfOneToManyParentWithUnencodedStringPk(new HasOneToManyUnencodedStringPkSetJPA(), 148 TXN_START_END); 149 } 150 public void testFetchOfOneToManyParentWithUnencodedStringPk_NoTxn() throws Exception { 151 testFetchOfOneToManyParentWithUnencodedStringPk(new HasOneToManyUnencodedStringPkSetJPA(), 152 NEW_EM_START_END); 153 } 154 public void testAddChildToOneToManyParentWithLongPk() throws Exception { 155 testAddChildToOneToManyParentWithLongPk(new HasOneToManyLongPkSetJPA(), new BidirectionalChildLongPkSetJPA(), 156 TXN_START_END); 157 } 158 public void testAddChildToOneToManyParentWithLongPk_NoTxn() throws Exception { 159 testAddChildToOneToManyParentWithLongPk(new HasOneToManyLongPkSetJPA(), new BidirectionalChildLongPkSetJPA(), 160 NEW_EM_START_END); 161 } 162 public void testAddChildToOneToManyParentWithUnencodedStringPk() throws Exception { 163 testAddChildToOneToManyParentWithUnencodedStringPk( 164 new HasOneToManyUnencodedStringPkSetJPA(), new BidirectionalChildUnencodedStringPkSetJPA(), 165 TXN_START_END); 166 } 167 public void testAddChildToOneToManyParentWithUnencodedStringPk_NoTxn() throws Exception { 168 testAddChildToOneToManyParentWithUnencodedStringPk( 169 new HasOneToManyUnencodedStringPkSetJPA(), new BidirectionalChildUnencodedStringPkSetJPA(), 170 NEW_EM_START_END); 171 } 172 public void testAddQueriedParentToBidirChild() throws Exception { 173 testAddQueriedParentToBidirChild(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 174 TXN_START_END); 175 } 176 public void testAddQueriedParentToBidirChild_NoTxn() throws Exception { 177 testAddQueriedParentToBidirChild(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 178 NEW_EM_START_END); 179 } 180 public void testAddFetchedParentToBidirChild() throws Exception { 181 testAddFetchedParentToBidirChild(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 182 TXN_START_END); 183 } 184 public void testAddFetchedParentToBidirChild_NoTxn() throws Exception { 185 testAddFetchedParentToBidirChild(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 186 NEW_EM_START_END); 187 } 188 189 public void testOnlyOneParentPutOnParentAndChildUpdate() throws Throwable { 190 testOnlyOneParentPutOnParentAndChildUpdate(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 191 TXN_START_END); 192 } 193 public void testOnlyOneParentPutOnParentAndChildUpdate_NoTxn() throws Throwable { 194 testOnlyOneParentPutOnParentAndChildUpdate(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 195 NEW_EM_START_END); 196 } 197 198 public void testOnlyOnePutOnChildUpdate() throws Throwable { 199 testOnlyOnePutOnChildUpdate(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 200 TXN_START_END); 201 } 202 public void testOnlyOnePutOnChildUpdate_NoTxn() throws Throwable { 203 testOnlyOnePutOnChildUpdate(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 204 NEW_EM_START_END); 205 } 206 207 public void testOnlyOneParentPutOnChildDelete() throws Throwable { 208 // 1 put to remove the keys 209 int expectedUpdatePuts = 1; 210 testOnlyOneParentPutOnChildDelete(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 211 TXN_START_END, expectedUpdatePuts); 212 } 213 214 public void testOnlyOneParentPutOnChildDelete_NoTxn() throws Throwable { 215 // updates aren't necessarily atomic when non-tx, so get 1 after each collection clear. 216 int expectedUpdatePuts = 5; 217 testOnlyOneParentPutOnChildDelete(new HasOneToManySetJPA(), new BidirectionalChildSetJPA(), 218 NEW_EM_START_END, expectedUpdatePuts); 219 } 220}