本文整理了Java中org.apache.sis.test.Assert.assertNotNull()
方法的一些代码示例,展示了Assert.assertNotNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNotNull()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertNotNull
暂无
代码示例来源:origin: apache/sis
/**
* Registers a converter to test.
*/
private void register(final ObjectConverter<?,?> converter) {
assertNotNull("Missing ObjectConverter", converter);
converters.add(converter);
registry.register(converter);
}
代码示例来源:origin: apache/sis
/**
* Verifies the exception for an unmodifiable metadata.
*/
private static void verifyUnmodifiableException(final UnmodifiableMetadataException e) {
assertNotNull("Expected an error message.", e.getMessage());
}
代码示例来源:origin: apache/sis
/**
* Asserts that the angle between the parsed directions is equals to the given value.
* This method tests also the angle by interchanging the axis directions.
*/
private static void assertAngleEquals(final boolean isElevation, final double expected,
final String source, final String target)
{
final AxisDirection dir1 = parseAxisDirection(source);
final AxisDirection dir2 = parseAxisDirection(target);
assertNotNull(source, dir1);
assertNotNull(target, dir2);
assertAngleEquals(isElevation, expected, dir1, dir2);
}
代码示例来源:origin: apache/sis
/**
* Returns the factory to use for the tests.
*
* @return the factory to use for the tests.
*/
static DefaultMathTransformFactory factory() {
final MathTransformFactory factory = DefaultFactories.forClass(MathTransformFactory.class);
assertNotNull("No Apache SIS implementation of MathTransformFactory found in “META-INF/services”.", factory);
assertEquals("Expected the default implementation of MathTransformFactory to be first in “META-INF/services”.",
DefaultMathTransformFactory.class, factory.getClass());
return (DefaultMathTransformFactory) factory;
}
代码示例来源:origin: apache/sis
/**
* Verifies that attempt to create an envelope from an invalid WKT results in an exception.
*/
@Test(expected = IllegalArgumentException.class)
public void testCreatesFromInvalidWKT() {
assertNotNull(new ArrayEnvelope("BBOX[\"invalid\"]").ordinates);
}
代码示例来源: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
/**
* Verifies the {@link SystemUnit#related} array content of all system units declared in {@link Units}.
* This tests verify that the array has been fully populated and that the converter of all units are
* instance of {@link LinearConverter}.
*
* @throws ReflectiveOperationException if an error occurred while iterating over the field values.
*
* @see ConventionalUnit#create(AbstractUnit, UnitConverter)
*/
@Test
public void verifyRelatedUnits() throws ReflectiveOperationException {
for (final Field f : Units.class.getFields()) {
final Object value = f.get(null);
if (value instanceof SystemUnit<?>) {
final ConventionalUnit<?>[] related = ((SystemUnit<?>) value).related();
if (related != null) {
final String symbol = ((SystemUnit<?>) value).getSymbol();
for (final ConventionalUnit<?> r : related) {
assertNotNull(symbol, r);
assertInstanceOf(symbol, LinearConverter.class, r.toTarget);
}
}
}
}
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Tests {@link Complex#pow} method using complex values.
*/
@Test
public void testComplexPowers() {
final double[] reals = {0, 1, 0, 2, 2.5, -2.5};
final double[] imags = {0, 0, 1, 1, 1.5, 3.8};
for (int i=0; i<reals.length; i++) {
final Complex value = new Complex(reals[i], imags[i]);
for (int n=0; n<=6; n++) {
final String label = value.toString() + '^' + n;
assertNotNull(label, power(value, n, label));
}
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link DefaultRecord#setAll(Object[])}.
*/
@Test
public void testSetAll() {
final DefaultRecord record = new DefaultRecord(recordType);
try {
record.setAll("Machu Picchu", -13.1639, -72.5468);
fail("Shall not accept array of illegal length.");
} catch (IllegalArgumentException e) {
assertNotNull(e.getMessage());
}
try {
record.setAll("Machu Picchu", -13.1639, -72.5468, "Unknown");
fail("Shall not accept 'population' value of class String.");
} catch (ClassCastException e) {
final String message = e.getMessage();
assertTrue(message, message.contains("population"));
assertTrue(message, message.contains("String"));
}
setAllAndCompare(record, "Machu Picchu", -13.1639, -72.5468, null);
}
代码示例来源:origin: apache/sis
/**
* Tests {@code DefaultParameterValueGroup.values().get(…)} on a group expected to be pre-filled
* with mandatory parameters.
*/
@Test
public void testValuesGet() {
final DefaultParameterValueGroup group = new DefaultParameterValueGroup(descriptor);
final List<GeneralParameterValue> values = group.values();
assertEquals("Initial size", 2, values.size());
assertEquals(descriptor.descriptors().get(0).createValue(), values.get(0));
assertEquals(descriptor.descriptors().get(1).createValue(), values.get(1));
try {
values.get(2);
fail("Index 2 shall be out of bounds.");
} catch (IndexOutOfBoundsException e) {
assertNotNull(e.getMessage());
}
assertEquals(DefaultParameterDescriptorGroupTest.DEFAULT_VALUE, ((ParameterValue<?>) values.get(0)).getValue());
assertEquals(DefaultParameterDescriptorGroupTest.DEFAULT_VALUE, ((ParameterValue<?>) values.get(1)).getValue());
}
代码示例来源:origin: apache/sis
/**
* Validates the test parameter values created by {@link #createValues(int)}.
*/
@Test
public void validateTestObjects() {
for (final DefaultParameterValue<?> param : createValues(10)) {
AssertionError error = null;
try {
validate(param);
} catch (AssertionError e) {
error = e;
}
if (param.getDescriptor().getMaximumOccurs() > 1) {
assertNotNull("Validation methods should have detected that the descriptor is invalid.", error);
} else if (error != null) {
throw error;
}
}
}
代码示例来源:origin: apache/sis
/**
* Asserts that the two given arrays contains objects that are equal ignoring metadata.
* See {@link ComparisonMode#IGNORE_METADATA} for more information.
*
* @param expected the expected objects (array can be {@code null}).
* @param actual the actual objects (array can be {@code null}).
*
* @since 0.7
*/
public static void assertArrayEqualsIgnoreMetadata(final Object[] expected, final Object[] actual) {
if (expected != actual) {
if (expected == null) {
assertNull("Expected null array.", actual);
} else {
assertNotNull("Expected non-null array.", actual);
final int length = StrictMath.min(expected.length, actual.length);
for (int i=0; i<length; i++) try {
assertEqualsIgnoreMetadata(expected[i], actual[i]);
} catch (AssertionError e) {
throw new AssertionError(Exceptions.formatChainedMessages(null, "Comparison failure at index "
+ i + " (a " + Classes.getShortClassName(actual[i]) + ").", e), e);
}
assertEquals("Unexpected array length.", expected.length, actual.length);
}
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@code DefaultParameterValueGroup.values().set(…)}.
*/
@Test
@DependsOnMethod("testValuesGet")
public void testValuesSet() {
final DefaultParameterValueGroup group = new DefaultParameterValueGroup(descriptor);
final List<GeneralParameterValue> values = group.values();
assertEquals("Initial size", 2, values.size());
final ParameterValue<?> p0 = (ParameterValue<?>) descriptor.descriptors().get(0).createValue();
final ParameterValue<?> p1 = (ParameterValue<?>) descriptor.descriptors().get(1).createValue();
p0.setValue(4);
p1.setValue(5);
assertEquals("Mandatory 1", values.set(0, p0).getDescriptor().getName().toString());
assertEquals("Mandatory 2", values.set(1, p1).getDescriptor().getName().toString());
try {
values.set(2, p1);
fail("Index 2 shall be out of bounds.");
} catch (IndexOutOfBoundsException e) {
assertNotNull(e.getMessage());
}
assertEquals("size", 2, values.size()); // Size should be unchanged.
assertEquals(4, ((ParameterValue<?>) values.get(0)).intValue());
assertEquals(5, ((ParameterValue<?>) values.get(1)).intValue());
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor
* with more than one identifier. This method also tries a different identifier implementation
* than the one used by {@link #testWithSingleIdentifier()}.
*/
@Test
@DependsOnMethod("testWithSingleIdentifier")
public void testWithManyIdentifiers() {
final Set<ReferenceIdentifier> identifiers = new LinkedHashSet<>(4);
assertTrue(identifiers.add(new NamedIdentifier(EPSG, "7019")));
assertTrue(identifiers.add(new NamedIdentifier(EPSG, "IgnoreMe")));
final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties(identifiers));
final ReferenceIdentifier gmlId = validate(object, identifiers, "epsg-7019");
assertNotNull("gmlId", gmlId);
assertEquals ("gmlId.codespace", "EPSG", gmlId.getCodeSpace());
assertEquals ("gmlId.code", "7019", gmlId.getCode());
}
代码示例来源:origin: apache/sis
/**
* Tests the {@code IdentifiedObjectFinder.find(…)} method.
*
* @throws FactoryException if the operation failed creation failed.
*/
@Test
public void testFind() throws FactoryException {
final CRSAuthorityFactory factory = AuthorityFactories.ALL;
final IdentifiedObjectFinder finder = AuthorityFactories.ALL.newIdentifiedObjectFinder();
final IdentifiedObject find = finder.findSingleton(HardCodedCRS.WGS84);
assertNotNull("With scan allowed, should find the CRS.", find);
assertTrue(HardCodedCRS.WGS84.equals(find, ComparisonMode.DEBUG));
assertSame(factory.createCoordinateReferenceSystem("CRS:84"), find);
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link AbstractIdentifiedObject#getIdentifier()} with a sub-type of {@code AbstractIdentifiedObject}.
* The use of a subtype will allow {@code getIdentifier()} to build a URN and {@code getId()} to know what to
* insert between {@code "epsg-"} and the code.
*/
@Test
@DependsOnMethod("testWithManyIdentifiers")
public void testAsSubtype() {
final ReferenceIdentifier identifier = new NamedIdentifier(EPSG, "7019");
final Set<ReferenceIdentifier> identifiers = Collections.singleton(identifier);
final AbstractIdentifiedObject object = new AbstractDatum(properties(identifiers));
final ReferenceIdentifier gmlId = validate(object, identifiers, "epsg-datum-7019");
assertNotNull("gmlId", gmlId);
assertEquals ("gmlId.codespace", "EPSG", gmlId.getCodeSpace());
assertEquals ("gmlId.code", "7019", gmlId.getCode());
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor
* with only one identifier. The methods of interest for this test are:
*
* <ul>
* <li>{@link AbstractIdentifiedObject#getIdentifiers()}</li>
* <li>{@link AbstractIdentifiedObject#getIdentifier()}</li>
* <li>{@link AbstractIdentifiedObject#getID()}</li>
* </ul>
*/
@Test
@DependsOnMethod("testWithoutIdentifier")
public void testWithSingleIdentifier() {
final ReferenceIdentifier identifier = new ImmutableIdentifier(null, "EPSG", "7019");
final Set<ReferenceIdentifier> identifiers = Collections.singleton(identifier);
final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties(identifiers));
final ReferenceIdentifier gmlId = validate(object, identifiers, "epsg-7019");
assertNotNull("gmlId", gmlId);
assertEquals ("gmlId.codespace", "EPSG", gmlId.getCodeSpace());
assertEquals ("gmlId.code", "7019", gmlId.getCode());
}
代码示例来源:origin: apache/sis
/**
* Ensures that the given international string contains the expected localized texts.
*
* @param quebecker either {@link #MESSAGE_fr} or {@link #MESSAGE_fr_CA},
* depending on the localization details being tested.
*/
private static void assertLocalized(final InternationalString toTest, final String quebecker) {
assertEquals ("Unlocalized message:", MESSAGE, toTest.toString(null));
assertEquals ("Unlocalized message:", MESSAGE, toTest.toString(Locale.ROOT));
assertEquals ("English message:", MESSAGE_en, toTest.toString(Locale.ENGLISH));
assertEquals ("French message:", MESSAGE_fr, toTest.toString(Locale.FRENCH));
assertEquals ("Quebecker message:", quebecker, toTest.toString(Locale.CANADA_FRENCH));
assertNotNull("Other language:", toTest.toString(Locale.JAPANESE));
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Tests addition of system-wide defaults.
*/
@Test
public void testSystemDefaults(){
assertTrue(new Hints().isEmpty());
try {
assertNull(Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE));
final Hints hints = new Hints();
assertFalse(hints.isEmpty());
assertEquals(1, hints.size());
final Object value = hints.get(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
assertTrue(value instanceof Boolean);
assertFalse(((Boolean) value).booleanValue());
assertEquals(hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE), Boolean.FALSE);
assertEquals(hints.remove(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER), Boolean.TRUE);
assertTrue(hints.isEmpty());
} finally {
assertNotNull(Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER));
}
assertTrue(new Hints().isEmpty());
}
}
代码示例来源:origin: apache/sis
/**
* Tests the creation of a simple {@link DefaultAttributeType} instance for a mandatory singleton.
*/
@Test
public void testMandatorySingleton() {
final DefaultAttributeType<String> city = city();
final GenericName name = city.getName();
assertInstanceOf("city.name", LocalName.class, name);
assertEquals("city.name", "city", name.toString());
InternationalString p = city.getDesignation();
assertNotNull("designation", p);
assertEquals("designation", "City", p.toString(Locale.ENGLISH));
assertEquals("designation", "Ville", p.toString(Locale.FRENCH));
assertEquals("designation", "都市", p.toString(Locale.JAPANESE));
p = city.getDefinition();
assertEquals("definition", "The name of the city.", p.toString(Locale.ENGLISH));
assertEquals("definition", "Le nom de la ville.", p.toString(Locale.FRENCH));
assertEquals("definition", "都市の名前。", p.toString(Locale.JAPANESE));
p = city.getDescription();
assertEquals("description", "Some verbose description.", p.toString(Locale.ENGLISH));
assertEquals("valueClass", String.class, city.getValueClass());
assertEquals("defaultValue", "Utopia", city.getDefaultValue());
assertEquals("minimumOccurs", 1, city.getMinimumOccurs());
assertEquals("axnimumOccurs", 1, city.getMaximumOccurs());
}
内容来源于网络,如有侵权,请联系作者删除!