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/04/27 12:47:20 UTC
svn commit: r1331346 - in /incubator/isis/branches/0.3.0-incubating-NEW-OIDs:
core/commons/src/main/java/org/apache/isis/core/commons/matchers/
runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/
runtimes/df...
Author: danhaywood
Date: Fri Apr 27 10:47:18 2012
New Revision: 1331346
URL: http://svn.apache.org/viewvc?rev=1331346&view=rev
Log:
ISIS-214: runtimes.dflt.testsupport tests are now green again
Added:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java (with props)
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java (with props)
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java
- copied, changed from r1307477, incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data (with props)
Removed:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/memento/
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/profilestores/dflt/
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest.java
Modified:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureService.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest_encodedData.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorSessionHydratorTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/RuntimeTestPojo.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/eg/ExamplePojoWithCollections.java
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java Fri Apr 27 10:47:18 2012
@@ -308,5 +308,35 @@ public final class IsisMatchers {
};
}
+ public static Matcher<String> startsWith(final String expected) {
+ return new TypeSafeMatcher<String>() {
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" starts with '" + expected + "'");
+ }
+
+ @Override
+ public boolean matchesSafely(String actual) {
+ return actual.startsWith(expected);
+ }
+ };
+ }
+
+ public static Matcher<String> contains(final String expected) {
+ return new TypeSafeMatcher<String>() {
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" contains '" + expected + "'");
+ }
+
+ @Override
+ public boolean matchesSafely(String actual) {
+ return actual.contains(expected);
+ }
+ };
+ }
+
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java Fri Apr 27 10:47:18 2012
@@ -250,7 +250,7 @@ public class ObjectReaderTest {
assertEquals(ResolveState.RESOLVED, readObject.getResolveState());
final ExamplePojoWithCollections pojo = (ExamplePojoWithCollections) readObject.getObject();
- final List<ExamplePojoWithValues> collection2 = pojo.getHomogenousCollection();
+ final List<ExamplePojoWithValues> collection2 = pojo.getHomogeneousCollection();
assertEquals(2, collection2.size());
assertThat(collection2.get(0), CoreMatchers.instanceOf(ExamplePojoWithValues.class));
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java Fri Apr 27 10:47:18 2012
@@ -92,8 +92,8 @@ public class WriteObjectCommandTest {
epr1Adapter = iswf.remapAsPersistent(RootOidDefault.create("EPR|1"), epr1);
epc1 = iswf.fixtures.epc1;
- epc1.getHomogenousCollection().add(epv1);
- epc1.getHomogenousCollection().add(epv2);
+ epc1.getHomogeneousCollection().add(epv1);
+ epc1.getHomogeneousCollection().add(epv2);
epc1Adapter = iswf.remapAsPersistent(RootOidDefault.create("EPC|1"), epc1Adapter);
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureService.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureService.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureService.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureService.java Fri Apr 27 10:47:18 2012
@@ -34,7 +34,6 @@ import org.apache.log4j.Logger;
import org.apache.isis.applib.AbstractService;
import org.apache.isis.applib.annotation.DescribedAs;
import org.apache.isis.applib.annotation.Exploration;
-import org.apache.isis.applib.annotation.Hidden;
import org.apache.isis.applib.annotation.Ignore;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.core.commons.config.ConfigurationConstants;
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java Fri Apr 27 10:47:18 2012
@@ -142,8 +142,8 @@ public class IsisSystemWithFixtures impl
return this;
}
- public Builder with(Initialization fixturesInitialization) {
- this.fixturesInitialization = fixturesInitialization;
+ public Builder with(Initialization initialization) {
+ this.fixturesInitialization = initialization;
return this;
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java Fri Apr 27 10:47:18 2012
@@ -39,19 +39,20 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.tck.dom.eg.ExamplePojoWithCollections;
+import org.apache.isis.tck.dom.eg.ExamplePojoWithReferences;
import org.apache.isis.tck.dom.eg.ExamplePojoWithValues;
-import org.apache.isis.tck.dom.movies.Person;
public class ObjectFixtureFilePersistorTest {
- private static final String PACKAGE_BASE = "org.apache.isis.core.testsupport";
-
@Rule
public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
private ObjectFixtureFilePersistor persistor;
+ @SuppressWarnings("deprecation")
@Before
public void setup() {
Logger.getRootLogger().setLevel(Level.OFF);
@@ -67,12 +68,12 @@ public class ObjectFixtureFilePersistorT
iswf.fixtures.epv2.setDate(new Date(111, 3, 9, 1, 10));
}
-
+ @SuppressWarnings("deprecation")
@Test
public void loadInstance() throws Exception {
- final StringReader reader = new StringReader(PACKAGE_BASE + ".testdomain.Person#1\n name: Fred Smith\n date: 08-Mar-2010 00:00");
+ final StringReader reader = new StringReader(ExamplePojoWithValues.class.getName() + "#1\n name: Fred Smith\n date: 08-Mar-2010 00:00");
final Set<Object> objects = persistor.loadData(reader);
Assert.assertEquals(1, objects.size());
@@ -86,7 +87,7 @@ public class ObjectFixtureFilePersistorT
@Test
public void invalidFieldLine() throws Exception {
try {
- final StringReader reader = new StringReader(PACKAGE_BASE + ".testdomain.Person#1\n name Fred Smith");
+ final StringReader reader = new StringReader(ExamplePojoWithValues.class.getName() + "#1\n name Fred Smith");
persistor.loadData(reader);
Assert.fail();
} catch (final FixtureException e) {
@@ -97,10 +98,10 @@ public class ObjectFixtureFilePersistorT
@Test
public void oldFieldNameSkipped() throws Exception {
- final StringReader reader = new StringReader(PACKAGE_BASE + ".testdomain.Person#1\n xname: Fred Smith");
+ final StringReader reader = new StringReader(ExamplePojoWithValues.class.getName() + "#1\n xname: Fred Smith");
final Set<Object> objects = persistor.loadData(reader);
final Object object = objects.toArray()[0];
- Assert.assertNull(((Person) object).getName());
+ Assert.assertNull(((ExamplePojoWithValues) object).getName());
}
@@ -120,12 +121,11 @@ public class ObjectFixtureFilePersistorT
final StringWriter out = new StringWriter();
persistor.save(objects, out);
- final String string1 = PACKAGE_BASE + ".testdomain.Person#2\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
- final String string2 = PACKAGE_BASE + ".testdomain.Person#2\r\n date: 08-Mar-2010 00:00\r\n name: Fred Smith\r\n";
- // *nix vs Windows?
- if ((out.toString().compareTo(string1) != 0) && (out.toString().compareTo(string2) != 0)) {
- Assert.assertEquals(string1, out.toString());
- }
+ final String actual = out.toString().replaceAll("\r\n", "\n");
+
+ final String expected = ExamplePojoWithValues.class.getName() + "#2\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
+
+ assertThat(actual, IsisMatchers.startsWith(expected));
}
@Test
@@ -136,31 +136,59 @@ public class ObjectFixtureFilePersistorT
final StringWriter out = new StringWriter();
persistor.save(objects, out);
+ final String actual = out.toString().replaceAll("\r\n", "\n");
- // *nix vs Windows?
- final String string1 = PACKAGE_BASE + ".testdomain.Person#2\n date: 08-Mar-2010 00:00\n name: Fred Smith\n" + PACKAGE_BASE + ".testdomain.Person#3\n date: \n name: \n";
- final String string2 = PACKAGE_BASE + ".testdomain.Person#2\r\n date: 08-Mar-2010 00:00\r\n name: Fred Smith\r\n" + PACKAGE_BASE + ".testdomain.Person#3\r\n date: \r\n name: \r\n";
- if ((out.toString().compareTo(string1) != 0) && (out.toString().compareTo(string2) != 0)) {
- Assert.assertEquals(string1, out.toString());
- }
+ final String expected1 = ExamplePojoWithValues.class.getName() + "#2\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
+ final String expected2 = ExamplePojoWithValues.class.getName() + "#3\n date: \n name: \n";
+ assertThat(actual, IsisMatchers.contains(expected1));
+ assertThat(actual, IsisMatchers.contains(expected2));
}
@Test
- public void saveAssociatedObjects() throws Exception {
+ public void saveReferencedObject() throws Exception {
final Set<Object> objects = Sets.newLinkedHashSet();
+
+ iswf.fixtures.epr1.setReference(iswf.fixtures.epv1);
+ objects.add(iswf.fixtures.epr1);
objects.add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv2);
+
+ final StringWriter out = new StringWriter();
+ persistor.save(objects, out);
+ final String actual = out.toString().replaceAll("\r\n", "\n");
+
+ final String expected1 = ExamplePojoWithReferences.class.getName() + "#2\n aggregatedReference: \n reference: " + ExamplePojoWithValues.class.getName() + "#3";
+ final String expected2 = ExamplePojoWithValues.class.getName() + "#3\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
+ assertThat(actual, IsisMatchers.contains(expected1));
+ assertThat(actual, IsisMatchers.contains(expected2));
+ }
+
+
+ @Test
+ public void saveObjectAndAssociatedCollection() throws Exception {
+
+ final Set<Object> objects = Sets.newLinkedHashSet();
+
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv1);
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv2);
objects.add(iswf.fixtures.epc1);
+ objects.add(iswf.fixtures.epv1);
+ objects.add(iswf.fixtures.epv2);
+
final StringWriter out = new StringWriter();
persistor.save(objects, out);
- final String string1 = PACKAGE_BASE + ".testdomain.Movie#2\n director: " + PACKAGE_BASE + ".testdomain.Person#3\n name: The Blockbuster\n roles: \n" + PACKAGE_BASE + ".testdomain.Person#3\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
- final String string2 = PACKAGE_BASE + ".testdomain.Movie#2\r\n director: " + PACKAGE_BASE + ".testdomain.Person#3\r\n name: The Blockbuster\r\n roles: \r\n" + PACKAGE_BASE + ".testdomain.Person#3\r\n date: 08-Mar-2010 00:00\r\n name: Fred Smith\r\n";
- if ((out.toString().compareTo(string1) != 0) && (out.toString().compareTo(string2) != 0)) {
- Assert.assertEquals(string1, out.toString());
- }
+ final String actual = out.toString().replaceAll("\r\n", "\n");
+
+ final String expected1 = ExamplePojoWithCollections.class.getName() + "#2\n heterogeneousCollection: \n homogeneousCollection: " + ExamplePojoWithValues.class.getName() + "#3 " + ExamplePojoWithValues.class.getName() + "#4 " + "\n";
+ final String expected2 = ExamplePojoWithValues.class.getName() + "#3\n date: 08-Mar-2010 00:00\n name: Fred Smith\n";
+ final String expected3 = ExamplePojoWithValues.class.getName() + "#4\n date: 09-Apr-2011 01:10\n name: Joe Bloggs\n";
+ assertThat(actual.replaceAll("\n", "###"), IsisMatchers.contains(expected1.replaceAll("\n", "###")));
+ assertThat(actual, IsisMatchers.contains(expected2));
+ assertThat(actual, IsisMatchers.contains(expected3));
}
+
+
}
+
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java?rev=1331346&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java Fri Apr 27 10:47:18 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.runtime.fixturedomainservice;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Date;
+import java.util.Locale;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.tck.dom.eg.ExamplePojoWithValues;
+import org.apache.isis.tck.dom.movies.Person;
+
+public class ObjectFixtureServiceTest_loadFile {
+
+ private static IsisConfiguration configuration() {
+ IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+ configuration.add(ConfigurationConstants.ROOT + "exploration-objects.file", "test.data");
+ return configuration;
+ }
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().with(configuration()).build();
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ private ObjectFixtureService service;
+
+
+ @Before
+ public void setup() {
+ Logger.getRootLogger().setLevel(Level.OFF);
+ Locale.setDefault(Locale.UK);
+
+ service = new ObjectFixtureService();
+ }
+
+
+ @Test
+ public void loadFile() throws Exception {
+
+ // when
+ service.loadFile();
+
+ // then
+ final Set<Object> objects = service.allSavedObjects();
+ Assert.assertEquals(1, objects.size());
+ final Object object = objects.toArray()[0];
+ assertThat(object instanceof ExamplePojoWithValues, is(true));
+ Assert.assertEquals("Fred Smith", ((ExamplePojoWithValues) object).getName());
+ Assert.assertEquals(new Date(110, 2, 8, 13, 32), ((ExamplePojoWithValues) object).getDate());
+ }
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java?rev=1331346&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java Fri Apr 27 10:47:18 2012
@@ -0,0 +1,71 @@
+/*
+ * 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.runtime.fixturedomainservice;
+
+import java.io.File;
+import java.util.Locale;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+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;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+
+public class ObjectFixtureServiceTest_loadFile_nothingExists {
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ private ObjectFixtureService service;
+
+
+ @Before
+ public void setup() {
+ Logger.getRootLogger().setLevel(Level.OFF);
+ Locale.setDefault(Locale.UK);
+
+ service = new ObjectFixtureService();
+ deleteFixtureData();
+ }
+
+
+ private static void deleteFixtureData() {
+ new File("fixture-data").delete();
+ }
+
+ @Test
+ public void loadNothingIfNoFileExists() throws Exception {
+ service.loadFile();
+
+ final Set<Object> objects = service.allSavedObjects();
+ Assert.assertEquals(0, objects.size());
+ }
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java (from r1307477, incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest.java)
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java?p2=incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java&p1=incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest.java&r1=1307477&r2=1331346&rev=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java Fri Apr 27 10:47:18 2012
@@ -19,9 +19,6 @@
package org.apache.isis.runtimes.dflt.runtime.fixturedomainservice;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
import java.io.File;
import java.util.Date;
import java.util.Locale;
@@ -35,16 +32,13 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
import org.apache.isis.tck.dom.eg.ExamplePojoWithCollections;
import org.apache.isis.tck.dom.eg.ExamplePojoWithValues;
-import org.apache.isis.tck.dom.movies.Person;
-public class ObjectFixtureServiceTest {
+public class ObjectFixtureServiceTest_save {
@Rule
public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
@@ -54,6 +48,7 @@ public class ObjectFixtureServiceTest {
private ObjectFixtureService service;
+
@Before
public void setup() {
Logger.getRootLogger().setLevel(Level.OFF);
@@ -63,36 +58,11 @@ public class ObjectFixtureServiceTest {
deleteFixtureData();
}
+
private static void deleteFixtureData() {
new File("fixture-data").delete();
}
- @Test
- public void loadNothingIfNoFileExists() throws Exception {
- service.loadFile();
-
- final Set<Object> objects = service.allSavedObjects();
- Assert.assertEquals(0, objects.size());
- }
-
- @Test
- public void loadInstanceFromFile() throws Exception {
-
- // given
- IsisConfigurationDefault configuration = new IsisConfigurationDefault();
- configuration.add(ConfigurationConstants.ROOT + "exploration-objects.file", "test.data");
-
- // when
- service.loadFile();
-
- // then
- final Set<Object> objects = service.allSavedObjects();
- Assert.assertEquals(1, objects.size());
- final Object object = objects.toArray()[0];
- assertThat(object instanceof Person, is(true));
- Assert.assertEquals("Fred Smith", ((Person) object).getName());
- Assert.assertEquals(new Date(110, 2, 8, 13, 32), ((Person) object).getDate());
- }
@Test
public void saveObjectAddedToList() throws Exception {
@@ -102,12 +72,11 @@ public class ObjectFixtureServiceTest {
epv.setDate(new Date(110, 2, 8, 13, 32));
final ExamplePojoWithCollections epc = iswf.fixtures.epc1;
- epc.getHomogenousCollection().add(iswf.fixtures.epv1);
- epc.getHomogenousCollection().add(iswf.fixtures.epv2);
+ epc.getHomogeneousCollection().add(iswf.fixtures.epv1);
+ epc.getHomogeneousCollection().add(iswf.fixtures.epv2);
service.save(epc);
final Set<Object> savedObjects = service.allSavedObjects();
- Assert.assertEquals(4, savedObjects.size());
+ Assert.assertEquals(3, savedObjects.size());
}
-
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java Fri Apr 27 10:47:18 2012
@@ -90,11 +90,11 @@ public class MementoTest {
iswf.fixtures.epr1.setReference(iswf.fixtures.epv1);
iswf.fixtures.epr1.setAggregatedReference(iswf.fixtures.epr1_a1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv2);
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv1);
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv2);
- iswf.fixtures.epc1.getHeterogenousCollection().add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHeterogenousCollection().add(iswf.fixtures.epr1);
+ iswf.fixtures.epc1.getHeterogeneousCollection().add(iswf.fixtures.epv1);
+ iswf.fixtures.epc1.getHeterogeneousCollection().add(iswf.fixtures.epr1);
originalAdapterForEpv1 = iswf.adapterFor(iswf.fixtures.epv1);
originalAdapterForEpr1 = iswf.adapterFor(iswf.fixtures.epr1);
@@ -181,7 +181,7 @@ public class MementoTest {
public void recreateObject_homogeneousCollectionPreserved() throws Exception {
recreatedAdapter = mementoForEpc1.recreateObject();
final ExamplePojoWithCollections recreatedObject = (ExamplePojoWithCollections)recreatedAdapter.getObject();
- final List<ExamplePojoWithValues> homogenousCollection = recreatedObject.getHomogenousCollection();
+ final List<ExamplePojoWithValues> homogenousCollection = recreatedObject.getHomogeneousCollection();
assertNotNull(homogenousCollection);
assertThat(homogenousCollection.size(), is(2));
@@ -193,7 +193,7 @@ public class MementoTest {
public void recreateObject_heterogeneousCollectionPreserved() throws Exception {
recreatedAdapter = mementoForEpc1.recreateObject();
final ExamplePojoWithCollections recreatedObject = (ExamplePojoWithCollections)recreatedAdapter.getObject();
- final List<ExamplePojo> hetrogenousCollection = recreatedObject.getHeterogenousCollection();
+ final List<ExamplePojo> hetrogenousCollection = recreatedObject.getHeterogeneousCollection();
assertNotNull(hetrogenousCollection);
assertThat(hetrogenousCollection.size(), is(2));
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest_encodedData.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest_encodedData.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest_encodedData.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest_encodedData.java Fri Apr 27 10:47:18 2012
@@ -54,11 +54,11 @@ public class MementoTest_encodedData {
iswf.fixtures.epr1.setReference(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHomogenousCollection().add(iswf.fixtures.epv2);
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv1);
+ iswf.fixtures.epc1.getHomogeneousCollection().add(iswf.fixtures.epv2);
- iswf.fixtures.epc1.getHeterogenousCollection().add(iswf.fixtures.epv1);
- iswf.fixtures.epc1.getHeterogenousCollection().add(iswf.fixtures.epr1);
+ iswf.fixtures.epc1.getHeterogeneousCollection().add(iswf.fixtures.epv1);
+ iswf.fixtures.epc1.getHeterogeneousCollection().add(iswf.fixtures.epr1);
rootAdapter = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(iswf.fixtures.epv1);
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorSessionHydratorTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorSessionHydratorTest.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorSessionHydratorTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorSessionHydratorTest.java Fri Apr 27 10:47:18 2012
@@ -37,6 +37,7 @@ import org.apache.isis.core.testsupport.
import org.apache.isis.runtimes.dflt.objectstores.dflt.InMemoryPersistenceMechanismInstaller;
import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures.Fixtures.Initialization;
import org.apache.isis.tck.dom.eg.ExamplePojoRepository;
import org.apache.isis.tck.dom.eg.ExamplePojoWithValues;
import org.apache.isis.tck.dom.eg.TestPojoRepository;
@@ -78,11 +79,14 @@ public class PersistorSessionHydratorTes
@Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().with(new InMemoryPersistenceMechanismInstaller() {
- protected OidGenerator createOidGenerator(IsisConfiguration configuration) {
- return mockOidGenerator;
- };
- }).build();
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+ .with(Initialization.NO_INIT)
+ .with(new InMemoryPersistenceMechanismInstaller() {
+ protected OidGenerator createOidGenerator(IsisConfiguration configuration) {
+ return mockOidGenerator;
+ };
+ })
+ .build();
@Test
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/RuntimeTestPojo.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/RuntimeTestPojo.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/RuntimeTestPojo.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/RuntimeTestPojo.java Fri Apr 27 10:47:18 2012
@@ -19,6 +19,7 @@
package org.apache.isis.runtimes.dflt.runtime.persistence;
public class RuntimeTestPojo {
+
private static int nextId;
private final int id = nextId++;
private final String state = "pojo" + id;
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data?rev=1331346&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data Fri Apr 27 10:47:18 2012
@@ -0,0 +1,5 @@
+org.apache.isis.tck.dom.eg.ExamplePojoWithValues#4
+ date: 08-Mar-2010 13:32
+ name: Fred Smith
+ nullable:
+ size: 0
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/test.data
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/eg/ExamplePojoWithCollections.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/eg/ExamplePojoWithCollections.java?rev=1331346&r1=1331345&r2=1331346&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/eg/ExamplePojoWithCollections.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/eg/ExamplePojoWithCollections.java Fri Apr 27 10:47:18 2012
@@ -28,28 +28,28 @@ import org.apache.isis.applib.annotation
@ObjectType("EPC")
public class ExamplePojoWithCollections extends ExamplePojo {
- // {{ HomogenousCollection
- private List<ExamplePojoWithValues> homogenousCollection = new ArrayList<ExamplePojoWithValues>();
+ // {{ HomogeneousCollection
+ private List<ExamplePojoWithValues> homogeneousCollection = new ArrayList<ExamplePojoWithValues>();
- public List<ExamplePojoWithValues> getHomogenousCollection() {
- return homogenousCollection;
+ public List<ExamplePojoWithValues> getHomogeneousCollection() {
+ return homogeneousCollection;
}
- public void setHomogenousCollection(final List<ExamplePojoWithValues> homogenousCollection) {
- this.homogenousCollection = homogenousCollection;
+ public void setHomogeneousCollection(final List<ExamplePojoWithValues> homogenousCollection) {
+ this.homogeneousCollection = homogenousCollection;
}
// }}
- // {{ HetrogenousCollection
- private List<ExamplePojo> heterogenousCollection = new ArrayList<ExamplePojo>();
+ // {{ HetrogeneousCollection
+ private List<ExamplePojo> heterogeneousCollection = new ArrayList<ExamplePojo>();
- public List<ExamplePojo> getHeterogenousCollection() {
- return heterogenousCollection;
+ public List<ExamplePojo> getHeterogeneousCollection() {
+ return heterogeneousCollection;
}
- public void setHeterogenousCollection(final List<ExamplePojo> hetrogenousCollection) {
- this.heterogenousCollection = hetrogenousCollection;
+ public void setHeterogeneousCollection(final List<ExamplePojo> hetrogenousCollection) {
+ this.heterogeneousCollection = hetrogenousCollection;
}
// }}