### Question:
Ros { public boolean send(JsonObject jsonObject) { if (this.isConnected()) { try { this.session.getBasicRemote().sendText(jsonObject.toString()); return true; } catch (IOException e) { System.err.println("[ERROR]: Could not send message: " + e.getMessage()); } } return false; } Ros();  Ros(String hostname);  Ros(String hostname, int port);  Ros(String hostname, int port, JRosbridge.WebSocketType protocol); String getHostname(); int getPort(); JRosbridge.WebSocketType getProtocol(); String getURL(); long nextId(); void addRosHandler(RosHandler handler); boolean connect(); boolean disconnect(); boolean isConnected(); @OnOpen void onOpen(Session session); @OnClose void onClose(Session session); @OnError void onError(Session session, Throwable t); @OnMessage void onMessage(String message); boolean send(JsonObject jsonObject); void authenticate(String mac, String client, String dest,
			String rand, int t, String level, int end); void registerTopicCallback(String topic, TopicCallback cb); void deregisterTopicCallback(String topic, TopicCallback cb); void registerServiceCallback(String serviceCallId, ServiceCallback cb); void registerCallServiceCallback(String serviceName, CallServiceCallback cb); void deregisterCallServiceCallback(String serviceName); static final String DEFAULT_HOSTNAME; static final int DEFAULT_PORT; }### Answer:
@Test public void testSend() { assertTrue(r1.connect()); assertTrue(r1.send(Json.createObjectBuilder().add("test", "value") .build())); while (DummyHandler.latest == null) { Thread.yield(); } assertNotNull(DummyHandler.latest); assertEquals(1, DummyHandler.latest.size()); assertTrue(DummyHandler.latest.containsKey("test")); assertEquals("value", DummyHandler.latest.getString("test")); }
@Test public void testSendNoConnection() { assertFalse(r1.send(Json.createObjectBuilder().build())); assertFalse(r2.send(Json.createObjectBuilder().build())); assertFalse(r3.send(Json.createObjectBuilder().build())); assertFalse(r4.send(Json.createObjectBuilder().build())); assertNull(DummyHandler.latest); }