Here are the examples of the java api class com.google.caliper.bridge.OpenedSocket taken from open source projects.
1. ServerSocketServiceTest#getConnectionIdTwice_acceptComesFirst()
Project: caliper
File: ServerSocketServiceTest.java
File: ServerSocketServiceTest.java
@Test public void getConnectionIdTwice_acceptComesFirst() throws Exception { UUID id = UUID.randomUUID(); OpenedSocket clientSocket = openConnectionAndIdentify(id); ListenableFuture<OpenedSocket> pendingServerConnection = service.getConnection(id); // wait for the service to fully initialize the connection OpenedSocket serverSocket = pendingServerConnection.get(); assertEndsConnected(clientSocket, serverSocket); try { // the second request is an error service.getConnection(id).get(); fail(); } catch (IllegalStateException expected) { } }
2. ServerSocketServiceTest#openConnectionAndIdentify()
Project: caliper
File: ServerSocketServiceTest.java
File: ServerSocketServiceTest.java
/** * Opens a connection to the service and identifies itself using the id. */ private OpenedSocket openConnectionAndIdentify(UUID id) throws IOException { OpenedSocket clientSocket = openClientConnection(); OpenedSocket.Writer writer = clientSocket.writer(); writer.write(new StartupAnnounceMessage(id)); writer.flush(); return clientSocket; }
3. ServerSocketServiceTest#getConnectionId_requestComesInFirst()
Project: caliper
File: ServerSocketServiceTest.java
File: ServerSocketServiceTest.java
@Test public void getConnectionId_requestComesInFirst() throws Exception { UUID id = UUID.randomUUID(); ListenableFuture<OpenedSocket> pendingServerConnection = service.getConnection(id); assertFalse(pendingServerConnection.isDone()); OpenedSocket clientSocket = openConnectionAndIdentify(id); // Assert that the ends are hooked up to each other assertEndsConnected(clientSocket, pendingServerConnection.get()); }