Пример #1
0
  @Test
  public void testEnum() throws IOException {
    ObjectInputOutput io = new ObjectInputOutput();
    MarshallUtil.marshallEnum(null, io);
    Assert.assertNull(MarshallUtil.unmarshallEnum(io, ordinal -> TestEnum.values()[ordinal]));
    Assert.assertEquals(0, io.buffer.size());

    for (TestEnum e : TestEnum.values()) {
      io.reset();
      MarshallUtil.marshallEnum(e, io);
      Assert.assertEquals(
          e, MarshallUtil.unmarshallEnum(io, ordinal -> TestEnum.values()[ordinal]));
      Assert.assertEquals(0, io.buffer.size());
    }
  }
Пример #2
0
 public static void main(String[] args) {
   for (TestEnum e : TestEnum.values()) {
     e.test();
   }
   TestEnum e1 = TestEnum.valueOf("E");
   e1.test();
 }