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 01:01:07 UTC
[31/52] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMapping.java b/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMapping.java
deleted file mode 100644
index ffb0643..0000000
--- a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMapping.java
+++ /dev/null
@@ -1,48 +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.sql.mapping;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.Results;
-
-public interface FieldMapping {
-
- public ObjectAssociation getField();
-
- void appendColumnDefinitions(StringBuffer sql);
-
- void appendColumnNames(StringBuffer sql);
-
- void appendInsertValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
-
- void appendUpdateValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
-
- void initializeField(ObjectAdapter object, Results rs);
-
- void appendWhereClause(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
-
- void debugData(DebugBuilder debug);
-
- void appendWhereObject(DatabaseConnector connector, ObjectAdapter objectAdapter);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMappingFactory.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMappingFactory.java b/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMappingFactory.java
deleted file mode 100644
index 36d987c..0000000
--- a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/FieldMappingFactory.java
+++ /dev/null
@@ -1,27 +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.sql.mapping;
-
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-
-public interface FieldMappingFactory {
- FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMapping.java b/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMapping.java
deleted file mode 100644
index ca788d3..0000000
--- a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMapping.java
+++ /dev/null
@@ -1,40 +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.sql.mapping;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.Results;
-
-public interface ObjectReferenceMapping {
-
- void appendColumnDefinitions(StringBuffer sql);
-
- void appendInsertValues(DatabaseConnector connector, StringBuffer sb, ObjectAdapter value);
-
- void appendColumnNames(StringBuffer sql);
-
- void appendUpdateValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
-
- Oid recreateOid(final Results rs, final ObjectSpecification specification);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMappingFactory.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMappingFactory.java b/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMappingFactory.java
deleted file mode 100644
index 1212654..0000000
--- a/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/mapping/ObjectReferenceMappingFactory.java
+++ /dev/null
@@ -1,26 +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.sql.mapping;
-
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-public interface ObjectReferenceMappingFactory {
- ObjectReferenceMapping createReferenceMapping(String columnName, ObjectSpecification specification);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
new file mode 100644
index 0000000..4813f71
--- /dev/null
+++ b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.sql;
+
+import static org.hamcrest.Matchers.is;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.objectstore.sql.Defaults;
+
+public class DefaultsTest {
+ @Test
+ public void tablePrefixDefaultsTo_Isis() {
+ final String prefix = "isis.persistor.sql";
+ final IsisConfiguration config = new IsisConfigurationDefault();
+ Defaults.initialise(prefix, config);
+ Assert.assertThat(Defaults.getTablePrefix(), is("isis_"));
+ }
+
+ @Test
+ public void tablePrefixCanBeReplaced() {
+ final String prefix = "isis.persistor.sql";
+ final String key = "isis.persistor.sql.default.tableprefix";
+ final IsisConfigurationDefault config = new IsisConfigurationDefault();
+ config.add(key, "");
+ Defaults.initialise(prefix, config);
+ Assert.assertThat(Defaults.getTablePrefix(), is(""));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
new file mode 100644
index 0000000..407a82d
--- /dev/null
+++ b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.isis.objectstore.sql.jdbc.helpers;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+import org.apache.isis.objectstore.sql.jdbc.helpers.SimplePasswordEncoderDecoder;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public class SimplePasswordEncoderDecoderTest {
+
+ private static final String testSeed = "randomString12345";
+ private static final Integer encLength = 120;
+
+ @Test
+ public void testEncodingValueFromString() {
+ SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
+ String input = "password";
+ String encoded = encdec.encodeRawValueIntoEncodedString(input);
+ Assert.assertThat(encoded, is(not(input)));
+ Assert.assertThat(encoded.length(), is(120));
+ }
+
+ @Test
+ public void testDecodingEncodedValue() {
+ SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
+ String input = "password";
+ String encoded = encdec.encodeRawValueIntoEncodedString(input);
+ Assert.assertThat(encoded, is(not(input)));
+
+ String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
+ Assert.assertThat(decoded, is(input));
+ }
+
+ @Test
+ public void testNoSeedDoesNothing() {
+ SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(null, encLength);
+ String input = "password";
+ String encoded = encdec.encodeRawValueIntoEncodedString(input);
+ Assert.assertThat(encoded, is(input));
+
+ String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
+ Assert.assertThat(decoded, is(input));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/DefaultsTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/DefaultsTest.java b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/DefaultsTest.java
deleted file mode 100644
index bf9949d..0000000
--- a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/DefaultsTest.java
+++ /dev/null
@@ -1,48 +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.sql;
-
-import static org.hamcrest.Matchers.is;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-
-public class DefaultsTest {
- @Test
- public void tablePrefixDefaultsTo_Isis() {
- final String prefix = "isis.persistor.sql";
- final IsisConfiguration config = new IsisConfigurationDefault();
- Defaults.initialise(prefix, config);
- Assert.assertThat(Defaults.getTablePrefix(), is("isis_"));
- }
-
- @Test
- public void tablePrefixCanBeReplaced() {
- final String prefix = "isis.persistor.sql";
- final String key = "isis.persistor.sql.default.tableprefix";
- final IsisConfigurationDefault config = new IsisConfigurationDefault();
- config.add(key, "");
- Defaults.initialise(prefix, config);
- Assert.assertThat(Defaults.getTablePrefix(), is(""));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java b/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
deleted file mode 100644
index f8b8425..0000000
--- a/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
+++ /dev/null
@@ -1,66 +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.sql.jdbc.helpers;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- *
- * @version $Rev$ $Date$
- */
-public class SimplePasswordEncoderDecoderTest {
-
- private static final String testSeed = "randomString12345";
- private static final Integer encLength = 120;
-
- @Test
- public void testEncodingValueFromString() {
- SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
- String input = "password";
- String encoded = encdec.encodeRawValueIntoEncodedString(input);
- Assert.assertThat(encoded, is(not(input)));
- Assert.assertThat(encoded.length(), is(120));
- }
-
- @Test
- public void testDecodingEncodedValue() {
- SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
- String input = "password";
- String encoded = encdec.encodeRawValueIntoEncodedString(input);
- Assert.assertThat(encoded, is(not(input)));
-
- String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
- Assert.assertThat(decoded, is(input));
- }
-
- @Test
- public void testNoSeedDoesNothing() {
- SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(null, encLength);
- String input = "password";
- String encoded = encdec.encodeRawValueIntoEncodedString(input);
- Assert.assertThat(encoded, is(input));
-
- String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
- Assert.assertThat(decoded, is(input));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
new file mode 100644
index 0000000..f54f756
--- /dev/null
+++ b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.objectstore.sql.common;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.applib.value.Color;
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.applib.value.DateTime;
+import org.apache.isis.applib.value.Image;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.applib.value.Password;
+import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.applib.value.TimeStamp;
+
+public class Data {
+
+ // private static final TimeZone GMTm2_TIME_ZONE;
+
+ // Helper values
+ static final java.sql.Date sqlDate;
+ static final java.sql.Date sqlDate20100305;
+
+ static {
+ /*
+ *
+ * // For testing -ve offset timezone local regions. GMTm2_TIME_ZONE = TimeZone.getTimeZone("GMT-0200");
+ * //GMTm2_TIME_ZONE = TimeZone.getTimeZone("UTC"); TimeZone.setDefault(GMTm2_TIME_ZONE);
+ */
+
+ /*
+ * TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC"); if (timeZone == null) { timeZone =
+ * TimeZone.getTimeZone("UTC"); } UTC_TIME_ZONE = timeZone;
+ */
+
+ /*
+ * There is still an issue assigning a java.sql.Date variable from a calendar. final Calendar cal =
+ * Calendar.getInstance(); cal.setTimeZone(UTC_TIME_ZONE); cal.clear(); cal.set(Calendar.YEAR, 2011);
+ * cal.set(Calendar.MONTH, 4-1); cal.set(Calendar.DAY_OF_MONTH, 8);
+ */
+ // 2011-4-8 = 1,270,684,800,000
+ final Date date20100308 = new Date(2010, 4, 8);
+ sqlDate = new java.sql.Date(date20100308.getMillisSinceEpoch());
+
+ sqlDate20100305 = new java.sql.Date(new Date(2010, 3, 5).getMillisSinceEpoch());
+ }
+
+ static final Date applibDate = new Date(2010, 3, 5); // 2010-03-05 =
+ // 1,267,747,200,000
+ static final DateTime dateTime = new DateTime(2010, 3, 5, 1, 23); // 1,267,752,180,000
+ static final TimeStamp timeStamp = new TimeStamp(dateTime.millisSinceEpoch());
+ static final Time time = new Time(14, 56); // 53,760,000
+
+ static final Color color = Color.WHITE;
+ static final Image image = new Image(new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } });
+ static final Password password = new Password("password");
+ static final Percentage percentage = new Percentage(42);
+ static final Money money = new Money(99.99, "ZAR");
+
+ // Standard values
+ static final int intMaxValue = Integer.MAX_VALUE;
+ static final short shortMaxValue = Short.MAX_VALUE;
+ static final long longMaxValue = Long.MAX_VALUE;
+ static final double doubleMaxValue = 1e308;// Double.MAX_VALUE;
+ static final float floatMaxValue = (float) 1e37;// Float.MAX_VALUE;
+
+ static final int intMinValue = Integer.MIN_VALUE;
+ static final short shortMinValue = Short.MIN_VALUE;
+ static final long longMinValue = Long.MIN_VALUE;
+ static final double doubleMinValue = 1e-307;// Double.MIN_VALUE;
+ static final float floatMinValue = (float) 1e-37;// Float.MIN_VALUE;
+
+ // Collection mapper tests
+ static final List<String> stringList1 = Arrays.asList("Baking", "Bakery", "Canned", "Dairy");
+ static final List<String> stringList2 = Arrays.asList("Fridge", "Deli", "Fresh Produce", "Frozen", "Household",
+ "Other..");
+
+ public static List<String> getTableNames() {
+ return Arrays.asList("sqldataclass", "simpleclass", "simpleclasstwo", "primitivevaluedentity");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestCommonBase.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestCommonBase.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestCommonBase.java
new file mode 100755
index 0000000..3f43af4
--- /dev/null
+++ b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestCommonBase.java
@@ -0,0 +1,176 @@
+/*
+ * 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.sql.common;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+
+import org.apache.isis.core.tck.dom.poly.ReferencingPolyTypesEntity;
+import org.apache.isis.core.tck.dom.sqlos.SqlDomainObjectRepository;
+import org.apache.isis.core.tck.dom.sqlos.data.SqlDataClass;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.sql.common.SqlIntegrationTestFixtures.State;
+
+/**
+ * @author Kevin kevin@kmz.co.za
+ *
+ * This common test class is used by all sql objectstore tests to manage the Isis framework.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SqlIntegrationTestCommonBase {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ protected SqlIntegrationTestFixtures getSqlIntegrationTestFixtures() {
+ return SqlIntegrationTestFixtures.getInstance();
+ }
+
+ protected SqlDomainObjectRepository factory;
+ protected SqlDataClass sqlDataClass;
+ protected ReferencingPolyTypesEntity referencingPolyTypesEntity;
+
+ public Properties getProperties() {
+ try {
+ final Properties properties = new Properties();
+ properties.load(new FileInputStream("src/test/config/" + getPropertiesFilename()));
+ return properties;
+ } catch (final FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public abstract String getPropertiesFilename();
+
+ protected void setFixtureInitializationStateIfNot(State state, String persistenceMechanism) {
+ if (!persistenceMechanismIs(persistenceMechanism)) {
+ setFixtureInitializationState(state);
+ }
+ }
+
+ protected void setFixtureInitializationState(final State state, final String persistenceMechanism) {
+ if (persistenceMechanismIs(persistenceMechanism)) {
+ setFixtureInitializationState(state);
+ }
+ }
+
+ protected void setFixtureInitializationState(final State state) {
+ getSqlIntegrationTestFixtures().setState(state);
+ }
+
+ protected boolean persistenceMechanismIs(final String persistenceMechanism) {
+ return getProperties().getProperty("isis.persistor").equals(persistenceMechanism);
+ }
+
+ /**
+ * This method can be used to do any DB specific actions the first time the test framework is setup. e.g. In the XML
+ * test, it must delete all XML files in the data store directory.
+ */
+ public void resetPersistenceStoreDirectlyIfRequired() {
+ }
+
+ protected void testSetup() {
+ resetPersistenceStoreDirectlyIfRequired();
+ getSqlIntegrationTestFixtures().setState(State.INITIALIZE);
+ }
+
+ // //////////////////////////////////////////////////////////////////////////////
+ // before, after
+ // //////////////////////////////////////////////////////////////////////////////
+
+ @Before
+ public void setUpSystem() throws Exception {
+ Logger.getRootLogger().setLevel(Level.INFO);
+
+ if (!getSqlIntegrationTestFixtures().getState().isInitialize()) {
+ return;
+ }
+
+ final Properties properties = getProperties();
+ if (properties == null) {
+ getSqlIntegrationTestFixtures().initSystem("src/test/config", getPropertiesFilename());
+ } else {
+ getSqlIntegrationTestFixtures().initSystem(properties);
+ }
+
+ final String sqlSetupString = getSqlSetupString();
+ if (sqlSetupString != null) {
+ getSqlIntegrationTestFixtures().sqlExecute(sqlSetupString);
+ }
+ }
+
+ /**
+ * optional hook
+ */
+ protected String getSqlSetupString() {
+ return null;
+ }
+
+ @Before
+ public void setUpFactory() throws Exception {
+ factory = getSqlIntegrationTestFixtures().getSqlDataClassFactory();
+
+ // may have been setup by previous test
+ sqlDataClass = getSqlIntegrationTestFixtures().getSqlDataClass();
+ referencingPolyTypesEntity = getSqlIntegrationTestFixtures().getPolyTestClass();
+ }
+
+ // //////////////////////////////////////////////////////////////////////////////
+ // after
+ // //////////////////////////////////////////////////////////////////////////////
+
+ @After
+ public void tearDown() throws Exception {
+ if (!getSqlIntegrationTestFixtures().getState().isInitialize()) {
+ return;
+ }
+ final String sqlTeardownString = getSqlTeardownString();
+ if (sqlTeardownString != null) {
+ try {
+ getSqlIntegrationTestFixtures().sqlExecute(sqlTeardownString);
+ } catch (final SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ getSqlIntegrationTestFixtures().shutDown();
+ }
+
+ /**
+ * optional hook
+ */
+ protected String getSqlTeardownString() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestData.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestData.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestData.java
new file mode 100644
index 0000000..a561219
--- /dev/null
+++ b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestData.java
@@ -0,0 +1,601 @@
+/*
+ * 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.sql.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import org.apache.isis.applib.value.Color;
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.applib.value.DateTime;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.applib.value.Password;
+import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.applib.value.TimeStamp;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.sqlos.SqlDomainObjectRepository;
+import org.apache.isis.core.tck.dom.sqlos.data.SimpleClass;
+import org.apache.isis.core.tck.dom.sqlos.data.SimpleClassTwo;
+import org.apache.isis.core.tck.dom.sqlos.data.SqlDataClass;
+import org.apache.isis.objectstore.sql.common.SqlIntegrationTestFixtures.State;
+
+/**
+ * @author Kevin kevin@kmz.co.za
+ *
+ * This common class is used by the datatype tests (values, objects, collections) to ensure proper creation and
+ * reloading of domain objects.
+ *
+ * There are two "tests", with the framework re-initialised each time (to flush any objectstore memory of any
+ * created domain objects).
+ *
+ * The Singleton class {@link SqlIntegrationTestFixtures} is used to preserve values between tests.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SqlIntegrationTestData extends SqlIntegrationTestCommonBase {
+
+ private static final Logger LOG = Logger.getLogger(SqlIntegrationTestData.class);
+
+ private static List<SimpleClass> simpleClassList1 = new ArrayList<SimpleClass>();
+ private static List<SimpleClass> simpleClassList2 = new ArrayList<SimpleClass>();
+
+ private static SimpleClassTwo simpleClassTwoA;
+ private static SimpleClassTwo simpleClassTwoB;
+
+ private static PrimitiveValuedEntity pve1;
+ private static PrimitiveValuedEntity pve2;
+
+ @Test
+ /**
+ * Uses factory methods within the Isis framework to create the test data,
+ * thus exercising the "create data" portion of the object store.
+ *
+ * The Isis framework will be again be re-created in the next test unless the
+ * object store is "in-memory" (this is required since "in-memory" has to be
+ * left alone for created data to still be present in the next test).
+ */
+ public void testSetupStore() throws Exception {
+ testSetup();
+ setUpFactory();
+ testCreate();
+ }
+
+ protected void testCreate() throws Exception {
+
+ sqlDataClass = factory.newDataClass();
+
+ sqlDataClass.setString("Test String");
+ sqlDataClass.setDate(Data.applibDate);
+ sqlDataClass.setSqlDate(Data.sqlDate);
+ sqlDataClass.setMoney(Data.money);
+ sqlDataClass.setDateTime(Data.dateTime);
+ sqlDataClass.setTimeStamp(Data.timeStamp);
+ sqlDataClass.setTime(Data.time);
+ sqlDataClass.setColor(Data.color);
+ sqlDataClass.setImage(Data.image);
+ sqlDataClass.setPassword(Data.password);
+ sqlDataClass.setPercentage(Data.percentage);
+
+ // Setup SimpleClassTwo
+ simpleClassTwoA = factory.newSimpleClassTwo();
+ simpleClassTwoA.setText("A");
+ simpleClassTwoA.setIntValue(999);
+ simpleClassTwoA.setBooleanValue(true);
+
+ simpleClassTwoB = factory.newSimpleClassTwo();
+ simpleClassTwoB.setText("B");
+
+ sqlDataClass.setSimpleClassTwo(simpleClassTwoA);
+
+ // NumericClasses
+ // standard min types
+ pve2 = factory.newPrimitiveValuedEntity();
+ LOG.log(Level.INFO, "Bits to represent Double: " + Double.SIZE);
+ pve2.setIntProperty(Data.intMinValue);
+ pve2.setShortProperty(Data.shortMinValue);
+ pve2.setLongProperty(Data.longMinValue);
+ pve2.setDoubleProperty(Data.doubleMinValue);
+ pve2.setFloatProperty(Data.floatMinValue);
+ pve2.setCharProperty((char) (32)); // temporary work around: See ISIS-269
+
+ sqlDataClass.setPrimitiveValuedEntityMin(pve2);
+
+ // standard max types
+ pve1 = factory.newPrimitiveValuedEntity();
+ pve1.setIntProperty(Data.intMaxValue);
+ pve1.setShortProperty(Data.shortMaxValue);
+ pve1.setLongProperty(Data.longMaxValue);
+ pve1.setDoubleProperty(Data.doubleMaxValue);
+ pve1.setFloatProperty(Data.floatMaxValue);
+ pve1.setCharProperty((char) (255));
+
+ sqlDataClass.setPrimitiveValuedEntityMax(pve1);
+
+ // Initialise collection1
+ boolean bMustAdd = false;
+ if (simpleClassList1.size() == 0) {
+ bMustAdd = true;
+ }
+ for (final String string : Data.stringList1) {
+ final SimpleClass simpleClass = factory.newSimpleClass();
+ simpleClass.setString(string);
+ simpleClass.setSimpleClassTwoA(simpleClassTwoA);
+ sqlDataClass.addToSimpleClasses1(simpleClass);
+ if (bMustAdd) {
+ simpleClassList1.add(simpleClass);
+ }
+ }
+
+ // Initialise collection2
+ for (final String string : Data.stringList2) {
+ final SimpleClass simpleClass = factory.newSimpleClass();
+ simpleClass.setString(string);
+ simpleClass.setSimpleClassTwoA(simpleClassTwoB);
+ sqlDataClass.addToSimpleClasses2(simpleClass);
+ if (bMustAdd) {
+ simpleClassList2.add(simpleClass);
+ }
+ }
+ factory.save(sqlDataClass);
+
+ setFixtureInitializationState(State.DONT_INITIALIZE, "in-memory");
+ }
+
+ @Test
+ /**
+ * The actual "tests". Unless the test is using the "in-memory" object store
+ * the Isis framework is re-created, thus ensuring that no domain objects are
+ * left over from the previous "create" step, forcing the objects to be created
+ * via the object store.
+ *
+ * Exercises the "restore data" portion of the object store.
+ *
+ * Confirms that values and objects (single and collections) are loaded as expected.
+ * Especially, it confirms that dates, times, etc, do not suffer from differences in
+ * time zones between the database and the Isis framework.
+ */
+ public void testTestAll() throws Exception {
+ testLoad();
+
+ setUpFactory();
+
+ testString();
+ setStringToDifferentValue();
+ testSimpleClassCollection1Lazy();
+
+ testMoney();
+ testColor();
+ testPassword();
+ testPercentage();
+ testStandardValueTypesMaxima();
+ testStandardValueTypesMinima();
+
+ testSingleReferenceLazy();
+ testSimpleClassTwoReferenceLazy();
+
+ testSimpleClassCollection1();
+ testSimpleClassCollection2();
+
+ testSingleReferenceResolve();
+ testSimpleClassTwoReferenceResolve();
+ testSimpleClassTwo();
+ testUpdate1();
+ testUpdate2();
+ testUpdateCollectionIsDirty();
+ testFindByMatchString();
+ testFindByMatchEntity();
+
+ testApplibDate();
+ testSqlDate();
+ testTime();
+ testTimeStamp();
+ testDateTimezoneIssue();
+ testDateTime();
+
+ // Must be here so that the Isis framework is initialised for the next test package.
+ setFixtureInitializationState(State.INITIALIZE);
+ }
+
+ private void testLoad() throws Exception {
+ final List<SqlDataClass> dataClasses = factory.allDataClasses();
+ assertEquals(1, dataClasses.size());
+ final SqlDataClass sqlDataClass = dataClasses.get(0);
+ getSqlIntegrationTestFixtures().setSqlDataClass(sqlDataClass);
+
+ setFixtureInitializationState(State.DONT_INITIALIZE);
+ }
+
+ private void testString() {
+ assertEquals("Test String", sqlDataClass.getString());
+ }
+
+ private void setStringToDifferentValue() {
+ sqlDataClass.setString("String 2");
+ }
+
+ private void testSimpleClassCollection1Lazy() {
+ final List<SimpleClass> collection = sqlDataClass.simpleClasses1;
+
+ assertEquals("collection size is not equal!", collection.size(), simpleClassList1.size());
+ }
+
+ /**
+ * Test {@link SqlDataClass} {@link Date} field.
+ *
+ * @throws Exception
+ */
+ private void testApplibDate() {
+
+ LOG.log(Level.INFO, "Test: testDate() '2010-3-5' = 1267747200000");
+
+ // 2010-3-5 = 1267747200000
+ LOG.log(Level.INFO, "applibDate.dateValue() as String: " + Data.applibDate);
+ LOG.log(Level.INFO, "applibDate.dateValue() as Long: " + Data.applibDate.getMillisSinceEpoch());
+
+ // 2010-3-5 = 1267747200000
+ LOG.log(Level.INFO, "sqlDataClass.getDate() as String: " + sqlDataClass.getDate());
+ LOG.log(Level.INFO, "sqlDataClass.getDate().getTime() as Long: " + sqlDataClass.getDate().getMillisSinceEpoch());
+
+ if (!Data.applibDate.isEqualTo(sqlDataClass.getDate())) {
+ fail("Applib date: Test '2010-3-5', expected " + Data.applibDate.toString() + ", but got "
+ + sqlDataClass.getDate().toString() + ". Check log for more info.");
+ // LOG.log(Level.INFO, "Applib date: Test '2011-3-5', expected " +
+ // applibDate.toString() + ", but got "
+ // +
+ // sqlDataClass.getDate().toString()+". Check log for more info.");
+ } else {
+ // LOG.log(Level.INFO,
+ // "SQL applib.value.date: test passed! Woohoo!");
+ }
+
+ }
+
+ /**
+ * Test {@link SqlDataClass} {@link java.sql.Date} field.
+ *
+ * @throws Exception
+ */
+ private void testSqlDate() {
+
+ LOG.log(Level.INFO, "Test: testSqlDate() '2011-4-8' == 1302220800000");
+
+ // 2011-4-8 = 1302220800000
+ LOG.log(Level.INFO, "sqlDate.toString() as String:" + Data.sqlDate); // shows
+ // as
+ // 2011-04-07
+ LOG.log(Level.INFO, "sqlDate.getTime() as Long:" + Data.sqlDate.getTime());
+
+ // 2011-4-8 = 1302220800000
+ LOG.log(Level.INFO, "sqlDataClass.getSqlDate() as String:" + sqlDataClass.getSqlDate()); // shows
+ // as
+ // 2011-04-07
+ LOG.log(Level.INFO, "sqlDataClass.getSqlDate().getTime() as Long:" + sqlDataClass.getSqlDate().getTime());
+
+ if (Data.sqlDate.compareTo(sqlDataClass.getSqlDate()) != 0) {
+ fail("SQL date: Test '2011-4-8', expected " + Data.sqlDate.toString() + ", but got "
+ + sqlDataClass.getSqlDate().toString() + ". Check log for more info.");
+ // LOG.log(Level.INFO, "SQL date: Test '2011-4-8', expected " +
+ // sqlDate.toString() + ", and got "
+ // + sqlDataClass.getSqlDate().toString()
+ // +". Check log for more info.");
+ } else {
+ // LOG.log(Level.INFO, "SQL date: test passed! Woohoo!");
+ }
+
+ }/**/
+
+ private void testDateTimezoneIssue() {
+ /*
+ * At the moment, applib Date and java.sql.Date are restored from ValueSemanticsProviderAbstractTemporal with an
+ * explicit hourly offset that comes from the timezone. I.e. in South Africa, with TZ +2h00, they have an
+ * implicit time of 02h00 (2AM). This can potentially seriously screw up GMT-X dates, which, I suspect, will
+ * actually be set to the dat BEFORE.
+ *
+ * This test is a simple test to confirm that date/time before and after checks work as expected.
+ */
+
+ DateTime dateTime = sqlDataClass.getDateTime(); // new DateTime(2010, 3, 5, 1, 23);
+ Date date = sqlDataClass.getDate(); // new Date(2010, 3, 5);
+
+ // java.sql.Date sqlDate = sqlDataClass.getSqlDate(); // "2010-03-05"
+ // assertTrue("dateTime's value (" + dateTime.dateValue() + ") should be after java.sql.date's (" + sqlDate +
+ // ")",
+ // dateTime.dateValue().after(sqlDate));
+
+ assertTrue("dateTime's value (" + dateTime.dateValue() + ") should be after date's (" + date + ")", dateTime
+ .dateValue().after(date.dateValue()));
+
+ }
+
+ /**
+ * Test {@link Money} type.
+ */
+ private void testMoney() {
+ assertEquals(Data.money, sqlDataClass.getMoney());
+ }
+
+ /**
+ * Test {@link DateTime} type.
+ */
+ private void testDateTime() {
+
+ LOG.log(Level.INFO, "Test: testDateTime()");
+ LOG.log(Level.INFO, "sqlDataClass.getDateTime() as String:" + sqlDataClass.getDateTime());
+ LOG.log(Level.INFO, "dateTime.toString() as String:" + Data.dateTime);
+
+ LOG.log(Level.INFO, "sqlDataClass.getDateTime().getTime() as Long:"
+ + sqlDataClass.getDateTime().millisSinceEpoch());
+ LOG.log(Level.INFO, "dateTime.getTime() as Long:" + Data.dateTime.millisSinceEpoch());
+
+ if (!Data.dateTime.equals(sqlDataClass.getDateTime())) {
+ fail("DateTime " + Data.dateTime.toString() + " is not expected " + sqlDataClass.getDateTime().toString());
+ }
+ }
+
+ /**
+ * Test {@link TimeStamp} type.
+ */
+ private void testTimeStamp() {
+ assertTrue(
+ "TimeStamp " + sqlDataClass.getTimeStamp().toString() + " does not equal expected "
+ + Data.timeStamp.toString(), Data.timeStamp.isEqualTo(sqlDataClass.getTimeStamp()));
+ }
+
+ /**
+ * Test {@link Time} type.
+ */
+ /**/
+ private void testTime() {
+ assertNotNull("sqlDataClass is null", sqlDataClass);
+ assertNotNull("getTime() is null", sqlDataClass.getTime());
+ assertTrue("Time 14h56: expected " + Data.time.toString() + ", but got " + sqlDataClass.getTime().toString(),
+ Data.time.isEqualTo(sqlDataClass.getTime()));
+ }
+
+ /**
+ * Test {@link Color} type.
+ */
+ private void testColor() {
+ assertEquals(Data.color, sqlDataClass.getColor());
+ }
+
+ /**
+ * Test {@link Image} type.
+ */
+ // TODO: Images are not equal...
+ /*
+ * public void testImage(){ SqlDataClass sqlDataClass = SqlIntegrationTestSingleton.getPerson(); Image image2 =
+ * sqlDataClass.getImage(); assertEqual(image, image2); }
+ *
+ * private void assertEqual(Image image2, Image image3) { assertEquals(image2.getHeight(), image3.getHeight());
+ * assertEquals(image2.getWidth(), image3.getWidth()); boolean same = true; int i=0,j=0; int p1=0, p2=0; String
+ * error = ""; int [][] i1 = image2.getImage(), i2 = image3.getImage(); for(i = 0; same &&
+ * i<image2.getHeight();i++){ int [] r1 = i1[i], r2 = i2[i]; for (j = 0; same && j < image2.getWidth(); j++){ if
+ * (r1[j] != r2[j]){ same = false; p1 = r1[j]; p2 = r2[j]; error = "Images differ at i = "+i+", j = "+j+", "+p1+
+ * " is not "+p2+"!"; break; } } } assertTrue(error, same); }
+ */
+
+ /**
+ * Test {@link Password} type.
+ */
+ private void testPassword() {
+ assertEquals(Data.password, sqlDataClass.getPassword());
+ }
+
+ /**
+ * Test {@link Percentage} type.
+ */
+ private void testPercentage() {
+ assertEquals(Data.percentage, sqlDataClass.getPercentage());
+ }
+
+ private void testStandardValueTypesMaxima() {
+ final PrimitiveValuedEntity pveMax = sqlDataClass.getPrimitiveValuedEntityMax();
+
+ assertEquals(Data.shortMaxValue, pveMax.getShortProperty());
+ assertEquals(Data.intMaxValue, pveMax.getIntProperty());
+ assertEquals(Data.longMaxValue, pveMax.getLongProperty());
+ assertEquals(Data.doubleMaxValue, pveMax.getDoubleProperty(), 0.00001f); // fails
+ // in
+ assertEquals(Data.floatMaxValue, pveMax.getFloatProperty(), 0.00001f);
+ }
+
+ private void testStandardValueTypesMinima() {
+ final PrimitiveValuedEntity pveMin = sqlDataClass.getPrimitiveValuedEntityMin();
+
+ assertEquals(Data.shortMinValue, pveMin.getShortProperty());
+ assertEquals(Data.intMinValue, pveMin.getIntProperty());
+ assertEquals(Data.longMinValue, pveMin.getLongProperty());
+ assertEquals(Data.doubleMinValue, pveMin.getDoubleProperty(), 0.00001f); // fails
+ // in
+ // MySQL
+ // =
+ // infinity
+ assertEquals(Data.floatMinValue, pveMin.getFloatProperty(), 0.00001f);
+ }
+
+ /**
+ * Test {@link StringCollection} type.
+ */
+ /*
+ * public void testStringCollection(){ SqlDataClass sqlDataClass = SqlIntegrationTestSingleton.getPerson();
+ * List<String> collection = sqlDataClass.getStringCollection(); int i = 0; for (String string : collection) {
+ * assertEquals(SqlIntegrationTestCommon.stringList.get(i++), string); } }
+ */
+
+ private void testSingleReferenceLazy() {
+ final SimpleClassTwo a = sqlDataClass.getSimpleClassTwo();
+ if (!persistenceMechanismIs("in-memory")) {
+ assertEquals(null, a.text); // must check direct value, as
+ // framework can auto-resolve, if you use getText()
+ }
+ }
+
+ /**
+ * Test a collection of {@link SimpleClass} type.
+ */
+ private void testSimpleClassCollection1() {
+ final List<SimpleClass> collection = sqlDataClass.getSimpleClasses1();
+
+ assertEquals("collection size is not equal!", simpleClassList1.size(), collection.size());
+
+ int i = 0;
+ for (final SimpleClass simpleClass : simpleClassList1) {
+ assertEquals(simpleClass.getString(), collection.get(i++).getString());
+ }
+ }
+
+ /**
+ * Test another collection of {@link SimpleClass} type.
+ */
+ private void testSimpleClassCollection2() {
+ final List<SimpleClass> collection = sqlDataClass.getSimpleClasses2();
+
+ assertEquals("collection size is not equal!", simpleClassList2.size(), collection.size());
+
+ int i = 0;
+ for (final SimpleClass simpleClass : simpleClassList2) {
+ assertEquals(simpleClass.getString(), collection.get(i++).getString());
+ }
+ }
+
+ private void testSimpleClassTwoReferenceLazy() {
+ final List<SimpleClass> collection = sqlDataClass.getSimpleClasses1();
+ if (getProperties().getProperty("isis.persistor") != "in-memory") {
+ for (final SimpleClass simpleClass : collection) {
+ final SimpleClassTwo a = simpleClass.getSimpleClassTwoA();
+ assertEquals(null, a.text); // must check direct value, as
+ // framework can auto-resolve, if
+ // you use getText()
+ }
+ }
+ }
+
+ private void testSingleReferenceResolve() {
+ final SimpleClassTwo a = sqlDataClass.getSimpleClassTwo();
+ factory.resolve(a);
+ assertEquals(simpleClassTwoA.getText(), a.getText());
+ }
+
+ private void testSimpleClassTwoReferenceResolve() {
+ final List<SimpleClass> collection = sqlDataClass.getSimpleClasses1();
+ for (final SimpleClass simpleClass : collection) {
+ final SimpleClassTwo a = simpleClass.getSimpleClassTwoA();
+ factory.resolve(a);
+ assertEquals(simpleClassTwoA.getText(), a.getText());
+ assertEquals(simpleClassTwoA.getIntValue(), a.getIntValue());
+ assertEquals(simpleClassTwoA.getBooleanValue(), a.getBooleanValue());
+ }
+ }
+
+ private void testSimpleClassTwo() {
+ final SqlDomainObjectRepository factory = getSqlIntegrationTestFixtures().getSqlDataClassFactory();
+ final List<SimpleClassTwo> classes = factory.allSimpleClassTwos();
+ assertEquals(2, classes.size());
+ for (final SimpleClassTwo simpleClass : classes) {
+ // assertEquals(simpleClassTwoA.getText(), simpleClass.getText());
+ assertTrue("AB".contains(simpleClass.getText()));
+ }
+ }
+
+ private void testUpdate1() {
+ final List<SimpleClassTwo> classes = factory.allSimpleClassTwos();
+ assertEquals(2, classes.size());
+
+ final SimpleClassTwo simpleClass = classes.get(0);
+ simpleClass.setText("XXX");
+ simpleClass.setBooleanValue(false);
+ simpleClassTwoA.setBooleanValue(false);
+
+ setFixtureInitializationStateIfNot(State.INITIALIZE, "in-memory");
+ }
+
+ private void testUpdate2() {
+ final List<SimpleClassTwo> classes = factory.allSimpleClassTwos();
+ assertEquals(2, classes.size());
+
+ final SimpleClassTwo simpleClass = classes.get(0);
+ assertEquals("XXX", simpleClass.getText());
+ assertEquals(simpleClassTwoA.getBooleanValue(), simpleClass.getBooleanValue());
+
+ setFixtureInitializationState(State.DONT_INITIALIZE);
+ }
+
+ private void testUpdateCollectionIsDirty() {
+
+ final List<SqlDataClass> sqlDataClasses = factory.allDataClasses();
+ final SqlDataClass sqlDataClass = sqlDataClasses.get(0);
+
+ final List<SimpleClass> collection = sqlDataClass.getSimpleClasses1();
+ final SimpleClass simpleClass1 = collection.get(0);
+ // simpleClass1.setString(stringList1.get(3));
+
+ collection.remove(simpleClass1);
+
+ // REVIEW: I'm very doubtful about this...
+ // what exactly is meant by updating an internal collection?
+ if (!persistenceMechanismIs("xml")) {
+ factory.update(collection);
+ }
+
+ factory.update(sqlDataClass);
+ }
+
+ private void testFindByMatchString() {
+ final SimpleClass simpleClassMatch = new SimpleClass();
+ simpleClassMatch.setString(Data.stringList1.get(1));
+
+ final List<SimpleClass> classes = factory.allSimpleClassesThatMatch(simpleClassMatch);
+ assertEquals(1, classes.size());
+
+ }
+
+ private void testFindByMatchEntity() {
+ final List<SimpleClassTwo> classTwos = factory.allSimpleClassTwos();
+
+ final SimpleClass simpleClassMatch = new SimpleClass();
+ simpleClassMatch.setSimpleClassTwoA(classTwos.get(0));
+
+ final List<SimpleClass> classes = factory.allSimpleClassesThatMatch(simpleClassMatch);
+
+ // TODO: Why is this hack required?
+ if (!getProperties().getProperty("isis.persistor").equals("in-memory")) {
+ assertEquals(Data.stringList1.size(), classes.size());
+ } else {
+ assertEquals(Data.stringList1.size() + 2, classes.size());
+ }
+ }
+
+ private void reinitializeFixtures() {
+ setFixtureInitializationState(State.INITIALIZE);
+ SqlIntegrationTestFixtures.recreate();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestFixtures.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestFixtures.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestFixtures.java
new file mode 100644
index 0000000..d630bcc
--- /dev/null
+++ b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/SqlIntegrationTestFixtures.java
@@ -0,0 +1,237 @@
+/*
+ * 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.sql.common;
+
+import java.io.FileInputStream;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures.Fixtures.Initialization;
+import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract;
+import org.apache.isis.core.tck.dom.poly.ReferencingPolyTypesEntity;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.core.tck.dom.sqlos.SqlDomainObjectRepository;
+import org.apache.isis.core.tck.dom.sqlos.data.SimpleClass;
+import org.apache.isis.core.tck.dom.sqlos.data.SimpleClassTwo;
+import org.apache.isis.core.tck.dom.sqlos.data.SqlDataClass;
+import org.apache.isis.objectstore.sql.SqlObjectStore;
+
+/**
+ * @author Kevin
+ *
+ */
+public class SqlIntegrationTestFixtures {
+
+ static SqlIntegrationTestFixtures instance;
+
+ public static SqlIntegrationTestFixtures getInstance() {
+ if (instance == null) {
+ instance = new SqlIntegrationTestFixtures();
+ }
+ return instance;
+ }
+
+ public static void recreate() {
+ instance = new SqlIntegrationTestFixtures();
+ }
+
+ public enum State {
+ INITIALIZE,
+ DONT_INITIALIZE;
+
+ public boolean isInitialize() { return this == INITIALIZE; }
+ }
+
+ private State state = State.INITIALIZE;
+ public State getState() {
+ return state;
+ }
+ public void setState(final State state) {
+ this.state = state;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+
+ private IsisSystemWithFixtures system;
+
+
+ // JDBC
+ private Connection conn = null;
+ private Statement stmt = null;
+
+ public void initSystem(final String propertiesDirectory, final String propertiesFileName) throws Exception {
+
+ final Properties properties = new Properties();
+ properties.load(new FileInputStream(propertiesDirectory + "/" + propertiesFileName));
+
+ initSystem(properties);
+ }
+
+ public void initSystem(final Properties properties) throws Exception {
+ final IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+ configuration.add(properties);
+
+ sqlDomainObjectRepository = new SqlDomainObjectRepository();
+ if (system != null) {
+ system.tearDownSystem();
+ }
+
+ final PersistenceMechanismInstallerAbstract persistorInstaller = Utils.createPersistorInstaller(configuration);
+ system = IsisSystemWithFixtures.builder().with(configuration).withServices(sqlDomainObjectRepository).with(Initialization.NO_INIT).with(persistorInstaller).build();
+
+ system.setUpSystem();
+
+ registerDriverAndConnect(configuration);
+ }
+
+
+ public void shutDown() throws Exception {
+ if (system != null) {
+ system.tearDownSystem();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+
+ @SuppressWarnings("unchecked")
+ private void registerDriverAndConnect(final IsisConfiguration isisConfiguration) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+ final String jdbcClassName = isisConfiguration.getString(SqlObjectStore.BASE_NAME + ".jdbc.driver");
+ if (jdbcClassName == null) {
+ conn = null;
+ stmt = null;
+ return;
+ }
+ final Class<Driver> driverClass = (Class<Driver>) Class.forName(jdbcClassName);
+ final Driver driver = driverClass.newInstance();
+ DriverManager.registerDriver(driver);
+
+ // jdbc - connect to DB and drop tables.
+ conn = DriverManager.getConnection(isisConfiguration.getString(SqlObjectStore.BASE_NAME + ".jdbc.connection"), isisConfiguration.getString(SqlObjectStore.BASE_NAME + ".jdbc.user"), isisConfiguration.getString(SqlObjectStore.BASE_NAME + ".jdbc.password"));
+ stmt = conn.createStatement();
+
+
+ // doesn't seem to be used...
+
+ // dropTable(SqlObjectStore.getTableName());
+ }
+
+ public void dropTable(final String tableName) {
+ if (stmt == null) {
+ if (tableName.equalsIgnoreCase("sqldataclass")) {
+ final List<SqlDataClass> list = sqlDomainObjectRepository.allDataClasses();
+ for (final SqlDataClass sqlDataClass : list) {
+ sqlDomainObjectRepository.delete(sqlDataClass);
+ }
+ return;
+ }
+ if (tableName.equalsIgnoreCase("simpleclass")) {
+ final List<SimpleClass> list = sqlDomainObjectRepository.allSimpleClasses();
+ for (final SimpleClass sqlClass : list) {
+ sqlDomainObjectRepository.delete(sqlClass);
+ }
+ return;
+ }
+ if (tableName.equalsIgnoreCase("simpleclasstwo")) {
+ final List<SimpleClassTwo> list = sqlDomainObjectRepository.allSimpleClassTwos();
+ for (final SimpleClassTwo sqlClass : list) {
+ sqlDomainObjectRepository.delete(sqlClass);
+ }
+ return;
+ }
+ if (tableName.equalsIgnoreCase("primitivevaluedentity")) {
+ final List<PrimitiveValuedEntity> list = sqlDomainObjectRepository.allPrimitiveValueEntities();
+ for (final PrimitiveValuedEntity pve : list) {
+ sqlDomainObjectRepository.delete(pve);
+ }
+ return;
+ }
+ throw new IsisException("Unknown table: " + tableName);
+ }
+
+ try {
+ String tableIdentifier = Utils.tableIdentifierFor(tableName);
+ stmt.executeUpdate("DROP TABLE " + tableIdentifier);
+ } catch (final SQLException e) {
+ // this can happen, not a problem.
+ // e.printStackTrace();
+ }
+ }
+
+ public void sqlExecute(final String sqlString) throws SQLException {
+ if (stmt != null) {
+ stmt.executeUpdate(sqlString);
+ }
+ }
+
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ private SqlDomainObjectRepository sqlDomainObjectRepository = null;
+
+ private SqlDataClass sqlDataClass;
+ private ReferencingPolyTypesEntity referencingPolyTypesEntity;
+
+
+ public SqlDomainObjectRepository getSqlDataClassFactory() {
+ return sqlDomainObjectRepository;
+ }
+
+
+
+ public SqlDataClass getSqlDataClass() {
+ return sqlDataClass;
+ }
+ public void setSqlDataClass(SqlDataClass sqlDataClass) {
+ this.sqlDataClass = sqlDataClass;
+ }
+
+
+
+ public ReferencingPolyTypesEntity getPolyTestClass() {
+ return referencingPolyTypesEntity;
+ }
+ public void setPolyTestClass(final ReferencingPolyTypesEntity referencingPolyTypesEntity) {
+ this.referencingPolyTypesEntity = referencingPolyTypesEntity;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Utils.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Utils.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Utils.java
new file mode 100644
index 0000000..c037e61
--- /dev/null
+++ b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Utils.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sql.common;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
+import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract;
+import org.apache.isis.objectstore.sql.Sql;
+import org.apache.isis.objectstore.sql.SqlObjectStore;
+import org.apache.isis.objectstore.sql.SqlPersistorInstaller;
+import org.apache.isis.objectstore.xml.XmlPersistenceMechanismInstaller;
+
+public class Utils {
+
+ static PersistenceMechanismInstallerAbstract createPersistorInstaller(final IsisConfiguration configuration) {
+
+ final String jdbcDriver = configuration.getString(SqlObjectStore.BASE_NAME + ".jdbc.driver");
+ if (jdbcDriver != null) {
+ return new SqlPersistorInstaller();
+ }
+
+ final String persistor = configuration.getString("isis.persistor");
+ if (persistor.equals(InMemoryPersistenceMechanismInstaller.NAME)) {
+ return new InMemoryPersistenceMechanismInstaller();
+ }
+ if (persistor.equals(XmlPersistenceMechanismInstaller.NAME)) {
+ return new XmlPersistenceMechanismInstaller();
+ }
+ if (persistor.equals(SqlPersistorInstaller.NAME)) {
+ return new SqlPersistorInstaller();
+ }
+ return new InMemoryPersistenceMechanismInstaller();
+ }
+
+ static String tableIdentifierFor(final String tableName) {
+ if (tableName.substring(0, 4).toUpperCase().equals("ISIS")) {
+ return Sql.tableIdentifier(tableName);
+ } else {
+ return Sql.tableIdentifier("isis_" + tableName);
+ }
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java
deleted file mode 100644
index 1708cde..0000000
--- a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java
+++ /dev/null
@@ -1,100 +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.sql.common;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.applib.value.Color;
-import org.apache.isis.applib.value.Date;
-import org.apache.isis.applib.value.DateTime;
-import org.apache.isis.applib.value.Image;
-import org.apache.isis.applib.value.Money;
-import org.apache.isis.applib.value.Password;
-import org.apache.isis.applib.value.Percentage;
-import org.apache.isis.applib.value.Time;
-import org.apache.isis.applib.value.TimeStamp;
-
-public class Data {
-
- // private static final TimeZone GMTm2_TIME_ZONE;
-
- // Helper values
- static final java.sql.Date sqlDate;
- static final java.sql.Date sqlDate20100305;
-
- static {
- /*
- *
- * // For testing -ve offset timezone local regions. GMTm2_TIME_ZONE = TimeZone.getTimeZone("GMT-0200");
- * //GMTm2_TIME_ZONE = TimeZone.getTimeZone("UTC"); TimeZone.setDefault(GMTm2_TIME_ZONE);
- */
-
- /*
- * TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC"); if (timeZone == null) { timeZone =
- * TimeZone.getTimeZone("UTC"); } UTC_TIME_ZONE = timeZone;
- */
-
- /*
- * There is still an issue assigning a java.sql.Date variable from a calendar. final Calendar cal =
- * Calendar.getInstance(); cal.setTimeZone(UTC_TIME_ZONE); cal.clear(); cal.set(Calendar.YEAR, 2011);
- * cal.set(Calendar.MONTH, 4-1); cal.set(Calendar.DAY_OF_MONTH, 8);
- */
- // 2011-4-8 = 1,270,684,800,000
- final Date date20100308 = new Date(2010, 4, 8);
- sqlDate = new java.sql.Date(date20100308.getMillisSinceEpoch());
-
- sqlDate20100305 = new java.sql.Date(new Date(2010, 3, 5).getMillisSinceEpoch());
- }
-
- static final Date applibDate = new Date(2010, 3, 5); // 2010-03-05 =
- // 1,267,747,200,000
- static final DateTime dateTime = new DateTime(2010, 3, 5, 1, 23); // 1,267,752,180,000
- static final TimeStamp timeStamp = new TimeStamp(dateTime.millisSinceEpoch());
- static final Time time = new Time(14, 56); // 53,760,000
-
- static final Color color = Color.WHITE;
- static final Image image = new Image(new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } });
- static final Password password = new Password("password");
- static final Percentage percentage = new Percentage(42);
- static final Money money = new Money(99.99, "ZAR");
-
- // Standard values
- static final int intMaxValue = Integer.MAX_VALUE;
- static final short shortMaxValue = Short.MAX_VALUE;
- static final long longMaxValue = Long.MAX_VALUE;
- static final double doubleMaxValue = 1e308;// Double.MAX_VALUE;
- static final float floatMaxValue = (float) 1e37;// Float.MAX_VALUE;
-
- static final int intMinValue = Integer.MIN_VALUE;
- static final short shortMinValue = Short.MIN_VALUE;
- static final long longMinValue = Long.MIN_VALUE;
- static final double doubleMinValue = 1e-307;// Double.MIN_VALUE;
- static final float floatMinValue = (float) 1e-37;// Float.MIN_VALUE;
-
- // Collection mapper tests
- static final List<String> stringList1 = Arrays.asList("Baking", "Bakery", "Canned", "Dairy");
- static final List<String> stringList2 = Arrays.asList("Fridge", "Deli", "Fresh Produce", "Frozen", "Household",
- "Other..");
-
- public static List<String> getTableNames() {
- return Arrays.asList("sqldataclass", "simpleclass", "simpleclasstwo", "primitivevaluedentity");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java
----------------------------------------------------------------------
diff --git a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java b/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java
deleted file mode 100755
index 723d06c..0000000
--- a/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java
+++ /dev/null
@@ -1,176 +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.sql.common;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-import org.apache.isis.runtimes.dflt.objectstores.sql.common.SqlIntegrationTestFixtures.State;
-import org.apache.isis.tck.dom.poly.ReferencingPolyTypesEntity;
-import org.apache.isis.tck.dom.sqlos.SqlDomainObjectRepository;
-import org.apache.isis.tck.dom.sqlos.data.SqlDataClass;
-
-/**
- * @author Kevin kevin@kmz.co.za
- *
- * This common test class is used by all sql objectstore tests to manage the Isis framework.
- *
- * @version $Rev$ $Date$
- */
-public abstract class SqlIntegrationTestCommonBase {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- protected SqlIntegrationTestFixtures getSqlIntegrationTestFixtures() {
- return SqlIntegrationTestFixtures.getInstance();
- }
-
- protected SqlDomainObjectRepository factory;
- protected SqlDataClass sqlDataClass;
- protected ReferencingPolyTypesEntity referencingPolyTypesEntity;
-
- public Properties getProperties() {
- try {
- final Properties properties = new Properties();
- properties.load(new FileInputStream("src/test/config/" + getPropertiesFilename()));
- return properties;
- } catch (final FileNotFoundException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- public abstract String getPropertiesFilename();
-
- protected void setFixtureInitializationStateIfNot(State state, String persistenceMechanism) {
- if (!persistenceMechanismIs(persistenceMechanism)) {
- setFixtureInitializationState(state);
- }
- }
-
- protected void setFixtureInitializationState(final State state, final String persistenceMechanism) {
- if (persistenceMechanismIs(persistenceMechanism)) {
- setFixtureInitializationState(state);
- }
- }
-
- protected void setFixtureInitializationState(final State state) {
- getSqlIntegrationTestFixtures().setState(state);
- }
-
- protected boolean persistenceMechanismIs(final String persistenceMechanism) {
- return getProperties().getProperty("isis.persistor").equals(persistenceMechanism);
- }
-
- /**
- * This method can be used to do any DB specific actions the first time the test framework is setup. e.g. In the XML
- * test, it must delete all XML files in the data store directory.
- */
- public void resetPersistenceStoreDirectlyIfRequired() {
- }
-
- protected void testSetup() {
- resetPersistenceStoreDirectlyIfRequired();
- getSqlIntegrationTestFixtures().setState(State.INITIALIZE);
- }
-
- // //////////////////////////////////////////////////////////////////////////////
- // before, after
- // //////////////////////////////////////////////////////////////////////////////
-
- @Before
- public void setUpSystem() throws Exception {
- Logger.getRootLogger().setLevel(Level.INFO);
-
- if (!getSqlIntegrationTestFixtures().getState().isInitialize()) {
- return;
- }
-
- final Properties properties = getProperties();
- if (properties == null) {
- getSqlIntegrationTestFixtures().initSystem("src/test/config", getPropertiesFilename());
- } else {
- getSqlIntegrationTestFixtures().initSystem(properties);
- }
-
- final String sqlSetupString = getSqlSetupString();
- if (sqlSetupString != null) {
- getSqlIntegrationTestFixtures().sqlExecute(sqlSetupString);
- }
- }
-
- /**
- * optional hook
- */
- protected String getSqlSetupString() {
- return null;
- }
-
- @Before
- public void setUpFactory() throws Exception {
- factory = getSqlIntegrationTestFixtures().getSqlDataClassFactory();
-
- // may have been setup by previous test
- sqlDataClass = getSqlIntegrationTestFixtures().getSqlDataClass();
- referencingPolyTypesEntity = getSqlIntegrationTestFixtures().getPolyTestClass();
- }
-
- // //////////////////////////////////////////////////////////////////////////////
- // after
- // //////////////////////////////////////////////////////////////////////////////
-
- @After
- public void tearDown() throws Exception {
- if (!getSqlIntegrationTestFixtures().getState().isInitialize()) {
- return;
- }
- final String sqlTeardownString = getSqlTeardownString();
- if (sqlTeardownString != null) {
- try {
- getSqlIntegrationTestFixtures().sqlExecute(sqlTeardownString);
- } catch (final SQLException e) {
- e.printStackTrace();
- }
- }
- getSqlIntegrationTestFixtures().shutDown();
- }
-
- /**
- * optional hook
- */
- protected String getSqlTeardownString() {
- return null;
- }
-
-}