本文整理了Java中org.apache.sis.test.Assert.assertInstanceOf()
方法的一些代码示例,展示了Assert.assertInstanceOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertInstanceOf()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertInstanceOf
暂无
代码示例来源:origin: apache/sis
/**
* Creates a {@link NumberConverter} for the given source and target classes.
* We have to use the {@link ConverterRegistry} instead than instantiating the
* converters directly because some tests are going to verify that the converter
* has been properly cached.
*/
private static <S extends Number, T> ObjectConverter<S,T> create(
final Class<S> sourceClass, final Class<T> targetClass)
{
final ObjectConverter<S,T> converter = SystemRegistry.INSTANCE.findExact(sourceClass, targetClass);
assertInstanceOf("ConverterRegistry.find(" + sourceClass.getSimpleName() + ", " + targetClass.getSimpleName() + ')',
(targetClass == Comparable.class) ? NumberConverter.Comparable.class : NumberConverter.class, converter);
return converter;
}
代码示例来源:origin: apache/sis
/**
* Returns the children of the root of the given table as a list.
* Instances of {@link DefaultTreeTable.Node} shall be guaranteed
* to store their children in a list.
*/
private static List<TreeTable.Node> getChildrenList(final TreeTable table) {
final Collection<TreeTable.Node> children = table.getRoot().getChildren();
assertInstanceOf("TreeTable.Node.getChildren()", List.class, children);
return (List<TreeTable.Node>) children;
}
代码示例来源:origin: apache/sis
/**
* Follows an association in the given feature.
*/
private static Object getIndirectPropertyValue(final AbstractFeature feature, final String p1, final String p2) {
final Object dependency = feature.getPropertyValue(p1);
assertNotNull(p1, dependency);
assertInstanceOf(p1, AbstractFeature.class, dependency);
return ((AbstractFeature) dependency).getPropertyValue(p2);
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link LinearConverter#convert(Number)} with a value of type {@link Float}.
* This method indirectly tests {@link org.apache.sis.math.DecimalFunctions#floatToDouble(float)}.
*/
@Test
@DependsOnMethod("testConvertDouble")
public void testConvertFloat() {
LinearConverter c = LinearConverter.offset(27315, 100);
final Number n = c.convert(Float.valueOf(27.01f));
assertInstanceOf("convert(Float)", Double.class, n);
assertEquals(300.16, n.doubleValue(), STRICT); // Really want STRICT; see testConvertDouble()
}
代码示例来源:origin: apache/sis
/**
* Tests {@link LinearConverter#convert(Number)} with a value of type {@link BigDecimal}.
*/
@Test
@DependsOnMethod("testConvertDouble")
public void testConvertBigDecimal() {
LinearConverter c = LinearConverter.offset(27315, 100);
final Number n = c.convert(new BigDecimal("27.01"));
assertInstanceOf("convert(BigDecimal)", BigDecimal.class, n);
assertEquals(new BigDecimal("300.16"), n);
}
代码示例来源:origin: apache/sis
/**
* Ensures that the converter for the given target is an {@link IdentityConverter}.
*
* @param targetClass the target for which an identity converter should be obtained.
*/
private void assertIdentityForTarget(final Class<?> targetClass) {
final ObjectConverter<?,?> converter = converters.peekLast();
final Class<?> sourceClass = converter.getSourceClass();
final ObjectConverter<?,?> actual = registry.find(sourceClass, targetClass);
final String message = sourceClass.getSimpleName() + " ← " + targetClass.getSimpleName();
assertInstanceOf(message, IdentityConverter.class, actual);
assertSame(message, sourceClass, actual.getSourceClass());
assertSame(message, targetClass, actual.getTargetClass());
}
代码示例来源:origin: apache/sis
/**
* Tests the interfaces implemented by the transforms returned by {@link MathTransforms#translation(double...)}.
*/
@Test
public void testTranslation() {
MathTransform tr = MathTransforms.translation(4);
assertInstanceOf("1D", MathTransform1D.class, tr);
assertFalse("isIdentity", tr.isIdentity());
tr = MathTransforms.translation(4, 7);
assertInstanceOf("2D", MathTransform2D.class, tr);
assertFalse("isIdentity", tr.isIdentity());
}
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of {@link CollectionConverter}.
*/
@Test
@SuppressWarnings("rawtypes")
public void testCollection() {
final ObjectConverter<Collection,List> c1 = INSTANCE.findExact(Collection.class, List.class);
assertInstanceOf("List ← Collection", CollectionConverter.class, c1);
assertSame(c1, assertSerializedEquals(c1));
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link MathTransforms#getSteps(MathTransform)}.
*/
@Test
public void testGetSteps() {
final Matrix4 scale = new Matrix4(); // Scales a value.
final Matrix4 swap = new Matrix4(); // Swaps two dimensions.
final List<MathTransform> steps = MathTransforms.getSteps(createConcatenateAndPassThrough(scale, swap));
assertEquals(3, steps.size());
assertMatrixEquals("Step 1", scale, MathTransforms.getMatrix(steps.get(0)), STRICT);
assertMatrixEquals("Step 3", swap, MathTransforms.getMatrix(steps.get(2)), STRICT);
assertInstanceOf ("Step 2", PassThroughTransform.class, steps.get(1));
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of {@link NumberConverter}.
*/
@Test
public void testFloatAndDouble() {
final ObjectConverter<Float,Double> c1 = INSTANCE.findExact(Float.class, Double.class);
final ObjectConverter<Double,Float> c2 = INSTANCE.findExact(Double.class, Float.class);
assertInstanceOf("Double ← Float", NumberConverter.class, c1);
assertInstanceOf("Float ← Double", NumberConverter.class, c2);
assertSame("inverse()", c2, c1.inverse());
assertSame("inverse()", c1, c2.inverse());
assertSame(c1, assertSerializedEquals(c1));
assertSame(c2, assertSerializedEquals(c2));
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of {@link StringConverter}.
*/
@Test
public void testStringAndFile() {
final ObjectConverter<String,File> c1 = INSTANCE.findExact(String.class, File.class);
final ObjectConverter<File,String> c2 = INSTANCE.findExact(File.class, String.class);
assertInstanceOf("File ← String", StringConverter.File.class, c1);
assertInstanceOf("String ← File", ObjectToString.class, c2);
assertSame("inverse()", c2, c1.inverse());
assertSame("inverse()", c1, c2.inverse());
assertSame(c1, assertSerializedEquals(c1));
assertSame(c2, assertSerializedEquals(c2));
}
代码示例来源:origin: apache/sis
/**
* Creates an arbitrary metadata for testing purpose.
*/
public ModifiableMetadataTest() {
md = new DefaultMedium();
md.setMediumNote(new SimpleInternationalString("The original note."));
md.setIdentifier(new DefaultIdentifier("A medium identifier"));
assertInstanceOf("mediumFormat", CodeListSet.class, md.getMediumFormats()); // Force assignation of a Set in private field.
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of {@link StringConverter}.
*/
@Test
public void testStringAndInteger() {
final ObjectConverter<String,Integer> c1 = INSTANCE.findExact(String.class, Integer.class);
final ObjectConverter<Integer,String> c2 = INSTANCE.findExact(Integer.class, String.class);
assertInstanceOf("Integer ← String", StringConverter.Integer.class, c1);
assertInstanceOf("String ← Integer", ObjectToString.class, c2);
assertSame("inverse()", c2, c1.inverse());
assertSame("inverse()", c1, c2.inverse());
assertSame(c1, assertSerializedEquals(c1));
assertSame(c2, assertSerializedEquals(c2));
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of {@link NilObject} instances.
*/
@Test
public void testCreateNilObject() {
final Citation citation = NilReason.TEMPLATE.createNilObject(Citation.class);
assertInstanceOf("Unexpected proxy.", NilObject.class, citation);
assertNull(citation.getTitle());
assertTrue(citation.getDates().isEmpty());
assertEquals("NilObject.toString()", "Citation[template]", citation.toString());
assertSame("NilReason.forObject(…)", NilReason.TEMPLATE, NilReason.forObject(citation));
assertSame("Expected cached value.", citation, NilReason.TEMPLATE.createNilObject(Citation.class));
}
代码示例来源:origin: apache/sis
/**
* Implementation of {@link #testIdentityTransform()} using the given CRS.
*/
private void testIdentityTransform(final CoordinateReferenceSystem crs) throws FactoryException {
final CoordinateOperation operation = finder.createOperation(crs, crs);
assertSame ("sourceCRS", crs, operation.getSourceCRS());
assertSame ("targetCRS", crs, operation.getTargetCRS());
assertTrue ("isIdentity", operation.getMathTransform().isIdentity());
assertTrue ("accuracy", operation.getCoordinateOperationAccuracy().isEmpty());
assertInstanceOf("operation", Conversion.class, operation);
finder = new CoordinateOperationFinder(null, factory, null); // Reset for next call.
}
代码示例来源:origin: apache/sis
/**
* Tests a single case of Geographic ↔︎ Geocentric conversions.
*/
private void testGeocentricConversion(final CoordinateReferenceSystem sourceCRS,
final CoordinateReferenceSystem targetCRS)
throws FactoryException
{
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame ("targetCRS", targetCRS, operation.getTargetCRS());
assertEquals ("name", "Geocentric conversion", operation.getName().getCode());
assertInstanceOf("operation", Conversion.class, operation);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link SpecialCases#information(int)}.
*/
@Test
public void testPropertyInformation() {
final ExtendedElementInformation info = accessor.information(accessor.indexOf("westBoundLongitude", true));
final InternationalString domain = info.getDomainValue();
assertInstanceOf("Expected numerical information about range.", NumberRange.class, domain);
final NumberRange<?> range = (NumberRange) domain;
assertEquals(-180, range.getMinDouble(), STRICT);
assertEquals(+180, range.getMaxDouble(), STRICT);
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link NilReason#createNilObject(Class)} for an international string type.
* Opportunistically tests {@link NilReason#forObject(Object)} with the created object.
*
* @since 0.4
*/
@Test
public void testCreateNilInternationalString() {
final InternationalString value = NilReason.MISSING.createNilObject(InternationalString.class);
assertEquals("", value.toString());
assertInstanceOf("Unexpected impl.", NilObject.class, value);
assertSame("NilReason.forObject(…)", NilReason.MISSING, NilReason.forObject(value));
assertSame("Expected cached value.", value, NilReason.MISSING.createNilObject(InternationalString.class));
}
代码示例来源:origin: apache/sis
/**
* Tests automatic creation of a converter for an array of values.
*/
@Test
public void testArrayOfWrapperTypes() {
register(new NumberConverter<>(Float.class, Double.class));
final ObjectConverter<?,?> converter = registry.find(Float[].class, Double[].class);
assertInstanceOf("Array conversions", ArrayConverter.class, converter);
assertEquals(Float [].class, converter.getSourceClass());
assertEquals(Double[].class, converter.getTargetClass());
assertSame("Converter shall be cached.", converter, registry.find(Float[].class, Double[].class));
}
代码示例来源:origin: apache/sis
/**
* Tests automatic creation of a converter for an array of values.
*/
@Test
@DependsOnMethod("testArrayOfWrapperTypes")
public void testArrayOfPrimitiveTypes() {
register(new NumberConverter<>(Float.class, Double.class));
final ObjectConverter<?,?> converter = registry.find(float[].class, double[].class);
assertInstanceOf("Array conversions", ArrayConverter.class, converter);
assertEquals(float [].class, converter.getSourceClass());
assertEquals(double[].class, converter.getTargetClass());
assertSame("Converter shall be cached.", converter, registry.find(float[].class, double[].class));
}
内容来源于网络,如有侵权,请联系作者删除!