本文整理了Java中org.apache.sis.test.Assert.assertMultilinesEquals()
方法的一些代码示例,展示了Assert.assertMultilinesEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertMultilinesEquals()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertMultilinesEquals
[英]Asserts that two strings are equal, ignoring the differences in EOL characters. The comparisons is performed one a line-by-line basis. For each line, trailing spaces (but not leading spaces) are ignored.
[中]断言两个字符串相等,忽略EOL字符的差异。逐行进行比较。对于每一行,将忽略尾随空格(但不忽略前导空格)。
代码示例来源:origin: apache/sis
/**
* Asserts that two strings are equal, ignoring the differences in EOL characters.
* The comparisons is performed one a line-by-line basis. For each line, trailing
* spaces (but not leading spaces) are ignored.
*
* @param expected the expected string.
* @param actual the actual string.
*/
public static void assertMultilinesEquals(final CharSequence expected, final CharSequence actual) {
assertMultilinesEquals(null, expected, actual);
}
代码示例来源:origin: apache/sis
/**
* Verify the string representation of "administrative area" location type.
* This is the body of {@link #testToString()} method, but is also shared by other tests
* as a convenient way to verify that a {@code ModifiableLocationType} did not changed.
*/
private static void verifyToString(final ModifiableLocationType area) {
assertMultilinesEquals(
"administrative area………………… area of responsibility of highest level local authority\n" +
" ├─town……………………………………………… city or town\n" +
" │ ├─locality………………………… neighbourhood, suburb, district, village, or settlement\n" +
" │ │ └─street…………………… thoroughfare providing access to properties\n" +
" │ │ └─property…… land use\n" +
" │ └─street……………………………… thoroughfare providing access to properties\n" +
" │ └─property……………… land use\n" +
" └─street………………………………………… thoroughfare providing access to properties\n" +
" └─property………………………… land use\n", area.toString());
}
代码示例来源:origin: apache/sis
/**
* Asserts that the converter to the given target is a fallback having the given string representation.
*
* @param expected the expected string representation of the fallback.
*/
private void assertFallbackEquals(final Class<?> target, final String expected) {
ObjectConverter<?,?> converter = converters.peekLast();
final Class<?> sourceClass = converter.getSourceClass();
converter = registry.find(sourceClass, target);
assertMultilinesEquals(expected, converter.toString());
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link org.apache.sis.test.Assert#assertMultilinesEquals(CharSequence, CharSequence)} method.
*/
@Test
public void testAssertEqualsMultilines() {
// Without trailing spaces.
assertMultilinesEquals("Line 1\nLine 2\r\nLine 3\n\rLine 5",
"Line 1\rLine 2\nLine 3\n\nLine 5");
// With different trailing spaces.
assertMultilinesEquals("Line 1\nLine 2\r\nLine 3\n\rLine 5",
"Line 1\rLine 2\nLine 3\n\nLine 5 ");
// With different leading spaces.
try {
assertMultilinesEquals("Line 1\nLine 2\r\nLine 3\n\rLine 5",
"Line 1\rLine 2\n Line 3\n\nLine 5");
fail("Lines are not equal.");
} catch (AssertionError e) {
assertTrue(e.getMessage().startsWith("Line[2]"));
}
}
代码示例来源:origin: apache/sis
/**
* Ensures that the buffer content is equals to the given string.
*
* @param expected the expected content.
* @throws IOException should never happen since the tests will write in a buffer.
*/
final void assertOutputEquals(final String expected) throws IOException {
IO.flush(appender);
final String actual = buffer.toString();
assertMultilinesEquals("Ignoring line separators.", expected, actual);
assertEquals ("Checking line separators.", expected, actual);
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link ArrayEnvelope#formatTo(Formatter)} method.
* Contrarily to {@code toString()}, the precision depends on the CRS.
*/
@Test
public void testFormatWKT() {
ArrayEnvelope envelope = new ArrayEnvelope(new double[] {4, -10, 50, 2});
assertMultilinesEquals("BOX[ 4 -10,\n" +
" 50 2]", envelope.toWKT());
envelope.crs = AbstractEnvelopeTest.WGS84;
assertMultilinesEquals("BOX[ 4.00000000 -10.00000000,\n" +
" 50.00000000 2.00000000]", envelope.toWKT());
}
代码示例来源:origin: apache/sis
/**
* Tests serialization.
*
* @throws Exception if an error occurred during the serialization process.
*/
@Test
@DependsOnMethod("testToString")
public void testSerialization() throws Exception {
final Object original = create(ValueExistencePolicy.COMPACT);
final Object deserialized;
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
out.writeObject(original);
}
// Now reads the object we just serialized.
final byte[] data = buffer.toByteArray();
try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
deserialized = in.readObject();
}
assertMultilinesEquals(EXPECTED, formatMetadata((TreeTableView) deserialized));
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Tests formatting of a metadata object.
*
* @throws IOException Should never happen.
*/
@Test
public void testFormat() throws IOException {
final StringBuilder buffer = new StringBuilder();
Writer writer = new Writer(buffer);
writer.format(createMetadata());
assertMultilinesEquals("JSON format", JSON, buffer.toString());
}
}
代码示例来源:origin: apache/sis
/**
* Tests formatting of a multi-line message.
*/
@Test
@DependsOnMethod("testlevelWidth")
public void testMultilines() {
final LogRecord record = new LogRecord(Level.INFO, "First line\n Indented line\nLast line\n");
final String formatted = formatter.format(record);
assertMultilinesEquals(localize(Level.INFO,
"INFO\t First line\n" +
"\t Indented line\n" +
"\t Last line\n"), formatted);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link GridExtent#toString()}.
* Note that the string representation may change in any future SIS version.
*/
@Test
public void testToString() {
final StringBuilder buffer = new StringBuilder(100);
create3D().appendTo(buffer, Vocabulary.getResources(Locale.ENGLISH));
assertMultilinesEquals(
"Column: [100 … 499] (400 cells)\n" +
"Row: [200 … 799] (600 cells)\n" +
"Time: [ 40 … 49] (10 cells)\n", buffer);
}
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link #concatenateSingletons(TreeTable.Node)} example.
*
* @throws ParseException if parsing of test tree failed.
*/
@Test
public void testConcatenateSingletons() throws ParseException {
final TreeTable table = TreeTables.parse(
"root\n" +
" ├─users\n" +
" │ └─alice\n" +
" │ ├─data\n" +
" │ │ └─mercator\n" +
" │ └─document\n" +
" └─lib\n", NAME);
((DefaultTreeTable) table).setRoot(concatenateSingletons(table.getRoot()));
assertMultilinesEquals((
"root\n" +
" ├─users/alice\n" +
" │ ├─data/mercator\n" +
" │ └─document\n" +
" └─lib\n").replace('/', File.separatorChar), table.toString());
}
代码示例来源:origin: apache/sis
/**
* Tests formatting a tree containing a remark. We use a geographic bounding box spanning the anti-meridian.
* In this test the longitude value and the remarks and separated by "……" characters, but this is because we
* use the default {@link org.apache.sis.util.collection.TreeTableFormat}. When using {@link MetadataFormat}
* specialization, the formatting is a little bit different
*
* @since 1.0
*/
@Test
public void testRemarks() {
final DefaultGeographicBoundingBox bbox = new DefaultGeographicBoundingBox(170, -160, -30, 40);
final String text = formatMetadata(bbox.asTreeTable());
assertMultilinesEquals(
"Geographic bounding box\n" +
" ├─West bound longitude…… 170°E\n" +
" ├─East bound longitude…… 160°W…… Bounding box crosses the antimeridian.\n" + // See method javadoc.
" ├─South bound latitude…… 30°S\n" +
" ├─North bound latitude…… 40°N\n" +
" └─Extent type code……………… true\n", text);
}
}
代码示例来源:origin: apache/sis
/**
* Tests the formatting of a {@link DefaultFeatureType}.
*/
@Test
public void testFeatureType() {
final DefaultFeatureType feature = DefaultFeatureTypeTest.worldMetropolis();
final FeatureFormat format = create();
final String text = format.format(feature);
assertMultilinesEquals("World metropolis ⇾ Metropolis, University city\n" +
"┌──────────────┬─────────────────────┬──────────────┬───────────────┬────────────────────────────┐\n" +
"│ Name │ Type │ Multiplicity │ Default value │ Characteristics │\n" +
"├──────────────┼─────────────────────┼──────────────┼───────────────┼────────────────────────────┤\n" +
"│ city │ String │ [1 … 1] │ Utopia │ │\n" +
"│ population │ Integer │ [1 … 1] │ │ │\n" +
"│ region │ InternationalString │ [1 … 1] │ │ │\n" +
"│ isGlobal │ Boolean │ [1 … 1] │ │ │\n" +
"│ universities │ String │ [0 … ∞] │ │ │\n" +
"│ temperature │ Float │ [1 … 1] │ │ accuracy = 0.1, units = °C │\n" +
"└──────────────┴─────────────────────┴──────────────┴───────────────┴────────────────────────────┘\n", text);
}
代码示例来源:origin: apache/sis
/**
* Tests formatting of an instance having only geographic coordinates.
*/
@Test
public void testGeographic() {
final SimpleLocation loc = new SimpleLocation(null, "A location");
loc.minX = 8;
loc.maxX = 10;
loc.minY = -2;
loc.maxY = 30;
final LocationFormat format = new LocationFormat(Locale.US, null);
assertMultilinesEquals(
"┌─────────────────────────────────────────┐\n" +
"│ Geographic identifier: A location │\n" +
"│ West bound: 8°00′00″E │\n" +
"│ Representative value: 9°00′00″E │\n" +
"│ East bound: 10°00′00″E │\n" +
"│ South bound: 2°00′00″S │\n" +
"│ Representative value: 14°00′00″N │\n" +
"│ North bound: 30°00′00″N │\n" +
"│ Coordinate reference system: WGS 84 │\n" +
"└─────────────────────────────────────────┘\n", format.format(loc));
}
代码示例来源:origin: apache/sis
/**
* Tests the formatting as a tree, with control on the indentation.
*/
@Test
public void testTreeFormat() {
final DefaultTreeTable.Node root = new DefaultTreeTable.Node("Node #1");
final DefaultTreeTable.Node branch = new DefaultTreeTable.Node("Node #2");
root.getChildren().add(branch);
root.getChildren().add(new DefaultTreeTable.Node("Node #3"));
branch.getChildren().add(new DefaultTreeTable.Node("Node #4"));
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setVerticalLinePosition(2);
assertMultilinesEquals(
"Node #1\n" +
" ├─Node #2\n" +
" │ └─Node #4\n" +
" └─Node #3\n", tf.format(new DefaultTreeTable(root)));
}
代码示例来源:origin: apache/sis
/**
* Tests {@link TreeTableView#toString()}.
* Since the result is locale-dependent, we can not compare against an exact string.
* We will only compare the beginning of each line.
*/
@Test
public void testToString() {
final TreeTableView metadata = create(ValueExistencePolicy.COMPACT);
assertMultilinesEquals(EXPECTED, formatMetadata(metadata)); // Locale-independent
assertArrayEquals(toTreeStructure(EXPECTED), toTreeStructure(metadata.toString())); // Locale-dependent.
}
代码示例来源:origin: apache/sis
/**
* Tests formatting in a non-English locale.
*/
@Test
@DependsOnMethod("testFormatBriefValues")
public void testFormatLocalized() {
final ParameterFormat format = new ParameterFormat(Locale.FRANCE, null);
format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
final String text = format.format(createParameterValues());
assertMultilinesEquals(
"EPSG: Mercator (variant A)\n" +
"┌────────────────────────────────┬────────┬─────────────────────┬──────────┐\n" +
"│ Nom (EPSG) │ Type │ Domaine des valeurs │ Valeur │\n" +
"├────────────────────────────────┼────────┼─────────────────────┼──────────┤\n" +
"│ Latitude of natural origin¹ │ Double │ [-80 … 84]° │ 20° │\n" +
"│ Longitude of natural origin │ Double │ [-180 … 180]° │ -60° │\n" +
"│ Scale factor at natural origin │ Double │ (0 … ∞) │ 0,997 │\n" +
"│ False northing │ Double │ (−∞ … ∞) m │ 20 km │\n" +
"└────────────────────────────────┴────────┴─────────────────────┴──────────┘\n" +
"¹ This parameter is shown for completeness, but should never have a value different than 0 for this projection.\n", text);
}
代码示例来源:origin: apache/sis
/**
* Tests the parsing of a tree. This method parses and reformats a tree,
* and performs its check on the assumption that the tree formatting is
* accurate.
*
* @throws ParseException if the parsing failed.
*/
@Test
@DependsOnMethod("testTreeFormat")
public void testTreeParse() throws ParseException {
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setVerticalLinePosition(0);
final String text =
"Node #1\n" +
"├───Node #2\n" +
"│ └───Node #4\n" +
"└───Node #3\n";
final TreeTable table = tf.parseObject(text);
assertMultilinesEquals(text, tf.format(table));
}
代码示例来源:origin: apache/sis
/**
* Tests the formatting of a {@link DefaultImageDescription} object.
*/
@Test
public void testImageDescription() {
final DefaultImageDescription image = new DefaultImageDescription();
image.setAttributeGroups(Arrays.asList(
new DefaultAttributeGroup(null, createBand(0.25, 0.26)),
new DefaultAttributeGroup(null, createBand(0.28, 0.29))
));
final String text = format.format(image.asTreeTable());
assertMultilinesEquals(
"Image description\n" +
" ├─Attribute group (1 of 2)\n" +
" │ └─Attribute\n" +
" │ ├─Max value………………… 0.26\n" +
" │ ├─Min value………………… 0.25\n" +
" │ └─Units…………………………… centimetre\n" +
" └─Attribute group (2 of 2)\n" +
" └─Attribute\n" +
" ├─Max value………………… 0.29\n" +
" ├─Min value………………… 0.28\n" +
" └─Units…………………………… centimetre\n", text);
}
代码示例来源:origin: apache/sis
/**
* Tests the parsing of a tree table. This method parses and reformats a tree table,
* and performs its check on the assumption that the tree table formatting is accurate.
*
* @throws ParseException if the parsing failed.
*/
@Test
@DependsOnMethod("testTreeTableFormat")
public void testTreeTableParse() throws ParseException {
final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
final TableColumn<String> valueB = new TableColumn<>(String .class, "value #2");
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setColumns(NAME, valueA, valueB);
tf.setVerticalLinePosition(1);
final String text =
"Node #1………………………… 10…… Value #1B\n" +
" ├──Node #2……………… 20\n" +
" │ └──Node #4…… 40…… Value #4B\n" +
" └──Node #3……………… ………… Value #3B\n";
final TreeTable table = tf.parseObject(text);
assertMultilinesEquals(text, tf.format(table));
}
内容来源于网络,如有侵权,请联系作者删除!