From commits-return-6442-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Wed Oct 7 14:00:26 2015 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1D2117BF0 for ; Wed, 7 Oct 2015 14:00:26 +0000 (UTC) Received: (qmail 95423 invoked by uid 500); 7 Oct 2015 13:59:52 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 95392 invoked by uid 500); 7 Oct 2015 13:59:52 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 95383 invoked by uid 99); 7 Oct 2015 13:59:52 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2015 13:59:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 36582180E0F for ; Wed, 7 Oct 2015 13:59:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.79 X-Spam-Level: * X-Spam-Status: No, score=1.79 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id mqSiXi5LQUpf for ; Wed, 7 Oct 2015 13:59:49 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 6D6E3439C4 for ; Wed, 7 Oct 2015 13:59:49 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id CDA4CE0ED5 for ; Wed, 7 Oct 2015 13:59:48 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id AED833A03EC for ; Wed, 7 Oct 2015 13:59:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1707309 [3/3] - in /sis/trunk: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/ core/sis-metad... Date: Wed, 07 Oct 2015 13:59:48 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151007135948.AED833A03EC@svn01-us-west.apache.org> Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java?rev=1707309&r1=1707308&r2=1707309&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java [UTF-8] Wed Oct 7 13:59:47 2015 @@ -16,19 +16,14 @@ */ package org.apache.sis.internal.jaxb; -import java.net.URI; import java.util.Map; import java.util.List; import java.util.ArrayList; -import java.util.Iterator; -import java.util.Collection; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; -import org.apache.sis.xml.IdentifierMap; import org.apache.sis.test.TestCase; import org.junit.Test; -import static java.util.UUID.fromString; import static org.apache.sis.test.Assert.*; import static org.apache.sis.xml.IdentifierSpace.*; @@ -38,198 +33,11 @@ import static org.apache.sis.xml.Identif * * @author Martin Desruisseaux (Geomatys) * @since 0.3 - * @version 0.3 + * @version 0.7 * @module */ public strictfp class IdentifierMapAdapterTest extends TestCase { /** - * Creates the {@link IdentifierMapAdapter} instance to test for the given identifiers. - * This {@code IdentifierMapAdapterTest} class creates {@link IdentifierMapAdapter} instances. - * Subclasses will override this method in order to create instances of the class to test. - * - * @param identifiers The identifiers to wrap in an {@code IdentifierMapAdapter}. - * @return The {@code IdentifierMapAdapter} to test. - */ - IdentifierMapAdapter create(final Collection identifiers) { - return new IdentifierMapAdapter(identifiers); - } - - /** - * Asserts that the content of the given map is equals to the given content, represented - * as a string. Subclasses can override this method in order to alter the expected string. - * This is needed when, using the "special case rules", {@code "href"} have been replaced - * be {@code "xlink:href"}. - * - * @param expected The expected content. - * @return The map to compare with the expected content. - */ - void assertMapEquals(final String expected, final Map map) { - assertEquals(expected, map.toString()); - } - - /** - * Returns a string representation of the given {@code href} value. - * The default implementation returns the value unchanged. - */ - String toHRefString(final String href) { - return href; - } - - /** - * Tests read and write operations on an {@link IdentifierMapAdapter}, using a well-formed - * identifier collection (no null values, no duplicated authorities). - * - *

This test does not use the {@link IdentifierMap}-specific API.

- */ - @Test - public void testGetAndPut() { - final List identifiers = new ArrayList(); - final Map map = create(identifiers); - assertTrue ("Newly created map shall be empty.", map.isEmpty()); - assertEquals("Newly created map shall be empty.", 0, map.size()); - /* - * Add two entries, then verify the map content. - */ - assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID"))); - assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID"))); - assertFalse ("After add, map shall not be empty.", map.isEmpty()); - assertEquals("After add, map shall not be empty.", 2, map.size()); - assertEquals("After add, map shall not be empty.", 2, identifiers.size()); - assertTrue ("Shall contain the entry we added.", map.containsKey(ID)); - assertTrue ("Shall contain the entry we added.", map.containsKey(UUID)); - assertFalse ("Shall not contain entry we didn't added.", map.containsKey(HREF)); - assertTrue ("Shall contain the entry we added.", map.containsValue("myID")); - assertTrue ("Shall contain the entry we added.", map.containsValue("myUUID")); - assertFalse ("Shall not contain entry we didn't added.", map.containsValue("myHREF")); - assertEquals("Shall contain the entry we added.", "myID", map.get(ID)); - assertEquals("Shall contain the entry we added.", "myUUID", map.get(UUID)); - assertNull ("Shall not contain entry we didn't added.", map.get(HREF)); - assertMapEquals("{gml:id=“myID”, gco:uuid=“myUUID”}", map); - /* - * Alter one entry (no new entry added). - */ - assertEquals("Shall get the old value.", "myUUID", map.put(UUID, "myNewUUID")); - assertFalse ("Shall not contain anymore the old value.", map.containsValue("myUUID")); - assertTrue ("Shall contain the new value.", map.containsValue("myNewUUID")); - assertMapEquals("{gml:id=“myID”, gco:uuid=“myNewUUID”}", map); - assertEquals("Map size shall be unchanged.", 2, map.size()); - assertEquals("Map size shall be unchanged.", 2, identifiers.size()); - /* - * Add a third identifier. - */ - assertNull ("Shall not contain entry we didn't added.", map.put(HREF, "myHREF")); - assertTrue ("Shall contain the entry we added.", map.containsValue("myHREF")); - assertTrue ("Shall contain the entry we added.", map.containsKey(HREF)); - assertMapEquals("{gml:id=“myID”, gco:uuid=“myNewUUID”, xlink:href=“myHREF”}", map); - assertEquals("Map size shall be updated.", 3, map.size()); - assertEquals("Map size shall be updated.", 3, identifiers.size()); - /* - * Remove an identifier using the Map.remove(…) API. - */ - assertEquals("Shall get the old value.", "myNewUUID", map.remove(UUID)); - assertFalse ("Shall not contain the entry we removed.", map.containsValue("myNewUUID")); - assertFalse ("Shall not contain the entry we removed.", map.containsKey(UUID)); - assertMapEquals("{gml:id=“myID”, xlink:href=“myHREF”}", map); - assertEquals("Map size shall be updated.", 2, map.size()); - assertEquals("Map size shall be updated.", 2, identifiers.size()); - /* - * Remove an identifier using the Set.remove(…) API on values. - */ - assertTrue (map.values().remove(toHRefString("myHREF"))); - assertFalse ("Shall not contain the entry we removed.", map.containsValue("myHREF")); - assertFalse ("Shall not contain the entry we removed.", map.containsKey(HREF)); - assertMapEquals("{gml:id=“myID”}", map); - assertEquals("Map size shall be updated.", 1, map.size()); - assertEquals("Map size shall be updated.", 1, identifiers.size()); - /* - * Remove an identifier using the Set.remove(…) API on keys. - */ - assertTrue (map.keySet().remove(ID)); - assertFalse ("Shall not contain the entry we removed.", map.containsValue("myID")); - assertFalse ("Shall not contain the entry we removed.", map.containsKey(ID)); - assertMapEquals("{}", map); - assertEquals("Map size shall be updated.", 0, map.size()); - assertEquals("Map size shall be updated.", 0, identifiers.size()); - } - - /** - * Tests write operations on an {@link IdentifierMap} using specific API. - */ - @Test - public void testPutSpecialized() { - final List identifiers = new ArrayList(); - final IdentifierMap map = create(identifiers); - final String myID = "myID"; - final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"); - final URI myURI = URI.create("http://mylink"); - - assertNull(map.putSpecialized(ID, myID)); - assertNull(map.putSpecialized(UUID, myUUID)); - assertNull(map.putSpecialized(HREF, myURI)); - assertMapEquals("{gml:id=“myID”," - + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”," - + " xlink:href=“http://mylink”}", map); - - assertSame(myID, map.getSpecialized(ID)); - assertSame(myUUID, map.getSpecialized(UUID)); - assertSame(myURI, map.getSpecialized(HREF)); - assertEquals("myID", map.get(ID)); - assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get(UUID)); - assertEquals("http://mylink", map.get(HREF)); - } - - /** - * Tests read operations on an {@link IdentifierMap} using specific API. - */ - @Test - public void testGetSpecialized() { - final List identifiers = new ArrayList(); - final IdentifierMap map = create(identifiers); - - assertNull(map.put(ID, "myID")); - assertNull(map.put(UUID, "a1eb6e53-93db-4942-84a6-d9e7fb9db2c7")); - assertNull(map.put(HREF, "http://mylink")); - assertMapEquals("{gml:id=“myID”," - + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”," - + " xlink:href=“http://mylink”}", map); - - assertEquals("myID", map.get (ID)); - assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get (UUID)); - assertEquals("http://mylink", map.get (HREF)); - assertEquals("myID", map.getSpecialized(ID)); - assertEquals(URI.create("http://mylink"), map.getSpecialized(HREF)); - assertEquals(fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"), map.getSpecialized(UUID)); - } - - /** - * Tests the handling of duplicated authorities. - */ - @Test - public void testDuplicatedAuthorities() { - final List identifiers = new ArrayList(); - assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID1"))); - assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID"))); - assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID2"))); - - final IdentifierMap map = create(identifiers); - assertEquals("Duplicated authorities shall be filtered.", 2, map.size()); - assertEquals("Duplicated authorities shall still exist.", 3, identifiers.size()); - assertEquals("myID1", map.get(ID)); - assertEquals("myUUID", map.get(UUID)); - - final Iterator it = map.keySet().iterator(); - assertTrue(it.hasNext()); - assertSame(ID, it.next()); - it.remove(); - assertTrue(it.hasNext()); - assertSame(UUID, it.next()); - assertFalse("Duplicated authority shall have been removed.", it.hasNext()); - - assertEquals(1, identifiers.size()); - assertEquals(1, map.size()); - } - - /** * Tests serialization. */ @Test @@ -239,7 +47,7 @@ public strictfp class IdentifierMapAdapt assertSame(HREF, assertSerializedEquals(HREF)); final List identifiers = new ArrayList(); - final Map map = create(identifiers); + final Map map = new IdentifierMapAdapter(identifiers); assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID"))); assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID"))); Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java?rev=1707309&r1=1707308&r2=1707309&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java [UTF-8] Wed Oct 7 13:59:47 2015 @@ -22,7 +22,7 @@ import org.opengis.metadata.Identifier; import org.opengis.metadata.quality.Result; import org.apache.sis.xml.IdentifiedObject; import org.apache.sis.xml.IdentifierMap; -import org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCases; +import org.apache.sis.internal.jaxb.ModifiableIdentifierMap; /** @@ -84,7 +84,7 @@ final strictfp class PropertyTypeMock ex /** Creates a new instance with initially no identifier. */ Value() { identifiers = new ArrayList(); - map = new IdentifierMapWithSpecialCases(identifiers); + map = new ModifiableIdentifierMap(identifiers); } /** Returns the identifiers as a modifiable list. */ Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1707309&r1=1707308&r2=1707309&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Wed Oct 7 13:59:47 2015 @@ -139,7 +139,7 @@ import org.junit.BeforeClass; org.apache.sis.xml.MarshallerPoolTest.class, org.apache.sis.internal.jaxb.XmlUtilitiesTest.class, org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class, - org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class, + org.apache.sis.internal.jaxb.ModifiableIdentifierMapTest.class, org.apache.sis.internal.jaxb.gco.StringAdapterTest.class, org.apache.sis.internal.jaxb.gco.PropertyTypeTest.class, org.apache.sis.internal.jaxb.gmd.LanguageCodeTest.class,