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 2015/07/25 11:29:58 UTC
[40/48] isis git commit: ISIS-1178: mothballing the tck tests.
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
new file mode 100644
index 0000000..44a5b46
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+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.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.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+
+public class DataNucleusPersistenceMechanismInstallerTest_services {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void servicesBootstrapped() {
+ final List<Object> services = IsisContext.getServices();
+ assertThat(services.size(), is(1));
+ assertThat(services.get(0), is((Object)repo));
+
+ final ObjectAdapter serviceAdapter = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(repo);
+ assertThat(serviceAdapter, is(not(nullValue())));
+
+ assertThat(serviceAdapter.getOid(), is(equalTo((Oid)RootOidDefault.create(ObjectSpecId.of("PrimitiveValuedEntities"), "1"))));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
new file mode 100644
index 0000000..5b0bb73
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
@@ -0,0 +1,124 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public class Utils {
+
+ private Utils(){}
+
+ public static IsisSystemWithFixtures.Builder systemBuilder() {
+ return IsisSystemWithFixtures.builder()
+ .with(configurationForDataNucleusDb())
+ .with(new DataNucleusPersistenceMechanismInstaller());
+ }
+
+ public static IsisSystemWithFixtures.Listener listenerToDeleteFrom(final String... tables) {
+ return new IsisSystemWithFixtures.ListenerAdapter(){
+
+ @Override
+ public void postSetupSystem(boolean firstTime) throws Exception {
+ Connection connection = getConnection();
+ try {
+ final Statement statement = connection.createStatement();
+ for(String table: tables) {
+ statement.executeUpdate("DELETE FROM " + table);
+ }
+ } catch(Exception ex) {
+ connection.rollback();
+ throw ex;
+ } finally {
+ connection.commit();
+ }
+ }
+
+ private Connection getConnection() {
+ final DataNucleusObjectStore objectStore = (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+ return objectStore.getJavaSqlConnection();
+ }
+ };
+ }
+
+ public static IsisConfiguration configurationForDataNucleusDb() {
+ final IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+ Properties props = new Properties();
+
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
+
+ // last one wins!
+ configureHsqlDbFileBased(props);
+ configureForMsSqlServer(props);
+ configureHsqlDbInMemory(props);
+
+ props.put("isis.persistor.datanucleus.impl.datanucleus.autoCreateSchema", "true");
+ props.put("isis.persistor.datanucleus.impl.datanucleus.validateTables", "true");
+ props.put("isis.persistor.datanucleus.impl.datanucleus.validateConstraints", "true");
+
+ props.put("isis.persistor.datanucleus.impl.datanucleus.cache.level2.type", "none");
+
+ configuration.add(props);
+ return configuration;
+ }
+
+
+ private static void configureHsqlDbInMemory(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+ }
+
+ private static void configureHsqlDbFileBased(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:file:hsql-db/test;hsqldb.write_delay=false;shutdown=true");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+ }
+
+ private static void configureForMsSqlServer(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:sqlserver://127.0.0.1:1433;instance=SQLEXPRESS;databaseName=jdo;");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "jdo");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "jdopass");
+ }
+
+
+
+ public static long toMillis(int year, int monthOfYear, int dayOfMonth) {
+ LocalDate d = new LocalDate(year, monthOfYear, dayOfMonth);
+ return d.toDateMidnight().getMillis();
+ }
+
+ public static long toMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute) {
+ LocalDateTime d = new LocalDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute);
+ return d.toDateTime().getMillis();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
new file mode 100644
index 0000000..f4c5364
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
@@ -0,0 +1,150 @@
+/*
+ * 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.persistence.spi;
+
+import java.math.BigInteger;
+import java.util.Date;
+import org.datanucleus.identity.ObjectId;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.applib.annotation.ObjectType;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class JdoObjectIdSerializerTest {
+
+ @ObjectType("CUS")
+ public static class Customer {}
+ public static class CustomerRepository {
+ public void foo(Customer x) {}
+ }
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+ .withServices(new CustomerRepository())
+ .build();
+
+
+
+ @Test
+ public void whenJavaxJdoIntIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.IntIdentity(Customer.class, 123);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("i_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenJavaxJdoStringIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.StringIdentity(Customer.class, "123");
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("s_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenJavaxJdoLongIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.LongIdentity(Customer.class, 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("l_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenLong() throws Exception {
+ Object jdoOid = new ObjectId(Customer.class, 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("L_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndLong() throws Exception {
+ Object jdoOid = new ObjectId(Customer.class, 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("L_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndBigInteger() throws Exception {
+ Object jdoOid = new ObjectId(Customer.class, new BigInteger("123"));
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("B_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is(((Object)("123"+ "[OID]" + Customer.class.getName()))));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndString() throws Exception {
+ Object jdoOid = new ObjectId(Customer.class, "456");
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("S_456"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("456" + "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndOtherKeyValue() throws Exception {
+ Date key = new Date();
+ Object jdoOid = new ObjectId(Customer.class, key);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, IsisMatchers.startsWith(ObjectId.class.getName() + "_" + key.toString()));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)(key.toString() + "[OID]" + Customer.class.getName())));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
new file mode 100644
index 0000000..94087d7
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
@@ -0,0 +1,84 @@
+/*
+ * 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.adaptermanager;
+
+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.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.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;
+
+public class Persistence_lazyLoading {
+
+ 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 lazyLoading_and_adapters() throws Exception {
+ iswf.beginTran();
+ referencedRepo.newEntity().setName("Referenced 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.list().get(0);
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirReferencingEntity> list = referencingRepo.list();
+ referencingEntity1 = list.get(0);
+
+ assertThat(referencingEntity1.referenced, is(nullValue())); // lazy loading
+ UnidirReferencedEntity referenced = referencingEntity1.getReferenced();
+ ObjectAdapter referencedAdapter = iswf.adapterFor(referenced);
+ assertThat(referencedAdapter.getResolveState(), is(ResolveState.RESOLVED));
+ assertThat(referenced, is(not(nullValue())));
+
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
new file mode 100644
index 0000000..32487be
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
@@ -0,0 +1,102 @@
+/*
+ * 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.adaptermanager;
+
+import static org.hamcrest.CoreMatchers.is;
+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.metamodel.adapter.ObjectAdapter;
+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;
+
+public class Persistence_loadObject {
+
+ 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_using_persistentAdapterFor() 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();
+
+ TypedOid referencingOid2 = (TypedOid) iswf.adapterFor(referencingEntity2).getOid();
+
+ TypedOid referencedOid1 = (TypedOid) iswf.adapterFor(referencedEntity1).getOid();
+ TypedOid referencedOid2 = (TypedOid) iswf.adapterFor(referencedEntity2).getOid();
+
+
+ // when ...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ ObjectAdapter referencingAdapter2 = iswf.getPersistor().loadObject(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ UnidirReferencedEntity referenced = referencingEntity2.getReferenced();
+
+ ObjectAdapter referencedAdapter1 = iswf.getAdapterManager().adapterFor(referencedOid1);
+ assertThat(referenced, is(referencedAdapter1.getObject()));
+
+ // ...switch to refer to other
+
+ ObjectAdapter referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+ referencedEntity2 = (UnidirReferencedEntity) referencedAdapter2.getObject();
+
+ referencingEntity2.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
new file mode 100644
index 0000000..39d9833
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
@@ -0,0 +1,115 @@
+/*
+ * 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.adaptermanager;
+
+import static org.hamcrest.CoreMatchers.is;
+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.metamodel.adapter.ObjectAdapter;
+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;
+
+public class Persistence_persistentAdapterFor {
+
+ 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_using_persistentAdapterFor() 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();
+
+ TypedOid referencingOid2 = (TypedOid) iswf.adapterFor(referencingEntity2).getOid();
+
+ TypedOid referencedOid1 = (TypedOid) iswf.adapterFor(referencedEntity1).getOid();
+ TypedOid referencedOid2 = (TypedOid) iswf.adapterFor(referencedEntity2).getOid();
+
+
+ // when ...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ ObjectAdapter referencingAdapter2 = iswf.getAdapterManager().adapterFor(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ UnidirReferencedEntity referenced = referencingEntity2.getReferenced();
+
+ ObjectAdapter referencedAdapter1 = iswf.getAdapterManager().adapterFor(referencedOid1);
+ assertThat(referenced, is(referencedAdapter1.getObject()));
+
+ // ...switch to refer to other
+
+ ObjectAdapter referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+ referencedEntity2 = (UnidirReferencedEntity) referencedAdapter2.getObject();
+
+ referencingEntity2.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ // then...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ referencingAdapter2 = iswf.getAdapterManager().adapterFor(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ referenced = referencingEntity2.getReferenced();
+
+ referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+
+ // ...is switched
+ assertThat(referenced, is(referencedAdapter2.getObject()));
+
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java
new file mode 100644
index 0000000..b618efd
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.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.refs;
+
+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.refs.BidirWithListChildEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithListParentEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithListParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_bidirWithListParent {
+
+ private BidirWithListParentEntityRepository repo = new BidirWithListParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHLISTCHILDeNTITY"))
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHLISTPARENTENTITY"))
+ .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<BidirWithListParentEntity> 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();
+ BidirWithListParentEntity 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);
+ List<BidirWithListChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(3));
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
new file mode 100644
index 0000000..21447b7
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithSetParent.java
@@ -0,0 +1,127 @@
+/*
+ * 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.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.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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyclass.java b/mothballed/tck/tck-integtests/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/mothballed/tck/tck-integtests/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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
new file mode 100644
index 0000000..60a8ee7
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinter.java
@@ -0,0 +1,95 @@
+/*
+ * 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.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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.java
new file mode 100644
index 0000000..9484c1d
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_polyinterIdentityStrategy.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.PolyInterfaceIdentityStrategy;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceIdentityStrategyParentEntity;
+import org.apache.isis.core.tck.dom.refs.PolyInterfaceIdentityStrategyParentEntityRepository;
+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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
new file mode 100644
index 0000000..d29c674
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_referencing.java
@@ -0,0 +1,133 @@
+/*
+ * 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.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+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;
+
+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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
new file mode 100644
index 0000000..387f561
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidir.java
@@ -0,0 +1,128 @@
+/*
+ * 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.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.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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
new file mode 100644
index 0000000..3f56f4e
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_unidirJoin.java
@@ -0,0 +1,128 @@
+/*
+ * 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.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.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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.java
new file mode 100644
index 0000000..b7d8026
--- /dev/null
+++ b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_update_using_domMethodCalls.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.refs;
+
+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.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;
+
+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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_allInstances.java
new file mode 100644
index 0000000..7a2fad1
--- /dev/null
+++ b/mothballed/tck/tck-integtests/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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_bounceSystem.java
new file mode 100644
index 0000000..4512592
--- /dev/null
+++ b/mothballed/tck/tck-integtests/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/93a1d5cc/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java
----------------------------------------------------------------------
diff --git a/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java b/mothballed/tck/tck-integtests/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/scalar/Persistence_findInstance.java
new file mode 100644
index 0000000..cea02d5
--- /dev/null
+++ b/mothballed/tck/tck-integtests/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();
+ }
+
+
+}