org.apache.sis.test.Assert.assertSerializedEquals()方法的使用及代码示例

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

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

Assert.assertSerializedEquals介绍

[英]Serializes the given object in memory, deserializes it and ensures that the deserialized object is equals to the original one. This method does not write anything to the disk.

If the serialization fails, then this method throws an AssertionErroras do the other JUnit assertion methods.
[中]序列化内存中的给定对象,将其反序列化,并确保反序列化的对象等于原始对象。此方法不向磁盘写入任何内容。
如果序列化失败,那么此方法将抛出AssertionError,就像其他JUnit断言方法一样。

代码示例

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

/**
   * Tests serialization of pre-defined constants.
   */
  @Test
  public void testConstantSerialization() {
    assertSame("SUPPORTED",           SUPPORTED,           assertSerializedEquals(SUPPORTED));
    assertSame("UNSUPPORTED_STORAGE", UNSUPPORTED_STORAGE, assertSerializedEquals(UNSUPPORTED_STORAGE));
    assertSame("INSUFFICIENT_BYTES",  INSUFFICIENT_BYTES,  assertSerializedEquals(INSUFFICIENT_BYTES));
    assertSame("UNDETERMINED",        UNDETERMINED,        assertSerializedEquals(UNDETERMINED));
  }
}

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

/**
 * Tests conversions from URI to URL values.
 *
 * @throws MalformedURLException if this test uses a malformed URL.
 * @throws URISyntaxException if this test uses a malformed URI.
 */
@Test
public void testURI_URL() throws MalformedURLException, URISyntaxException {
  final ObjectConverter<URI,URL> c = PathConverter.URI_URL.INSTANCE;
  runInvertibleConversion(c, new URI("file:/home/user/index.txt"), new URL("file:/home/user/index.txt"));
  assertSerializedEquals(c);
}

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

/**
   * Serializes some units, deserializes them and verifies that we get the same instance.
   */
  @Test
  public void testSerialization() {
    assertSame(Units.KILOMETRE, assertSerializedEquals(Units.KILOMETRE));
    assertSame(Units.HECTARE,   assertSerializedEquals(Units.HECTARE));
  }
}

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

/**
 * Serializes some units, deserializes them and verifies that we get the same instance.
 */
@Test
@DependsOnMethod("testEqualsAndHashCode")
public void testSerialization() {
  assertSame(Units.METRE,  assertSerializedEquals(Units.METRE));
  assertSame(Units.SECOND, assertSerializedEquals(Units.SECOND));
  assertSame(Units.NEWTON, assertSerializedEquals(Units.NEWTON));
  assertSame(Units.UNITY,  assertSerializedEquals(Units.UNITY));
}

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

/**
 * Tests conversions to {@link Integer} values.
 */
@Test
public void testInteger() {
  final ObjectConverter<Float, Integer> c = create(Float.class, Integer.class);
  runInvertibleConversion(c, Float.valueOf(-8),    Integer.valueOf(-8));
  runConversion          (c, Float.valueOf(2.25f), Integer.valueOf(2), Float.valueOf(2f));
  runConversion          (c, Float.valueOf(2.75f), Integer.valueOf(3), Float.valueOf(3f));
  // Can not easily tests the values around Integer.MIN/MAX_VALUE because of rounding errors in float.
  assertSame("Deserialization shall resolves to the singleton instance.", c, assertSerializedEquals(c));
}

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

/**
   * Tests the {@link org.apache.sis.test.Assert#assertSerializedEquals(Object)} method.
   */
  @Test
  public void testAssertSerializedEquals() {
    final String local = "Le silence éternel de ces espaces infinis m'effraie";
    assertNotSame(local, assertSerializedEquals(local));
  }
}

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

/**
 * Tests conversions to {@link Path}.
 */
@Test
public void testPath() {
  final ObjectConverter<String,Path> c = new StringConverter.Path();
  final String path = "home/user/index.txt".replace('/', File.separatorChar);
  runInvertibleConversion(c, path, Paths.get(path));
  assertSerializedEquals(c);
}

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

/**
   * Tests serialization.
   */
  @Test
  public void testSerialization() {
    NumberRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
    NumberRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, Units.KILOMETRE);
    assertNotSame(r1, assertSerializedEquals(r1));
    assertNotSame(r2, assertSerializedEquals(r2));
  }
}

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

/**
 * Tests serialization.
 */
@Test
public void testSerialization() {
  final AbstractAssociation twinTown = twinTown();
  assertNotSame(twinTown, assertSerializedEquals(twinTown));
}

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

/**
   * Tests the serialization of a custom subclass. {@link OptionKey} can not resolve
   * to a unique instance, unless the subclass provides its own resolution mechanism.
   */
  @Test
  public void testSubclassSerialization() {
    final CustomKey<Integer> key = new CustomKey<>("key", Integer.class);
    assertNotSame(key, assertSerializedEquals(key));
  }
}

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

/**
 * Tests serialization.
 */
@Test
@DependsOnMethod("testEquals")
public void testSerialization() {
  final DefaultAttributeType<String> attribute = city();
  assertSerializedEquals(attribute);
}

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

/**
   * Tests serialization.
   */
  @Test
  public void testSerialization() {
    final Fraction local = new Fraction(5, 7);
    assertNotSame(local, assertSerializedEquals(local));
  }
}

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

/**
   * Tests serialization. Since we can not serialize native resources, {@link PJ} is expected
   * to serialize the Proj.4 definition string instead.
   *
   * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
   */
  @Test
  public void testSerialization() throws FactoryException {
    final PJ pj = new PJ("+proj=latlong +datum=WGS84");
    assertNotSame(pj, assertSerializedEquals(pj));
  }
}

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

/**
   * Tests serialization.
   */
  @Test
  public void testSerialization() {
    final Version version = new Version("1.6.b2");
    assertNotSame(version, assertSerializedEquals(version));
  }
}

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

/**
   * Tests serialization.
   */
  @Test
  @DependsOnMethod({"testInheritance", "testEquals"})
  public void testSerialization() {
    assertPropertiesEquals(assertSerializedEquals(capital()), true, "city", "population", "parliament");
  }
}

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

/**
 * Tests conversions to {@link org.opengis.util.CodeList}.
 */
@Test
public void testCodeList() {
  final ObjectConverter<String, OnLineFunction> c = new StringConverter.CodeList<>(OnLineFunction.class);
  runInvertibleConversion(c, "OFFLINE_ACCESS", OnLineFunction.OFFLINE_ACCESS);
  tryUnconvertibleValue(c);
  assertSerializedEquals(c);
}

代码示例来源: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 serialization.
   */
  @Test
  public void testSerialize() {
    final GeneralDirectPosition p1 = new GeneralDirectPosition(12, -20, 4, 9);
    final GeneralDirectPosition p2 = assertSerializedEquals(p1);
    assertNotSame(p1, p2);
    validate(p2);
  }
}

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

/**
   * Tests serialization.
   */
  @Test
  @DependsOnMethod("testEquals")
  public void testSerialization() {
    final AbstractAttribute<String> attribute = universities();
    attribute.setValue("University of international development");
    assertNotSame(attribute, assertSerializedEquals(attribute));
  }
}

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

/**
 * Tests serialization.
 */
@Test
public void testSerialization() {
  final RangeSet<Double> ranges = RangeSet.create(Double.class, true, false);
  assertTrue(ranges.add(12.0, 12.5));
  assertTrue(ranges.add(18.0, 18.5));
  assertTrue(ranges.add(19.0, 20.0));
  assertNotSame(ranges, assertSerializedEquals(ranges));
}

相关文章