001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * http://www.geoapi.org 004 * 005 * Copyright (C) 2009-2019 Open Geospatial Consortium, Inc. 006 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal 007 * 008 * Permission to use, copy, and modify this software and its documentation, with 009 * or without modification, for any purpose and without fee or royalty is hereby 010 * granted, provided that you include the following on ALL copies of the software 011 * and documentation or portions thereof, including modifications, that you make: 012 * 013 * 1. The full text of this NOTICE in a location viewable to users of the 014 * redistributed or derivative work. 015 * 2. Notice of any changes or modifications to the OGC files, including the 016 * date changes were made. 017 * 018 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE 019 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 020 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT 021 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY 022 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. 023 * 024 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR 025 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. 026 * 027 * The name and trademarks of copyright holders may NOT be used in advertising or 028 * publicity pertaining to the software without specific, written prior permission. 029 * Title to copyright in this software and any associated documentation will at all 030 * times remain with copyright holders. 031 */ 032package org.opengis.test.referencing; 033 034import java.util.List; 035 036import org.opengis.referencing.crs.*; 037import org.opengis.util.Factory; 038import org.opengis.util.FactoryException; 039import org.opengis.referencing.NoSuchAuthorityCodeException; 040 041import org.junit.Test; 042import org.junit.runner.RunWith; 043import org.junit.runners.Parameterized; 044 045 046/** 047 * Tests {@link CoordinateReferenceSystem} and related objects 048 * from the {@code org.opengis.referencing.crs} package. 049 * CRS instances are created using the authority factory given at construction time. 050 * 051 * <div class="note"><b>Usage example:</b> 052 * in order to specify their factories and run the tests in a JUnit framework, implementors can 053 * define a subclass in their own test suite as in the example below: 054 * 055 * <blockquote><pre>import org.junit.runner.RunWith; 056 *import org.junit.runners.JUnit4; 057 *import org.opengis.test.referencing.CRSTest; 058 * 059 *@RunWith(JUnit4.class) 060 *public class MyTest extends CRSTest { 061 * public MyTest() { 062 * super(new MyCRSAuthorityFactory()); 063 * } 064 *}</pre></blockquote> 065 * </div> 066 * 067 * @author Cédric Briançon (Geomatys) 068 * @author Martin Desruisseaux (Geomatys) 069 * @version 3.1 070 * @since 2.3 071 * 072 * @deprecated Renamed as {@link AuthorityFactoryTest}. 073 */ 074@Deprecated 075@RunWith(Parameterized.class) 076public strictfp class CRSTest extends ReferencingTestCase { 077 /** 078 * The authority factory for creating a {@link CoordinateReferenceSystem} from a code, 079 * or {@code null} if none. 080 */ 081 protected final CRSAuthorityFactory factory; 082 083 /** 084 * Returns a default set of factories to use for running the tests. Those factories are given 085 * in arguments to the constructor when this test class is instantiated directly by JUnit (for 086 * example as a {@linkplain org.junit.runners.Suite.SuiteClasses suite} element), instead than 087 * subclassed by the implementor. The factories are fetched as documented in the 088 * {@link #factories(Class[])} javadoc. 089 * 090 * @return the default set of arguments to be given to the {@code CRSTest} constructor. 091 * 092 * @since 3.1 093 */ 094 @Parameterized.Parameters 095 @SuppressWarnings("unchecked") 096 public static List<Factory[]> factories() { 097 return factories(CRSAuthorityFactory.class); 098 } 099 100 /** 101 * Creates a new test using the given factory. If the given factory is {@code null}, 102 * then the tests will be skipped. 103 * 104 * @param factory factory for creating {@link CoordinateReferenceSystem} instances. 105 */ 106 public CRSTest(final CRSAuthorityFactory factory) { 107 super(factory); 108 this.factory = factory; 109 } 110 111 /** 112 * Tests the creation of the WGS84 {@linkplain CoordinateReferenceSystem crs} from the 113 * EPSG code. 114 * 115 * @throws NoSuchAuthorityCodeException if the specified code is not found among the ones present in the database. 116 * @throws FactoryException if the creation of the {@link CoordinateReferenceSystem} failed for an other raison. 117 */ 118 @Test 119 public void testCRSAuthorityCreation() throws NoSuchAuthorityCodeException, FactoryException { 120 new AuthorityFactoryTest(factory, null, null).testWGS84(); 121 } 122}