(no commit message)
[utils] / support / general / src / test / java / org / wamblee / persistence / PersistentFactoryTest.java
index 9f254c694f53cf6f0b6c55b3e6d904a25a2eceac..82f0bebaccba6633af692508d831e2c3197dcc0e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2005-2010 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.wamblee.persistence;
 
 import static junit.framework.Assert.*;
@@ -6,10 +21,8 @@ import javax.persistence.Id;
 import javax.persistence.Version;
 
 import org.junit.Test;
-import org.wamblee.persistence.PersistentFactory.Accessor;
 import org.wamblee.persistence.PersistentFactory.EntityAccessor;
-import org.wamblee.persistence.PersistentFactory.FieldAccessor;
-import org.wamblee.persistence.PersistentFactory.PropertyAccessor;
+import org.wamblee.persistence.PersistentFactory.EntityObjectAccessor;
 
 public class PersistentFactoryTest {
 
@@ -251,4 +264,16 @@ public class PersistentFactoryTest {
         
         assertSame(accessor, accessor2);
     }
+    
+    // EntityObjectAccessor test for undefined pk and/or version. 
+    @Test
+    public void testEntityObjectAccessorRobustness() { 
+        EntityObjectAccessor accessor =  new EntityObjectAccessor("hello world", 
+            new EntityAccessor(null, null));
+        assertNull(accessor.getPrimaryKey());
+        assertNull(accessor.getPersistedVersion());
+        accessor.setPrimaryKey("bla");
+        accessor.setPersistedVersion(100);
+        
+    }
 }