@Before
  public void setUp() throws Exception {
    frameEncoder = new MessageLengthFrameEncoder();

    SimpleDirectory directory = new SimpleDirectory();
    engine =
        Engine.builder()
            .withAuthenticator(new SimpleAuthenticator().withDirectory(directory))
            .build();
    engine.open();

    reactor2 =
        EventReactor.builder()
            .withDispatcher(new ByteBufferDispatcher())
            .withPayloadAllocator(new ByteBufferPayload(2048))
            .build();
    reactor2.open().get();

    directory.add(userCredentials);

    messages = new byte[messageCount][];
    for (int i = 0; i < messageCount; ++i) {
      messages[i] = new byte[i];
      Arrays.fill(messages[i], (byte) i);
    }
  }
 @After
 public void tearDown() throws Exception {
   engine.close();
   reactor2.close();
 }