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

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

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

Assert.assertFalse介绍

暂无

代码示例

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

/**
 * Validates the image or stream metadata format names.
 * This method ensures that there is no duplicated values.
 */
private static void validateMetadataFormatName(final String type, String nativeMetadataFormatName,
    final String[] extraMetadataFormatNames)
{
  if (nativeMetadataFormatName != null) {
    nativeMetadataFormatName = nativeMetadataFormatName.trim();
    assertFalse("The native" + type + "MetadataFormatName value can not be equal to \"" +
        IIOMetadataFormatImpl.standardMetadataFormatName + "\".",
        IIOMetadataFormatImpl.standardMetadataFormatName.equalsIgnoreCase(nativeMetadataFormatName));
  }
  if (extraMetadataFormatNames != null) {
    final String field = "extra" + type + "MetadataFormatNames";
    validateArray(field, extraMetadataFormatNames);
    for (int i=0; i<extraMetadataFormatNames.length; i++) {
      final String formatName = extraMetadataFormatNames[i].trim();
      assertFalse("The " + field + '[' + i + "] value can not be equal to \"" +
          IIOMetadataFormatImpl.standardMetadataFormatName + "\".",
          IIOMetadataFormatImpl.standardMetadataFormatName.equalsIgnoreCase(formatName));
      if (nativeMetadataFormatName != null) {
        assertFalse("The " + field + '[' + i + "] value can not be equal to \"" +
            nativeMetadataFormatName + "\" since it is already declared as the native format name.",
            nativeMetadataFormatName.equalsIgnoreCase(formatName));
      }
    }
  }
}

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

/**
 * Tests the {@link ValueMap#entrySet()} method for the same metadata than {@link #testEntrySet()},
 * but asking for all non-null and non-nil entries including the empty collections.
 */
@Test
@DependsOnMethod("testEntrySet")
public void testEntrySetForNonNil() {
  final Map<String,Object> map = createCitation();
  final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
      null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_NIL);
  assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
  assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
  assertFalse("Nil objects shall be excluded.", map.containsKey("edition"));
  assertFalse("Nil objects shall be excluded.", all.containsKey("edition"));
  assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
  assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
  assertArrayEquals(new SimpleEntry<?,?>[] {
    new SimpleEntry<>("title",                   title),
    new SimpleEntry<>("alternateTitles",         emptyList()),
    new SimpleEntry<>("dates",                   emptyList()),
    new SimpleEntry<>("identifiers",             citation.getIdentifiers()),
    new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
    new SimpleEntry<>("presentationForms",       emptySet()),
    new SimpleEntry<>("ISBN",                    "9782505004509"),
    new SimpleEntry<>("onlineResources",         emptyList()),
    new SimpleEntry<>("graphics",                emptyList())
  }, all.entrySet().toArray());
}

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

/**
 * Tests the {@link ValueMap#entrySet()} method for the same metadata than {@link #testEntrySet()},
 * but asking for all non-null entries including nil objects and the empty collections.
 */
@Test
@DependsOnMethod("testEntrySet")
public void testEntrySetForNonNull() {
  final Map<String,Object> map = createCitation();
  final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
      null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_NULL);
  assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
  assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
  assertFalse("Nil objects shall be excluded.", map.containsKey("edition"));
  assertTrue ("Nil objects shall be included.", all.containsKey("edition"));
  assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
  assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
  assertArrayEquals(new SimpleEntry<?,?>[] {
    new SimpleEntry<>("title",                   title),
    new SimpleEntry<>("alternateTitles",         emptyList()),
    new SimpleEntry<>("dates",                   emptyList()),
    new SimpleEntry<>("edition",                 NilReason.UNKNOWN.createNilObject(InternationalString.class)),
    new SimpleEntry<>("identifiers",             citation.getIdentifiers()),
    new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
    new SimpleEntry<>("presentationForms",       emptySet()),
    new SimpleEntry<>("ISBN",                    "9782505004509"),
    new SimpleEntry<>("onlineResources",         emptyList()),
    new SimpleEntry<>("graphics",                emptyList())
  }, all.entrySet().toArray());
}

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

