コード例 #1
0
  @Test
  public void testExternalizingRelation() throws IOException, ClassNotFoundException {
    ObjectOutputStream oos = null;
    ObjectInputStream ois = null;
    ByteArrayOutputStream baos = null;
    int maxTests = GeneralTesting.createRandomUpperLimit(1000);

    for (int j = 0; j <= maxTests; j++) {
      OsmRelationImpl relation = OsmTesting.generateOsmRelationWithTagsAndMembers();

      baos = new ByteArrayOutputStream();
      oos = new ObjectOutputStream(baos);
      externalizer.writeExternalRelation(relation, oos);

      oos.flush();

      ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));

      IOsmRelation deserializedRelation = externalizer.readExternalRelation(ois);

      assertTrue(OsmComparator.areRelationsEqual(relation, deserializedRelation));

      oos.close();
      ois.close();
      baos.close();
    }
  }
コード例 #2
0
  @Test
  public void testExternalizingWay() throws IOException, ClassNotFoundException {
    ObjectOutputStream oos = null;
    ObjectInputStream ois = null;
    ByteArrayOutputStream baos = null;
    int maxTests = GeneralTesting.createRandomUpperLimit(1000);

    for (int j = 0; j <= maxTests; j++) {
      OsmWayImpl node = OsmTesting.generateOsmWayWithTagsAndNds();

      baos = new ByteArrayOutputStream();
      oos = new ObjectOutputStream(baos);
      externalizer.writeExternalWay(node, oos);

      oos.flush();

      ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));

      IOsmWay deserializedNode = externalizer.readExternalWay(ois);

      assertTrue(OsmComparator.areWaysEqual(node, deserializedNode));

      oos.close();
      ois.close();
      baos.close();
    }
  }