TextSenderThread extends Thread { public void sendData(final SpeakableText speakable) { final String ssml = speakable.getSpeakableText(); final TextMessage message = TextMessage.newBuilder() .setType(TextMessageType.SSML).setData(ssml) .setSequenceNumber(sequenceNumber++).build(); final PendingMessage pending = new PendingMessage(message, speakable); messages.add(pending); } TextSenderThread(final Socket asyncSocket,
            final TextTelephony textTelephony); @Override void run(); void sendData(final SpeakableText speakable); void sendExpectingInput(); void sendClosedInput(); void sendBye(); void sendAck(final TextMessage message); boolean isSending();  }
@Test public void testSendData() throws Exception { final String test1 = "test1"; final SpeakableSsmlText speakable1 = new SpeakableSsmlText(test1, Locale.US); sender.sendData(speakable1); synchronized (lock) { lock.wait(MAX_WAIT); } assertEquals(speakable1.getDocument(), receivedObject); }
@Test public void testSendDataMultiple() throws Exception { final int max = 100; for (int i = 0; i < max; i++) { final String test = "test " + i; final SpeakableText speakable = new SpeakableSsmlText(test, Locale.US); sender.sendData(speakable); } int i = 0; while (i < max) { synchronized (lock) { lock.wait(MAX_WAIT); } ++i; } Assert.assertEquals(max, i); }