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:04 UTC
[42/58] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest.java
new file mode 100644
index 0000000..ac2017d
--- /dev/null
+++ b/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest.java
@@ -0,0 +1,355 @@
+/*
+ * 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.xml.internal.data.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.xml.XmlFile;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.tck.dom.xmlos.Role;
+import org.apache.isis.core.tck.dom.xmlos.Team;
+import org.apache.isis.core.tck.dom.xmlos.TeamDomainRepository;
+import org.apache.isis.objectstore.xml.XmlPersistenceMechanismInstaller;
+import org.apache.isis.objectstore.xml.internal.clock.DefaultClock;
+import org.apache.isis.objectstore.xml.internal.data.ListOfRootOid;
+import org.apache.isis.objectstore.xml.internal.data.ObjectData;
+import org.apache.isis.objectstore.xml.internal.data.xml.Utils;
+import org.apache.isis.objectstore.xml.internal.data.xml.XmlDataManager;
+import org.apache.isis.objectstore.xml.internal.version.FileVersion;
+
+public class XmlDataManagerTest {
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+ .with(new XmlPersistenceMechanismInstaller())
+ .withServices(new TeamDomainRepository())
+ .build();
+
+ protected XmlDataManager manager;
+
+ @Before
+ public void setUp() throws Exception {
+ FileVersion.setClock(new DefaultClock());
+
+ clearTestDirectory();
+ final String charset = Utils.lookupCharset(iswf.getIsisSystem().getConfiguration());
+ manager = new XmlDataManager(new XmlFile(charset, "tmp/tests"));
+ }
+
+ protected static void clearTestDirectory() {
+ final File directory = new File("tmp" + File.separator + "tests");
+ final String[] files = directory.list(new FilenameFilter() {
+ @Override
+ public boolean accept(final File arg0, final String name) {
+ return name.endsWith(".xml");
+ }
+ });
+
+ if (files != null) {
+ for (final String file : files) {
+ new File(directory, file).delete();
+ }
+ }
+ }
+
+ @Test
+ public void testWriteReadTypeOidAndVersion() {
+ final ObjectData data = createData(Role.class, 99, FileVersion.create("user", 19));
+ manager.insertObject(data);
+
+ final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
+
+ assertEquals(data.getRootOid(), read.getRootOid());
+ assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
+ assertEquals(data.getVersion(), read.getVersion());
+ }
+
+ @Test
+ public void testNextId() throws Exception {
+ final long first = manager.nextId();
+ assertEquals(first + 1, manager.nextId());
+ assertEquals(first + 2, manager.nextId());
+ assertEquals(first + 3, manager.nextId());
+ }
+
+ @Test
+ public void testInsertObjectWithFields() throws ObjectPersistenceException {
+ final ObjectData data = createData(Role.class, 99, FileVersion.create("user", 13));
+ data.set("Person", RootOidDefault.create(ObjectSpecId.of("RLE"), ""+101));
+ assertNotNull(data.get("Person"));
+ data.set("Name", "Harry");
+ assertNotNull(data.get("Name"));
+
+ manager.insertObject(data);
+
+ final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
+ assertEquals(data.getRootOid(), read.getRootOid());
+ assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
+
+ assertEquals(data.get("Person"), read.get("Person"));
+ assertEquals(data.get("Name"), read.get("Name"));
+ }
+
+ @Test
+ public void testInsertObjectWithEmptyOneToManyAssociations() throws ObjectPersistenceException {
+ final ObjectData data = createData(Team.class, 99, FileVersion.create("user", 13));
+
+ data.initCollection("Members");
+
+ manager.insertObject(data);
+
+ final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
+ assertEquals(data.getRootOid(), read.getRootOid());
+ assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
+
+ final ListOfRootOid c = read.elements("Members");
+ assertNull(c);
+ }
+
+ @Test
+ public void testInsertObjectWithOneToManyAssociations() throws ObjectPersistenceException {
+ final ObjectData data = createData(Team.class, 99, FileVersion.create("user", 13));
+
+ data.initCollection("Members");
+ final RootOidDefault oid[] = new RootOidDefault[3];
+ for (int i = 0; i < oid.length; i++) {
+ oid[i] = RootOidDefault.create(ObjectSpecId.of("TEA"), ""+ (104 + i));
+ data.addElement("Members", oid[i]);
+ }
+ manager.insertObject(data);
+
+ final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
+ assertEquals(data.getRootOid(), read.getRootOid());
+ assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
+
+ final ListOfRootOid c = read.elements("Members");
+ for (int i = 0; i < oid.length; i++) {
+ assertEquals(oid[i], c.elementAt(i));
+ }
+ }
+
+
+ private ObjectData createData(final Class<?> type, final long id, final Version version) {
+
+ final ObjectSpecification objSpec = IsisContext.getSpecificationLoader().loadSpecification(type);
+ final ObjectSpecId objectSpecId = objSpec.getSpecId();
+ final RootOidDefault oid = RootOidDefault.create(objectSpecId, ""+id);
+ return new ObjectData(oid, version);
+ }
+ /*
+ * public void xxxtestInsertValues() throws ObjectStoreException {
+ * ObjectSpecification type =
+ * Isis.getSpecificationLoader().loadSpecification
+ * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
+ * ObjectData data = new ObjectData(type, oid);
+ *
+ *
+ * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
+ *
+ * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
+ * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
+ * floatingPoint1);
+ *
+ * Label label1 = new Label(); label1.setValue("Labelled");
+ * data.saveValue("Label", label1);
+ *
+ * Logical logical1 = new Logical(); logical1.setValue(true);
+ * data.saveValue("Logical", logical1);
+ *
+ * Money money1 = new Money(); money1.setValue(1233.45);
+ * data.saveValue("Money", money1);
+ *
+ * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
+ * data.saveValue("Option", option1);
+ *
+ * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
+ * data.saveValue("Percentage", percentage1);
+ *
+ * TextString textString1 = new TextString("Fred");
+ * data.saveValue("Text String", textString1);
+ *
+ * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
+ * data.saveValue("Time Stamp", timestamp1);
+ *
+ * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
+ *
+ * URLString urlString1 = new URLString("http://isis.apache.org/");
+ * data.saveValue("Url String", urlString1);
+ *
+ * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
+ * data.saveValue("Whole Number", number1);
+ *
+ *
+ * manager.insert(data);
+ *
+ *
+ *
+ * ObjectData object = manager.loadObjectData(oid);
+ *
+ * Date date2 = new Date(); object.restoreValue("Date", date2);
+ * assertEquals(date1, date2);
+ *
+ * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
+ * object.restoreValue("Floating Point", floatingPoint2);
+ * assertEquals(floatingPoint1, floatingPoint2);
+ *
+ * Label label2 = new Label(); object.restoreValue("Label", label2);
+ * assertEquals(label1, label2);
+ *
+ * Logical logical2 = new Logical(); object.restoreValue("Logical",
+ * logical2); assertEquals(logical1, logical2);
+ *
+ * Money money2 = new Money(); object.restoreValue("Money", money2);
+ * assertEquals(money1, money2);
+ *
+ * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
+ * object.restoreValue("Option", option2); assertEquals(option1, option2);
+ *
+ * Percentage percentage2 = new Percentage();
+ * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
+ * percentage2);
+ *
+ * Time time2 = new Time(); object.restoreValue("Time", time2);
+ * assertEquals(time1, time2);
+ *
+ * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
+ * timestamp2); assertEquals(timestamp1, timestamp2);
+ *
+ * TextString textString2 = new TextString();
+ * object.restoreValue("Text String", textString2);
+ * assertEquals(textString1, textString2);
+ *
+ * URLString urlString2 = new URLString(); object.restoreValue("Url String",
+ * urlString2); assertEquals(urlString1, urlString2);
+ *
+ * WholeNumber number2 = new WholeNumber();
+ * object.restoreValue("Whole Number", number2); assertEquals(number1,
+ * number2); }
+ *
+ * public void xxxtestSaveValues() throws ObjectStoreException {
+ * ObjectSpecification type =
+ * Isis.getSpecificationLoader().loadSpecification
+ * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
+ * ObjectData data = new ObjectData(type, oid);
+ *
+ * manager.insert(data);
+ *
+ *
+ * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
+ *
+ * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
+ * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
+ * floatingPoint1);
+ *
+ * Label label1 = new Label(); label1.setValue("Labelled");
+ * data.saveValue("Label", label1);
+ *
+ * Logical logical1 = new Logical(); logical1.setValue(true);
+ * data.saveValue("Logical", logical1);
+ *
+ * Money money1 = new Money(); money1.setValue(1233.45);
+ * data.saveValue("Money", money1);
+ *
+ * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
+ * data.saveValue("Option", option1);
+ *
+ * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
+ * data.saveValue("Percentage", percentage1);
+ *
+ * TextString textString1 = new TextString("Fred");
+ * data.saveValue("Text String", textString1);
+ *
+ * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
+ * data.saveValue("Time Stamp", timestamp1);
+ *
+ * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
+ *
+ * URLString urlString1 = new URLString("http://isis.apache.org/");
+ * data.saveValue("Url String", urlString1);
+ *
+ * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
+ * data.saveValue("Whole Number", number1);
+ *
+ *
+ * manager.save(data);
+ *
+ *
+ *
+ * ObjectData object = manager.loadObjectData(oid);
+ *
+ * Date date2 = new Date(); object.restoreValue("Date", date2);
+ * assertEquals(date1, date2);
+ *
+ * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
+ * object.restoreValue("Floating Point", floatingPoint2);
+ * assertEquals(floatingPoint1, floatingPoint2);
+ *
+ * Label label2 = new Label(); object.restoreValue("Label", label2);
+ * assertEquals(label1, label2);
+ *
+ * Logical logical2 = new Logical(); object.restoreValue("Logical",
+ * logical2); assertEquals(logical1, logical2);
+ *
+ * Money money2 = new Money(); object.restoreValue("Money", money2);
+ * assertEquals(money1, money2);
+ *
+ * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
+ * object.restoreValue("Option", option2); assertEquals(option1, option2);
+ *
+ * Percentage percentage2 = new Percentage();
+ * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
+ * percentage2);
+ *
+ * Time time2 = new Time(); object.restoreValue("Time", time2);
+ * assertEquals(time1, time2);
+ *
+ * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
+ * timestamp2); assertEquals(timestamp1, timestamp2);
+ *
+ * TextString textString2 = new TextString();
+ * object.restoreValue("Text String", textString2);
+ * assertEquals(textString1, textString2);
+ *
+ * URLString urlString2 = new URLString(); object.restoreValue("Url String",
+ * urlString2); assertEquals(urlString1, urlString2);
+ *
+ * WholeNumber number2 = new WholeNumber();
+ * object.restoreValue("Whole Number", number2); assertEquals(number1,
+ * number2);
+ *
+ * }
+ */
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest_instances.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest_instances.java b/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest_instances.java
new file mode 100644
index 0000000..31c798d
--- /dev/null
+++ b/component/objectstore/xml/src/test/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManagerTest_instances.java
@@ -0,0 +1,317 @@
+/*
+ * 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.xml.internal.data.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.xml.XmlFile;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.tck.dom.xmlos.TeamDomainRepository;
+import org.apache.isis.objectstore.xml.XmlPersistenceMechanismInstaller;
+import org.apache.isis.objectstore.xml.internal.clock.DefaultClock;
+import org.apache.isis.objectstore.xml.internal.data.ObjectData;
+import org.apache.isis.objectstore.xml.internal.data.ObjectDataVector;
+import org.apache.isis.objectstore.xml.internal.data.xml.Utils;
+import org.apache.isis.objectstore.xml.internal.data.xml.XmlDataManager;
+import org.apache.isis.objectstore.xml.internal.version.FileVersion;
+
+public class XmlDataManagerTest_instances {
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+ .with(new XmlPersistenceMechanismInstaller())
+ .withServices(new TeamDomainRepository())
+ .build();
+
+ protected XmlDataManager manager;
+ protected final int SIZE = 5;
+
+ private RootOid oids[];
+ private ObjectData data[];
+ private ObjectData pattern;
+
+ @Before
+ public void setUp() throws Exception {
+
+ clearTestDirectory();
+ final String charset = Utils.lookupCharset(iswf.getIsisSystem().getConfiguration());
+ manager = new XmlDataManager(new XmlFile(charset, "tmp/tests"));
+
+ FileVersion.setClock(new DefaultClock());
+
+ oids = new RootOid[SIZE];
+ data = new ObjectData[SIZE];
+
+ pattern = new ObjectData(RootOidDefault.deString("RLE:1", new OidMarshaller()), FileVersion.create("user", 13));
+ for (int i = 0; i < SIZE; i++) {
+ oids[i] = RootOidDefault.create(ObjectSpecId.of("RLE"), ""+i);
+ data[i] = new ObjectData(oids[i], FileVersion.create("user", 13));
+ manager.insertObject(data[i]);
+ }
+ }
+
+ protected static void clearTestDirectory() {
+ final File directory = new File("tmp" + File.separator + "tests");
+ final String[] files = directory.list(new FilenameFilter() {
+ @Override
+ public boolean accept(final File arg0, final String name) {
+ return name.endsWith(".xml");
+ }
+ });
+
+ if (files != null) {
+ for (final String file : files) {
+ new File(directory, file).delete();
+ }
+ }
+ }
+
+
+ @Test
+ public void testNumberOfInstances() {
+ assertEquals(SIZE, manager.numberOfInstances(pattern));
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ final RootOid oid = oids[2];
+ manager.remove(oid);
+
+ assertEquals(SIZE - 1, manager.numberOfInstances(pattern));
+
+ final ObjectDataVector instances = manager.getInstances(pattern);
+ for (int i = 0; i < instances.size(); i++) {
+ assertFalse(instances.element(i) == data[2]);
+ }
+
+ assertNull((manager.loadData(oid)));
+ }
+
+ @Test
+ public void testSaveObject() throws Exception {
+ data[2].set("Person", RootOidDefault.create(ObjectSpecId.of("PER"), ""+231));
+ data[2].set("Name", "Fred");
+ manager.save(data[2]);
+
+ assertTrue(manager.getInstances(pattern).contains(data[2]));
+ final ObjectData read = (ObjectData) manager.loadData(oids[2]);
+ assertEquals(data[2], read);
+ assertEquals(data[2].get("Name"), read.get("Name"));
+ assertEquals(data[2].get("Person"), read.get("Person"));
+ }
+
+ /*
+ * public void xxxtestInsertValues() throws ObjectStoreException {
+ * ObjectSpecification type =
+ * Isis.getSpecificationLoader().loadSpecification
+ * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
+ * ObjectData data = new ObjectData(type, oid);
+ *
+ *
+ * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
+ *
+ * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
+ * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
+ * floatingPoint1);
+ *
+ * Label label1 = new Label(); label1.setValue("Labelled");
+ * data.saveValue("Label", label1);
+ *
+ * Logical logical1 = new Logical(); logical1.setValue(true);
+ * data.saveValue("Logical", logical1);
+ *
+ * Money money1 = new Money(); money1.setValue(1233.45);
+ * data.saveValue("Money", money1);
+ *
+ * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
+ * data.saveValue("Option", option1);
+ *
+ * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
+ * data.saveValue("Percentage", percentage1);
+ *
+ * TextString textString1 = new TextString("Fred");
+ * data.saveValue("Text String", textString1);
+ *
+ * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
+ * data.saveValue("Time Stamp", timestamp1);
+ *
+ * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
+ *
+ * URLString urlString1 = new URLString("http://isis.apache.org/");
+ * data.saveValue("Url String", urlString1);
+ *
+ * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
+ * data.saveValue("Whole Number", number1);
+ *
+ *
+ * manager.insert(data);
+ *
+ *
+ *
+ * ObjectData object = manager.loadObjectData(oid);
+ *
+ * Date date2 = new Date(); object.restoreValue("Date", date2);
+ * assertEquals(date1, date2);
+ *
+ * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
+ * object.restoreValue("Floating Point", floatingPoint2);
+ * assertEquals(floatingPoint1, floatingPoint2);
+ *
+ * Label label2 = new Label(); object.restoreValue("Label", label2);
+ * assertEquals(label1, label2);
+ *
+ * Logical logical2 = new Logical(); object.restoreValue("Logical",
+ * logical2); assertEquals(logical1, logical2);
+ *
+ * Money money2 = new Money(); object.restoreValue("Money", money2);
+ * assertEquals(money1, money2);
+ *
+ * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
+ * object.restoreValue("Option", option2); assertEquals(option1, option2);
+ *
+ * Percentage percentage2 = new Percentage();
+ * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
+ * percentage2);
+ *
+ * Time time2 = new Time(); object.restoreValue("Time", time2);
+ * assertEquals(time1, time2);
+ *
+ * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
+ * timestamp2); assertEquals(timestamp1, timestamp2);
+ *
+ * TextString textString2 = new TextString();
+ * object.restoreValue("Text String", textString2);
+ * assertEquals(textString1, textString2);
+ *
+ * URLString urlString2 = new URLString(); object.restoreValue("Url String",
+ * urlString2); assertEquals(urlString1, urlString2);
+ *
+ * WholeNumber number2 = new WholeNumber();
+ * object.restoreValue("Whole Number", number2); assertEquals(number1,
+ * number2); }
+ *
+ * public void xxxtestSaveValues() throws ObjectStoreException {
+ * ObjectSpecification type =
+ * Isis.getSpecificationLoader().loadSpecification
+ * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
+ * ObjectData data = new ObjectData(type, oid);
+ *
+ * manager.insert(data);
+ *
+ *
+ * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
+ *
+ * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
+ * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
+ * floatingPoint1);
+ *
+ * Label label1 = new Label(); label1.setValue("Labelled");
+ * data.saveValue("Label", label1);
+ *
+ * Logical logical1 = new Logical(); logical1.setValue(true);
+ * data.saveValue("Logical", logical1);
+ *
+ * Money money1 = new Money(); money1.setValue(1233.45);
+ * data.saveValue("Money", money1);
+ *
+ * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
+ * data.saveValue("Option", option1);
+ *
+ * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
+ * data.saveValue("Percentage", percentage1);
+ *
+ * TextString textString1 = new TextString("Fred");
+ * data.saveValue("Text String", textString1);
+ *
+ * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
+ * data.saveValue("Time Stamp", timestamp1);
+ *
+ * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
+ *
+ * URLString urlString1 = new URLString("http://isis.apache.org/");
+ * data.saveValue("Url String", urlString1);
+ *
+ * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
+ * data.saveValue("Whole Number", number1);
+ *
+ *
+ * manager.save(data);
+ *
+ *
+ *
+ * ObjectData object = manager.loadObjectData(oid);
+ *
+ * Date date2 = new Date(); object.restoreValue("Date", date2);
+ * assertEquals(date1, date2);
+ *
+ * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
+ * object.restoreValue("Floating Point", floatingPoint2);
+ * assertEquals(floatingPoint1, floatingPoint2);
+ *
+ * Label label2 = new Label(); object.restoreValue("Label", label2);
+ * assertEquals(label1, label2);
+ *
+ * Logical logical2 = new Logical(); object.restoreValue("Logical",
+ * logical2); assertEquals(logical1, logical2);
+ *
+ * Money money2 = new Money(); object.restoreValue("Money", money2);
+ * assertEquals(money1, money2);
+ *
+ * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
+ * object.restoreValue("Option", option2); assertEquals(option1, option2);
+ *
+ * Percentage percentage2 = new Percentage();
+ * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
+ * percentage2);
+ *
+ * Time time2 = new Time(); object.restoreValue("Time", time2);
+ * assertEquals(time1, time2);
+ *
+ * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
+ * timestamp2); assertEquals(timestamp1, timestamp2);
+ *
+ * TextString textString2 = new TextString();
+ * object.restoreValue("Text String", textString2);
+ * assertEquals(textString1, textString2);
+ *
+ * URLString urlString2 = new URLString(); object.restoreValue("Url String",
+ * urlString2); assertEquals(urlString1, urlString2);
+ *
+ * WholeNumber number2 = new WholeNumber();
+ * object.restoreValue("Whole Number", number2); assertEquals(number1,
+ * number2);
+ *
+ * }
+ */
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_isFixturesInstalled.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_isFixturesInstalled.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_isFixturesInstalled.java
deleted file mode 100644
index 8738c54..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_isFixturesInstalled.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml;
-
-import static org.junit.Assert.assertFalse;
-
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-
-public class XmlObjectStoreTest_isFixturesInstalled {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private IsisConfiguration mockConfiguration;
-
- private XmlObjectStore objectStore;
-
- @Before
- public void setUp() throws Exception {
- context.ignoring(mockConfiguration);
- objectStore = new XmlObjectStore(mockConfiguration);
- }
-
-
- @Test
- public void validateObjectStoreCreation_isFixturesInstalled() throws Exception {
- assertFalse(objectStore.isFixturesInstalled());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_name.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_name.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_name.java
deleted file mode 100644
index ca260b3..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_name.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-
-public class XmlObjectStoreTest_name {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private IsisConfiguration mockConfiguration;
-
- private XmlObjectStore objectStore;
-
- @Before
- public void setUp() throws Exception {
- context.ignoring(mockConfiguration);
- objectStore = new XmlObjectStore(mockConfiguration);
- }
-
- @Test
- public void name() throws Exception {
- assertTrue(objectStore.name().equals("XML"));
- }
-
-
- @Test
- public void validateObjectStoreCreation_isFixturesInstalled() throws Exception {
- assertFalse(objectStore.isFixturesInstalled());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_persist.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_persist.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_persist.java
deleted file mode 100644
index 46f86b7..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_persist.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.apache.isis.core.testsupport.files.Files;
-import org.apache.isis.core.testsupport.files.Files.Recursion;
-import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.runtimes.dflt.testsupport.tck.ObjectStoreContractTest_persist;
-
-public class XmlObjectStoreTest_persist extends ObjectStoreContractTest_persist {
-
- @Override
- protected PersistenceMechanismInstaller createPersistenceMechanismInstaller() {
- return new XmlPersistenceMechanismInstaller();
- }
-
- protected void resetPersistenceStore() {
- Files.deleteFiles("xml/objects", Files.and(endsWithXml(), notServicesXml()), Recursion.DO_RECURSE);
- }
-
- private static FilenameFilter notServicesXml() {
- return new FilenameFilter() {
-
- @Override
- public boolean accept(File parentDirectory, String fileName) {
- return !fileName.equals("services.xml");
- }
- };
- }
-
- private static FilenameFilter endsWithXml() {
- return Files.filterFileNameExtension(".xml");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_toRefactor.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_toRefactor.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_toRefactor.java
deleted file mode 100644
index f818aa3..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest_toRefactor.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jmock.Expectations;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
-import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
-
-public class XmlObjectStoreTest_toRefactor {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().with(new XmlPersistenceMechanismInstaller()).build();
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private XmlObjectStore objectStore;
-
- @Mock
- private PersistenceQueryBuiltIn persistenceHelper;
-
- private PersistenceCommandContext transaction;
-
- ObjectAdapter mockAdapter;
-
- private ObjectAdapter adapter1;
-
- private ObjectSpecification specification;
-
-
- @Before
- public void setUpSystem() throws Exception {
-
- // system
- objectStore = iswf.getObjectStore(XmlObjectStore.class);
- objectStore.setClock(new DefaultClock());
-
- // objects
-// adapter.setOptimisticLock(new SerialNumberVersion(23, null, null));
-// adapter.setupOid(RootOidDefault.createPersistent(objectType, ""+1));
-
- transaction = null;
- }
-
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void createSaveObjectCommand_setsVersionOnAdapter() throws Exception {
-
- allowingGetOidAndGetObjectAndTitleStringFromAdapter();
- context.checking(new Expectations() {
- {
- one(mockAdapter).setVersion(with(any(Version.class)));
- }
- });
- objectStore.createSaveObjectCommand(mockAdapter);
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void createCreateObjectCommand_andExecute_persistsNewInstance() throws Exception {
- // given
- final CreateObjectCommand command = objectStore.createCreateObjectCommand(adapter1);
- // when
- command.execute(transaction);
- // then
- assertFalse(objectStore.hasInstances(specification));
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesDestroyObjectCommand() throws Exception {
- final DestroyObjectCommand command = objectStore.createDestroyObjectCommand(adapter1);
- command.execute(transaction);
- assertFalse(objectStore.hasInstances(specification));
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesSaveObjectCommand() throws Exception {
- final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter1);
- command.execute(transaction);
- assertTrue(objectStore.hasInstances(specification));
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesGettingObjectStoreInstances() throws Exception {
- final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter1);
- objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
- final List<ObjectAdapter> array = objectStore.loadInstancesAndAdapt(persistenceHelper);
- assertTrue(array.size() == 1);
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesObjectStoreHasInstances() throws Exception {
- final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter1);
- objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
- assertTrue(objectStore.hasInstances(specification));
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesObjectStoreIfFixtureIsInstalled() throws Exception {
- final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter1);
- objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
- objectStore.open();
- assertTrue(objectStore.isFixturesInstalled());
- }
-
- @Ignore // DKH: refactor to use contract tests (see in-memory object store for basis)
- @Test
- public void validatesObjectStoreGetObject() throws Exception {
- final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter1);
- objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
- final ObjectAdapter retrievedAdapter = objectStore.loadInstanceAndAdapt((TypedOid) adapter1.getOid());
- assertTrue(retrievedAdapter.getOid().equals(adapter1.getOid()));
- }
-
-
- private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
- context.checking(new Expectations() {
- {
- allowing(mockAdapter).getOid();
- allowing(mockAdapter).getObject();
- allowing(mockAdapter).titleString();
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java
deleted file mode 100644
index 63a906c..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml;
-
-import static org.junit.Assert.assertTrue;
-
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
-
-public class XmlPersistenceMechanismInstallerTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
-
- private DeploymentType deploymentType;
- XmlPersistenceMechanismInstaller installer;
-
- @Mock
- private IsisConfiguration mockConfiguration;
-
- @Before
- public void setUpSystem() throws Exception {
- installer = new XmlPersistenceMechanismInstaller();
- installer.setConfiguration(mockConfiguration);
- }
-
- @Test
- public void testCreatePersistenceSessionFactory() throws Exception {
- deploymentType = DeploymentType.EXPLORATION;
- final PersistenceSessionFactory factory = installer.createPersistenceSessionFactory(deploymentType);
- assertTrue(factory != null);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java
deleted file mode 100644
index 88d8f93..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.clock;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-
-public class DefaultClockTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private DefaultClock clock;
-
-
- @Test
- public void testGetTime() {
- clock = new DefaultClock();
- assertTrue(clock.getTime() > 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java
deleted file mode 100644
index 714346a..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.clock;
-
-public class TestClock implements Clock {
- long time = 0;
-
- @Override
- public synchronized long getTime() {
- time += 1;
- return time;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java
deleted file mode 100644
index 5841437..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.data;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.testspec.ObjectSpecificationStub;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-
-public class ObjectDataTest extends TestCase {
-
- private String objectType = "CLK";
-
- public void testValueField() {
- FileVersion.setClock(new DefaultClock());
-
- final ObjectSpecificationStub type = new ObjectSpecificationStub("test");
- final ObjectData objectData = new ObjectData(RootOidDefault.create(ObjectSpecId.of(objectType), ""+13), FileVersion.create(""));
-
- assertEquals(null, objectData.get("name"));
- objectData.set("name", "value");
- assertEquals("value", objectData.get("name"));
-
- final Iterator<String> e = objectData.fields().iterator();
- e.next();
- assertFalse(e.hasNext());
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVectorTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVectorTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVectorTest.java
deleted file mode 100644
index 1d1adf2..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVectorTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.data;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.core.metamodel.adapter.oid.Oid.State;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.testspec.ObjectSpecificationStub;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-
-public class ObjectDataVectorTest {
-
- private final String objectType = "ODV";
-
- private ObjectDataVector objectDataVector;
- private ObjectData objectData;
- private ObjectSpecificationStub spec;
- private RootOidDefault oid;
- private Version version;
-
- @Before
- public void setUp() throws Exception {
- final ObjectSpecId objectSpecId = ObjectSpecId.of(objectType);
- oid = new RootOidDefault(objectSpecId, ""+1, State.TRANSIENT);
-
- spec = new ObjectSpecificationStub(this.getClass());
- spec.fields = Collections.emptyList();
-
- version = FileVersion.create("", System.currentTimeMillis());
- objectData = new ObjectData(oid, version);
- objectDataVector = new ObjectDataVector();
- }
-
- @Test
- public void validatesObjectDataIsStored() throws Exception {
- objectDataVector.addElement(objectData);
- assertTrue(objectDataVector.contains(objectData));
- assertTrue(objectDataVector.element(0).equals(objectData));
- }
-
- @Test
- public void validatesObjectDataVectorSize() throws Exception {
- objectDataVector.addElement(objectData);
- assertTrue(objectDataVector.size() == 1);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVectorTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVectorTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVectorTest.java
deleted file mode 100644
index 7b06036..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVectorTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.data;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-
-public class ReferenceVectorTest {
-
- private final String objectType = "FOO";
-
- private ListOfRootOid listOfRootOid;
- private RootOidDefault oid;
-
- @Before
- public void setUp() throws Exception {
- oid = RootOidDefault.createTransient(ObjectSpecId.of(objectType), ""+1);
- listOfRootOid = new ListOfRootOid();
- }
-
- @Test
- public void validatesSerialOidIsStoredInElements() throws Exception {
- listOfRootOid.add(oid);
- assertTrue(listOfRootOid.elementAt(0).equals(oid));
- }
-
- @Test
- public void validatesSerialOidIsRemovedInElements() throws Exception {
- listOfRootOid.add(oid);
- listOfRootOid.remove(oid);
- assertTrue(listOfRootOid.size() == 0);
- }
-
- @Test
- public void validatesReferenceVectorIsEqual() throws Exception {
- assertTrue(listOfRootOid.equals(listOfRootOid));
- assertTrue(listOfRootOid.equals(new ListOfRootOid()));
- assertFalse(listOfRootOid.equals(new Object()));
- }
-
- @Test
- public void validateReferenceVectorHashCode() throws Exception {
- assertTrue(listOfRootOid.hashCode() == 630);
- }
-
- @Test
- public void validateReferenceToString() throws Exception {
- assertTrue(listOfRootOid.toString() != null);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest.java
deleted file mode 100644
index 793ba66..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.data.xml;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.xml.XmlFile;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.runtimes.dflt.objectstores.xml.XmlPersistenceMechanismInstaller;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ListOfRootOid;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
-import org.apache.isis.tck.dom.xmlos.Role;
-import org.apache.isis.tck.dom.xmlos.Team;
-import org.apache.isis.tck.dom.xmlos.TeamDomainRepository;
-
-public class XmlDataManagerTest {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(new XmlPersistenceMechanismInstaller())
- .withServices(new TeamDomainRepository())
- .build();
-
- protected XmlDataManager manager;
-
- @Before
- public void setUp() throws Exception {
- FileVersion.setClock(new DefaultClock());
-
- clearTestDirectory();
- final String charset = Utils.lookupCharset(iswf.getIsisSystem().getConfiguration());
- manager = new XmlDataManager(new XmlFile(charset, "tmp/tests"));
- }
-
- protected static void clearTestDirectory() {
- final File directory = new File("tmp" + File.separator + "tests");
- final String[] files = directory.list(new FilenameFilter() {
- @Override
- public boolean accept(final File arg0, final String name) {
- return name.endsWith(".xml");
- }
- });
-
- if (files != null) {
- for (final String file : files) {
- new File(directory, file).delete();
- }
- }
- }
-
- @Test
- public void testWriteReadTypeOidAndVersion() {
- final ObjectData data = createData(Role.class, 99, FileVersion.create("user", 19));
- manager.insertObject(data);
-
- final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
-
- assertEquals(data.getRootOid(), read.getRootOid());
- assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
- assertEquals(data.getVersion(), read.getVersion());
- }
-
- @Test
- public void testNextId() throws Exception {
- final long first = manager.nextId();
- assertEquals(first + 1, manager.nextId());
- assertEquals(first + 2, manager.nextId());
- assertEquals(first + 3, manager.nextId());
- }
-
- @Test
- public void testInsertObjectWithFields() throws ObjectPersistenceException {
- final ObjectData data = createData(Role.class, 99, FileVersion.create("user", 13));
- data.set("Person", RootOidDefault.create(ObjectSpecId.of("RLE"), ""+101));
- assertNotNull(data.get("Person"));
- data.set("Name", "Harry");
- assertNotNull(data.get("Name"));
-
- manager.insertObject(data);
-
- final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
- assertEquals(data.getRootOid(), read.getRootOid());
- assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
-
- assertEquals(data.get("Person"), read.get("Person"));
- assertEquals(data.get("Name"), read.get("Name"));
- }
-
- @Test
- public void testInsertObjectWithEmptyOneToManyAssociations() throws ObjectPersistenceException {
- final ObjectData data = createData(Team.class, 99, FileVersion.create("user", 13));
-
- data.initCollection("Members");
-
- manager.insertObject(data);
-
- final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
- assertEquals(data.getRootOid(), read.getRootOid());
- assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
-
- final ListOfRootOid c = read.elements("Members");
- assertNull(c);
- }
-
- @Test
- public void testInsertObjectWithOneToManyAssociations() throws ObjectPersistenceException {
- final ObjectData data = createData(Team.class, 99, FileVersion.create("user", 13));
-
- data.initCollection("Members");
- final RootOidDefault oid[] = new RootOidDefault[3];
- for (int i = 0; i < oid.length; i++) {
- oid[i] = RootOidDefault.create(ObjectSpecId.of("TEA"), ""+ (104 + i));
- data.addElement("Members", oid[i]);
- }
- manager.insertObject(data);
-
- final ObjectData read = (ObjectData) manager.loadData(data.getRootOid());
- assertEquals(data.getRootOid(), read.getRootOid());
- assertEquals(data.getObjectSpecId(), read.getObjectSpecId());
-
- final ListOfRootOid c = read.elements("Members");
- for (int i = 0; i < oid.length; i++) {
- assertEquals(oid[i], c.elementAt(i));
- }
- }
-
-
- private ObjectData createData(final Class<?> type, final long id, final Version version) {
-
- final ObjectSpecification objSpec = IsisContext.getSpecificationLoader().loadSpecification(type);
- final ObjectSpecId objectSpecId = objSpec.getSpecId();
- final RootOidDefault oid = RootOidDefault.create(objectSpecId, ""+id);
- return new ObjectData(oid, version);
- }
- /*
- * public void xxxtestInsertValues() throws ObjectStoreException {
- * ObjectSpecification type =
- * Isis.getSpecificationLoader().loadSpecification
- * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
- * ObjectData data = new ObjectData(type, oid);
- *
- *
- * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
- *
- * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
- * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
- * floatingPoint1);
- *
- * Label label1 = new Label(); label1.setValue("Labelled");
- * data.saveValue("Label", label1);
- *
- * Logical logical1 = new Logical(); logical1.setValue(true);
- * data.saveValue("Logical", logical1);
- *
- * Money money1 = new Money(); money1.setValue(1233.45);
- * data.saveValue("Money", money1);
- *
- * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
- * data.saveValue("Option", option1);
- *
- * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
- * data.saveValue("Percentage", percentage1);
- *
- * TextString textString1 = new TextString("Fred");
- * data.saveValue("Text String", textString1);
- *
- * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
- * data.saveValue("Time Stamp", timestamp1);
- *
- * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
- *
- * URLString urlString1 = new URLString("http://isis.apache.org/");
- * data.saveValue("Url String", urlString1);
- *
- * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
- * data.saveValue("Whole Number", number1);
- *
- *
- * manager.insert(data);
- *
- *
- *
- * ObjectData object = manager.loadObjectData(oid);
- *
- * Date date2 = new Date(); object.restoreValue("Date", date2);
- * assertEquals(date1, date2);
- *
- * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
- * object.restoreValue("Floating Point", floatingPoint2);
- * assertEquals(floatingPoint1, floatingPoint2);
- *
- * Label label2 = new Label(); object.restoreValue("Label", label2);
- * assertEquals(label1, label2);
- *
- * Logical logical2 = new Logical(); object.restoreValue("Logical",
- * logical2); assertEquals(logical1, logical2);
- *
- * Money money2 = new Money(); object.restoreValue("Money", money2);
- * assertEquals(money1, money2);
- *
- * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
- * object.restoreValue("Option", option2); assertEquals(option1, option2);
- *
- * Percentage percentage2 = new Percentage();
- * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
- * percentage2);
- *
- * Time time2 = new Time(); object.restoreValue("Time", time2);
- * assertEquals(time1, time2);
- *
- * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
- * timestamp2); assertEquals(timestamp1, timestamp2);
- *
- * TextString textString2 = new TextString();
- * object.restoreValue("Text String", textString2);
- * assertEquals(textString1, textString2);
- *
- * URLString urlString2 = new URLString(); object.restoreValue("Url String",
- * urlString2); assertEquals(urlString1, urlString2);
- *
- * WholeNumber number2 = new WholeNumber();
- * object.restoreValue("Whole Number", number2); assertEquals(number1,
- * number2); }
- *
- * public void xxxtestSaveValues() throws ObjectStoreException {
- * ObjectSpecification type =
- * Isis.getSpecificationLoader().loadSpecification
- * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
- * ObjectData data = new ObjectData(type, oid);
- *
- * manager.insert(data);
- *
- *
- * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
- *
- * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
- * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
- * floatingPoint1);
- *
- * Label label1 = new Label(); label1.setValue("Labelled");
- * data.saveValue("Label", label1);
- *
- * Logical logical1 = new Logical(); logical1.setValue(true);
- * data.saveValue("Logical", logical1);
- *
- * Money money1 = new Money(); money1.setValue(1233.45);
- * data.saveValue("Money", money1);
- *
- * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
- * data.saveValue("Option", option1);
- *
- * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
- * data.saveValue("Percentage", percentage1);
- *
- * TextString textString1 = new TextString("Fred");
- * data.saveValue("Text String", textString1);
- *
- * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
- * data.saveValue("Time Stamp", timestamp1);
- *
- * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
- *
- * URLString urlString1 = new URLString("http://isis.apache.org/");
- * data.saveValue("Url String", urlString1);
- *
- * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
- * data.saveValue("Whole Number", number1);
- *
- *
- * manager.save(data);
- *
- *
- *
- * ObjectData object = manager.loadObjectData(oid);
- *
- * Date date2 = new Date(); object.restoreValue("Date", date2);
- * assertEquals(date1, date2);
- *
- * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
- * object.restoreValue("Floating Point", floatingPoint2);
- * assertEquals(floatingPoint1, floatingPoint2);
- *
- * Label label2 = new Label(); object.restoreValue("Label", label2);
- * assertEquals(label1, label2);
- *
- * Logical logical2 = new Logical(); object.restoreValue("Logical",
- * logical2); assertEquals(logical1, logical2);
- *
- * Money money2 = new Money(); object.restoreValue("Money", money2);
- * assertEquals(money1, money2);
- *
- * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
- * object.restoreValue("Option", option2); assertEquals(option1, option2);
- *
- * Percentage percentage2 = new Percentage();
- * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
- * percentage2);
- *
- * Time time2 = new Time(); object.restoreValue("Time", time2);
- * assertEquals(time1, time2);
- *
- * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
- * timestamp2); assertEquals(timestamp1, timestamp2);
- *
- * TextString textString2 = new TextString();
- * object.restoreValue("Text String", textString2);
- * assertEquals(textString1, textString2);
- *
- * URLString urlString2 = new URLString(); object.restoreValue("Url String",
- * urlString2); assertEquals(urlString1, urlString2);
- *
- * WholeNumber number2 = new WholeNumber();
- * object.restoreValue("Whole Number", number2); assertEquals(number1,
- * number2);
- *
- * }
- */
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest_instances.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest_instances.java b/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest_instances.java
deleted file mode 100644
index df056ae..0000000
--- a/component/objectstore/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest_instances.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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.runtimes.dflt.objectstores.xml.internal.data.xml;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.xml.XmlFile;
-import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.runtimes.dflt.objectstores.xml.XmlPersistenceMechanismInstaller;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectDataVector;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
-import org.apache.isis.tck.dom.xmlos.TeamDomainRepository;
-
-public class XmlDataManagerTest_instances {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(new XmlPersistenceMechanismInstaller())
- .withServices(new TeamDomainRepository())
- .build();
-
- protected XmlDataManager manager;
- protected final int SIZE = 5;
-
- private RootOid oids[];
- private ObjectData data[];
- private ObjectData pattern;
-
- @Before
- public void setUp() throws Exception {
-
- clearTestDirectory();
- final String charset = Utils.lookupCharset(iswf.getIsisSystem().getConfiguration());
- manager = new XmlDataManager(new XmlFile(charset, "tmp/tests"));
-
- FileVersion.setClock(new DefaultClock());
-
- oids = new RootOid[SIZE];
- data = new ObjectData[SIZE];
-
- pattern = new ObjectData(RootOidDefault.deString("RLE:1", new OidMarshaller()), FileVersion.create("user", 13));
- for (int i = 0; i < SIZE; i++) {
- oids[i] = RootOidDefault.create(ObjectSpecId.of("RLE"), ""+i);
- data[i] = new ObjectData(oids[i], FileVersion.create("user", 13));
- manager.insertObject(data[i]);
- }
- }
-
- protected static void clearTestDirectory() {
- final File directory = new File("tmp" + File.separator + "tests");
- final String[] files = directory.list(new FilenameFilter() {
- @Override
- public boolean accept(final File arg0, final String name) {
- return name.endsWith(".xml");
- }
- });
-
- if (files != null) {
- for (final String file : files) {
- new File(directory, file).delete();
- }
- }
- }
-
-
- @Test
- public void testNumberOfInstances() {
- assertEquals(SIZE, manager.numberOfInstances(pattern));
- }
-
- @Test
- public void testRemove() throws Exception {
- final RootOid oid = oids[2];
- manager.remove(oid);
-
- assertEquals(SIZE - 1, manager.numberOfInstances(pattern));
-
- final ObjectDataVector instances = manager.getInstances(pattern);
- for (int i = 0; i < instances.size(); i++) {
- assertFalse(instances.element(i) == data[2]);
- }
-
- assertNull((manager.loadData(oid)));
- }
-
- @Test
- public void testSaveObject() throws Exception {
- data[2].set("Person", RootOidDefault.create(ObjectSpecId.of("PER"), ""+231));
- data[2].set("Name", "Fred");
- manager.save(data[2]);
-
- assertTrue(manager.getInstances(pattern).contains(data[2]));
- final ObjectData read = (ObjectData) manager.loadData(oids[2]);
- assertEquals(data[2], read);
- assertEquals(data[2].get("Name"), read.get("Name"));
- assertEquals(data[2].get("Person"), read.get("Person"));
- }
-
- /*
- * public void xxxtestInsertValues() throws ObjectStoreException {
- * ObjectSpecification type =
- * Isis.getSpecificationLoader().loadSpecification
- * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
- * ObjectData data = new ObjectData(type, oid);
- *
- *
- * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
- *
- * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
- * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
- * floatingPoint1);
- *
- * Label label1 = new Label(); label1.setValue("Labelled");
- * data.saveValue("Label", label1);
- *
- * Logical logical1 = new Logical(); logical1.setValue(true);
- * data.saveValue("Logical", logical1);
- *
- * Money money1 = new Money(); money1.setValue(1233.45);
- * data.saveValue("Money", money1);
- *
- * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
- * data.saveValue("Option", option1);
- *
- * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
- * data.saveValue("Percentage", percentage1);
- *
- * TextString textString1 = new TextString("Fred");
- * data.saveValue("Text String", textString1);
- *
- * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
- * data.saveValue("Time Stamp", timestamp1);
- *
- * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
- *
- * URLString urlString1 = new URLString("http://isis.apache.org/");
- * data.saveValue("Url String", urlString1);
- *
- * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
- * data.saveValue("Whole Number", number1);
- *
- *
- * manager.insert(data);
- *
- *
- *
- * ObjectData object = manager.loadObjectData(oid);
- *
- * Date date2 = new Date(); object.restoreValue("Date", date2);
- * assertEquals(date1, date2);
- *
- * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
- * object.restoreValue("Floating Point", floatingPoint2);
- * assertEquals(floatingPoint1, floatingPoint2);
- *
- * Label label2 = new Label(); object.restoreValue("Label", label2);
- * assertEquals(label1, label2);
- *
- * Logical logical2 = new Logical(); object.restoreValue("Logical",
- * logical2); assertEquals(logical1, logical2);
- *
- * Money money2 = new Money(); object.restoreValue("Money", money2);
- * assertEquals(money1, money2);
- *
- * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
- * object.restoreValue("Option", option2); assertEquals(option1, option2);
- *
- * Percentage percentage2 = new Percentage();
- * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
- * percentage2);
- *
- * Time time2 = new Time(); object.restoreValue("Time", time2);
- * assertEquals(time1, time2);
- *
- * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
- * timestamp2); assertEquals(timestamp1, timestamp2);
- *
- * TextString textString2 = new TextString();
- * object.restoreValue("Text String", textString2);
- * assertEquals(textString1, textString2);
- *
- * URLString urlString2 = new URLString(); object.restoreValue("Url String",
- * urlString2); assertEquals(urlString1, urlString2);
- *
- * WholeNumber number2 = new WholeNumber();
- * object.restoreValue("Whole Number", number2); assertEquals(number1,
- * number2); }
- *
- * public void xxxtestSaveValues() throws ObjectStoreException {
- * ObjectSpecification type =
- * Isis.getSpecificationLoader().loadSpecification
- * (ValueObjectExample.class.getName()); SerialOid oid = new SerialOid(99);
- * ObjectData data = new ObjectData(type, oid);
- *
- * manager.insert(data);
- *
- *
- * Date date1 = new Date(); date1.add(1,2,3); data.saveValue("Date", date1);
- *
- * FloatingPointNumber floatingPoint1 = new FloatingPointNumber();
- * floatingPoint1.setValue(3.145); data.saveValue("Floating Point",
- * floatingPoint1);
- *
- * Label label1 = new Label(); label1.setValue("Labelled");
- * data.saveValue("Label", label1);
- *
- * Logical logical1 = new Logical(); logical1.setValue(true);
- * data.saveValue("Logical", logical1);
- *
- * Money money1 = new Money(); money1.setValue(1233.45);
- * data.saveValue("Money", money1);
- *
- * Option option1 = new Option(new String[] {"Fred", "Sam", "joe"}, 1);
- * data.saveValue("Option", option1);
- *
- * Percentage percentage1 = new Percentage(); percentage1.setValue(95);
- * data.saveValue("Percentage", percentage1);
- *
- * TextString textString1 = new TextString("Fred");
- * data.saveValue("Text String", textString1);
- *
- * DateTime timestamp1 = new DateTime(); timestamp1.add(1,2,3);
- * data.saveValue("Time Stamp", timestamp1);
- *
- * Time time1 = new Time(); time1.add(1,30); data.saveValue("Time", time1);
- *
- * URLString urlString1 = new URLString("http://isis.apache.org/");
- * data.saveValue("Url String", urlString1);
- *
- * WholeNumber number1 = new WholeNumber(); number1.setValue(435422);
- * data.saveValue("Whole Number", number1);
- *
- *
- * manager.save(data);
- *
- *
- *
- * ObjectData object = manager.loadObjectData(oid);
- *
- * Date date2 = new Date(); object.restoreValue("Date", date2);
- * assertEquals(date1, date2);
- *
- * FloatingPointNumber floatingPoint2 = new FloatingPointNumber();
- * object.restoreValue("Floating Point", floatingPoint2);
- * assertEquals(floatingPoint1, floatingPoint2);
- *
- * Label label2 = new Label(); object.restoreValue("Label", label2);
- * assertEquals(label1, label2);
- *
- * Logical logical2 = new Logical(); object.restoreValue("Logical",
- * logical2); assertEquals(logical1, logical2);
- *
- * Money money2 = new Money(); object.restoreValue("Money", money2);
- * assertEquals(money1, money2);
- *
- * Option option2 = new Option(new String [] {"Fred", "Sam", "joe"});
- * object.restoreValue("Option", option2); assertEquals(option1, option2);
- *
- * Percentage percentage2 = new Percentage();
- * object.restoreValue("Percentage", percentage2); assertEquals(percentage1,
- * percentage2);
- *
- * Time time2 = new Time(); object.restoreValue("Time", time2);
- * assertEquals(time1, time2);
- *
- * DateTime timestamp2 = new DateTime(); object.restoreValue("Time Stamp",
- * timestamp2); assertEquals(timestamp1, timestamp2);
- *
- * TextString textString2 = new TextString();
- * object.restoreValue("Text String", textString2);
- * assertEquals(textString1, textString2);
- *
- * URLString urlString2 = new URLString(); object.restoreValue("Url String",
- * urlString2); assertEquals(urlString1, urlString2);
- *
- * WholeNumber number2 = new WholeNumber();
- * object.restoreValue("Whole Number", number2); assertEquals(number1,
- * number2);
- *
- * }
- */
-}