org.opengis.test.Assert.assertTrue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(15.0k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中org.opengis.test.Assert.assertTrue()方法的一些代码示例,展示了Assert.assertTrue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertTrue()方法的具体详情如下:
包路径:org.opengis.test.Assert
类名称:Assert
方法名:assertTrue

Assert.assertTrue介绍

暂无

代码示例

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Ensures that all <code>is&lt;</code><var>Operation</var><code>&gt;Supported</code> fields
 * are set to {@code true}. This method can be invoked before testing a math transform which
 * is expected to be fully implemented.
 */
protected void assertAllTestsEnabled() {
  assertTrue("isDoubleToDoubleSupported",   isDoubleToDoubleSupported  );
  assertTrue("isFloatToFloatSupported",     isFloatToFloatSupported    );
  assertTrue("isDoubleToFloatSupported",    isDoubleToFloatSupported   );
  assertTrue("isFloatToDoubleSupported",    isFloatToDoubleSupported   );
  assertTrue("isOverlappingArraySupported", isOverlappingArraySupported);
  assertTrue("isInverseTransformSupported", isInverseTransformSupported);
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Ensures that all <code>is&lt;</code><var>Operation</var><code>&gt;Supported</code> fields
 * are set to {@code true}. This method can be invoked before testing a math transform which
 * is expected to be fully implemented.
 *
 * @deprecated No replacement.
 */
@Deprecated
protected void assertAllTestsEnabled() {
  assertTrue("isDoubleToDoubleSupported",   isDoubleToDoubleSupported  );
  assertTrue("isFloatToFloatSupported",     isFloatToFloatSupported    );
  assertTrue("isDoubleToFloatSupported",    isDoubleToFloatSupported   );
  assertTrue("isFloatToDoubleSupported",    isFloatToDoubleSupported   );
  assertTrue("isOverlappingArraySupported", isOverlappingArraySupported);
  assertTrue("isInverseTransformSupported", isInverseTransformSupported);
  assertTrue("isDerivativeSupported",       isDerivativeSupported      );
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Ensure that given class exists and is an instance of the given type.
 *
 * @param field         the name of the tested field.
 * @param expectedType  the expected base class.
 * @param loader        the loader to use for loading the class.
 * @param classname     the name of the class to test.
 */
private void validateClass(final String field, final Class<?> expectedType,
    final ClassLoader loader, final String classname)
{
  mandatory("ImageReaderWriterSpi: shall have a " + field + " string.", classname);
  if (classname != null) try {
    final Class<?> actual = Class.forName(classname, false, loader);
    assertTrue(actual.getCanonicalName() + " is not an instance of " +
        expectedType.getSimpleName() + '.', expectedType.isAssignableFrom(actual));
  } catch (ClassNotFoundException e) {
    throw new AssertionError("Class \"" + classname + "\" declared in " + field + " was not found.", e);
  }
}

代码示例来源:origin: apache/sis

/**
   * Tests the {@link Types#getCodeValues(Class)} method.
   */
  @Test
  public void testGetCodeValues() {
    final OnLineFunction[] actual = Types.getCodeValues(OnLineFunction.class);
    assertTrue(Arrays.asList(actual).containsAll(Arrays.asList(
        OnLineFunction.INFORMATION, OnLineFunction.SEARCH, OnLineFunction.ORDER,
        OnLineFunction.DOWNLOAD, OnLineFunction.OFFLINE_ACCESS)));
  }
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Transforms the given coordinates, applies the inverse transform and compares with the
 * original values. If a difference between the expected and actual ordinate values is
 * greater than the {@linkplain #tolerance tolerance} threshold (after optional
 * {@linkplain #toleranceModifier tolerance modification}), then the assertion fails.
 *
 * <p>The default implementation delegates to {@link #verifyInverse(double[])}.</p>
 *
 * @param  coordinates  the source coordinates to transform.
 * @throws TransformException if at least one coordinate can't be transformed.
 */
protected void verifyInverse(final float... coordinates) throws TransformException {
  assertTrue("isInverseTransformSupported == false.", isInverseTransformSupported);
  final double[] sourceDoubles = new double[coordinates.length];
  for (int i=0; i<coordinates.length; i++) {
    sourceDoubles[i] = coordinates[i];
  }
  verifyInverse(sourceDoubles);
  final int dimension = transform.getSourceDimensions();
  assertCoordinatesEqual("Unexpected change in source coordinates.", dimension,
      coordinates, 0, sourceDoubles, 0, coordinates.length / dimension, CalculationType.IDENTITY);
}

代码示例来源:origin: apache/sis

/**
 * Tests {@link FranceGeocentricInterpolation#isRecognized(Path)}.
 */
@Test
public void testIsRecognized() {
  assertTrue (FranceGeocentricInterpolation.isRecognized(Paths.get("GR3DF97A.txt")));
  assertTrue (FranceGeocentricInterpolation.isRecognized(Paths.get("gr3df")));
  assertFalse(FranceGeocentricInterpolation.isRecognized(Paths.get("gr3d")));
  assertTrue (FranceGeocentricInterpolation.isRecognized(Paths.get(TEST_FILE)));
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given ellipsoid.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final Ellipsoid object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  final Unit<Length> unit = object.getAxisUnit();
  mandatory("Ellipsoid: must have a unit of measurement.", unit);
  if (unit != null) {
    assertTrue("Ellipsoid: unit must be compatible with metres.",
        unit.isCompatible(units.metre()));
  }
  final double semiMajor = object.getSemiMajorAxis();
  final double semiMinor = object.getSemiMinorAxis();
  assertTrue("Ellipsoid: expected semi-minor <= semi-major axis length.", semiMinor <= semiMajor);
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the vertical extent.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final VerticalExtent object) {
  if (object == null) {
    return;
  }
  final Double minimum = object.getMinimumValue();
  final Double maximum = object.getMaximumValue();
  mandatory("VerticalExtent: must have a minimum value.", minimum);
  mandatory("VerticalExtent: must have a maximum value.", maximum);
  if (minimum != null && maximum != null) {
    assertTrue("VerticalExtent: invalid range.", minimum <= maximum);
  }
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the geographic bounding box.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final GeographicBoundingBox object) {
  if (object == null) {
    return;
  }
  final double west  = object.getWestBoundLongitude();
  final double east  = object.getEastBoundLongitude();
  final double south = object.getSouthBoundLatitude();
  final double north = object.getNorthBoundLatitude();
  assertBetween("GeographicBoundingBox: illegal west bound.",  -180, +180, west);
  assertBetween("GeographicBoundingBox: illegal east bound.",  -180, +180, east);
  assertBetween("GeographicBoundingBox: illegal south bound.", -90,   +90, south);
  assertBetween("GeographicBoundingBox: illegal north bound.", -90,   +90, north);
  assertTrue("GeographicBoundingBox: invalid range of longitudes.", west <= east);
  assertTrue("GeographicBoundingBox: invalid range of latitudes.",  south <= north);
}

代码示例来源:origin: apache/sis

/**
 * Tests the {@link StorageConnector#getStorageAs(Class)} method for the {@link String} type.
 *
 * @throws DataStoreException if an error occurred while using the storage connector.
 * @throws IOException should never happen since we do not open any file.
 */
@Test
public void testGetAsString() throws DataStoreException, IOException {
  final StorageConnector c = create(false);
  assertTrue(c.getStorageAs(String.class).endsWith("org/apache/sis/storage/" + FILENAME));
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the vertical extent.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final VerticalExtent object) {
  if (object == null) {
    return;
  }
  final Double minimum = object.getMinimumValue();
  final Double maximum = object.getMaximumValue();
  mandatory("VerticalExtent: must have a minimum value.", minimum);
  mandatory("VerticalExtent: must have a maximum value.", maximum);
  if (minimum != null && maximum != null) {
    assertTrue("VerticalExtent: invalid range.", minimum <= maximum);
  }
  container.validate(object.getVerticalCRS());
}

代码示例来源:origin: apache/sis

/**
   * Tests the {@link StorageConnector#closeAllExcept(Object)} method.
   *
   * @throws DataStoreException if an error occurred while using the storage connector.
   * @throws IOException if an error occurred while reading the test file.
   */
  @Test
  @DependsOnMethod("testGetAsDataInputFromStream")
  public void testCloseAllExcept() throws DataStoreException, IOException {
    final StorageConnector connection = create(true);
    final DataInput input = connection.getStorageAs(DataInput.class);
    final ReadableByteChannel channel = ((ChannelImageInputStream) input).channel;
    assertTrue("channel.isOpen()", channel.isOpen());
    connection.closeAllExcept(input);
    assertTrue("channel.isOpen()", channel.isOpen());
    channel.close();
  }
}

代码示例来源:origin: apache/sis

/**
 * Tests <cite>"Geocentric translations (geocentric domain)"</cite> (EPSG:1031).
 *
 * @throws FactoryException if an error occurred while creating the transform.
 * @throws TransformException if transformation of a point failed.
 */
@Test
public void testGeocentricDomain() throws FactoryException, TransformException {
  create(new GeocentricTranslation());
  assertTrue(transform instanceof LinearTransform);
  derivativeDeltas = new double[] {100, 100, 100};                // In metres
  datumShift(2, 3);
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given prime meridian.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final PrimeMeridian object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  final Unit<Angle> unit = object.getAngularUnit();
  mandatory("PrimeMeridian: shall have a unit of measurement.", unit);
  double longitude = object.getGreenwichLongitude();
  if (unit != null) {
    final Unit<Angle> degree = units.degree();
    assertTrue("PrimeMeridian: unit must be compatible with degrees.", unit.isCompatible(degree));
    longitude = unit.getConverterTo(degree).convert(longitude);
  }
  assertBetween("PrimeMeridian: expected longitude in [-180 … +180]° range.", -180, +180, longitude);
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given prime meridian.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final PrimeMeridian object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  final Unit<Angle> unit = object.getAngularUnit();
  mandatory("PrimeMeridian: must have a unit of measurement.", unit);
  if (unit != null) {
    assertTrue("PrimeMeridian: unit must be compatible with degrees.",
        unit.isCompatible(units.degree()));
  }
  double longitude = object.getGreenwichLongitude();
  if (unit != null) {
    longitude = unit.getConverterTo(units.degree()).convert(longitude);
  }
  assertBetween("PrimeMeridian: expected longitude in [-180 ... +180°] range.", -180, +180, longitude);
}

代码示例来源:origin: apache/sis

/**
 * Verifies that {@link StorageConnector#getStorageAs(Class)} returns {@code null} for unavailable
 * target classes, and throws an exception for illegal target classes.
 *
 * @throws DataStoreException if an error occurred while using the storage connector.
 */
@Test
public void testGetInvalidObject() throws DataStoreException {
  final StorageConnector connection = create(true);
  assertNotNull("getStorageAs(InputStream.class)", connection.getStorageAs(InputStream.class));
  assertNull   ("getStorageAs(URI.class)",         connection.getStorageAs(URI.class));
  assertNull   ("getStorageAs(String.class)",      connection.getStorageAs(String.class));
  try {
    connection.getStorageAs(Float.class);       // Any unconvertible type.
    fail("Should not have accepted Float.class");
  } catch (UnconvertibleObjectException e) {
    final String message = e.getMessage();
    assertTrue(message, message.contains("Float"));
  }
  connection.closeAllExcept(null);
}

代码示例来源:origin: apache/sis

/**
 * Implementation of {@link #testGetAsDataInputFromURL()} and {@link #testGetAsDataInputFromStream()}.
 */
private void testGetAsDataInput(final boolean asStream) throws DataStoreException, IOException {
  final StorageConnector connection = create(asStream);
  final DataInput input = connection.getStorageAs(DataInput.class);
  assertSame("Value shall be cached.", input, connection.getStorageAs(DataInput.class));
  assertInstanceOf("Needs the SIS implementation.", ChannelImageInputStream.class, input);
  assertSame("Instance shall be shared.", input, connection.getStorageAs(ChannelDataInput.class));
  /*
   * Reads a single integer for checking that the stream is at the right position, then close the stream.
   * Since the file is a compiled Java class, the integer that we read shall be the Java magic number.
   */
  final ReadableByteChannel channel = ((ChannelImageInputStream) input).channel;
  assertTrue("channel.isOpen()", channel.isOpen());
  assertEquals("First 4 bytes", MAGIC_NUMBER, input.readInt());
  connection.closeAllExcept(null);
  assertFalse("channel.isOpen()", channel.isOpen());
}

代码示例来源:origin: apache/sis

/**
   * Tests a category with a NaN value.
   */
  @Test
  public void testCategoryNaN() {
    final Category category = new Category("NaN", new NumberRange<>(Float.class, Float.NaN, true, Float.NaN, true), null, null, null);
    final NumberRange<?> range = category.getSampleRange();
    assertSame  ("converse",       category,   category.converse);
    assertEquals("name",           "NaN",      String.valueOf(category.name));
    assertEquals("name",           "NaN",      String.valueOf(category.getName()));
    assertEquals("minimum",        Double.NaN, category.minimum, STRICT);
    assertEquals("maximum",        Double.NaN, category.maximum, STRICT);
    assertNull  ("sampleRange",                category.range);
    assertEquals("range.minValue", Float.NaN,  range.getMinValue());
    assertEquals("range.maxValue", Float.NaN,  range.getMaxValue());
    assertFalse ("measurementRange",           category.getMeasurementRange().isPresent());
    assertFalse ("transferFunction",           category.getTransferFunction().isPresent());
    assertTrue  ("toConverse.isIdentity",      category.toConverse.isIdentity());
    assertFalse ("isQuantitative",             category.isQuantitative());
  }
}

代码示例来源:origin: apache/sis

/**
 * Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for a UCAR {@link NetcdfFile} object.
 *
 * @throws IOException if an error occurred while opening the netCDF file.
 * @throws DataStoreException if a logical error occurred.
 */
@Test
public void testProbeContentFromUCAR() throws IOException, DataStoreException {
  try (NetcdfFile file = createUCAR(TestData.NETCDF_2D_GEOGRAPHIC)) {
    final StorageConnector c = new StorageConnector(file);
    final NetcdfStoreProvider provider = new NetcdfStoreProvider();
    final ProbeResult probe = provider.probeContent(c);
    assertTrue  ("isSupported", probe.isSupported());
    assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType());
    assertNull  ("getVersion",  probe.getVersion());
  }
}

代码示例来源:origin: apache/sis

/**
 * Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for an input stream which shall
 * be recognized as a classic netCDF file.
 *
 * @throws DataStoreException if a logical error occurred.
 */
@Test
public void testProbeContentFromStream() throws DataStoreException {
  final StorageConnector c = new StorageConnector(TestData.NETCDF_2D_GEOGRAPHIC.location());
  final NetcdfStoreProvider provider = new NetcdfStoreProvider();
  final ProbeResult probe = provider.probeContent(c);
  assertTrue  ("isSupported", probe.isSupported());
  assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType());
  assertEquals("getVersion",  new Version("1"), probe.getVersion());
  c.closeAllExcept(null);
}

相关文章