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

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

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

Assert.assertArrayEquals介绍

暂无

代码示例

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

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()),

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

/**
 * Tests {@link Variable#getAttributeValues(String, boolean)}.
 *
 * @throws IOException if an I/O error occurred while opening the file.
 * @throws DataStoreException if a logical error occurred.
 */
@Test
public void testGetAttributes() throws IOException, DataStoreException {
  final Variable[] variables = getVariablesCIP(selectDataset(TestData.NETCDF_4D_PROJECTED));
  Variable variable = variables[6];
  assertEquals("CIP", variable.getName());
  assertArrayEquals("CIP:_FillValue", new Number[] { -1f  }, variable.getAttributeValues("_FillValue", true));
  assertArrayEquals("CIP:_FillValue", new String[] {"-1.0"}, variable.getAttributeValues("_FillValue", false));
  assertArrayEquals("CIP:units",      new String[] {   "%"}, variable.getAttributeValues("units",      false));
  assertArrayEquals("CIP:units",      new Number[] {      }, variable.getAttributeValues("units",      true));
  variable = variables[0];
  assertEquals("grid_mapping_0", variable.getName());
  assertArrayEquals("standard_parallel", new Number[] { 25.f,   25.05f}, variable.getAttributeValues("standard_parallel", true));
  assertArrayEquals("standard_parallel", new String[] {"25.0", "25.05"}, variable.getAttributeValues("standard_parallel", false));
}

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

/**
 * Tests the {@link ValueMap#entrySet()} method.
 * The expected metadata is:
 *
 * {@preformat text
 *     Citation
 *       ├─Title…………………………………………………… Undercurrent
 *       ├─Identifiers…………………………………… 9782505004509
 *       ├─Cited Responsible Parties
 *       │   └─Individual Name……………… Testsuya Toyoda
 *       └─ISBN……………………………………………………… 9782505004509
 * }
 *
 * Note that this test is intentionally sensitive to iteration order.
 * That order shall be fixed by the {@code XmlType} annotation.
 */
@Test
@DependsOnMethod("testGet")
public void testEntrySet() {
  final Map<String,Object> map = createCitation();
  assertEquals(1, citation.getIdentifiers().size());
  assertArrayEquals(new SimpleEntry<?,?>[] {
    new SimpleEntry<>("title",                   title),
    new SimpleEntry<>("identifiers",             citation.getIdentifiers()),
    new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
    new SimpleEntry<>("ISBN",                    "9782505004509")
  }, map.entrySet().toArray());
}

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

/**
 * Tests {@link Vector#repetitions(int...)}.
 */
@Test
public void testRepetitions() {
  Vector vec = Vector.create(new int[] {
      10, 10, 10, 10,
      12, 12, 13, 12,             // Different value (13) break the regularity.
      15, 15, 15, 15}, false);
  assertArrayEquals(new int[] {}, vec.repetitions());
  vec = Vector.create(new int[] {
      10, 10, 10, 10,
      12, 12, 12, 12,
      15, 15, 15, 15}, false);
  assertArrayEquals(new int[] {4}, vec.repetitions());
  vec = Vector.create(new int[] {
      10, 10, 10,  12, 12, 12,  15, 15, 15,  18, 18, 18,
      10, 10, 10,  12, 12, 12,  15, 15, 15,  18, 18, 18,
      10, 10, 10,  12, 12, 12,  15, 15, 15,  18, 18, 18}, false);
  assertArrayEquals(new int[] {3,4}, vec.repetitions());
  vec = Vector.create(new int[] {
      10, 12, 15, 18,
      10, 12, 15, 18,
      10, 12, 15, 18}, false);
  assertArrayEquals(new int[] {1,4}, vec.repetitions());
}

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

