/**
   * Tests characteristic round tripping
   *
   * @throws IOException
   */
  @Test
  public void characteristic_writable_01() throws IOException {
    Node n = NodeFactory.createURI("http://example.org");
    CharacteristicWritable expected = new CharacteristicWritable(n);
    Assert.assertEquals(1, expected.getCount().get());

    this.checkRoundTrip(expected);
  }
  /**
   * Checks whether a writable round trips successfully
   *
   * @param cw Characteristic writable
   * @throws IOException
   */
  private void checkRoundTrip(CharacteristicWritable cw) throws IOException {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    DataOutputStream output = new DataOutputStream(outputStream);
    cw.write(output);

    ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    DataInputStream input = new DataInputStream(inputStream);
    CharacteristicWritable actual = CharacteristicWritable.read(input);
    Assert.assertEquals(cw, actual);
  }
 /**
  * Checks a characteristic set
  *
  * @param set Set
  * @param expectedItems Expected number of characteristics
  * @param expectedCounts Expected counts for characteristics
  */
 protected final void checkCharacteristicSet(
     CharacteristicSetWritable set, int expectedItems, long[] expectedCounts) {
   Assert.assertEquals(expectedItems, set.size());
   Assert.assertEquals(expectedItems, expectedCounts.length);
   Iterator<CharacteristicWritable> iter = set.getCharacteristics();
   int i = 0;
   while (iter.hasNext()) {
     CharacteristicWritable cw = iter.next();
     Assert.assertEquals(expectedCounts[i], cw.getCount().get());
     i++;
   }
 }