sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1608469 - /sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
Date Mon, 07 Jul 2014 14:18:30 GMT
Author: desruisseaux
Date: Mon Jul  7 14:18:29 2014
New Revision: 1608469

URL: http://svn.apache.org/r1608469
Log:
Missing class in previous commit.

Added:
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
  (with props)

Added: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java?rev=1608469&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
(added)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
[UTF-8] Mon Jul  7 14:18:29 2014
@@ -0,0 +1,114 @@
+/*
+ * 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.sis.util.iso;
+
+import java.util.Map;
+import java.util.LinkedHashMap;
+import org.opengis.util.Type;
+import org.opengis.util.RecordType;
+import org.opengis.util.MemberName;
+
+// Test imports
+import org.apache.sis.internal.simple.SimpleAttributeType;
+import org.junit.Test;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link DefaultRecordSchema} implementation.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+@DependsOn({
+    DefaultRecordTypeTest.class,
+    NamesTest.class
+})
+public final strictfp class DefaultRecordSchemaTest extends TestCase {
+    /**
+     * Tests {@link DefaultRecordSchema#createRecordType(CharSequence, Map)}.
+     */
+    @Test
+    public void testCreateRecordType() {
+        final DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "MySchema");
+        final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(8);
+        assertNull(members.put("city",       String.class));
+        assertNull(members.put("latitude",   Double.class));
+        assertNull(members.put("longitude",  Double.class));
+        assertNull(members.put("population", Integer.class));
+        final RecordType recordType = schema.createRecordType("MyRecordType", members);
+        /*
+         * Inspect properties.
+         */
+        assertSame("container", schema, recordType.getContainer());
+        assertEquals("typeName", Names.createTypeName("MySchema", ":", "MyRecordType"), recordType.getTypeName());
+        int count = 0;
+        for (final Map.Entry<MemberName, Type> entry : recordType.getMemberTypes().entrySet())
{
+            final String     expectedName;
+            final String     expectedType;
+            final Class<?>   expectedClass;
+            switch (count) {
+                case 0: {
+                    expectedName  = "city";
+                    expectedType  = "gco:CharacterString";
+                    expectedClass = String.class;
+                    break;
+                }
+                case 1: {
+                    expectedName  = "latitude";
+                    expectedType  = "gco:Real";
+                    expectedClass = Double.class;
+                    break;
+                }
+                case 2: {
+                    expectedName  = "longitude";
+                    expectedType  = "gco:Real";
+                    expectedClass = Double.class;
+                    break;
+                }
+                case 3: {
+                    expectedName  = "population";
+                    expectedType  = "gco:Integer";
+                    expectedClass = Integer.class;
+                    break;
+                }
+                default: {
+                    throw new AssertionError(count);
+                }
+            }
+            final Type type = entry.getValue();
+            assertEquals(expectedName,  entry.getKey().toString());
+            assertEquals(expectedType,  type.getTypeName().toFullyQualifiedName().toString());
+            assertEquals(expectedClass, ((SimpleAttributeType) type).getValueClass());
+            count++;
+        }
+        /*
+         * The DefaultRecordType(TypeName, RecordSchema, Map) constructor performs many argument
checks, so
+         * we use that constructor as a way to perform a final validation, especially regarding
namespaces.
+         */
+        final DefaultRecordType copy = new DefaultRecordType(
+                recordType.getTypeName(),
+                recordType.getContainer(),
+                recordType.getMemberTypes());
+        assertEquals(recordType, copy);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8



Mime
View raw message