/**
 * Invoked when the existence of a mandatory attribute needs to be verified.
 * If the given value is {@code null} or is an {@linkplain Collection#isEmpty()
 * empty collection}, then there is a choice:
 *
 * <ul>
 *   <li>If {@link #requireMandatoryAttributes} is {@code true} (which is the default),
 *       then the test fails with the given message.</li>
 *   <li>Otherwise, the message is logged as a warning and the test continues.</li>
 * </ul>
 *
 * Subclasses can override this method if they want more control.
 *
 * @param message  the message to send in case of failure.
 * @param value    the value to test for non-nullity.
 *
 * @see #requireMandatoryAttributes
 * @see Obligation#MANDATORY
 */
protected void mandatory(final String message, final Object value) {
  if (requireMandatoryAttributes) {
    assertNotNull(message, value);
    assertFalse(message, isEmptyCollection(value));
  } else if (value == null || isEmptyCollection(value)) {
    WarningMessage.log(logger, message, true);
  }
}

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

final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
    null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.ALL);
assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
  new SimpleEntry<>("title",                   title),

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

/**
 * Validates the given conversion.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final Conversion object) {
  if (object == null) {
    return;
  }
  validateOperation(object);
  assertFalse("Projection: can't be both planar and conic.",
      (object instanceof PlanarProjection) && (object instanceof ConicProjection));
  assertFalse("Projection: can't be both planar and cylindrical.",
      (object instanceof PlanarProjection) && (object instanceof CylindricalProjection));
  assertFalse("Projection: can't be both cylindrical and conic.",
      (object instanceof CylindricalProjection) && (object instanceof ConicProjection));
  if (object.getMathTransform() != null) {
    mandatory("Conversion: non-defining conversion should have a source CRS.", object.getSourceCRS());
    mandatory("Conversion: non-defining conversion should have a target CRS.", object.getTargetCRS());
  }
  forbidden("Conversion: should not have operation version.", object.getOperationVersion());
  if (object.getMathTransform() == null) {
    forbidden("Conversion: defining conversion should not have source CRS", object.getSourceCRS());
    forbidden("Conversion: defining conversion should not have target CRS", object.getTargetCRS());
  }
}

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

/**
 * Validates the given conversion.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final Conversion object) {
  if (object == null) {
    return;
  }
  validateOperation(object);
  assertFalse("Projection: can't be both planar and conic.",
      (object instanceof PlanarProjection) && (object instanceof ConicProjection));
  assertFalse("Projection: can't be both planar and cylindrical.",
      (object instanceof PlanarProjection) && (object instanceof CylindricalProjection));
  assertFalse("Projection: can't be both cylindrical and conic.",
      (object instanceof CylindricalProjection) && (object instanceof ConicProjection));
  if (object.getMathTransform() != null) {
    mandatory("Conversion: non-defining conversion should have a source CRS.", object.getSourceCRS());
    mandatory("Conversion: non-defining conversion should have a target CRS.", object.getTargetCRS());
  }
  forbidden("Conversion: should not have operation version.", object.getOperationVersion());
  if (object.getMathTransform() == null) {
    forbidden("Conversion: defining conversion should not have source CRS", object.getSourceCRS());
    forbidden("Conversion: defining conversion should not have target CRS", object.getTargetCRS());
  }
}

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

/**
 * Ensures that the {@link CharSequence} methods are consistent with the {@code toString()} value.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final InternationalString object) {
  if (object == null) {
    return;
  }
  final int length = object.length();
  final String s = object.toString();
  mandatory("CharSequence: toString() shall never returns null.", s);
  if (s != null) {
    assertEquals("CharSequence: length is inconsistent with toString() length.", s.length(), length);
    boolean expectLowSurrogate = false;
    for (int i=0; i<length; i++) {
      final char c = s.charAt(i);
      assertEquals("CharSequence: character inconsistent with toString().", c, object.charAt(i));
      if (expectLowSurrogate) {
        assertTrue("CharSequence: High surrogate shall be followed by low surrogate.", Character.isLowSurrogate(c));
      }
      expectLowSurrogate = Character.isHighSurrogate(c);
    }
    assertFalse("CharSequence: High surrogate shall be followed by low surrogate.", expectLowSurrogate);
  }
  mandatory("InternationalString: toString(Locale) shall not return null.", object.toString(null));
  assertEquals("InternationalString: shall be equal to itself.", object, object);
  assertEquals("InternationalString: shall be comparable to itself.", 0, object.compareTo(object));
}

代码示例来源: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: apache/sis

} catch (NoninvertibleTransformException e) {
  final String message = e.getMessage();
  assertFalse(message, message.isEmpty());
} catch (IllegalArgumentException e) {
  final String message = e.getMessage();
  assertFalse(message, message.isEmpty());

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

/**
 * Validates the current {@linkplain #transform transform}. This method verifies that
 * the transform implements {@link MathTransform1D} or {@link MathTransform2D} if the
 * transform dimension suggests that it should. In addition, all Apache SIS transforms
 * shall implement {@link Parameterized}.
 *
 * @see Validators#validate(MathTransform)
 */
