@Test public void testConstructor() throws Exception { String errorMessage = "protocol doesn't support output"; when(mHttpConMock.getOutputStream()).thenThrow(new IOException(errorMessage)); mThrown.expect(IOException.class); mThrown.expectMessage(errorMessage); new SwiftOutputStream(mHttpConMock).close(); }
@Override public void close() throws IOException { mOutputStream.close(); InputStream is = null; try { if (mHttpCon.getResponseCode() >= 400) { LOG.error("Failed to write data to Swift with error code: " + mHttpCon.getResponseCode()); is = mHttpCon.getErrorStream(); } else { is = mHttpCon.getInputStream(); } is.close(); } catch (Exception e) { LOG.error(e.getMessage()); if (is != null) { is.close(); } } mHttpCon.disconnect(); }
SwiftOutputStream extends OutputStream { @Override public void close() throws IOException { mOutputStream.close(); InputStream is = null; try { if (mHttpCon.getResponseCode() >= 400) { LOG.error("Failed to write data to Swift with error code: " + mHttpCon.getResponseCode()); is = mHttpCon.getErrorStream(); } else { is = mHttpCon.getInputStream(); } is.close(); } catch (Exception e) { LOG.error(e.getMessage()); if (is != null) { is.close(); } } mHttpCon.disconnect(); } }
SwiftOutputStream extends OutputStream { @Override public void close() throws IOException { mOutputStream.close(); InputStream is = null; try { if (mHttpCon.getResponseCode() >= 400) { LOG.error("Failed to write data to Swift with error code: " + mHttpCon.getResponseCode()); is = mHttpCon.getErrorStream(); } else { is = mHttpCon.getInputStream(); } is.close(); } catch (Exception e) { LOG.error(e.getMessage()); if (is != null) { is.close(); } } mHttpCon.disconnect(); } SwiftOutputStream(HttpURLConnection httpCon); }
SwiftOutputStream extends OutputStream { @Override public void close() throws IOException { mOutputStream.close(); InputStream is = null; try { if (mHttpCon.getResponseCode() >= 400) { LOG.error("Failed to write data to Swift with error code: " + mHttpCon.getResponseCode()); is = mHttpCon.getErrorStream(); } else { is = mHttpCon.getInputStream(); } is.close(); } catch (Exception e) { LOG.error(e.getMessage()); if (is != null) { is.close(); } } mHttpCon.disconnect(); } SwiftOutputStream(HttpURLConnection httpCon); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b); @Override void close(); @Override void flush(); }
SwiftOutputStream extends OutputStream { @Override public void close() throws IOException { mOutputStream.close(); InputStream is = null; try { if (mHttpCon.getResponseCode() >= 400) { LOG.error("Failed to write data to Swift with error code: " + mHttpCon.getResponseCode()); is = mHttpCon.getErrorStream(); } else { is = mHttpCon.getInputStream(); } is.close(); } catch (Exception e) { LOG.error(e.getMessage()); if (is != null) { is.close(); } } mHttpCon.disconnect(); } SwiftOutputStream(HttpURLConnection httpCon); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b); @Override void close(); @Override void flush();  }