public Void call() throws Exception { HttpWire wire = setUp(); InputStream in = wire.input(fromServer); ByteArrayOutputStream out = new ByteArrayOutputStream();// TODO copy(in, out); byte[] compare = md5().hashBytes(out.toByteArray()).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); return null; } }
public Void call() throws Exception { HttpWire wire = setUp(); InputStream in = wire.input(fromServer); byte[] compare = md5().hashBytes(ByteStreams.toByteArray(in)).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); return null; } }
public void testInputInputStream() throws Exception { HttpWire wire = setUp(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Strings2.toStringAndClose(in); Thread.sleep(100); assertEquals(compare, "foo"); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); }
public void testInputInputStreamSynch() throws Exception { HttpWire wire = setUpSynch(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Strings2.toStringAndClose(in); assertEquals(compare, "foo"); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); }
public void testInputInputStream() throws Exception { HttpWire wire = setUp(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Strings2.toStringAndClose(in); Thread.sleep(100); assertEquals(compare, "foo"); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); }
@Test(groups = "live") public void testRemoteInputStream() throws Exception { try { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); HttpWire wire = setUp(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = ByteStreams2.hashAndClose(in, md5()).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } catch (UnknownHostException e) { // probably in offline mode } }
public void testInputInputStreamSynch() throws Exception { HttpWire wire = setUpSynch(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Strings2.toStringAndClose(in); assertEquals(compare, "foo"); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); }
@Test(groups = "live") public void testRemoteInputStream() throws Exception { try { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); HttpWire wire = setUp(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = asByteSource(in).hash(md5()).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } catch (UnknownHostException e) { // probably in offline mode } }
@Test(groups = "live") public void testRemoteInputStreamSynch() throws Exception { try { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); HttpWire wire = setUpSynch(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = asByteSource(in).hash(md5()).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } catch (UnknownHostException e) { // probably in offline mode } }
@Test(groups = "live") public void testRemoteInputStreamSynch() throws Exception { try { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); HttpWire wire = setUpSynch(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = ByteStreams2.hashAndClose(in, md5()).asBytes(); Thread.sleep(100); assertEquals(base16().lowerCase().encode(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } catch (UnknownHostException e) { // probably in offline mode } }
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response); int statusCode = response.getStatusCode(); if (statusCode >= 300) {
@Test public void testInputPayload() throws Exception { HttpWire wire = setUp(); StringPayload payload = new StringPayload("foo"); PayloadEnclosing request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); BufferLogger wireLog = (BufferLogger) wire.getWireLog(); assertEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to be printed in logs"); wireLog.buff.setLength(0); payload.setSensitive(true); request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); assertNotEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to NOT be printed in logs"); wireLog.buff.setLength(0); wire.logSensitiveInformation = true; request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); assertEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to be printed in logs"); }
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);
utils.logResponse(headerLog, response, "<<"); if (response.getPayload() != null && wire.enabled()) wire.input(response);