/*
 * 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.console;

import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;

import static org.apache.sis.test.Assert.*;


/**
 * Tests the {@link CRSCommand} sub-command.
 *
 * @author  Martin Desruisseaux (Geomatys)
 * @since   0.8
 * @version 0.8
 * @module
 */
@DependsOn(CommandRunnerTest.class)
public final strictfp class CRSCommandTest extends TestCase {
    /**
     * The Well Known Text for EPSG:4326.
     */
    private static final String WGS84 =
            "GeodeticCRS[\"WGS 84\",\n" +
            "  Datum[\"World Geodetic System 1984\",\n" +
            "    Ellipsoid[\"WGS 84\", 6378137.0, 298.257223563]],\n" +
            "  CS[ellipsoidal, 2],\n" +
            "    Axis[\"Latitude (B)\", north],\n" +
            "    Axis[\"Longitude (L)\", east],\n" +
            "    Unit[\"degree\", 0.017453292519943295],\n" +
            "  Scope[\"Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.\"],\n" +
            "  Area[\"World.\"],\n" +
            "  BBox[-90.00, -180.00, 90.00, 180.00],\n" +
            "  Id[\"EPSG\", 4326, \"8.9\", URI[\"urn:ogc:def:crs:EPSG:8.9:4326\"]]]\n";

    /**
     * Tests fetching the CRS from a simple code ({@code "EPSG:4326"}).
     *
     * @throws Exception if an error occurred while creating the command.
     */
    @Test
    public void testCode() throws Exception {
        final CRSCommand test = new CRSCommand(0, CommandRunner.TEST, "EPSG:4326");
        test.run();
        assertMultilinesEquals(WGS84, test.outputBuffer.toString());
    }

    /**
     * Tests fetching the CRS from a URN ({@code "urn:ogc:def:crs:epsg::4326"}).
     *
     * @throws Exception if an error occurred while creating the command.
     */
    @Test
    @DependsOnMethod("testCode")
    public void testURN() throws Exception {
        final CRSCommand test = new CRSCommand(0, CommandRunner.TEST, "urn:ogc:def:crs:epsg::4326");
        test.run();
        assertMultilinesEquals(WGS84, test.outputBuffer.toString());
    }

    /**
     * Tests fetching the CRS from a HTTP code ({@code "http://www.opengis.net/gml/srs/epsg.xml#4326"}).
     *
     * @throws Exception if an error occurred while creating the command.
     */
    @Test
    @DependsOnMethod("testURN")
    public void testHTTP() throws Exception {
        final CRSCommand test = new CRSCommand(0, CommandRunner.TEST, "http://www.opengis.net/gml/srs/epsg.xml#4326");
        test.run();
        assertMultilinesEquals(WGS84, test.outputBuffer.toString());
    }
}

@@ -989,30 +989,20 @@
 tic org.
-apache.sis.tes
+juni
 t.Assert
@@ -1295,16 +1295,40 @@
 PSG:4326
+ as a regular expression
 .%0A     *
@@ -1382,16 +1382,19 @@
        %22
+%5C%5CQ
 Geodetic
@@ -1813,103 +1813,99 @@
 tem.
- Used by the GPS satellite navigation system and for NATO military geodetic surveying.%5C%22%5D,%5Cn%22 +
+%5C%5CE.*%5C%5CQ%5C%22%5D,%5Cn%22 +                      // EPSG geodetic dataset provides more details here.
 %0A   
@@ -1927,14 +1927,16 @@
 a%5B%5C%22
-World.
+%5C%5CE.*%5C%5CQ
 %5C%22%5D,
@@ -1936,24 +1936,130 @@
 %5C%5CQ%5C%22%5D,%5Cn%22 +
+                                                         // Language may vary because of SIS localization.
 %0A           
@@ -2142,17 +2142,16 @@
 326,
- %5C%228.9%5C%22,
+%5C%5CE.*%5C%5CQ
  URI
@@ -2178,11 +2178,16 @@
 PSG:
-8.9
+%5C%5CE.*%5C%5CQ
 :432
@@ -2198,10 +2198,58 @@
 %5D%5D%5Cn
-%22;
+%5C%5CE%22;  // Version number of EPSG dataset may vary.
 %0A%0A  
@@ -2587,65 +2587,98 @@
     
-assertMultilinesEquals(WGS84, test.outputBuffer.toString(
+final String wkt = test.outputBuffer.toString();%0A        assertTrue(wkt, wkt.matches(WGS84
 ));%0A
@@ -3083,65 +3083,98 @@
     
-assertMultilinesEquals(WGS84, test.outputBuffer.toString(
+final String wkt = test.outputBuffer.toString();%0A        assertTrue(wkt, wkt.matches(WGS84
 ));%0A
@@ -3621,65 +3621,98 @@
     
-assertMultilinesEquals(WGS84, test.outputBuffer.toString(
+final String wkt = test.outputBuffer.toString();%0A        assertTrue(wkt, wkt.matches(WGS84
 ));%0A

Make a test more robust to different way a WKT may be expressed. This fix a test failure when the EPSG geodetic dataset is not installed.