assertNull("ISBN shall have been removed.", citation.getISBN());
assertTrue("ISBN shall have been removed.", citation.getIdentifiers().isEmpty());
assertArrayEquals(new SimpleEntry<?,?>[] {
  new SimpleEntry<>("title",                   title),
  new SimpleEntry<>("citedResponsibleParties", singletonList(author))
assertArrayEquals(new SimpleEntry<?,?>[] {
  new SimpleEntry<>("title",                   title),
  new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
assertEquals("9782505004509", citation.getISBN());
assertEquals("ISBN shall appears in the identifier list.", 1, citation.getIdentifiers().size());
assertArrayEquals(new SimpleEntry<?,?>[] {
  new SimpleEntry<>("title",                   title),
  new SimpleEntry<>("identifiers",             citation.getIdentifiers()),

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

/**
 * Tests {@link Variable#getGridDimensionNames()} and {@link Variable#getShape()}
 * on a simple two-dimensional dataset.
 *
 * @throws IOException if an I/O error occurred while opening the file.
 * @throws DataStoreException if a logical error occurred.
 */
@Test
public void testGridRange2D() throws IOException, DataStoreException {
  final Variable variable = selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getVariables()[0];
  assertEquals("SST", variable.getName());
  assertArrayEquals("getGridDimensionNames()", new String[] {
    "lat", "lon"
  }, variable.getGridDimensionNames());
  assertArrayEquals("getGridEnvelope()", new int[] {
    73, 73
  }, variable.getShape());
}

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

/**
 * Tests {@link Variable#getGridDimensionNames()} and {@link Variable#getShape()}
 * on a compound four-dimensional dataset.
 *
 * @throws IOException if an I/O error occurred while opening the file.
 * @throws DataStoreException if a logical error occurred.
 */
@Test
public void testGridRange4D() throws IOException, DataStoreException {
  final Variable variable = getVariablesCIP(selectDataset(TestData.NETCDF_4D_PROJECTED))[6];
  assertEquals("CIP", variable.getName());
  assertArrayEquals("getGridDimensionNames()", new String[] {
    "time", "z0", "y0", "x0"
  }, variable.getGridDimensionNames());
  assertArrayEquals("getGridEnvelope()", new int[] {
    1, 4, 19, 38
  }, variable.getShape());
}

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

in.mark(1000);
assertEquals("Number of characters read.", expected.length, in.read(actual));
assertArrayEquals("First sentence.", expected, actual);
assertSame("Expected cached value.", in, connection.getStorageAs(Reader.class));
in.reset();
assertNotSame("Expected a new Reader instance.", in, in2);
assertEquals("Number of characters read.", expected.length, in.read(actual));
assertArrayEquals("First sentence.", expected, actual);
assertSame("Expected cached value.", in2, connection.getStorageAs(Reader.class));
connection.closeAllExcept(null);

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

final byte[] actual = new byte[sample.length];
assertEquals("Should read all requested bytes.", actual.length, in.read(actual));
assertArrayEquals("InputStream shall be reseted to the beginning of the stream.", sample, actual);
connection.closeAllExcept(null);

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

assertArrayEquals(new Integer[] {0, 1, 255}, nodataValues.toArray());

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

assertTrue (r.value > r.error);
assertFalse(r.error == 0);          // Paranoiac checks for making sure that next assertion will test something.
assertArrayEquals(new double[] {    // Paranoiac check for making sure that getExtendedElements() is not broken.
    r.value, 0, 0, 0,
    0, r.value, 0, 0,
assertEquals("targetDimensions", 3, tr.getTargetDimensions());
Assert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0);
assertArrayEquals("elements", elements, tr.getExtendedElements(), 0.0);
transform = tr;
validate();

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

/**
 * Sets the {@link #transform} field to the {@link ScaleTransform} instance to test.
 *
 * @param  sourceDimensions  expected number of source dimensions.
 * @param  targetDimensions  expected number of source dimensions.
 * @param  matrix            the data to use for creating the transform.
 */
private void create(final int sourceDimensions, final int targetDimensions, final MatrixSIS matrix) {
  final double[] elements = matrix.getElements();
  final ScaleTransform tr = new ScaleTransform(matrix.getNumRow(), matrix.getNumCol(), elements);
  assertEquals("sourceDimensions", sourceDimensions, tr.getSourceDimensions());
  assertEquals("targetDimensions", targetDimensions, tr.getTargetDimensions());
  Assert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0);
  assertArrayEquals("elements", elements, tr.getExtendedElements(), 0.0);
  transform = tr;
  validate();
}

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

final double[] point  = samplePoint(3);
final double[] vector = grid.interpolateAt(point[0], point[1]);
assertArrayEquals("(ΔX, ΔY, ΔZ)", expected, vector, 0.0005);

相关文章