protected final void validate() {
  assertNotNull("The 'transform' field shall be assigned a value.", transform);
  Validators.validate(transform);
  final int dimension = transform.getSourceDimensions();
  if (transform.getTargetDimensions() == dimension) {
    assertEquals("transform instanceof MathTransform1D:", (transform instanceof MathTransform1D), dimension == 1);
    assertEquals("transform instanceof MathTransform2D:", (transform instanceof MathTransform2D), dimension == 2);
  } else {
    assertFalse("transform instanceof MathTransform1D:", transform instanceof MathTransform1D);
    assertFalse("transform instanceof MathTransform2D:", transform instanceof MathTransform2D);
  }
  assertInstanceOf("The transform does not implement all expected interfaces.", Parameterized.class, transform);
}

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

/**
 * 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);
  assertFalse("GeographicBoundingBox: invalid range of latitudes.",  south > north);          // Accept NaN.
  // Do not require west <= east, as this condition is not specified in ISO 19115.
  // Some implementations may use west > east for box spanning the anti-meridian.
}

代码示例来源: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 <cite>"Geocentric translations (geog3D domain)"</cite> (EPSG:1035).
 *
 * @throws FactoryException if an error occurred while creating the transform.
 * @throws TransformException if transformation of a point failed.
 */
@Test
@DependsOnMethod("testGeocentricDomain")
public void testGeographicDomain() throws FactoryException, TransformException {
  create(new GeocentricTranslation3D());
  assertFalse(transform instanceof LinearTransform);
  final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres
  derivativeDeltas = new double[] {delta, delta, 100};    // (Δλ, Δφ, Δh)
  zTolerance = Formulas.LINEAR_TOLERANCE / 2;             // Half the precision of h value given by EPSG
  zDimension = new int[] {2};                             // Dimension of h where to apply zTolerance
  tolerance  = Formulas.LINEAR_TOLERANCE;                 // Other SIS branches use a stricter threshold.
  datumShift(1, 4);
}

