public void testAddIP() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try a ping which doesn't ask for ip PingRequest noRequest = pingRequestFactory.createPingRequest((byte) 1); assertFalse(noRequest.requestsIP()); noRequest.write(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); PingRequest fromNet = (PingRequest) messageFactory.read(bais, Network.TCP); assertFalse(fromNet.requestsIP()); // try a ping without any other ggeps except the ip request byte[] guid = GUID.makeGuid(); PingRequest noPayload = pingRequestFactory.createPingRequest(guid, (byte) 1, (byte) 0); assertFalse(noPayload.requestsIP()); noPayload.addIPRequest(); assertTrue(noPayload.requestsIP()); baos = new ByteArrayOutputStream(); noPayload.write(baos); bais = new ByteArrayInputStream(baos.toByteArray()); fromNet = (PingRequest) messageFactory.read(bais, Network.TCP); assertTrue(fromNet.requestsIP()); // now try a ping with locale String original = ApplicationSettings.LANGUAGE.get(); ApplicationSettings.LANGUAGE.set("zz"); PingRequest withLocale = pingRequestFactory.createPingRequest((byte) 1); ApplicationSettings.LANGUAGE.set(original); withLocale.addIPRequest(); baos = new ByteArrayOutputStream(); withLocale.write(baos); bais = new ByteArrayInputStream(baos.toByteArray()); fromNet = (PingRequest) messageFactory.read(bais, Network.TCP); assertTrue(fromNet.requestsIP()); assertEquals("zz", fromNet.getLocale()); assertFalse(fromNet.supportsCachedPongs()); assertNull(fromNet.getSupportsCachedPongData()); }
public String getLocalePref() { return ApplicationSettings.LANGUAGE.getValue(); }