Search in sources :

Example 41 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class MonolineFormatterTest method testException.

/**
 * Tests formatting a log record which contains an exception.
 */
@Test
@DependsOnMethod("testlevelWidth")
public void testException() {
    final LogRecord record = new LogRecord(Level.WARNING, "An exception occured.");
    final Exception exception = new Exception();
    exception.setStackTrace(new StackTraceElement[] { new StackTraceElement("org.apache.sis.NonExistent", "foo", "NonExistent.java", 10), new StackTraceElement("org.junit.WhoKnows", "main", "WhoKnows.java", 20) });
    record.setThrown(exception);
    String formatted = formatter.format(record);
    assertMultilinesEquals(localize(Level.WARNING, "WARNING\t An exception occured.\n" + "\t Caused by: java.lang.Exception\n" + "\t     at org.apache.sis.NonExistent.foo(NonExistent.java:10)\n" + "\t     at org.junit.WhoKnows.main(WhoKnows.java:20)\n"), formatted);
    /*
         * Remove the message and try again.
         */
    record.setMessage(null);
    formatted = formatter.format(record);
    assertMultilinesEquals(localize(Level.WARNING, "WARNING\t java.lang.Exception\n" + "\t     at org.apache.sis.NonExistent.foo(NonExistent.java:10)\n" + "\t     at org.junit.WhoKnows.main(WhoKnows.java:20)\n"), formatted);
}
Also used : LogRecord(java.util.logging.LogRecord) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 42 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class IndexedResourceBundleTest method testList.

/**
 * Tests the {@link IndexedResourceBundle#list(Appendable)} method.
 *
 * @throws IOException should never happen since this test writes only in memory.
 */
@Test
@DependsOnMethod("testGetResources")
public void testList() throws IOException {
    final StringBuilder buffer = new StringBuilder(4096);
    Errors.getResources(Locale.ENGLISH).list(buffer);
    final String text = buffer.toString();
    final int key = text.indexOf("NullArgument_1");
    final int value = text.indexOf("Argument ‘{0}’ shall not be null.");
    assertTrue(key > 0);
    assertTrue(value > key);
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 43 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class IndexedResourceBundleTest method testGetKeys.

/**
 * Tests the {@link IndexedResourceBundle#getKeys()} method.
 */
@Test
@DependsOnMethod("testGetResources")
public void testGetKeys() {
    testing = Errors.getResources(Locale.ENGLISH);
    final Enumeration<String> e = testing.getKeys();
    int count = 0;
    boolean foundNullArgument_1 = false;
    while (e.hasMoreElements()) {
        final String key = e.nextElement();
        if (key.equals("NullArgument_1")) {
            foundNullArgument_1 = true;
        }
        count++;
    }
    assertTrue("foundNullArgument_1:", foundNullArgument_1);
    assertTrue("count > 5", count > 5);
    testing = null;
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 44 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class GeoKeysTest method verifyProjectionNames.

/**
 * Verifies that GeoTIFF projection aliases registered in the {@link org.apache.sis.internal.referencing.provider}
 * package match the name of fields listed in {@link GeoIdentifiers} and that GeoTIFF numerical codes correspond.
 * This method verifies only projection names and identifiers, not parameter names.
 */
@Test
@DependsOnMethod("testName")
public void verifyProjectionNames() {
    final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
    for (final OperationMethod method : factory.getAvailableMethods(SingleOperation.class)) {
        final Identifier identifier = IdentifiedObjects.getIdentifier(method, Citations.GEOTIFF);
        final Set<String> names = IdentifiedObjects.getNames(method, Citations.GEOTIFF);
        /*
             * If there is no GeoTIFF identifiers, we should have no GeoTIFF name neither.
             * However we may have more than one name, since GeoTIFF defines also aliases.
             */
        assertEquals(method.getName().getCode(), identifier == null, names.isEmpty());
        if (identifier != null) {
            final int code = Short.parseShort(identifier.getCode());
            for (final String name : names) {
                assertEquals(name, code, GeoIdentifiers.code(name));
            }
        }
    }
}
Also used : Identifier(org.opengis.metadata.Identifier) MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory) OperationMethod(org.opengis.referencing.operation.OperationMethod) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 45 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class MetadataCommandTest method testFormatXML.

/**
 * Tests with the same file than {@link #testNetCDF()}, but producing a XML output.
 *
 * @throws Exception if an error occurred while creating the command.
 */
@Test
@Ignore("Requires GeoAPI 3.1")
@DependsOnMethod("testNetCDF")
public void testFormatXML() throws Exception {
    final URL url = MetadataCommandTest.class.getResource("NCEP-SST.nc");
    final MetadataCommand test = new MetadataCommand(0, CommandRunner.TEST, url.toString(), "--format", "XML");
    test.run();
    verifyNetCDF("<?xml", test.outputBuffer.toString());
}
Also used : URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7