代码示例来源: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 the {@link StorageConnector#getStorageAs(Class)} method for the {@link ChannelDataInput} type.
 * The initial value should not be an instance of {@link ChannelImageInputStream} in order to avoid initializing
 * the Image I/O classes. However after a call to {@code getStorageAt(ChannelImageInputStream.class)}, the type
 * should have been promoted.
 *
 * @throws DataStoreException if an error occurred while using the storage connector.
 * @throws IOException if an error occurred while reading the test file.
 */
@Test
public void testGetAsChannelDataInput() throws DataStoreException, IOException {
  final StorageConnector connection = create(true);
  final ChannelDataInput input = connection.getStorageAs(ChannelDataInput.class);
  assertFalse(input instanceof ChannelImageInputStream);
  assertEquals(MAGIC_NUMBER, input.buffer.getInt());
  /*
   * Get as an image input stream and ensure that the cached value has been replaced.
   */
  final DataInput stream = connection.getStorageAs(DataInput.class);
  assertInstanceOf("Needs the SIS implementation", ChannelImageInputStream.class, stream);
  assertNotSame("Expected a new instance.", input, stream);
  assertSame("Shall share the channel.", input.channel, ((ChannelDataInput) stream).channel);
  assertSame("Shall share the buffer.",  input.buffer,  ((ChannelDataInput) stream).buffer);
  assertSame("Cached valud shall have been replaced.", stream, connection.getStorageAs(ChannelDataInput.class));
  connection.closeAllExcept(null);
}

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

return;
assertFalse("CoordinateOperation: can't be both a ConcatenatedOperation and a SingleOperation.",
    (object instanceof ConcatenatedOperation) && (object instanceof SingleOperation));
validateIdentifiedObject(object);

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

/**
 * Creates a "Geographic 2D to 3D → Geocentric → Affine → Geographic → Geographic 3D to 2D" chain
 * using EPSG or OGC standard operation methods and parameters. This is used for integration tests.
 *
 * @param  factory  the math transform factory to use for creating and concatenating the transform.
 * @return the chain of transforms.
 * @throws FactoryException if an error occurred while creating a transform.
 */
public static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory) throws FactoryException {
  final Parameters values = Parameters.castOrWrap(factory.getDefaultParameters("Geocentric translations (geog2D domain)"));
  setTranslation(values);
  setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid());
  final MathTransform gt = new GeocentricTranslation().createMathTransform(factory, values);
  assertFalse("isIdentity", gt.isIdentity());
  assertEquals("sourceDimensions", 3, gt.getSourceDimensions());
  assertEquals("targetDimensions", 3, gt.getTargetDimensions());
  assertInstanceOf("Geocentric translation", LinearTransform.class, gt);
  return Geographic3Dto2DTest.createDatumShiftForGeographic2D(factory, gt, values);
}

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

/**
 * Compares the basic properties of the given variables.
 *
 * @param  expected   the expected property values.
 * @param  variables  the variable for which to test properties.
 */
private static void assertBasicPropertiesEqual(final Object[] expected, final Variable[] variables) {
  int propertyIndex = 0;
  for (final Variable variable : variables) {
    final String name = variable.getName();
    final DataType dataType = variable.getDataType();
    assertFalse("Too many variables.", propertyIndex == expected.length);
    assertEquals(name, expected[propertyIndex++], name);
    assertEquals(name, expected[propertyIndex++], variable.getDescription());
    assertEquals(name, expected[propertyIndex++], dataType);
    assertEquals(name, expected[propertyIndex++], variable.getShape().length);
    assertEquals(name, expected[propertyIndex++], variable.isCoordinateSystemAxis());
    assertEquals(name, expected[propertyIndex++], variable.isCoverage());
    assertEquals(0, propertyIndex % NUM_BASIC_PROPERTY_COLUMNS);            // Sanity check for VariableTest itself.
  }
  assertEquals("Expected more variables.",
      expected.length / NUM_BASIC_PROPERTY_COLUMNS,
      propertyIndex   / NUM_BASIC_PROPERTY_COLUMNS);
}

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

/**
 * Tests the {@link StorageConnector#getStorageAs(Class)} method for the {@link InputStream} type.
 * The {@code InputStream} was specified as a URL.
 *
 * @throws DataStoreException if an error occurred while using the storage connector.
 * @throws IOException if an error occurred while reading the test file.
 */
@Test
@DependsOnMethod("testGetAsImageInputStream")
public void testGetAsInputStream() throws DataStoreException, IOException {
  final StorageConnector connection = create(false);
  final InputStream in = connection.getStorageAs(InputStream.class);
  assertNotSame(connection.getStorage(), in);
  assertSame("Expected cached value.", in, connection.getStorageAs(InputStream.class));
  assertInstanceOf("Expected Channel backend.", InputStreamAdapter.class, in);
  final ImageInputStream input = ((InputStreamAdapter) in).input;
  assertInstanceOf("Expected Channel backend.", ChannelImageInputStream.class, input);
  assertSame(input, connection.getStorageAs(DataInput.class));
  assertSame(input, connection.getStorageAs(ImageInputStream.class));
  final ReadableByteChannel channel = ((ChannelImageInputStream) input).channel;
  assertTrue(channel.isOpen());
  connection.closeAllExcept(null);
  assertFalse(channel.isOpen());
}

相关文章