You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/13 08:30:03 UTC
[14/58] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
new file mode 100644
index 0000000..6002b58
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetChildEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.ParentEntity;
+import org.apache.isis.core.tck.dom.refs.ParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_bidirWithSetParent {
+
+ private BidirWithSetParentEntityRepository repo = new BidirWithSetParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHSETCHILDENTITY"))
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHSETPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<BidirWithSetParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistTwoChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ BidirWithSetParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newChild("Child 1 of Parent 1");
+ retrievedEntity.newChild("Child 2 of Parent 1");
+ retrievedEntity.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<BidirWithSetChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(3));
+ iswf.commitTran();
+ }
+
+ @Ignore("Not currently working, is an update")
+ @Test
+ public void updateBidirectional() throws Exception {
+ iswf.beginTran();
+ BidirWithSetParentEntity parent1 = repo.newEntity();
+ parent1.setName("Parent 1");
+ BidirWithSetParentEntity parent2 = repo.newEntity();
+ parent2.setName("Parent 2");
+
+ parent1.newChild("Child 1 of Parent 1");
+ parent1.newChild("Child 2 of Parent 1");
+ parent1.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ Set<BidirWithSetChildEntity> children = parent1.getChildren();
+ assertThat(children.size(), is(3));
+ BidirWithSetChildEntity child1 = parent1.getChildren().iterator().next();
+ child1.moveTo(parent2);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ children = parent1.getChildren();
+ assertThat(children.size(), is(2));
+
+ children = parent2.getChildren();
+ assertThat(children.size(), is(1));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java
new file mode 100644
index 0000000..bb1b8c6
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.PolyClassChildEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_polyclass {
+
+ private PolyClassParentEntityRepository repo = new PolyClassParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("POLYCLASSSUBTYPE1ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYCLASSCHILDENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYCLASSPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<PolyClassParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistSixDifferentChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ PolyClassParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newSubtype1("Child 1 of Parent 1", 123);
+ retrievedEntity.newSubtype1("Child 2 of Parent 1", 456);
+ retrievedEntity.newSubtype2("Child 3 of Parent 1", "abc");
+ retrievedEntity.newSubtype2("Child 4 of Parent 1", "def");
+ retrievedEntity.newSubtype3("Child 5 of Parent 1", BigDecimal.ONE);
+ retrievedEntity.newSubtype3("Child 6 of Parent 1", BigDecimal.TEN);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<PolyClassChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(6));
+ iswf.commitTran();
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
new file mode 100644
index 0000000..40f65e9
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.PolyClassChildEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.PolyInterface;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_polyinter {
+
+ private PolyInterfaceParentEntityRepository repo = new PolyInterfaceParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEPARENTENTITY_CHILDREN"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACESUBTYPE1ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACESUBTYPE2ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACESUBTYPE3ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<PolyInterfaceParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistSixDifferentChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ PolyInterfaceParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newSubtype1("Child 1 of Parent 1", 123);
+ retrievedEntity.newSubtype1("Child 2 of Parent 1", 456);
+ retrievedEntity.newSubtype2("Child 3 of Parent 1", "abc");
+ retrievedEntity.newSubtype2("Child 4 of Parent 1", "def");
+ retrievedEntity.newSubtype3("Child 5 of Parent 1", BigDecimal.ONE);
+ retrievedEntity.newSubtype3("Child 6 of Parent 1", BigDecimal.TEN);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<PolyInterface> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(6));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java
new file mode 100644
index 0000000..33c55db
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.PolyClassChildEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyClassParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.PolyInterface;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceIdentityStrategy;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceIdentityStrategyParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceIdentityStrategyParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_polyinterIdentityStrategy {
+
+ private PolyInterfaceIdentityStrategyParentEntityRepository repo = new PolyInterfaceIdentityStrategyParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEIDENTITYSTRATEGYPARENTENTITY_CHILDREN"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEIDENTITYSTRATEGYSUBTYPE1ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEIDENTITYSTRATEGYSUBTYPE2ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEIDENTITYSTRATEGYSUBTYPE3ENTITY"))
+ .with(Utils.listenerToDeleteFrom("POLYINTERFACEIDENTITYSTRATEGYPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<PolyInterfaceIdentityStrategyParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistSixDifferentChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ PolyInterfaceIdentityStrategyParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newSubtype1("Child 1 of Parent 1", 123);
+ retrievedEntity.newSubtype1("Child 2 of Parent 1", 456);
+ retrievedEntity.newSubtype2("Child 3 of Parent 1", "abc");
+ retrievedEntity.newSubtype2("Child 4 of Parent 1", "def");
+ retrievedEntity.newSubtype3("Child 5 of Parent 1", BigDecimal.ONE);
+ retrievedEntity.newSubtype3("Child 6 of Parent 1", BigDecimal.TEN);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<PolyInterfaceIdentityStrategy> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(6));
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
new file mode 100644
index 0000000..d2ef5d8
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Persistence_persist_referencing {
+
+ private UnidirReferencingEntityRepository referencingRepo = new UnidirReferencingEntityRepository();
+ private UnidirReferencedEntityRepository referencedRepo = new UnidirReferencedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCINGENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCEDENTITY"))
+ .withServices(referencingRepo, referencedRepo)
+ .build();
+
+ @Test
+ public void persist() throws Exception {
+
+ iswf.beginTran();
+ referencedRepo.newEntity().setName("Referenced 1");
+ referencedRepo.newEntity().setName("Referenced 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.list().get(0);
+ UnidirReferencedEntity referencedEntity2 = referencedRepo.list().get(1);
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+
+ UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
+ referencingEntity2.setName("Referencing 2");
+ referencingEntity2.setReferenced(referencedEntity1);
+
+ UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
+ referencingEntity3.setName("Referencing 3");
+ referencingEntity3.setReferenced(referencedEntity2);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirReferencingEntity> list = referencingRepo.list();
+ referencingEntity1 = list.get(0);
+ referencingEntity2 = list.get(1);
+ referencingEntity3 = list.get(2);
+
+ assertThat(referencingEntity1.getReferenced(), is(not(nullValue())));
+ assertThat(referencingEntity2.getReferenced(), is(not(nullValue())));
+ assertThat(referencingEntity3.getReferenced(), is(not(nullValue())));
+
+ assertThat(referencingEntity1.getReferenced(), is(referencingEntity1.getReferenced()));
+ assertThat(referencingEntity1.getReferenced(), is(not(referencingEntity3.getReferenced())));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistAGraphOfObjects() throws Exception {
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.newEntity();
+ referencedEntity1.setName("Referenced 1");
+ UnidirReferencedEntity referencedEntity2 = referencedRepo.newEntity();
+ referencedEntity2.setName("Referenced 2");
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
+ referencingEntity2.setName("Referencing 2");
+ referencingEntity2.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
+ referencingEntity3.setName("Referencing 3");
+ referencingEntity3.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirReferencingEntity> list = referencingRepo.list();
+ referencingEntity1 = list.get(0);
+ referencingEntity2 = list.get(1);
+ referencingEntity3 = list.get(2);
+
+ assertThat(referencingEntity1.getReferenced(), is(not(nullValue())));
+ assertThat(referencingEntity2.getReferenced(), is(not(nullValue())));
+ assertThat(referencingEntity3.getReferenced(), is(not(nullValue())));
+
+ assertThat(referencingEntity1.getReferenced(), is(referencingEntity1.getReferenced()));
+ assertThat(referencingEntity1.getReferenced(), is(not(referencingEntity3.getReferenced())));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
new file mode 100644
index 0000000..4dd3912
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetChildEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.ParentEntity;
+import org.apache.isis.core.tck.dom.refs.ParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirFkChildEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirFkParentEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirFkParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_unidir {
+
+ private UnidirFkParentEntityRepository repo = new UnidirFkParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRFKCHILDENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRFKPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirFkParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistTwoChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ UnidirFkParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newChild("Child 1 of Parent 1");
+ retrievedEntity.newChild("Child 2 of Parent 1");
+ retrievedEntity.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<UnidirFkChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(3));
+ iswf.commitTran();
+ }
+
+ @Ignore("Not currently working, is an update")
+ @Test
+ public void updateBidirectional() throws Exception {
+ iswf.beginTran();
+ UnidirFkParentEntity parent1 = repo.newEntity();
+ parent1.setName("Parent 1");
+ UnidirFkParentEntity parent2 = repo.newEntity();
+ parent2.setName("Parent 2");
+
+ parent1.newChild("Child 1 of Parent 1");
+ parent1.newChild("Child 2 of Parent 1");
+ parent1.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ Set<UnidirFkChildEntity> children = parent1.getChildren();
+ assertThat(children.size(), is(3));
+ UnidirFkChildEntity child1 = parent1.getChildren().iterator().next();
+ parent1.removeChild(child1);
+ parent2.addChild(child1);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ children = parent1.getChildren();
+ assertThat(children.size(), is(2));
+
+ children = parent2.getChildren();
+ assertThat(children.size(), is(1));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
new file mode 100644
index 0000000..51e9099
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetChildEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithSetParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.ParentEntity;
+import org.apache.isis.core.tck.dom.refs.ParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirFkChildEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirFkParentEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirFkParentEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirJoinChildEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirJoinParentEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirJoinParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_unidirJoin {
+
+ private UnidirJoinParentEntityRepository repo = new UnidirJoinParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRJOINCHILDENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRJOINPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirJoinParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistTwoChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ UnidirJoinParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newChild("Child 1 of Parent 1");
+ retrievedEntity.newChild("Child 2 of Parent 1");
+ retrievedEntity.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ Set<UnidirJoinChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(3));
+ iswf.commitTran();
+ }
+
+ @Ignore("Not currently working, is an update")
+ @Test
+ public void updateBidirectional() throws Exception {
+ iswf.beginTran();
+ UnidirJoinParentEntity parent1 = repo.newEntity();
+ parent1.setName("Parent 1");
+ UnidirJoinParentEntity parent2 = repo.newEntity();
+ parent2.setName("Parent 2");
+
+ parent1.newChild("Child 1 of Parent 1");
+ parent1.newChild("Child 2 of Parent 1");
+ parent1.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ Set<UnidirJoinChildEntity> children = parent1.getChildren();
+ assertThat(children.size(), is(3));
+ UnidirJoinChildEntity child1 = parent1.getChildren().iterator().next();
+ parent1.removeChild(child1);
+ parent2.addChild(child1);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ parent1 = repo.list().get(0);
+ parent2 = repo.list().get(0);
+ children = parent1.getChildren();
+ assertThat(children.size(), is(2));
+
+ children = parent2.getChildren();
+ assertThat(children.size(), is(1));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java
new file mode 100644
index 0000000..ff469a3
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Persistence_update_using_domMethodCalls {
+
+ private UnidirReferencingEntityRepository referencingRepo = new UnidirReferencingEntityRepository();
+ private UnidirReferencedEntityRepository referencedRepo = new UnidirReferencedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCINGENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCEDENTITY"))
+ .withServices(referencingRepo, referencedRepo)
+ .build();
+
+
+ @Test
+ public void persist_then_update() throws Exception {
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.newEntity();
+ referencedEntity1.setName("Referenced 1");
+ UnidirReferencedEntity referencedEntity2 = referencedRepo.newEntity();
+ referencedEntity2.setName("Referenced 2");
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
+ referencingEntity2.setName("Referencing 2");
+ referencingEntity2.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
+ referencingEntity3.setName("Referencing 3");
+ referencingEntity3.setReferenced(referencedEntity2);
+
+ iswf.commitTran();
+
+ // when ...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirReferencingEntity> referencingList = referencingRepo.list();
+ referencingEntity1 = referencingList.get(0);
+ referencingEntity2 = referencingList.get(1);
+ referencingEntity3 = referencingList.get(2);
+
+ List<UnidirReferencedEntity> referencedList = referencedRepo.list();
+ referencedEntity1 = referencedList.get(0);
+ referencedEntity2 = referencedList.get(1);
+
+ assertThat(referencingEntity2.getReferenced(), is(referencedEntity1));
+
+ // ...switch to refer to other
+ referencingEntity2.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ // then...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ referencingList = referencingRepo.list();
+ referencingEntity1 = referencingList.get(0);
+ referencingEntity2 = referencingList.get(1);
+ referencingEntity3 = referencingList.get(2);
+
+ referencedList = referencedRepo.list();
+ referencedEntity1 = referencedList.get(0);
+ referencedEntity2 = referencedList.get(1);
+
+ // ...is switched
+ assertThat(referencingEntity2.getReferenced(), is(referencedEntity2));
+ iswf.commitTran();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java
new file mode 100644
index 0000000..7a2fad1
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_allInstances {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void whenNoInstances() {
+ iswf.beginTran();
+ final List<PrimitiveValuedEntity> list = repo.list();
+ assertThat(list.size(), is(0));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persist_dontBounce_listAll() throws Exception {
+
+ iswf.beginTran();
+ PrimitiveValuedEntity entity = repo.newEntity();
+ entity.setId(1);
+ entity = repo.newEntity();
+ entity.setId(2);
+ iswf.commitTran();
+
+ // don't bounce
+ iswf.beginTran();
+ List<PrimitiveValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persist_bounce_listAll() throws Exception {
+
+ iswf.beginTran();
+ repo.newEntity().setId(1);
+ repo.newEntity().setId(2);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<PrimitiveValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java
new file mode 100644
index 0000000..4512592
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_bounceSystem {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void bounceSystem() throws Exception {
+ iswf.bounceSystem();
+ iswf.bounceSystem();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java
new file mode 100644
index 0000000..cea02d5
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_findInstance {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void whenNoInstances() {
+ iswf.beginTran();
+ final PrimitiveValuedEntity entity = repo.findById(1);
+ assertThat(entity, is(nullValue()));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenAnInstance() throws Exception {
+
+ iswf.beginTran();
+ repo.newEntity().setId(1);
+ iswf.commitTran();
+
+ iswf.beginTran();
+ final PrimitiveValuedEntity entity = repo.findById(1);
+ assertThat(entity, is(not(nullValue())));
+ assertThat(entity.getId(), is(1));
+ iswf.commitTran();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_all.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_all.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_all.java
new file mode 100644
index 0000000..b3c05f1
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_all.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_namedQuery_all {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Before
+ public void setUp() throws Exception {
+
+ iswf.beginTran();
+
+ PrimitiveValuedEntity entity = repo.newEntity();
+ entity.setId(1);
+ entity.setIntProperty(111);
+
+ entity = repo.newEntity();
+ entity.setId(2);
+ entity.setIntProperty(222);
+
+ entity = repo.newEntity();
+ entity.setId(3);
+ entity.setIntProperty(333);
+
+ entity = repo.newEntity();
+ entity.setId(4);
+ entity.setIntProperty(111);
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenOne() throws Exception {
+
+ iswf.beginTran();
+
+ List<PrimitiveValuedEntity> entities = repo.findByNamedQueryAll("prmv_findByIntProperty", ImmutableMap.of("i", (Object)222));
+ assertThat(entities, is(not(nullValue())));
+ assertThat(entities.size(), is(1));
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenTwo() throws Exception {
+
+ iswf.beginTran();
+
+ List<PrimitiveValuedEntity> entities = repo.findByNamedQueryAll("prmv_findByIntProperty", ImmutableMap.of("i", (Object)111));
+ assertThat(entities, is(not(nullValue())));
+ assertThat(entities.size(), is(2));
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenNone() throws Exception {
+
+ iswf.beginTran();
+
+ List<PrimitiveValuedEntity> entities = repo.findByNamedQueryAll("prmv_findByIntProperty", ImmutableMap.of("i", (Object)999));
+ assertThat(entities, is(not(nullValue())));
+ assertThat(entities.size(), is(0));
+
+ iswf.commitTran();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_firstOnly.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_firstOnly.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_firstOnly.java
new file mode 100644
index 0000000..15fdcd7
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_namedQuery_firstOnly.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_namedQuery_firstOnly {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Before
+ public void setUp() throws Exception {
+
+ iswf.beginTran();
+
+ PrimitiveValuedEntity entity = repo.newEntity();
+ entity.setId(1);
+ entity.setIntProperty(111);
+
+ entity = repo.newEntity();
+ entity.setId(2);
+ entity.setIntProperty(222);
+
+ entity = repo.newEntity();
+ entity.setId(3);
+ entity.setIntProperty(333);
+
+ entity = repo.newEntity();
+ entity.setId(4);
+ entity.setIntProperty(111);
+
+ iswf.commitTran();
+
+ }
+
+ @Test
+ public void whenOne() throws Exception {
+
+ PrimitiveValuedEntity entity;
+
+ iswf.beginTran();
+
+ entity = repo.findByNamedQueryFirstOnly("prmv_findByIntProperty", ImmutableMap.of("i", (Object)222));
+ assertThat(entity, is(not(nullValue())));
+ assertThat(entity.getId(), is(2));
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenTwo() throws Exception {
+
+ PrimitiveValuedEntity entity;
+
+ iswf.beginTran();
+
+ entity = repo.findByNamedQueryFirstOnly("prmv_findByIntProperty", ImmutableMap.of("i", (Object)111));
+ assertThat(entity, is(not(nullValue())));
+ assertThat(entity.getId(), is(1));
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void whenNone() throws Exception {
+
+ PrimitiveValuedEntity entity;
+
+ iswf.beginTran();
+
+ entity = repo.findByNamedQueryFirstOnly("prmv_findByIntProperty", ImmutableMap.of("i", (Object)999));
+ assertThat(entity, is(nullValue()));
+
+ iswf.commitTran();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_applibValuedEntity.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_applibValuedEntity.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_applibValuedEntity.java
new file mode 100644
index 0000000..4b27d8d
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_applibValuedEntity.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persistAndUpdate_applibValuedEntity {
+
+ private ApplibValuedEntityRepository repo = new ApplibValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("APPLIBVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwo() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setStringProperty("1");
+ repo.newEntity().setStringProperty("2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<ApplibValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persist_then_update() throws Exception {
+ iswf.beginTran();
+
+ ApplibValuedEntity entity = repo.newEntity();
+ entity.setStringProperty("1");
+
+ Date date = new Date();
+ entity.setDateProperty(date);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getDateProperty().dateValue(), is(date.dateValue()));
+
+ date = date.add(-1, -1, -1);
+ entity.setDateProperty(date);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getDateProperty().dateValue(), is(date.dateValue()));
+
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_jdkValuedEntity.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_jdkValuedEntity.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_jdkValuedEntity.java
new file mode 100644
index 0000000..b74224e
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_jdkValuedEntity.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Timestamp;
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.JdkValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.JdkValuedEntityRepository;
+import org.apache.isis.core.tck.dom.scalars.MyEnum;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persistAndUpdate_jdkValuedEntity {
+
+ private JdkValuedEntityRepository repo = new JdkValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("JDKVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwo() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setStringProperty("1");
+ repo.newEntity().setStringProperty("2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<JdkValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persist_then_update() throws Exception {
+ iswf.beginTran();
+ JdkValuedEntity entity = repo.newEntity();
+ entity.setStringProperty("1");
+ entity.setBigDecimalProperty(BigDecimal.valueOf(543210987654321L, 0)); // mssqlserver can cope with scale>0, but hsqldb cannot
+ entity.setBigIntegerProperty(BigInteger.valueOf(123456789012345L));
+ entity.setJavaSqlDateProperty(new java.sql.Date(Utils.toMillis(2009, 6, 11)));
+ entity.setJavaSqlTimeProperty(new java.sql.Time(Utils.toMillis(1970, 1, 1, 0, 5, 10))); // date portion is unimportant, is preserved on mssqlserver but not on hsqldb
+ entity.setJavaSqlTimestampProperty(new Timestamp(Utils.toMillis(2010, 5, 13, 20, 25, 30)));
+ entity.setJavaUtilDateProperty(new java.util.Date(Utils.toMillis(2010, 5, 13, 22, 17, 12)));
+ entity.setMyEnum(MyEnum.GREEN);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+
+ assertThat(entity.getStringProperty(), is("1"));
+ assertThat(entity.getBigDecimalProperty(), is(BigDecimal.valueOf(543210987654321L, 0)));
+ assertThat(entity.getBigIntegerProperty(), is(BigInteger.valueOf(123456789012345L)));
+ assertThat(entity.getJavaSqlDateProperty(), is(new java.sql.Date(Utils.toMillis(2009, 6, 11))));
+ assertThat(entity.getJavaSqlTimeProperty(), is(new java.sql.Time(Utils.toMillis(1970, 1, 1, 0, 5, 10))));
+ assertThat(entity.getJavaSqlTimestampProperty(), is(new Timestamp(Utils.toMillis(2010, 5, 13, 20, 25, 30))));
+ assertThat(entity.getJavaUtilDateProperty(), is(new java.util.Date(Utils.toMillis(2010, 5, 13, 22, 17, 12))));
+ assertThat(entity.getMyEnum(), is(MyEnum.GREEN));
+
+
+ entity.setBigDecimalProperty(BigDecimal.valueOf(123456789012345L, 0));
+ entity.setBigIntegerProperty(BigInteger.valueOf(543210987654321L));
+ entity.setJavaSqlDateProperty(new java.sql.Date(Utils.toMillis(2010, 5, 13)));
+ entity.setJavaSqlTimeProperty(new java.sql.Time(Utils.toMillis(1970, 1, 1, 5, 10, 15)));
+ entity.setJavaSqlTimestampProperty(new Timestamp(Utils.toMillis(2010, 5, 13, 10, 15, 20)));
+ entity.setJavaUtilDateProperty(new java.util.Date(Utils.toMillis(2010, 5, 13, 20, 15, 10)));
+ entity.setMyEnum(MyEnum.BLUE);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getBigDecimalProperty(), is(BigDecimal.valueOf(123456789012345L, 0)));
+ assertThat(entity.getBigIntegerProperty(), is(BigInteger.valueOf(543210987654321L)));
+ assertThat(entity.getJavaSqlDateProperty(), is(new java.sql.Date(Utils.toMillis(2010, 5, 13))));
+ assertThat(entity.getJavaSqlTimeProperty(), is(new java.sql.Time(Utils.toMillis(1970, 1, 1, 5, 10, 15))));
+ assertThat(entity.getJavaSqlTimestampProperty(), is(new Timestamp(Utils.toMillis(2010, 5, 13, 10, 15, 20))));
+ assertThat(entity.getJavaUtilDateProperty(), is(new java.util.Date(Utils.toMillis(2010, 5, 13, 20, 15, 10))));
+ assertThat(entity.getMyEnum(), is(MyEnum.BLUE));
+
+ iswf.commitTran();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_objectAdapters.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_objectAdapters.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_objectAdapters.java
new file mode 100644
index 0000000..84292d8
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_objectAdapters.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persistAndUpdate_objectAdapters {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void transient_then_persistent() throws Exception {
+
+ iswf.beginTran();
+ PrimitiveValuedEntity entity = repo.newEntity();
+ ObjectAdapter adapter = iswf.adapterFor(entity);
+
+ assertThat(adapter.isTransient(), is(true));
+ assertThat(adapter.getResolveState(), is(ResolveState.TRANSIENT));
+ assertThat(adapter.getOid().isTransient(), is(true));
+
+ entity.setId(1);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ final List<PrimitiveValuedEntity> list = repo.list();
+ assertThat(list.size(), is(1));
+
+ adapter = iswf.adapterFor(list.get(0));
+ assertThat(adapter.getResolveState(), is(ResolveState.RESOLVED));
+ assertThat(adapter.isTransient(), is(false));
+ assertThat(adapter.getOid().enString(new OidMarshaller()), is("PRMV:i~1"));
+
+ iswf.commitTran();
+ }
+
+ @Test
+ public void updated_and_retrieved() throws Exception {
+
+ // given persisted
+ iswf.beginTran();
+ PrimitiveValuedEntity entity = repo.newEntity();
+ ObjectAdapter adapter = iswf.adapterFor(entity);
+
+ entity.setId(1);
+ entity.setCharProperty('X');
+
+ iswf.commitTran();
+
+ // when update
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ entity.setCharProperty('Y');
+ iswf.commitTran();
+
+ // then adapter's state is resolved
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getCharProperty(), is('Y'));
+
+ adapter = iswf.adapterFor(entity);
+ assertThat(adapter.getResolveState(), is(ResolveState.RESOLVED));
+
+ iswf.commitTran();
+
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_primitiveValuedEntity.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_primitiveValuedEntity.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_primitiveValuedEntity.java
new file mode 100644
index 0000000..3dfb7d4
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_primitiveValuedEntity.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persistAndUpdate_primitiveValuedEntity {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwo() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setId(1);
+ repo.newEntity().setId(2);
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<PrimitiveValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persist_then_update() throws Exception {
+
+ iswf.beginTran();
+ PrimitiveValuedEntity entity = repo.newEntity();
+ entity.setId(1);
+
+ entity.setBooleanProperty(false);
+ entity.setByteProperty((byte)456);
+ entity.setDoubleProperty(123456789876.0);
+ entity.setFloatProperty(654321.0f);
+ entity.setIntProperty(765);
+ entity.setLongProperty(7654321012345L);
+ entity.setShortProperty((short)543);
+ entity.setCharProperty('A');
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+
+ assertThat(entity.getBooleanProperty(), is(false));
+ assertThat(entity.getByteProperty(), is((byte)456));
+ assertThat(entity.getDoubleProperty(), is(123456789876.0));
+ assertThat(entity.getFloatProperty(), is(654321.0f));
+ assertThat(entity.getIntProperty(), is(765));
+ assertThat(entity.getLongProperty(), is(7654321012345L));
+ assertThat(entity.getShortProperty(), is((short)543));
+ assertThat(entity.getCharProperty(), is('A'));
+
+
+ entity.setBooleanProperty(true);
+ entity.setByteProperty((byte)123);
+ entity.setDoubleProperty(9876543210987.0);
+ entity.setFloatProperty(123456.0f);
+ entity.setIntProperty(456);
+ entity.setLongProperty(12345678901L);
+ entity.setShortProperty((short)4567);
+ entity.setCharProperty('X');
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+
+ assertThat(entity.getBooleanProperty(), is(true));
+ assertThat(entity.getByteProperty(), is((byte)123));
+ assertThat(entity.getDoubleProperty(), is(9876543210987.0));
+ assertThat(entity.getFloatProperty(), is(123456.0f));
+ assertThat(entity.getIntProperty(), is(456));
+ assertThat(entity.getLongProperty(), is(12345678901L));
+ assertThat(entity.getShortProperty(), is((short)4567));
+ assertThat(entity.getCharProperty(), is('X'));
+
+ iswf.commitTran();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_wrapperValuedEntity.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_wrapperValuedEntity.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_wrapperValuedEntity.java
new file mode 100644
index 0000000..fc0841f
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_persistAndUpdate_wrapperValuedEntity.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.objectstore.jdo.datanucleus.scenarios.scalar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+import org.apache.isis.core.tck.dom.scalars.WrapperValuedEntity;
+import org.apache.isis.core.tck.dom.scalars.WrapperValuedEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persistAndUpdate_wrapperValuedEntity {
+
+ private WrapperValuedEntityRepository repo = new WrapperValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("WRAPPERVALUEDENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwo() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setStringProperty("1");
+ repo.newEntity().setStringProperty("2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<WrapperValuedEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+
+ @Test
+ public void persist_then_update() throws Exception {
+ iswf.beginTran();
+ WrapperValuedEntity entity = repo.newEntity();
+ entity.setStringProperty("1");
+ entity.setBooleanProperty(false);
+ entity.setByteProperty((byte)321);
+ entity.setDoubleProperty(123456768723429.0);
+ entity.setFloatProperty(654321.0f);
+ entity.setIntegerProperty(543);
+ entity.setLongProperty(90876512345L);
+ entity.setShortProperty((short)7654);
+ entity.setCharacterProperty('A');
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getStringProperty(), is("1"));
+ assertThat(entity.getBooleanProperty(), is(false));
+ assertThat(entity.getByteProperty(), is((byte)321));
+ assertThat(entity.getDoubleProperty(), is(123456768723429.0));
+ assertThat(entity.getFloatProperty(), is(654321.0f));
+ assertThat(entity.getIntegerProperty(), is(543));
+ assertThat(entity.getLongProperty(), is(90876512345L));
+ assertThat(entity.getShortProperty(), is((short)7654));
+ assertThat(entity.getCharacterProperty(), is('A'));
+
+
+ entity.setBooleanProperty(true);
+ entity.setByteProperty((byte)123);
+ entity.setDoubleProperty(9876543210987.0);
+ entity.setFloatProperty(123456.0f);
+ entity.setIntegerProperty(456);
+ entity.setLongProperty(12345678901L);
+ entity.setShortProperty((short)4567);
+ entity.setCharacterProperty('X');
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ entity = repo.list().get(0);
+ assertThat(entity.getBooleanProperty(), is(true));
+ assertThat(entity.getByteProperty(), is((byte)123));
+ assertThat(entity.getDoubleProperty(), is(9876543210987.0));
+ assertThat(entity.getFloatProperty(), is(123456.0f));
+ assertThat(entity.getIntegerProperty(), is(456));
+ assertThat(entity.getLongProperty(), is(12345678901L));
+ assertThat(entity.getShortProperty(), is((short)4567));
+ assertThat(entity.getCharacterProperty(), is('X'));
+
+ iswf.commitTran();
+ }
+
+}