Code example for Charset

Methods: encode, sleep

0
		 
		when(mockFactory.createClient(HOSTNAME, PORT)).thenReturn(mockClient);
		 
		// Set message on the queue 
		when(mockClient.acquire(POOL))
			.thenReturn(new Job(utf8.encode(MESSAGE_ONE), utf8.encode(ID_ONE)))
			.thenReturn(new Job(utf8.encode(MESSAGE_TWO), utf8.encode(ID_TWO)))
			.thenThrow(new EmptyPool()); 
		 
		LoggingTextConsumer consumer = new LoggingTextConsumer(HOSTNAME, PORT, POOL);
		 
		// Run as background thread then tell to stop after processing documents. 
		Thread t = new Thread(consumer);
		t.start();
		Thread.sleep(10); // Could in case this if it starts to be a problem.
		consumer.stop();
		 
		// Check it gets messages 
		assertEquals(2, consumer.count);
		assertEquals(Arrays.asList(MESSAGE_ONE, MESSAGE_TWO), consumer.messages);
				 
		verify(mockClient).purge(POOL, utf8.encode(ID_ONE));
		verify(mockClient).purge(POOL, utf8.encode(ID_TWO));
	} 
}