target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void uri_resource_path_ends_with_question_mark_returns_path_removed_with_question_mark(){ final String expectedResourcePath = "/foo/bar"; final String pathWithEmptyStaticQueryParams = expectedResourcePath + "?"; Assert.assertEquals(expectedResourcePath, UriResourcePathUtils .addStaticQueryParamtersToRequest(new DefaultRequest<Object> (null, null), pathWithEmptyStaticQueryParams)); }
public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
@Test public void queryparam_value_empty_adds_parameter_with_empty_string_to_request() { final String uriResourcePath = "/foo/bar"; final String uriResourcePathWithParams = uriResourcePath + "?param1="; final Request<Object> request = new DefaultRequest<Object> (null, null); Assert.assertEquals(uriResourcePath, UriResourcePathUtils .addStaticQueryParamtersToRequest(request, uriResourcePathWithParams)); Assert.assertTrue(request.getParameters().containsKey("param1")); Assert.assertEquals(Arrays.asList(""), request.getParameters().get("param1")); }
public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
@Test public void static_queryparams_in_path_added_to_request(){ final String uriResourcePath = "/foo/bar"; final String uriResourcePathWithParams = uriResourcePath + "?param1=value1&param2=value2"; final Request<Object> request = new DefaultRequest<Object> (null, null); Assert.assertEquals(uriResourcePath, UriResourcePathUtils .addStaticQueryParamtersToRequest(request, uriResourcePathWithParams)); Assert.assertTrue(request.getParameters().containsKey("param1")); Assert.assertTrue(request.getParameters().containsKey("param2")); Assert.assertEquals(Arrays.asList("value1"), request.getParameters().get("param1")); Assert.assertEquals(Arrays.asList("value2"), request.getParameters().get("param2")); }
public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
@Test public void queryparam_without_value_returns_list_containing_null_value() { final String uriResourcePath = "/foo/bar"; final String uriResourcePathWithParams = uriResourcePath + "?param"; final Request<Object> request = new DefaultRequest<Object>(null, null); Assert.assertEquals(uriResourcePath, UriResourcePathUtils.addStaticQueryParamtersToRequest(request, uriResourcePathWithParams)); Assert.assertTrue(request.getParameters().containsKey("param")); Assert.assertEquals(Arrays.asList((String)null), request.getParameters().get("param")); }
public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath); }
@Test public void testInfoLogCallsMadeForStartTransfer() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.startTransfer(anyString(), isNull(String.class), anyString(), any(TransferListener.class)) ).thenReturn(3L); when(mockLog.isDebugEnabled()).thenReturn(false); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(new AsperaTransactionImpl(null, null, null, null, null, null)); wrapper.log = mockLog; long rtn = wrapper.startTransfer("xyz123", "configString1"); assertEquals(3L, rtn); verify(mockLog, times(1)).info(Mockito.eq("Starting transfer with xferId [xyz123]")); }
public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testDebugLogCallsMadeForStartTransfer() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.startTransfer(anyString(), isNull(String.class), anyString(), any(TransferListener.class)) ).thenReturn(3L); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(new AsperaTransactionImpl(null, null, null, null, null, null)); wrapper.log = mockLog; long rtn = wrapper.startTransfer("xyz123", "configString1"); assertEquals(3L, rtn); verify(mockLog, times(1)).debug(Mockito.eq("Transfer Spec for Session with xferId [xyz123]")); }
public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testTraceLogCallsMadeForStartTransfer() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.startTransfer(anyString(), isNull(String.class), anyString(), any(TransferListener.class)) ).thenReturn(3L); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(new AsperaTransactionImpl(null, null, null, null, null, null)); wrapper.log = mockLog; long rtn = wrapper.startTransfer("xyz123", "configString1"); assertEquals(3L, rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [startTransfer] with parameters [\"xyz123\", null, transferSpecStr, transferListener]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [startTransfer] returned for xferId [\"xyz123\"] with result: [3]")); }
public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public long startTransfer(final String xferId, final String transferSpecStr) { log.info("Starting transfer with xferId [" + xferId + "]"); if (log.isDebugEnabled()) { log.debug("Transfer Spec for Session with xferId [" + xferId + "]"); log.debug(AsperaTransferManagerUtils.getRedactedJsonString( transferSpecStr, "token")); } log.trace("Calling method [startTransfer] with parameters [\"" + xferId + "\", null, transferSpecStr, transferListener]"); long rtn = faspmanager2.startTransfer(xferId, null, transferSpecStr, asperaTransaction.getTransferListener()); log.trace("Method [startTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testInfoLogCallsMadeForPause() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.modifyTransfer(anyString(), anyInt(), anyLong()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(false); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.pause("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).info(Mockito.eq("Pausing transfer with xferId [xyz123]")); }
public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void unmarshall_ValidJsonContent_UnmarshallsCorrectly() throws Exception { CustomException ase = (CustomException) unmarshaller.unmarshall(JSON); assertEquals("Some error message", ase.getErrorMessage()); assertEquals("This is a customField", ase.getCustomField()); assertEquals(Integer.valueOf(42), ase.getCustomInt()); }
@Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); @Override AmazonServiceException unmarshall(JsonNode jsonContent); boolean matchErrorCode(String actualErrorCode); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); @Override AmazonServiceException unmarshall(JsonNode jsonContent); boolean matchErrorCode(String actualErrorCode); static final JsonErrorUnmarshaller DEFAULT_UNMARSHALLER; }
@Test public void unmarshall_InvalidCaseJsonContent_DoesNotUnmarshallCustomFields() throws Exception { CustomException ase = (CustomException) unmarshaller.unmarshall(INVALID_CASE_JSON); assertEquals("Some error message", ase.getErrorMessage()); assertNull(ase.getCustomField()); assertNull(ase.getCustomInt()); }
@Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); @Override AmazonServiceException unmarshall(JsonNode jsonContent); boolean matchErrorCode(String actualErrorCode); }
JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { @Override public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception { return MAPPER.treeToValue(jsonContent, exceptionClass); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); @Override AmazonServiceException unmarshall(JsonNode jsonContent); boolean matchErrorCode(String actualErrorCode); static final JsonErrorUnmarshaller DEFAULT_UNMARSHALLER; }
@Test public void testTraceLogCallsMadeForPause() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.modifyTransfer(anyString(), anyInt(), anyLong()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.pause("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [modifyTransfer] with parameters [\"xyz123\", 4, 0]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [modifyTransfer] returned for xferId [\"xyz123\"] with result: [true]")); }
public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean pause(final String xferId) { log.info("Pausing transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 4, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 4, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testInfoLogCallsMadeForResume() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.modifyTransfer(anyString(), anyInt(), anyLong()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(false); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.resume("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).info(Mockito.eq("Resuming transfer with xferId [xyz123]")); }
public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void clientConfigurationCopyConstructor_CopiesAllValues() throws Exception { ClientConfiguration customConfig = new ClientConfiguration(); for (Field field : ClientConfiguration.class.getDeclaredFields()) { if (isStaticField(field)) { continue; } field.setAccessible(true); final Class<?> clzz = field.getType(); if (clzz.isAssignableFrom(int.class) || clzz.isAssignableFrom(long.class)) { field.set(customConfig, Math.abs(RANDOM.nextInt())); } else if (clzz.isAssignableFrom(boolean.class)) { field.set(customConfig, !(Boolean) field.get(customConfig)); } else if (clzz.isAssignableFrom(String.class)) { field.set(customConfig, RandomStringUtils.random(10)); } else if (clzz.isAssignableFrom(RetryPolicy.class)) { field.set(customConfig, CUSTOM_RETRY_POLICY); } else if (clzz.isAssignableFrom(InetAddress.class)) { field.set(customConfig, InetAddress.getLocalHost()); } else if (clzz.isAssignableFrom(Protocol.class)) { if (field.getName().equals("protocol")) { field.set(customConfig, Protocol.HTTP); } else { field.set(customConfig, Protocol.HTTPS); } } else if (clzz.isAssignableFrom(DnsResolver.class)) { field.set(customConfig, new MyCustomDnsResolver()); } else if (clzz.isAssignableFrom(SecureRandom.class)) { field.set(customConfig, new SecureRandom()); } else if (field.getName().equals("headers")) { field.set(customConfig, ImmutableMapParameter.of("foo", "bar")); } else if (clzz.isAssignableFrom(ApacheHttpClientConfig.class)) { customConfig.getApacheHttpClientConfig() .setSslSocketFactory(Mockito.mock(ConnectionSocketFactory.class)); } else if (clzz.isAssignableFrom(List.class)) { field.set(customConfig, new ArrayList<Object>()); } else if (clzz.isAssignableFrom(AtomicReference.class)) { if (field.getName().equals("httpProxyHolder")) { field.set(customConfig, new AtomicReference<ClientConfiguration.URLHolder>(new ClientConfiguration.URLHolder())); } } else if (clzz.isAssignableFrom(TlsKeyManagersProvider.class)) { field.set(customConfig, new SystemPropertyTlsKeyManagersProvider()); } else { throw new RuntimeException( String.format("Field %s of type %s is not supported", field.getName(), field.getType())); } assertNotEquals( String.format("Field %s does not differ from default value", field.getName()), field.get(DEFAULT_CLIENT_CONFIG), field.get(customConfig)); } assertReflectionEquals(customConfig, new ClientConfiguration(customConfig)); }
public ApacheHttpClientConfig getApacheHttpClientConfig() { return apacheHttpClientConfig; }
ClientConfiguration { public ApacheHttpClientConfig getApacheHttpClientConfig() { return apacheHttpClientConfig; } }
ClientConfiguration { public ApacheHttpClientConfig getApacheHttpClientConfig() { return apacheHttpClientConfig; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); }
ClientConfiguration { public ApacheHttpClientConfig getApacheHttpClientConfig() { return apacheHttpClientConfig; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); Protocol getProtocol(); void setProtocol(Protocol protocol); ClientConfiguration withProtocol(Protocol protocol); int getMaxConnections(); void setMaxConnections(int maxConnections); ClientConfiguration withMaxConnections(int maxConnections); @Deprecated String getUserAgent(); @Deprecated void setUserAgent(String userAgent); @Deprecated ClientConfiguration withUserAgent(String userAgent); String getUserAgentPrefix(); void setUserAgentPrefix(String prefix); ClientConfiguration withUserAgentPrefix(String prefix); String getUserAgentSuffix(); void setUserAgentSuffix(String suffix); ClientConfiguration withUserAgentSuffix(String suffix); InetAddress getLocalAddress(); void setLocalAddress(InetAddress localAddress); ClientConfiguration withLocalAddress(InetAddress localAddress); Protocol getProxyProtocol(); ClientConfiguration withProxyProtocol(Protocol proxyProtocol); void setProxyProtocol(Protocol proxyProtocol); String getProxyHost(); void setProxyHost(String proxyHost); ClientConfiguration withProxyHost(String proxyHost); int getProxyPort(); void setProxyPort(int proxyPort); ClientConfiguration withProxyPort(int proxyPort); ClientConfiguration withDisableSocketProxy(boolean disableSocketProxy); void setDisableSocketProxy(boolean disableSocketProxy); boolean disableSocketProxy(); String getProxyUsername(); void setProxyUsername(String proxyUsername); ClientConfiguration withProxyUsername(String proxyUsername); String getProxyPassword(); void setProxyPassword(String proxyPassword); ClientConfiguration withProxyPassword(String proxyPassword); String getProxyDomain(); void setProxyDomain(String proxyDomain); ClientConfiguration withProxyDomain(String proxyDomain); String getProxyWorkstation(); void setProxyWorkstation(String proxyWorkstation); ClientConfiguration withProxyWorkstation(String proxyWorkstation); String getNonProxyHosts(); void setNonProxyHosts(String nonProxyHosts); ClientConfiguration withNonProxyHosts(String nonProxyHosts); List<ProxyAuthenticationMethod> getProxyAuthenticationMethods(); void setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); ClientConfiguration withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); RetryPolicy getRetryPolicy(); void setRetryPolicy(RetryPolicy retryPolicy); ClientConfiguration withRetryPolicy(RetryPolicy retryPolicy); int getMaxErrorRetry(); void setMaxErrorRetry(int maxErrorRetry); ClientConfiguration withMaxErrorRetry(int maxErrorRetry); int getSocketTimeout(); void setSocketTimeout(int socketTimeout); ClientConfiguration withSocketTimeout(int socketTimeout); int getConnectionTimeout(); void setConnectionTimeout(int connectionTimeout); ClientConfiguration withConnectionTimeout(int connectionTimeout); int getRequestTimeout(); void setRequestTimeout(int requestTimeout); ClientConfiguration withRequestTimeout(int requestTimeout); int getClientExecutionTimeout(); void setClientExecutionTimeout(int clientExecutionTimeout); ClientConfiguration withClientExecutionTimeout(int clientExecutionTimeout); boolean useReaper(); void setUseReaper(boolean use); ClientConfiguration withReaper(boolean use); boolean useThrottledRetries(); void setUseThrottleRetries(boolean use); ClientConfiguration withThrottledRetries(boolean use); void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); ClientConfiguration withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); int getMaxConsecutiveRetriesBeforeThrottling(); boolean useGzip(); void setUseGzip(boolean use); ClientConfiguration withGzip(boolean use); int[] getSocketBufferSizeHints(); void setSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); ClientConfiguration withSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); String getSignerOverride(); void setSignerOverride(final String value); ClientConfiguration withSignerOverride(final String value); boolean isPreemptiveBasicProxyAuth(); void setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth); ClientConfiguration withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth); long getConnectionTTL(); void setConnectionTTL(long connectionTTL); ClientConfiguration withConnectionTTL(long connectionTTL); long getConnectionMaxIdleMillis(); void setConnectionMaxIdleMillis(long connectionMaxIdleMillis); ClientConfiguration withConnectionMaxIdleMillis(long connectionMaxIdleMillis); int getValidateAfterInactivityMillis(); void setValidateAfterInactivityMillis(int validateAfterInactivityMillis); ClientConfiguration withValidateAfterInactivityMillis(int validateAfterInactivityMillis); boolean useTcpKeepAlive(); void setUseTcpKeepAlive(final boolean use); ClientConfiguration withTcpKeepAlive(final boolean use); DnsResolver getDnsResolver(); void setDnsResolver(final DnsResolver resolver); ClientConfiguration withDnsResolver(final DnsResolver resolver); boolean getCacheResponseMetadata(); void setCacheResponseMetadata(boolean shouldCache); ClientConfiguration withCacheResponseMetadata(final boolean shouldCache); int getResponseMetadataCacheSize(); void setResponseMetadataCacheSize(int responseMetadataCacheSize); ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize); ApacheHttpClientConfig getApacheHttpClientConfig(); SecureRandom getSecureRandom(); void setSecureRandom(SecureRandom secureRandom); ClientConfiguration withSecureRandom(SecureRandom secureRandom); boolean isUseExpectContinue(); void setUseExpectContinue(boolean useExpectContinue); ClientConfiguration withUseExpectContinue(boolean useExpectContinue); ClientConfiguration withHeader(String name, String value); void addHeader(String name, String value); Map<String, String> getHeaders(); boolean isDisableHostPrefixInjection(); void setDisableHostPrefixInjection(boolean disableHostPrefixInjection); ClientConfiguration withDisableHostPrefixInjection(boolean disableHostPrefixInjection); TlsKeyManagersProvider getTlsKeyManagersProvider(); ClientConfiguration withTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); void setTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); }
ClientConfiguration { public ApacheHttpClientConfig getApacheHttpClientConfig() { return apacheHttpClientConfig; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); Protocol getProtocol(); void setProtocol(Protocol protocol); ClientConfiguration withProtocol(Protocol protocol); int getMaxConnections(); void setMaxConnections(int maxConnections); ClientConfiguration withMaxConnections(int maxConnections); @Deprecated String getUserAgent(); @Deprecated void setUserAgent(String userAgent); @Deprecated ClientConfiguration withUserAgent(String userAgent); String getUserAgentPrefix(); void setUserAgentPrefix(String prefix); ClientConfiguration withUserAgentPrefix(String prefix); String getUserAgentSuffix(); void setUserAgentSuffix(String suffix); ClientConfiguration withUserAgentSuffix(String suffix); InetAddress getLocalAddress(); void setLocalAddress(InetAddress localAddress); ClientConfiguration withLocalAddress(InetAddress localAddress); Protocol getProxyProtocol(); ClientConfiguration withProxyProtocol(Protocol proxyProtocol); void setProxyProtocol(Protocol proxyProtocol); String getProxyHost(); void setProxyHost(String proxyHost); ClientConfiguration withProxyHost(String proxyHost); int getProxyPort(); void setProxyPort(int proxyPort); ClientConfiguration withProxyPort(int proxyPort); ClientConfiguration withDisableSocketProxy(boolean disableSocketProxy); void setDisableSocketProxy(boolean disableSocketProxy); boolean disableSocketProxy(); String getProxyUsername(); void setProxyUsername(String proxyUsername); ClientConfiguration withProxyUsername(String proxyUsername); String getProxyPassword(); void setProxyPassword(String proxyPassword); ClientConfiguration withProxyPassword(String proxyPassword); String getProxyDomain(); void setProxyDomain(String proxyDomain); ClientConfiguration withProxyDomain(String proxyDomain); String getProxyWorkstation(); void setProxyWorkstation(String proxyWorkstation); ClientConfiguration withProxyWorkstation(String proxyWorkstation); String getNonProxyHosts(); void setNonProxyHosts(String nonProxyHosts); ClientConfiguration withNonProxyHosts(String nonProxyHosts); List<ProxyAuthenticationMethod> getProxyAuthenticationMethods(); void setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); ClientConfiguration withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); RetryPolicy getRetryPolicy(); void setRetryPolicy(RetryPolicy retryPolicy); ClientConfiguration withRetryPolicy(RetryPolicy retryPolicy); int getMaxErrorRetry(); void setMaxErrorRetry(int maxErrorRetry); ClientConfiguration withMaxErrorRetry(int maxErrorRetry); int getSocketTimeout(); void setSocketTimeout(int socketTimeout); ClientConfiguration withSocketTimeout(int socketTimeout); int getConnectionTimeout(); void setConnectionTimeout(int connectionTimeout); ClientConfiguration withConnectionTimeout(int connectionTimeout); int getRequestTimeout(); void setRequestTimeout(int requestTimeout); ClientConfiguration withRequestTimeout(int requestTimeout); int getClientExecutionTimeout(); void setClientExecutionTimeout(int clientExecutionTimeout); ClientConfiguration withClientExecutionTimeout(int clientExecutionTimeout); boolean useReaper(); void setUseReaper(boolean use); ClientConfiguration withReaper(boolean use); boolean useThrottledRetries(); void setUseThrottleRetries(boolean use); ClientConfiguration withThrottledRetries(boolean use); void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); ClientConfiguration withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); int getMaxConsecutiveRetriesBeforeThrottling(); boolean useGzip(); void setUseGzip(boolean use); ClientConfiguration withGzip(boolean use); int[] getSocketBufferSizeHints(); void setSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); ClientConfiguration withSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); String getSignerOverride(); void setSignerOverride(final String value); ClientConfiguration withSignerOverride(final String value); boolean isPreemptiveBasicProxyAuth(); void setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth); ClientConfiguration withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth); long getConnectionTTL(); void setConnectionTTL(long connectionTTL); ClientConfiguration withConnectionTTL(long connectionTTL); long getConnectionMaxIdleMillis(); void setConnectionMaxIdleMillis(long connectionMaxIdleMillis); ClientConfiguration withConnectionMaxIdleMillis(long connectionMaxIdleMillis); int getValidateAfterInactivityMillis(); void setValidateAfterInactivityMillis(int validateAfterInactivityMillis); ClientConfiguration withValidateAfterInactivityMillis(int validateAfterInactivityMillis); boolean useTcpKeepAlive(); void setUseTcpKeepAlive(final boolean use); ClientConfiguration withTcpKeepAlive(final boolean use); DnsResolver getDnsResolver(); void setDnsResolver(final DnsResolver resolver); ClientConfiguration withDnsResolver(final DnsResolver resolver); boolean getCacheResponseMetadata(); void setCacheResponseMetadata(boolean shouldCache); ClientConfiguration withCacheResponseMetadata(final boolean shouldCache); int getResponseMetadataCacheSize(); void setResponseMetadataCacheSize(int responseMetadataCacheSize); ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize); ApacheHttpClientConfig getApacheHttpClientConfig(); SecureRandom getSecureRandom(); void setSecureRandom(SecureRandom secureRandom); ClientConfiguration withSecureRandom(SecureRandom secureRandom); boolean isUseExpectContinue(); void setUseExpectContinue(boolean useExpectContinue); ClientConfiguration withUseExpectContinue(boolean useExpectContinue); ClientConfiguration withHeader(String name, String value); void addHeader(String name, String value); Map<String, String> getHeaders(); boolean isDisableHostPrefixInjection(); void setDisableHostPrefixInjection(boolean disableHostPrefixInjection); ClientConfiguration withDisableHostPrefixInjection(boolean disableHostPrefixInjection); TlsKeyManagersProvider getTlsKeyManagersProvider(); ClientConfiguration withTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); void setTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); static final int DEFAULT_CONNECTION_TIMEOUT; static final int DEFAULT_SOCKET_TIMEOUT; static final int DEFAULT_REQUEST_TIMEOUT; static final int DEFAULT_CLIENT_EXECUTION_TIMEOUT; static final boolean DEFAULT_DISABLE_SOCKET_PROXY; static final int DEFAULT_MAX_CONNECTIONS; static final boolean DEFAULT_USE_EXPECT_CONTINUE; static final String DEFAULT_USER_AGENT; static final RetryPolicy DEFAULT_RETRY_POLICY; static final boolean DEFAULT_USE_REAPER; static final boolean DEFAULT_USE_GZIP; static final long DEFAULT_CONNECTION_TTL; static final long DEFAULT_CONNECTION_MAX_IDLE_MILLIS; static final int DEFAULT_VALIDATE_AFTER_INACTIVITY_MILLIS; static final boolean DEFAULT_TCP_KEEP_ALIVE; static final boolean DEFAULT_THROTTLE_RETRIES; static final boolean DEFAULT_CACHE_RESPONSE_METADATA; static final int DEFAULT_RESPONSE_METADATA_CACHE_SIZE; static final int DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING; }
@Test public void copyConstructorUsesAccessors() { ClientConfiguration config = new ClientConfiguration() { @Override public int getSocketTimeout() { return Integer.MAX_VALUE; } }; assertThat(new ClientConfiguration(config).getSocketTimeout(), equalTo(Integer.MAX_VALUE)); }
public int getSocketTimeout() { return socketTimeout; }
ClientConfiguration { public int getSocketTimeout() { return socketTimeout; } }
ClientConfiguration { public int getSocketTimeout() { return socketTimeout; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); }
ClientConfiguration { public int getSocketTimeout() { return socketTimeout; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); Protocol getProtocol(); void setProtocol(Protocol protocol); ClientConfiguration withProtocol(Protocol protocol); int getMaxConnections(); void setMaxConnections(int maxConnections); ClientConfiguration withMaxConnections(int maxConnections); @Deprecated String getUserAgent(); @Deprecated void setUserAgent(String userAgent); @Deprecated ClientConfiguration withUserAgent(String userAgent); String getUserAgentPrefix(); void setUserAgentPrefix(String prefix); ClientConfiguration withUserAgentPrefix(String prefix); String getUserAgentSuffix(); void setUserAgentSuffix(String suffix); ClientConfiguration withUserAgentSuffix(String suffix); InetAddress getLocalAddress(); void setLocalAddress(InetAddress localAddress); ClientConfiguration withLocalAddress(InetAddress localAddress); Protocol getProxyProtocol(); ClientConfiguration withProxyProtocol(Protocol proxyProtocol); void setProxyProtocol(Protocol proxyProtocol); String getProxyHost(); void setProxyHost(String proxyHost); ClientConfiguration withProxyHost(String proxyHost); int getProxyPort(); void setProxyPort(int proxyPort); ClientConfiguration withProxyPort(int proxyPort); ClientConfiguration withDisableSocketProxy(boolean disableSocketProxy); void setDisableSocketProxy(boolean disableSocketProxy); boolean disableSocketProxy(); String getProxyUsername(); void setProxyUsername(String proxyUsername); ClientConfiguration withProxyUsername(String proxyUsername); String getProxyPassword(); void setProxyPassword(String proxyPassword); ClientConfiguration withProxyPassword(String proxyPassword); String getProxyDomain(); void setProxyDomain(String proxyDomain); ClientConfiguration withProxyDomain(String proxyDomain); String getProxyWorkstation(); void setProxyWorkstation(String proxyWorkstation); ClientConfiguration withProxyWorkstation(String proxyWorkstation); String getNonProxyHosts(); void setNonProxyHosts(String nonProxyHosts); ClientConfiguration withNonProxyHosts(String nonProxyHosts); List<ProxyAuthenticationMethod> getProxyAuthenticationMethods(); void setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); ClientConfiguration withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); RetryPolicy getRetryPolicy(); void setRetryPolicy(RetryPolicy retryPolicy); ClientConfiguration withRetryPolicy(RetryPolicy retryPolicy); int getMaxErrorRetry(); void setMaxErrorRetry(int maxErrorRetry); ClientConfiguration withMaxErrorRetry(int maxErrorRetry); int getSocketTimeout(); void setSocketTimeout(int socketTimeout); ClientConfiguration withSocketTimeout(int socketTimeout); int getConnectionTimeout(); void setConnectionTimeout(int connectionTimeout); ClientConfiguration withConnectionTimeout(int connectionTimeout); int getRequestTimeout(); void setRequestTimeout(int requestTimeout); ClientConfiguration withRequestTimeout(int requestTimeout); int getClientExecutionTimeout(); void setClientExecutionTimeout(int clientExecutionTimeout); ClientConfiguration withClientExecutionTimeout(int clientExecutionTimeout); boolean useReaper(); void setUseReaper(boolean use); ClientConfiguration withReaper(boolean use); boolean useThrottledRetries(); void setUseThrottleRetries(boolean use); ClientConfiguration withThrottledRetries(boolean use); void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); ClientConfiguration withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); int getMaxConsecutiveRetriesBeforeThrottling(); boolean useGzip(); void setUseGzip(boolean use); ClientConfiguration withGzip(boolean use); int[] getSocketBufferSizeHints(); void setSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); ClientConfiguration withSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); String getSignerOverride(); void setSignerOverride(final String value); ClientConfiguration withSignerOverride(final String value); boolean isPreemptiveBasicProxyAuth(); void setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth); ClientConfiguration withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth); long getConnectionTTL(); void setConnectionTTL(long connectionTTL); ClientConfiguration withConnectionTTL(long connectionTTL); long getConnectionMaxIdleMillis(); void setConnectionMaxIdleMillis(long connectionMaxIdleMillis); ClientConfiguration withConnectionMaxIdleMillis(long connectionMaxIdleMillis); int getValidateAfterInactivityMillis(); void setValidateAfterInactivityMillis(int validateAfterInactivityMillis); ClientConfiguration withValidateAfterInactivityMillis(int validateAfterInactivityMillis); boolean useTcpKeepAlive(); void setUseTcpKeepAlive(final boolean use); ClientConfiguration withTcpKeepAlive(final boolean use); DnsResolver getDnsResolver(); void setDnsResolver(final DnsResolver resolver); ClientConfiguration withDnsResolver(final DnsResolver resolver); boolean getCacheResponseMetadata(); void setCacheResponseMetadata(boolean shouldCache); ClientConfiguration withCacheResponseMetadata(final boolean shouldCache); int getResponseMetadataCacheSize(); void setResponseMetadataCacheSize(int responseMetadataCacheSize); ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize); ApacheHttpClientConfig getApacheHttpClientConfig(); SecureRandom getSecureRandom(); void setSecureRandom(SecureRandom secureRandom); ClientConfiguration withSecureRandom(SecureRandom secureRandom); boolean isUseExpectContinue(); void setUseExpectContinue(boolean useExpectContinue); ClientConfiguration withUseExpectContinue(boolean useExpectContinue); ClientConfiguration withHeader(String name, String value); void addHeader(String name, String value); Map<String, String> getHeaders(); boolean isDisableHostPrefixInjection(); void setDisableHostPrefixInjection(boolean disableHostPrefixInjection); ClientConfiguration withDisableHostPrefixInjection(boolean disableHostPrefixInjection); TlsKeyManagersProvider getTlsKeyManagersProvider(); ClientConfiguration withTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); void setTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); }
ClientConfiguration { public int getSocketTimeout() { return socketTimeout; } ClientConfiguration(); ClientConfiguration(ClientConfiguration other); Protocol getProtocol(); void setProtocol(Protocol protocol); ClientConfiguration withProtocol(Protocol protocol); int getMaxConnections(); void setMaxConnections(int maxConnections); ClientConfiguration withMaxConnections(int maxConnections); @Deprecated String getUserAgent(); @Deprecated void setUserAgent(String userAgent); @Deprecated ClientConfiguration withUserAgent(String userAgent); String getUserAgentPrefix(); void setUserAgentPrefix(String prefix); ClientConfiguration withUserAgentPrefix(String prefix); String getUserAgentSuffix(); void setUserAgentSuffix(String suffix); ClientConfiguration withUserAgentSuffix(String suffix); InetAddress getLocalAddress(); void setLocalAddress(InetAddress localAddress); ClientConfiguration withLocalAddress(InetAddress localAddress); Protocol getProxyProtocol(); ClientConfiguration withProxyProtocol(Protocol proxyProtocol); void setProxyProtocol(Protocol proxyProtocol); String getProxyHost(); void setProxyHost(String proxyHost); ClientConfiguration withProxyHost(String proxyHost); int getProxyPort(); void setProxyPort(int proxyPort); ClientConfiguration withProxyPort(int proxyPort); ClientConfiguration withDisableSocketProxy(boolean disableSocketProxy); void setDisableSocketProxy(boolean disableSocketProxy); boolean disableSocketProxy(); String getProxyUsername(); void setProxyUsername(String proxyUsername); ClientConfiguration withProxyUsername(String proxyUsername); String getProxyPassword(); void setProxyPassword(String proxyPassword); ClientConfiguration withProxyPassword(String proxyPassword); String getProxyDomain(); void setProxyDomain(String proxyDomain); ClientConfiguration withProxyDomain(String proxyDomain); String getProxyWorkstation(); void setProxyWorkstation(String proxyWorkstation); ClientConfiguration withProxyWorkstation(String proxyWorkstation); String getNonProxyHosts(); void setNonProxyHosts(String nonProxyHosts); ClientConfiguration withNonProxyHosts(String nonProxyHosts); List<ProxyAuthenticationMethod> getProxyAuthenticationMethods(); void setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); ClientConfiguration withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods); RetryPolicy getRetryPolicy(); void setRetryPolicy(RetryPolicy retryPolicy); ClientConfiguration withRetryPolicy(RetryPolicy retryPolicy); int getMaxErrorRetry(); void setMaxErrorRetry(int maxErrorRetry); ClientConfiguration withMaxErrorRetry(int maxErrorRetry); int getSocketTimeout(); void setSocketTimeout(int socketTimeout); ClientConfiguration withSocketTimeout(int socketTimeout); int getConnectionTimeout(); void setConnectionTimeout(int connectionTimeout); ClientConfiguration withConnectionTimeout(int connectionTimeout); int getRequestTimeout(); void setRequestTimeout(int requestTimeout); ClientConfiguration withRequestTimeout(int requestTimeout); int getClientExecutionTimeout(); void setClientExecutionTimeout(int clientExecutionTimeout); ClientConfiguration withClientExecutionTimeout(int clientExecutionTimeout); boolean useReaper(); void setUseReaper(boolean use); ClientConfiguration withReaper(boolean use); boolean useThrottledRetries(); void setUseThrottleRetries(boolean use); ClientConfiguration withThrottledRetries(boolean use); void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); ClientConfiguration withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling); int getMaxConsecutiveRetriesBeforeThrottling(); boolean useGzip(); void setUseGzip(boolean use); ClientConfiguration withGzip(boolean use); int[] getSocketBufferSizeHints(); void setSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); ClientConfiguration withSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint); String getSignerOverride(); void setSignerOverride(final String value); ClientConfiguration withSignerOverride(final String value); boolean isPreemptiveBasicProxyAuth(); void setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth); ClientConfiguration withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth); long getConnectionTTL(); void setConnectionTTL(long connectionTTL); ClientConfiguration withConnectionTTL(long connectionTTL); long getConnectionMaxIdleMillis(); void setConnectionMaxIdleMillis(long connectionMaxIdleMillis); ClientConfiguration withConnectionMaxIdleMillis(long connectionMaxIdleMillis); int getValidateAfterInactivityMillis(); void setValidateAfterInactivityMillis(int validateAfterInactivityMillis); ClientConfiguration withValidateAfterInactivityMillis(int validateAfterInactivityMillis); boolean useTcpKeepAlive(); void setUseTcpKeepAlive(final boolean use); ClientConfiguration withTcpKeepAlive(final boolean use); DnsResolver getDnsResolver(); void setDnsResolver(final DnsResolver resolver); ClientConfiguration withDnsResolver(final DnsResolver resolver); boolean getCacheResponseMetadata(); void setCacheResponseMetadata(boolean shouldCache); ClientConfiguration withCacheResponseMetadata(final boolean shouldCache); int getResponseMetadataCacheSize(); void setResponseMetadataCacheSize(int responseMetadataCacheSize); ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize); ApacheHttpClientConfig getApacheHttpClientConfig(); SecureRandom getSecureRandom(); void setSecureRandom(SecureRandom secureRandom); ClientConfiguration withSecureRandom(SecureRandom secureRandom); boolean isUseExpectContinue(); void setUseExpectContinue(boolean useExpectContinue); ClientConfiguration withUseExpectContinue(boolean useExpectContinue); ClientConfiguration withHeader(String name, String value); void addHeader(String name, String value); Map<String, String> getHeaders(); boolean isDisableHostPrefixInjection(); void setDisableHostPrefixInjection(boolean disableHostPrefixInjection); ClientConfiguration withDisableHostPrefixInjection(boolean disableHostPrefixInjection); TlsKeyManagersProvider getTlsKeyManagersProvider(); ClientConfiguration withTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); void setTlsKeyManagersProvider(TlsKeyManagersProvider tlsKeyManagersProvider); static final int DEFAULT_CONNECTION_TIMEOUT; static final int DEFAULT_SOCKET_TIMEOUT; static final int DEFAULT_REQUEST_TIMEOUT; static final int DEFAULT_CLIENT_EXECUTION_TIMEOUT; static final boolean DEFAULT_DISABLE_SOCKET_PROXY; static final int DEFAULT_MAX_CONNECTIONS; static final boolean DEFAULT_USE_EXPECT_CONTINUE; static final String DEFAULT_USER_AGENT; static final RetryPolicy DEFAULT_RETRY_POLICY; static final boolean DEFAULT_USE_REAPER; static final boolean DEFAULT_USE_GZIP; static final long DEFAULT_CONNECTION_TTL; static final long DEFAULT_CONNECTION_MAX_IDLE_MILLIS; static final int DEFAULT_VALIDATE_AFTER_INACTIVITY_MILLIS; static final boolean DEFAULT_TCP_KEEP_ALIVE; static final boolean DEFAULT_THROTTLE_RETRIES; static final boolean DEFAULT_CACHE_RESPONSE_METADATA; static final int DEFAULT_RESPONSE_METADATA_CACHE_SIZE; static final int DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING; }
@Test public void copyBaseTo() { final ProgressListener listener = new SyncProgressListener() { @Override public void progressChanged(ProgressEvent progressEvent) { } }; final AWSCredentials credentials = new BasicAWSCredentials("accesskey", "accessid"); final RequestMetricCollector collector = new RequestMetricCollector() { @Override public void collectMetrics(Request<?> request, Response<?> response) { } }; final AmazonWebServiceRequest from = new AmazonWebServiceRequest() { }; from.setGeneralProgressListener(listener); from.setRequestCredentials(credentials); from.setRequestMetricCollector(collector); from.putCustomRequestHeader("k1", "v1"); from.putCustomRequestHeader("k2", "v2"); from.putCustomQueryParameter("k1", "v1"); from.putCustomQueryParameter("k2", "v2a"); from.putCustomQueryParameter("k2", "v2b"); from.getRequestClientOptions().setReadLimit(1234); final AmazonWebServiceRequest to = new AmazonWebServiceRequest() { }; RequestClientOptions toOptions; verifyBaseBeforeCopy(to); from.copyBaseTo(to); verifyBaseAfterCopy(listener, credentials, collector, from, to); }
protected final <T extends AmazonWebServiceRequest> T copyBaseTo(T target) { if (customRequestHeaders != null) { for (Map.Entry<String, String> e : customRequestHeaders.entrySet()) target.putCustomRequestHeader(e.getKey(), e.getValue()); } if (customQueryParameters != null) { for (Map.Entry<String, List<String>> e : customQueryParameters.entrySet()) { if (e.getValue() != null) { for (String value : e.getValue()) { target.putCustomQueryParameter(e.getKey(), value); } } } } target.setRequestCredentialsProvider(credentialsProvider); target.setGeneralProgressListener(progressListener); target.setRequestMetricCollector(requestMetricCollector); requestClientOptions.copyTo(target.getRequestClientOptions()); return target; }
AmazonWebServiceRequest implements Cloneable, ReadLimitInfo, HandlerContextAware { protected final <T extends AmazonWebServiceRequest> T copyBaseTo(T target) { if (customRequestHeaders != null) { for (Map.Entry<String, String> e : customRequestHeaders.entrySet()) target.putCustomRequestHeader(e.getKey(), e.getValue()); } if (customQueryParameters != null) { for (Map.Entry<String, List<String>> e : customQueryParameters.entrySet()) { if (e.getValue() != null) { for (String value : e.getValue()) { target.putCustomQueryParameter(e.getKey(), value); } } } } target.setRequestCredentialsProvider(credentialsProvider); target.setGeneralProgressListener(progressListener); target.setRequestMetricCollector(requestMetricCollector); requestClientOptions.copyTo(target.getRequestClientOptions()); return target; } }
AmazonWebServiceRequest implements Cloneable, ReadLimitInfo, HandlerContextAware { protected final <T extends AmazonWebServiceRequest> T copyBaseTo(T target) { if (customRequestHeaders != null) { for (Map.Entry<String, String> e : customRequestHeaders.entrySet()) target.putCustomRequestHeader(e.getKey(), e.getValue()); } if (customQueryParameters != null) { for (Map.Entry<String, List<String>> e : customQueryParameters.entrySet()) { if (e.getValue() != null) { for (String value : e.getValue()) { target.putCustomQueryParameter(e.getKey(), value); } } } } target.setRequestCredentialsProvider(credentialsProvider); target.setGeneralProgressListener(progressListener); target.setRequestMetricCollector(requestMetricCollector); requestClientOptions.copyTo(target.getRequestClientOptions()); return target; } }
AmazonWebServiceRequest implements Cloneable, ReadLimitInfo, HandlerContextAware { protected final <T extends AmazonWebServiceRequest> T copyBaseTo(T target) { if (customRequestHeaders != null) { for (Map.Entry<String, String> e : customRequestHeaders.entrySet()) target.putCustomRequestHeader(e.getKey(), e.getValue()); } if (customQueryParameters != null) { for (Map.Entry<String, List<String>> e : customQueryParameters.entrySet()) { if (e.getValue() != null) { for (String value : e.getValue()) { target.putCustomQueryParameter(e.getKey(), value); } } } } target.setRequestCredentialsProvider(credentialsProvider); target.setGeneralProgressListener(progressListener); target.setRequestMetricCollector(requestMetricCollector); requestClientOptions.copyTo(target.getRequestClientOptions()); return target; } @Deprecated void setRequestCredentials(AWSCredentials credentials); @Deprecated AWSCredentials getRequestCredentials(); void setRequestCredentialsProvider(AWSCredentialsProvider credentialsProvider); AWSCredentialsProvider getRequestCredentialsProvider(); RequestClientOptions getRequestClientOptions(); RequestMetricCollector getRequestMetricCollector(); void setRequestMetricCollector(RequestMetricCollector requestMetricCollector); T withRequestMetricCollector(RequestMetricCollector metricCollector); void setGeneralProgressListener(ProgressListener progressListener); ProgressListener getGeneralProgressListener(); T withGeneralProgressListener(ProgressListener progressListener); Map<String, String> getCustomRequestHeaders(); String putCustomRequestHeader(String name, String value); Map<String, List<String>> getCustomQueryParameters(); void putCustomQueryParameter(String name, String value); @Override final int getReadLimit(); AmazonWebServiceRequest getCloneSource(); AmazonWebServiceRequest getCloneRoot(); Integer getSdkRequestTimeout(); void setSdkRequestTimeout(int sdkRequestTimeout); T withSdkRequestTimeout(int sdkRequestTimeout); Integer getSdkClientExecutionTimeout(); void setSdkClientExecutionTimeout(int sdkClientExecutionTimeout); T withSdkClientExecutionTimeout(int sdkClientExecutionTimeout); @Override void addHandlerContext(HandlerContextKey<X> key, X value); @Override @SuppressWarnings("unchecked") X getHandlerContext(HandlerContextKey<X> key); @Override AmazonWebServiceRequest clone(); }
AmazonWebServiceRequest implements Cloneable, ReadLimitInfo, HandlerContextAware { protected final <T extends AmazonWebServiceRequest> T copyBaseTo(T target) { if (customRequestHeaders != null) { for (Map.Entry<String, String> e : customRequestHeaders.entrySet()) target.putCustomRequestHeader(e.getKey(), e.getValue()); } if (customQueryParameters != null) { for (Map.Entry<String, List<String>> e : customQueryParameters.entrySet()) { if (e.getValue() != null) { for (String value : e.getValue()) { target.putCustomQueryParameter(e.getKey(), value); } } } } target.setRequestCredentialsProvider(credentialsProvider); target.setGeneralProgressListener(progressListener); target.setRequestMetricCollector(requestMetricCollector); requestClientOptions.copyTo(target.getRequestClientOptions()); return target; } @Deprecated void setRequestCredentials(AWSCredentials credentials); @Deprecated AWSCredentials getRequestCredentials(); void setRequestCredentialsProvider(AWSCredentialsProvider credentialsProvider); AWSCredentialsProvider getRequestCredentialsProvider(); RequestClientOptions getRequestClientOptions(); RequestMetricCollector getRequestMetricCollector(); void setRequestMetricCollector(RequestMetricCollector requestMetricCollector); T withRequestMetricCollector(RequestMetricCollector metricCollector); void setGeneralProgressListener(ProgressListener progressListener); ProgressListener getGeneralProgressListener(); T withGeneralProgressListener(ProgressListener progressListener); Map<String, String> getCustomRequestHeaders(); String putCustomRequestHeader(String name, String value); Map<String, List<String>> getCustomQueryParameters(); void putCustomQueryParameter(String name, String value); @Override final int getReadLimit(); AmazonWebServiceRequest getCloneSource(); AmazonWebServiceRequest getCloneRoot(); Integer getSdkRequestTimeout(); void setSdkRequestTimeout(int sdkRequestTimeout); T withSdkRequestTimeout(int sdkRequestTimeout); Integer getSdkClientExecutionTimeout(); void setSdkClientExecutionTimeout(int sdkClientExecutionTimeout); T withSdkClientExecutionTimeout(int sdkClientExecutionTimeout); @Override void addHandlerContext(HandlerContextKey<X> key, X value); @Override @SuppressWarnings("unchecked") X getHandlerContext(HandlerContextKey<X> key); @Override AmazonWebServiceRequest clone(); static final AmazonWebServiceRequest NOOP; }
@Test public void getLegacyRetryPolicy_ReturnsSamePolicy() { assertEquals(legacyPolicy, adapter.getLegacyRetryPolicy()); }
public RetryPolicy getLegacyRetryPolicy() { return this.legacyRetryPolicy; }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { public RetryPolicy getLegacyRetryPolicy() { return this.legacyRetryPolicy; } }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { public RetryPolicy getLegacyRetryPolicy() { return this.legacyRetryPolicy; } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { public RetryPolicy getLegacyRetryPolicy() { return this.legacyRetryPolicy; } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { public RetryPolicy getLegacyRetryPolicy() { return this.legacyRetryPolicy; } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
@Test public void computeDelayBeforeNextRetry_DelegatesToLegacyPolicy() { final RetryPolicyContext context = RetryPolicyContexts.LEGACY; adapter.computeDelayBeforeNextRetry(context); verify(backoffStrategy).delayBeforeNextRetry( eq((AmazonWebServiceRequest) context.originalRequest()), eq((AmazonClientException) context.exception()), eq(context.retriesAttempted())); }
@Override public long computeDelayBeforeNextRetry(RetryPolicyContext context) { return legacyRetryPolicy.getBackoffStrategy().delayBeforeNextRetry( (AmazonWebServiceRequest) context.originalRequest(), (AmazonClientException) context.exception(), context.retriesAttempted()); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public long computeDelayBeforeNextRetry(RetryPolicyContext context) { return legacyRetryPolicy.getBackoffStrategy().delayBeforeNextRetry( (AmazonWebServiceRequest) context.originalRequest(), (AmazonClientException) context.exception(), context.retriesAttempted()); } }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public long computeDelayBeforeNextRetry(RetryPolicyContext context) { return legacyRetryPolicy.getBackoffStrategy().delayBeforeNextRetry( (AmazonWebServiceRequest) context.originalRequest(), (AmazonClientException) context.exception(), context.retriesAttempted()); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public long computeDelayBeforeNextRetry(RetryPolicyContext context) { return legacyRetryPolicy.getBackoffStrategy().delayBeforeNextRetry( (AmazonWebServiceRequest) context.originalRequest(), (AmazonClientException) context.exception(), context.retriesAttempted()); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public long computeDelayBeforeNextRetry(RetryPolicyContext context) { return legacyRetryPolicy.getBackoffStrategy().delayBeforeNextRetry( (AmazonWebServiceRequest) context.originalRequest(), (AmazonClientException) context.exception(), context.retriesAttempted()); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
@Test public void shouldRetry_MaxErrorRetryReached() { assertFalse(adapter.shouldRetry(RetryPolicyContexts.withRetriesAttempted(3))); }
@Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
@Test public void shouldRetry_MaxErrorInClientConfigHonored_DoesNotUseMaxErrorInPolicy() { when(retryCondition.shouldRetry(any(AmazonWebServiceRequest.class), any(AmazonClientException.class), anyInt())) .thenReturn(true); legacyPolicy = new RetryPolicy(retryCondition, backoffStrategy, 3, true); adapter = new RetryPolicyAdapter(legacyPolicy, clientConfiguration); assertTrue(adapter.shouldRetry(RetryPolicyContexts.withRetriesAttempted(3))); assertFalse(adapter.shouldRetry(RetryPolicyContexts.withRetriesAttempted(10))); }
@Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
@Test public void shouldRetry_MaxErrorNotExceeded_DelegatesToLegacyRetryCondition() { final RetryPolicyContext context = RetryPolicyContexts.LEGACY; adapter.shouldRetry(context); verify(retryCondition).shouldRetry( eq((AmazonWebServiceRequest) context.originalRequest()), eq((AmazonClientException) context.exception()), eq(context.retriesAttempted())); }
@Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
RetryPolicyAdapter implements com.ibm.cloud.objectstorage.retry.v2.RetryPolicy { @Override public boolean shouldRetry(RetryPolicyContext context) { return !maxRetriesExceeded(context) && isRetryable(context); } RetryPolicyAdapter(RetryPolicy legacyRetryPolicy, ClientConfiguration clientConfiguration); @Override long computeDelayBeforeNextRetry(RetryPolicyContext context); @Override boolean shouldRetry(RetryPolicyContext context); boolean isRetryable(RetryPolicyContext context); RetryPolicy getLegacyRetryPolicy(); boolean maxRetriesExceeded(RetryPolicyContext context); }
@Test public void testTraceLogCallsMadeForResume() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.modifyTransfer(anyString(), anyInt(), anyLong()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.resume("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [modifyTransfer] with parameters [\"xyz123\", 5, 0]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [modifyTransfer] returned for xferId [\"xyz123\"] with result: [true]")); }
public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean resume(final String xferId) { log.info("Resuming transfer with xferId [" + xferId + "]"); log.trace("Calling method [modifyTransfer] with parameters [\"" + xferId + "\", 5, 0]"); boolean rtn = faspmanager2.modifyTransfer(xferId, 5, 0); log.trace("Method [modifyTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testRegionHeaderIsAddedToExcpetion() throws XMLStreamException { String region = "myDummyRegion"; String strResponse = "<Error><Code>PermanentRedirect</Code><Message>The bucket is in this region: null. Please use this region to retry the request</Message></Error>"; ByteArrayInputStream content = new ByteArrayInputStream(strResponse.getBytes(Charset.forName("UTF-8"))); S3ErrorResponseHandler errorHandler = new S3ErrorResponseHandler(); Request request = new DefaultRequest("default"); request.setHttpMethod(HttpMethodName.GET); HttpResponse response = new HttpResponse(request, null); response.setContent(content); response.addHeader(Headers.S3_BUCKET_REGION, region); AmazonS3Exception exception = (AmazonS3Exception)errorHandler.handle(response); assertTrue(exception.getAdditionalDetails().get(Headers.S3_BUCKET_REGION).equals(region)); }
@Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; }
S3ErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; } }
S3ErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; } }
S3ErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; } @Override AmazonServiceException handle(HttpResponse httpResponse); boolean needsConnectionLeftOpen(); }
S3ErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; } @Override AmazonServiceException handle(HttpResponse httpResponse); boolean needsConnectionLeftOpen(); }
@Test public void testInfoLogCallsMadeForCancel() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.stopTransfer(anyString()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(false); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.cancel("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).info(Mockito.eq("Cancel transfer with xferId [xyz123]")); }
public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testTraceLogCallsMadeForCancel() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.stopTransfer(anyString()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.cancel("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [stopTransfer] with parameters [\"xyz123\", 8, 0]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [stopTransfer] returned for xferId [\"xyz123\"] with result: [true]")); }
public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean cancel(final String xferId) { log.info("Cancel transfer with xferId [" + xferId + "]"); log.trace("Calling method [stopTransfer] with parameters [\"" + xferId + "\", 8, 0]"); boolean rtn = faspmanager2.stopTransfer(xferId); log.trace("Method [stopTransfer] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void testTraceLogCallsMadeForIsRunning() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.isRunning(anyString()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.isRunning("xyz123"); assertTrue(rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [isRunning] with parameters [\"xyz123\"]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [isRunning] returned for xferId [\"xyz123\"] with result: [true]")); }
public boolean isRunning(final String xferId) { log.trace("Calling method [isRunning] with parameters [\"" + xferId + "\"]"); boolean rtn = faspmanager2.isRunning(xferId); log.trace("Method [isRunning] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean isRunning(final String xferId) { log.trace("Calling method [isRunning] with parameters [\"" + xferId + "\"]"); boolean rtn = faspmanager2.isRunning(xferId); log.trace("Method [isRunning] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean isRunning(final String xferId) { log.trace("Calling method [isRunning] with parameters [\"" + xferId + "\"]"); boolean rtn = faspmanager2.isRunning(xferId); log.trace("Method [isRunning] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean isRunning(final String xferId) { log.trace("Calling method [isRunning] with parameters [\"" + xferId + "\"]"); boolean rtn = faspmanager2.isRunning(xferId); log.trace("Method [isRunning] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean isRunning(final String xferId) { log.trace("Calling method [isRunning] with parameters [\"" + xferId + "\"]"); boolean rtn = faspmanager2.isRunning(xferId); log.trace("Method [isRunning] returned for xferId [\"" + xferId + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void isThrottlingException_TrueWhenErrorCodeMatchesKnownCodes() throws Exception { AmazonServiceException ase = new AmazonServiceException("msg"); ase.setErrorCode("ThrottlingException"); assertTrue("ThrottlingException error code should be true", RetryUtils.isThrottlingException(ase)); }
@Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
@Test public void isThrottlingException_TrueWhenStatusCodeIs429() throws Exception { AmazonServiceException ase = new AmazonServiceException("msg"); ase.setStatusCode(429); assertTrue("ThrottlingException error code should be true", RetryUtils.isThrottlingException(ase)); }
@Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
@Test public void isThrottlingException_FalseWhenErrorAndStatusCodeDoNotMatch() throws Exception { AmazonServiceException ase = new AmazonServiceException("msg"); ase.setStatusCode(500); ase.setErrorCode("InternalFailure"); assertFalse("InternalFailure error code should be false", RetryUtils.isThrottlingException(ase)); }
@Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
RetryUtils { @Deprecated public static boolean isThrottlingException(AmazonServiceException exception) { return isThrottlingException((SdkBaseException) exception); } @Deprecated static boolean isRetryableServiceException(AmazonServiceException exception); static boolean isRetryableServiceException(SdkBaseException exception); @Deprecated static boolean isThrottlingException(AmazonServiceException exception); static boolean isThrottlingException(SdkBaseException exception); @Deprecated static boolean isRequestEntityTooLargeException(AmazonServiceException exception); static boolean isRequestEntityTooLargeException(SdkBaseException exception); @Deprecated static boolean isClockSkewError(AmazonServiceException exception); static boolean isClockSkewError(SdkBaseException exception); }
@Test public void testTraceLogCallsMadeForConfigureLogLocation() throws Exception { PowerMockito .when( TransferListener.getInstance(null, null) ).thenReturn(mockTransferListener); PowerMockito .when( faspmanager2.configureLogLocation(anyString()) ).thenReturn(true); when(mockLog.isDebugEnabled()).thenReturn(true); AsperaFaspManagerWrapper wrapper = new AsperaFaspManagerWrapper(); wrapper.log = mockLog; boolean rtn = wrapper.configureLogLocation("somePath"); assertTrue(rtn); verify(mockLog, times(1)).trace(Mockito.eq("Calling method [configureLogLocation] with parameters [\"somePath\"]")); verify(mockLog, times(1)).trace(Mockito.eq("Method [configureLogLocation] returned for ascpLogPath [\"somePath\"] with result: [true]")); }
public boolean configureLogLocation(final String ascpLogPath) { log.trace("Calling method [configureLogLocation] with parameters [\"" + ascpLogPath + "\"]"); boolean rtn = faspmanager2.configureLogLocation(ascpLogPath); log.trace("Method [configureLogLocation] returned for ascpLogPath [\"" + ascpLogPath + "\"] with result: [" + rtn + "]"); return rtn; }
AsperaFaspManagerWrapper { public boolean configureLogLocation(final String ascpLogPath) { log.trace("Calling method [configureLogLocation] with parameters [\"" + ascpLogPath + "\"]"); boolean rtn = faspmanager2.configureLogLocation(ascpLogPath); log.trace("Method [configureLogLocation] returned for ascpLogPath [\"" + ascpLogPath + "\"] with result: [" + rtn + "]"); return rtn; } }
AsperaFaspManagerWrapper { public boolean configureLogLocation(final String ascpLogPath) { log.trace("Calling method [configureLogLocation] with parameters [\"" + ascpLogPath + "\"]"); boolean rtn = faspmanager2.configureLogLocation(ascpLogPath); log.trace("Method [configureLogLocation] returned for ascpLogPath [\"" + ascpLogPath + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean configureLogLocation(final String ascpLogPath) { log.trace("Calling method [configureLogLocation] with parameters [\"" + ascpLogPath + "\"]"); boolean rtn = faspmanager2.configureLogLocation(ascpLogPath); log.trace("Method [configureLogLocation] returned for ascpLogPath [\"" + ascpLogPath + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
AsperaFaspManagerWrapper { public boolean configureLogLocation(final String ascpLogPath) { log.trace("Calling method [configureLogLocation] with parameters [\"" + ascpLogPath + "\"]"); boolean rtn = faspmanager2.configureLogLocation(ascpLogPath); log.trace("Method [configureLogLocation] returned for ascpLogPath [\"" + ascpLogPath + "\"] with result: [" + rtn + "]"); return rtn; } AsperaFaspManagerWrapper(); AsperaFaspManagerWrapper(AsperaTransaction asperaTransaction); long startTransfer(final String xferId, final String transferSpecStr); boolean pause(final String xferId); boolean resume(final String xferId); boolean cancel(final String xferId); boolean isRunning(final String xferId); boolean configureLogLocation(final String ascpLogPath); void setAsperaTransaction(AsperaTransaction asperaTransaction); }
@Test public void readResourceWithDefaultRetryPolicy_DoesNotRetry_ForIoException() throws IOException { Mockito.when(mockConnection.connectToEndpoint(eq(endpoint), any(Map.class), eq("GET"))).thenThrow(new IOException()); try { new DefaultEC2ResourceFetcher(mockConnection).readResource(endpoint); fail("Expected an IOexception"); } catch (Exception exception) { Mockito.verify(mockConnection, Mockito.times(1)).connectToEndpoint(eq(endpoint), any(Map.class), eq("GET")); } }
public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers);
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
@Test public void readResourceWithCustomRetryPolicy_DoesRetry_ForIoException() throws IOException { Mockito.when(mockConnection.connectToEndpoint(eq(endpoint), any(Map.class), eq("GET"))).thenThrow(new IOException()); try { new DefaultEC2ResourceFetcher(mockConnection).readResource(endpoint, customRetryPolicy); fail("Expected an IOexception"); } catch (Exception exception) { Mockito.verify(mockConnection, Mockito.times(CustomRetryPolicy.MAX_RETRIES + 1)).connectToEndpoint(eq(endpoint), any(Map.class), eq("GET")); } }
public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers);
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
@Test public void testJarIsCreatedSuccessfully() throws IOException, URISyntaxException { JarFile jar = AsperaLibraryLoader.createJar(); assertNotNull(jar); }
public static JarFile createJar() throws IOException, URISyntaxException { URL location = faspmanager2.class.getProtectionDomain().getCodeSource().getLocation(); return new JarFile(new File(location.toURI())); }
AsperaLibraryLoader { public static JarFile createJar() throws IOException, URISyntaxException { URL location = faspmanager2.class.getProtectionDomain().getCodeSource().getLocation(); return new JarFile(new File(location.toURI())); } }
AsperaLibraryLoader { public static JarFile createJar() throws IOException, URISyntaxException { URL location = faspmanager2.class.getProtectionDomain().getCodeSource().getLocation(); return new JarFile(new File(location.toURI())); } }
AsperaLibraryLoader { public static JarFile createJar() throws IOException, URISyntaxException { URL location = faspmanager2.class.getProtectionDomain().getCodeSource().getLocation(); return new JarFile(new File(location.toURI())); } static String load(); static JarFile createJar(); static String jarVersion(JarFile jar); static void extractJar(JarFile jar, File extractedLocation); static void extractFile(JarFile jar, JarEntry entry, File destPath); static List<String> osLibs(); static void loadLibrary(File extractedPath, List<String> candidates); }
AsperaLibraryLoader { public static JarFile createJar() throws IOException, URISyntaxException { URL location = faspmanager2.class.getProtectionDomain().getCodeSource().getLocation(); return new JarFile(new File(location.toURI())); } static String load(); static JarFile createJar(); static String jarVersion(JarFile jar); static void extractJar(JarFile jar, File extractedLocation); static void extractFile(JarFile jar, JarEntry entry, File destPath); static List<String> osLibs(); static void loadLibrary(File extractedPath, List<String> candidates); }
@Test public void readResourceWithCustomRetryPolicy_DoesNotRetry_ForNonIoException() throws IOException { generateStub(500, "Non Json error body"); try { ec2ResourceFetcher.readResource(endpoint, customRetryPolicy, new HashMap<String, String>()); fail("Expected an AmazonServiceException"); } catch (AmazonServiceException ase) { assertEquals(500, ase.getStatusCode()); } }
public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers);
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
EC2ResourceFetcher { public abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); EC2ResourceFetcher(); @SdkTestInternalApi EC2ResourceFetcher(ConnectionUtils connectionUtils); static EC2ResourceFetcher defaultResourceFetcher(); abstract String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); final String readResource(URI endpoint); final String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy); }
@Test public void testInputStreamAbortedIsCalled(){ SdkFilterInputStream in = mock(SdkFilterInputStream.class); SdkFilterInputStream sdkFilterInputStream = spy(new SdkFilterInputStream(in)); sdkFilterInputStream.abort(); verify(in, times(1)).abort(); }
public void abort() { if (in instanceof SdkFilterInputStream) { ((SdkFilterInputStream) in).abort(); } aborted = true; }
SdkFilterInputStream extends FilterInputStream implements MetricAware, Releasable { public void abort() { if (in instanceof SdkFilterInputStream) { ((SdkFilterInputStream) in).abort(); } aborted = true; } }
SdkFilterInputStream extends FilterInputStream implements MetricAware, Releasable { public void abort() { if (in instanceof SdkFilterInputStream) { ((SdkFilterInputStream) in).abort(); } aborted = true; } protected SdkFilterInputStream(InputStream in); }
SdkFilterInputStream extends FilterInputStream implements MetricAware, Releasable { public void abort() { if (in instanceof SdkFilterInputStream) { ((SdkFilterInputStream) in).abort(); } aborted = true; } protected SdkFilterInputStream(InputStream in); @SdkProtectedApi InputStream getDelegateStream(); @Override boolean isMetricActivated(); void abort(); @Override int read(); @Override int read(byte b[], int off, int len); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); @Override void release(); }
SdkFilterInputStream extends FilterInputStream implements MetricAware, Releasable { public void abort() { if (in instanceof SdkFilterInputStream) { ((SdkFilterInputStream) in).abort(); } aborted = true; } protected SdkFilterInputStream(InputStream in); @SdkProtectedApi InputStream getDelegateStream(); @Override boolean isMetricActivated(); void abort(); @Override int read(); @Override int read(byte b[], int off, int len); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); @Override void release(); }
@Ignore @Test public void headersArePassedAsPartOfRequest() throws IOException { HttpURLConnection connection = sut.connectToEndpoint(URI.create("http: connection.getResponseCode(); mockServer.verify(getRequestedFor(urlMatching("/")).withHeader("HeaderA", equalTo("ValueA"))); }
public HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers) throws IOException { return connectToEndpoint(endpoint, headers, "GET"); }
ConnectionUtils { public HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers) throws IOException { return connectToEndpoint(endpoint, headers, "GET"); } }
ConnectionUtils { public HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers) throws IOException { return connectToEndpoint(endpoint, headers, "GET"); } private ConnectionUtils(); }
ConnectionUtils { public HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers) throws IOException { return connectToEndpoint(endpoint, headers, "GET"); } private ConnectionUtils(); static ConnectionUtils getInstance(); HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers); HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers, String method); }
ConnectionUtils { public HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers) throws IOException { return connectToEndpoint(endpoint, headers, "GET"); } private ConnectionUtils(); static ConnectionUtils getInstance(); HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers); HttpURLConnection connectToEndpoint(URI endpoint, Map<String, String> headers, String method); }
@Test public void testOSLibIsReturned() { String OS = System.getProperty("os.name").toLowerCase(); List<String> osNativeLibraries = AsperaLibraryLoader.osLibs(); assertNotNull(osNativeLibraries); if (OS.indexOf("win") >= 0){ assertTrue(osNativeLibraries.contains("faspmanager2.dll")); } else if (OS.indexOf("mac") >= 0) { assertTrue(osNativeLibraries.contains("libfaspmanager2.jnilib")); } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { assertTrue(osNativeLibraries.contains("libfaspmanager2.so")); } }
public static List<String> osLibs() { String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0){ return WINDOWS_DYNAMIC_LIBS; } else if (OS.indexOf("mac") >= 0) { return MAC_DYNAMIC_LIBS; } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { return UNIX_DYNAMIC_LIBS; } else { throw new AsperaLibraryLoadException("OS is not supported for Aspera"); } }
AsperaLibraryLoader { public static List<String> osLibs() { String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0){ return WINDOWS_DYNAMIC_LIBS; } else if (OS.indexOf("mac") >= 0) { return MAC_DYNAMIC_LIBS; } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { return UNIX_DYNAMIC_LIBS; } else { throw new AsperaLibraryLoadException("OS is not supported for Aspera"); } } }
AsperaLibraryLoader { public static List<String> osLibs() { String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0){ return WINDOWS_DYNAMIC_LIBS; } else if (OS.indexOf("mac") >= 0) { return MAC_DYNAMIC_LIBS; } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { return UNIX_DYNAMIC_LIBS; } else { throw new AsperaLibraryLoadException("OS is not supported for Aspera"); } } }
AsperaLibraryLoader { public static List<String> osLibs() { String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0){ return WINDOWS_DYNAMIC_LIBS; } else if (OS.indexOf("mac") >= 0) { return MAC_DYNAMIC_LIBS; } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { return UNIX_DYNAMIC_LIBS; } else { throw new AsperaLibraryLoadException("OS is not supported for Aspera"); } } static String load(); static JarFile createJar(); static String jarVersion(JarFile jar); static void extractJar(JarFile jar, File extractedLocation); static void extractFile(JarFile jar, JarEntry entry, File destPath); static List<String> osLibs(); static void loadLibrary(File extractedPath, List<String> candidates); }
AsperaLibraryLoader { public static List<String> osLibs() { String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0){ return WINDOWS_DYNAMIC_LIBS; } else if (OS.indexOf("mac") >= 0) { return MAC_DYNAMIC_LIBS; } else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) { return UNIX_DYNAMIC_LIBS; } else { throw new AsperaLibraryLoadException("OS is not supported for Aspera"); } } static String load(); static JarFile createJar(); static String jarVersion(JarFile jar); static void extractJar(JarFile jar, File extractedLocation); static void extractFile(JarFile jar, JarEntry entry, File destPath); static List<String> osLibs(); static void loadLibrary(File extractedPath, List<String> candidates); }
@Test public void testAsperaTransactionIsDoneERROR(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); transferListener.transferReporter(xferId, msgError); assertTrue(asperaTransaction.isDone()); }
@Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void testAsperaTransactionIsDoneSuccess(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); transferListener.transferReporter(xferId, msgError); transferListener.transferReporter(xferId, msgDone); assertTrue(asperaTransaction.isDone()); }
@Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean isDone() { return (doesStatusMatch(DONE)||doesStatusMatch(ERROR)||doesStatusMatch(STOP)||doesStatusMatch(ARGSTOP)); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void testAsperaTransactionIsProgress(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); assertTrue(asperaTransaction.progress()); }
@Override public boolean progress() { return doesStatusMatch(PROGRESS); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean progress() { return doesStatusMatch(PROGRESS); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean progress() { return doesStatusMatch(PROGRESS); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean progress() { return doesStatusMatch(PROGRESS); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean progress() { return doesStatusMatch(PROGRESS); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void disableCertChecking_FlagEnabled_TurnsOffCertChecking() { System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, ""); assertTrue(SDKGlobalConfiguration.isCertCheckingDisabled()); }
public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); static final String DISABLE_CERT_CHECKING_SYSTEM_PROPERTY; static final String DEFAULT_METRICS_SYSTEM_PROPERTY; static final String ACCESS_KEY_SYSTEM_PROPERTY; static final String SECRET_KEY_SYSTEM_PROPERTY; static final String EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY; static final String RETRY_THROTTLING_SYSTEM_PROPERTY; static final String REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY; static final String DISABLE_REMOTE_REGIONS_FILE_SYSTEM_PROPERTY; @Deprecated static final String ENABLE_S3_SIGV4_SYSTEM_PROPERTY; @Deprecated static final String ENFORCE_S3_SIGV4_SYSTEM_PROPERTY; static final String DISABLE_S3_IMPLICIT_GLOBAL_CLIENTS_SYSTEM_PROPERTY; static final String ENABLE_IN_REGION_OPTIMIZED_MODE; @Deprecated static final String DEFAULT_S3_STREAM_BUFFER_SIZE; @Deprecated static final String PROFILING_SYSTEM_PROPERTY; static final String IBM_API_KEY_SYSTEM_PROPERTY; static final String IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY; static final String IBM_API_KEY; static final String IBM_SERVICE_INSTANCE_ID; static String IAM_ENDPOINT; static int IAM_MAX_RETRY; static double IAM_REFRESH_OFFSET; static final String ACCESS_KEY_ENV_VAR; static final String ALTERNATE_ACCESS_KEY_ENV_VAR; static final String SECRET_KEY_ENV_VAR; static final String ALTERNATE_SECRET_KEY_ENV_VAR; static final String AWS_SESSION_TOKEN_ENV_VAR; static final String AWS_WEB_IDENTITY_ENV_VAR; static final String AWS_ROLE_ARN_ENV_VAR; static final String AWS_ROLE_SESSION_NAME_ENV_VAR; static final String AWS_REGION_ENV_VAR; static final String AWS_CONFIG_FILE_ENV_VAR; static final String AWS_CBOR_DISABLE_ENV_VAR; static final String AWS_CBOR_DISABLE_SYSTEM_PROPERTY; static final String AWS_ION_BINARY_DISABLE_ENV_VAR; static final String AWS_ION_BINARY_DISABLE_SYSTEM_PROPERTY; static final String AWS_EC2_METADATA_DISABLED_ENV_VAR; static final String AWS_EC2_METADATA_DISABLED_SYSTEM_PROPERTY; }
@Test public void disableCertChecking_PropertySetToTrue_TurnsOffCertChecking() { System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "true"); assertTrue(SDKGlobalConfiguration.isCertCheckingDisabled()); }
public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); static final String DISABLE_CERT_CHECKING_SYSTEM_PROPERTY; static final String DEFAULT_METRICS_SYSTEM_PROPERTY; static final String ACCESS_KEY_SYSTEM_PROPERTY; static final String SECRET_KEY_SYSTEM_PROPERTY; static final String EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY; static final String RETRY_THROTTLING_SYSTEM_PROPERTY; static final String REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY; static final String DISABLE_REMOTE_REGIONS_FILE_SYSTEM_PROPERTY; @Deprecated static final String ENABLE_S3_SIGV4_SYSTEM_PROPERTY; @Deprecated static final String ENFORCE_S3_SIGV4_SYSTEM_PROPERTY; static final String DISABLE_S3_IMPLICIT_GLOBAL_CLIENTS_SYSTEM_PROPERTY; static final String ENABLE_IN_REGION_OPTIMIZED_MODE; @Deprecated static final String DEFAULT_S3_STREAM_BUFFER_SIZE; @Deprecated static final String PROFILING_SYSTEM_PROPERTY; static final String IBM_API_KEY_SYSTEM_PROPERTY; static final String IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY; static final String IBM_API_KEY; static final String IBM_SERVICE_INSTANCE_ID; static String IAM_ENDPOINT; static int IAM_MAX_RETRY; static double IAM_REFRESH_OFFSET; static final String ACCESS_KEY_ENV_VAR; static final String ALTERNATE_ACCESS_KEY_ENV_VAR; static final String SECRET_KEY_ENV_VAR; static final String ALTERNATE_SECRET_KEY_ENV_VAR; static final String AWS_SESSION_TOKEN_ENV_VAR; static final String AWS_WEB_IDENTITY_ENV_VAR; static final String AWS_ROLE_ARN_ENV_VAR; static final String AWS_ROLE_SESSION_NAME_ENV_VAR; static final String AWS_REGION_ENV_VAR; static final String AWS_CONFIG_FILE_ENV_VAR; static final String AWS_CBOR_DISABLE_ENV_VAR; static final String AWS_CBOR_DISABLE_SYSTEM_PROPERTY; static final String AWS_ION_BINARY_DISABLE_ENV_VAR; static final String AWS_ION_BINARY_DISABLE_SYSTEM_PROPERTY; static final String AWS_EC2_METADATA_DISABLED_ENV_VAR; static final String AWS_EC2_METADATA_DISABLED_SYSTEM_PROPERTY; }
@Test public void disableCertChecking_PropertySet_TurnsOffCertChecking() { System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "anything"); assertTrue(SDKGlobalConfiguration.isCertCheckingDisabled()); }
public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); static final String DISABLE_CERT_CHECKING_SYSTEM_PROPERTY; static final String DEFAULT_METRICS_SYSTEM_PROPERTY; static final String ACCESS_KEY_SYSTEM_PROPERTY; static final String SECRET_KEY_SYSTEM_PROPERTY; static final String EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY; static final String RETRY_THROTTLING_SYSTEM_PROPERTY; static final String REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY; static final String DISABLE_REMOTE_REGIONS_FILE_SYSTEM_PROPERTY; @Deprecated static final String ENABLE_S3_SIGV4_SYSTEM_PROPERTY; @Deprecated static final String ENFORCE_S3_SIGV4_SYSTEM_PROPERTY; static final String DISABLE_S3_IMPLICIT_GLOBAL_CLIENTS_SYSTEM_PROPERTY; static final String ENABLE_IN_REGION_OPTIMIZED_MODE; @Deprecated static final String DEFAULT_S3_STREAM_BUFFER_SIZE; @Deprecated static final String PROFILING_SYSTEM_PROPERTY; static final String IBM_API_KEY_SYSTEM_PROPERTY; static final String IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY; static final String IBM_API_KEY; static final String IBM_SERVICE_INSTANCE_ID; static String IAM_ENDPOINT; static int IAM_MAX_RETRY; static double IAM_REFRESH_OFFSET; static final String ACCESS_KEY_ENV_VAR; static final String ALTERNATE_ACCESS_KEY_ENV_VAR; static final String SECRET_KEY_ENV_VAR; static final String ALTERNATE_SECRET_KEY_ENV_VAR; static final String AWS_SESSION_TOKEN_ENV_VAR; static final String AWS_WEB_IDENTITY_ENV_VAR; static final String AWS_ROLE_ARN_ENV_VAR; static final String AWS_ROLE_SESSION_NAME_ENV_VAR; static final String AWS_REGION_ENV_VAR; static final String AWS_CONFIG_FILE_ENV_VAR; static final String AWS_CBOR_DISABLE_ENV_VAR; static final String AWS_CBOR_DISABLE_SYSTEM_PROPERTY; static final String AWS_ION_BINARY_DISABLE_ENV_VAR; static final String AWS_ION_BINARY_DISABLE_SYSTEM_PROPERTY; static final String AWS_EC2_METADATA_DISABLED_ENV_VAR; static final String AWS_EC2_METADATA_DISABLED_SYSTEM_PROPERTY; }
@Test public void disableCertChecking_PropertySetToFalse_TurnsOffCertChecking() { System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "false"); assertFalse(SDKGlobalConfiguration.isCertCheckingDisabled()); }
public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); static final String DISABLE_CERT_CHECKING_SYSTEM_PROPERTY; static final String DEFAULT_METRICS_SYSTEM_PROPERTY; static final String ACCESS_KEY_SYSTEM_PROPERTY; static final String SECRET_KEY_SYSTEM_PROPERTY; static final String EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY; static final String RETRY_THROTTLING_SYSTEM_PROPERTY; static final String REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY; static final String DISABLE_REMOTE_REGIONS_FILE_SYSTEM_PROPERTY; @Deprecated static final String ENABLE_S3_SIGV4_SYSTEM_PROPERTY; @Deprecated static final String ENFORCE_S3_SIGV4_SYSTEM_PROPERTY; static final String DISABLE_S3_IMPLICIT_GLOBAL_CLIENTS_SYSTEM_PROPERTY; static final String ENABLE_IN_REGION_OPTIMIZED_MODE; @Deprecated static final String DEFAULT_S3_STREAM_BUFFER_SIZE; @Deprecated static final String PROFILING_SYSTEM_PROPERTY; static final String IBM_API_KEY_SYSTEM_PROPERTY; static final String IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY; static final String IBM_API_KEY; static final String IBM_SERVICE_INSTANCE_ID; static String IAM_ENDPOINT; static int IAM_MAX_RETRY; static double IAM_REFRESH_OFFSET; static final String ACCESS_KEY_ENV_VAR; static final String ALTERNATE_ACCESS_KEY_ENV_VAR; static final String SECRET_KEY_ENV_VAR; static final String ALTERNATE_SECRET_KEY_ENV_VAR; static final String AWS_SESSION_TOKEN_ENV_VAR; static final String AWS_WEB_IDENTITY_ENV_VAR; static final String AWS_ROLE_ARN_ENV_VAR; static final String AWS_ROLE_SESSION_NAME_ENV_VAR; static final String AWS_REGION_ENV_VAR; static final String AWS_CONFIG_FILE_ENV_VAR; static final String AWS_CBOR_DISABLE_ENV_VAR; static final String AWS_CBOR_DISABLE_SYSTEM_PROPERTY; static final String AWS_ION_BINARY_DISABLE_ENV_VAR; static final String AWS_ION_BINARY_DISABLE_SYSTEM_PROPERTY; static final String AWS_EC2_METADATA_DISABLED_ENV_VAR; static final String AWS_EC2_METADATA_DISABLED_SYSTEM_PROPERTY; }
@Test public void disableCertChecking_PropertySetToFalseMixedCase_TurnsOffCertChecking() { System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "FaLsE"); assertFalse(SDKGlobalConfiguration.isCertCheckingDisabled()); }
public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); }
SDKGlobalConfiguration { public static boolean isCertCheckingDisabled() { return isPropertyEnabled(System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY)); } @Deprecated static void setGlobalTimeOffset(int timeOffset); @Deprecated static int getGlobalTimeOffset(); static boolean isInRegionOptimizedModeEnabled(); static boolean isCertCheckingDisabled(); static boolean isCborDisabled(); static boolean isIonBinaryDisabled(); static boolean isEc2MetadataDisabled(); static final String DISABLE_CERT_CHECKING_SYSTEM_PROPERTY; static final String DEFAULT_METRICS_SYSTEM_PROPERTY; static final String ACCESS_KEY_SYSTEM_PROPERTY; static final String SECRET_KEY_SYSTEM_PROPERTY; static final String EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY; static final String RETRY_THROTTLING_SYSTEM_PROPERTY; static final String REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY; static final String DISABLE_REMOTE_REGIONS_FILE_SYSTEM_PROPERTY; @Deprecated static final String ENABLE_S3_SIGV4_SYSTEM_PROPERTY; @Deprecated static final String ENFORCE_S3_SIGV4_SYSTEM_PROPERTY; static final String DISABLE_S3_IMPLICIT_GLOBAL_CLIENTS_SYSTEM_PROPERTY; static final String ENABLE_IN_REGION_OPTIMIZED_MODE; @Deprecated static final String DEFAULT_S3_STREAM_BUFFER_SIZE; @Deprecated static final String PROFILING_SYSTEM_PROPERTY; static final String IBM_API_KEY_SYSTEM_PROPERTY; static final String IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY; static final String IBM_API_KEY; static final String IBM_SERVICE_INSTANCE_ID; static String IAM_ENDPOINT; static int IAM_MAX_RETRY; static double IAM_REFRESH_OFFSET; static final String ACCESS_KEY_ENV_VAR; static final String ALTERNATE_ACCESS_KEY_ENV_VAR; static final String SECRET_KEY_ENV_VAR; static final String ALTERNATE_SECRET_KEY_ENV_VAR; static final String AWS_SESSION_TOKEN_ENV_VAR; static final String AWS_WEB_IDENTITY_ENV_VAR; static final String AWS_ROLE_ARN_ENV_VAR; static final String AWS_ROLE_SESSION_NAME_ENV_VAR; static final String AWS_REGION_ENV_VAR; static final String AWS_CONFIG_FILE_ENV_VAR; static final String AWS_CBOR_DISABLE_ENV_VAR; static final String AWS_CBOR_DISABLE_SYSTEM_PROPERTY; static final String AWS_ION_BINARY_DISABLE_ENV_VAR; static final String AWS_ION_BINARY_DISABLE_SYSTEM_PROPERTY; static final String AWS_EC2_METADATA_DISABLED_ENV_VAR; static final String AWS_EC2_METADATA_DISABLED_SYSTEM_PROPERTY; }
@Test public void credentialsNotExplicitlySet_UsesDefaultCredentialChain() throws Exception { AwsAsyncClientParams params = builderWithRegion().build().getAsyncParams(); assertThat(params.getCredentialsProvider(), instanceOf(DefaultAWSCredentialsProviderChain.class)); }
public abstract TypeToBuild build();
AwsClientBuilder { public abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
@Test public void metricCollectorNotExplicitlySet_UsesNullMetricsCollector() throws Exception { assertNull(builderWithRegion().build().getAsyncParams().getRequestMetricCollector()); }
public abstract TypeToBuild build();
AwsClientBuilder { public abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
@Test public void defaultClientConfigAndNoExplicitExecutor_UsesDefaultExecutorBasedOnMaxConns() { ExecutorService executor = builderWithRegion().build().getAsyncParams().getExecutor(); assertThat(executor, instanceOf(ThreadPoolExecutor.class)); assertEquals(PredefinedClientConfigurations.defaultConfig().getMaxConnections(), ((ThreadPoolExecutor) executor).getMaximumPoolSize()); }
public abstract TypeToBuild build();
AwsClientBuilder { public abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
AwsClientBuilder { public abstract TypeToBuild build(); protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory); @SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider); final AWSCredentialsProvider getCredentials(); final void setCredentials(AWSCredentialsProvider credentialsProvider); final Subclass withCredentials(AWSCredentialsProvider credentialsProvider); Subclass withIAMEndpoint(String iamEndpoint); Subclass withIAMTokenRefresh(double offset); Subclass withIAMMaxRetry(int retryCount); final ClientConfiguration getClientConfiguration(); final void setClientConfiguration(ClientConfiguration config); final Subclass withClientConfiguration(ClientConfiguration config); final void setMetricsCollector(RequestMetricCollector metrics); final Subclass withMetricsCollector(RequestMetricCollector metrics); final String getRegion(); final void setRegion(String region); final Subclass withRegion(Regions region); final RequestMetricCollector getMetricsCollector(); final Subclass withRegion(String region); final EndpointConfiguration getEndpoint(); final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration); final Subclass withEndpointConfiguration(EndpointConfiguration endpointConfiguration); final List<RequestHandler2> getRequestHandlers(); final void setRequestHandlers(RequestHandler2... handlers); final Subclass withRequestHandlers(RequestHandler2... handlers); abstract TypeToBuild build(); }
@Test public void testAsperaTransactionIsQueued(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); assertTrue(asperaTransaction.onQueue()); }
@Override public boolean onQueue() { return doesStatusMatch(QUEUED); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean onQueue() { return doesStatusMatch(QUEUED); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean onQueue() { return doesStatusMatch(QUEUED); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean onQueue() { return doesStatusMatch(QUEUED); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean onQueue() { return doesStatusMatch(QUEUED); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void testHeadersAddedToObjectListing() throws Exception { Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false); S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller); HttpResponse httpResponse = new HttpResponse(null, null); httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True"); httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "123456"); InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());; httpResponse.setContent(is); AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse); assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "123456"); assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true); }
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
@Test public void testGetRegion() { Region region = metadata.getRegion("us-east-1"); Assert.assertNotNull(region); Assert.assertEquals("us-east-1", region.getName()); region = metadata.getRegion("us-west-1"); Assert.assertNotNull(region); Assert.assertEquals("us-west-1", region.getName()); region = metadata.getRegion("cn-north-1"); Assert.assertNotNull(region); Assert.assertEquals("cn-north-1", region.getName()); region = metadata.getRegion("bogus-monkeys"); Assert.assertNull(region); }
public Region getRegion(final String name) { return provider.getRegion(name); }
RegionMetadata { public Region getRegion(final String name) { return provider.getRegion(name); } }
RegionMetadata { public Region getRegion(final String name) { return provider.getRegion(name); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); }
RegionMetadata { public Region getRegion(final String name) { return provider.getRegion(name); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
RegionMetadata { public Region getRegion(final String name) { return provider.getRegion(name); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
@Test public void testGetRegionsForService() { List<Region> regions = metadata.getRegionsForService("s3"); Assert.assertNotNull(regions); Assert.assertEquals(2, regions.size()); Assert.assertEquals("us-east-1", regions.get(0).getName()); Assert.assertEquals("us-west-1", regions.get(1).getName()); regions = metadata.getRegionsForService("bogus-monkeys"); Assert.assertNotNull(regions); Assert.assertTrue(regions.isEmpty()); }
public List<Region> getRegionsForService(final String service) { return provider.getRegionsForService(service); }
RegionMetadata { public List<Region> getRegionsForService(final String service) { return provider.getRegionsForService(service); } }
RegionMetadata { public List<Region> getRegionsForService(final String service) { return provider.getRegionsForService(service); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); }
RegionMetadata { public List<Region> getRegionsForService(final String service) { return provider.getRegionsForService(service); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
RegionMetadata { public List<Region> getRegionsForService(final String service) { return provider.getRegionsForService(service); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
@Test public void testGetRegionByEndpoint() { Region region = metadata.getRegionByEndpoint("s3-us-west-1.amazonaws.com"); Assert.assertNotNull(region); Assert.assertEquals("us-west-1", region.getName()); try { metadata.getRegionByEndpoint("bogus-monkeys"); Assert.fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
@Deprecated public Region getRegionByEndpoint(final String endpoint) { return provider.getRegionByEndpoint(endpoint); }
RegionMetadata { @Deprecated public Region getRegionByEndpoint(final String endpoint) { return provider.getRegionByEndpoint(endpoint); } }
RegionMetadata { @Deprecated public Region getRegionByEndpoint(final String endpoint) { return provider.getRegionByEndpoint(endpoint); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); }
RegionMetadata { @Deprecated public Region getRegionByEndpoint(final String endpoint) { return provider.getRegionByEndpoint(endpoint); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
RegionMetadata { @Deprecated public Region getRegionByEndpoint(final String endpoint) { return provider.getRegionByEndpoint(endpoint); } RegionMetadata(final List<Region> regions); RegionMetadata(RegionMetadataProvider provider); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); @Deprecated Region getRegionByEndpoint(final String endpoint); @Override String toString(); }
@Test public void testAsperaTransactionPause(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); assertTrue(asperaTransaction.pause()); }
@Override public boolean pause() { return asperaFaspManagerWrapper.pause(xferid); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean pause() { return asperaFaspManagerWrapper.pause(xferid); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean pause() { return asperaFaspManagerWrapper.pause(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean pause() { return asperaFaspManagerWrapper.pause(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean pause() { return asperaFaspManagerWrapper.pause(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void shouldAcceptTokenProvider() { TokenProvider tokenProvider = new TokenProviderUtil(); defaultTokenManager = new DefaultTokenManager(tokenProvider); assertEquals(defaultTokenManager.getToken(), ("ProviderAccessToken")); }
@Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test(expected = Exception.class) public void shouldBubbleExceptionUpThroughSDK() { TokenProvider tokenProvider = null; defaultTokenManager = new DefaultTokenManager(tokenProvider); defaultTokenManager.getToken().equals("ProviderAccessToken"); }
@Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test @Ignore public void shouldOnlyCallIAMOnceInMutliThreadForInitialToken() { TokenProvider tokenProviderMock = mock(TokenProvider.class); when(tokenProviderMock.retrieveToken()).thenReturn(token); defaultTokenManager = new DefaultTokenManager(tokenProviderMock); Thread t1 = new Thread(new ManagerThreadUtil(defaultTokenManager)); Thread t2 = new Thread(new ManagerThreadUtil(defaultTokenManager)); Thread t3 = new Thread(new ManagerThreadUtil(defaultTokenManager)); Thread t4 = new Thread(new ManagerThreadUtil(defaultTokenManager)); t1.start(); t2.start(); t3.start(); t4.start(); assertEquals(1, Mockito.mockingDetails(tokenProviderMock).getInvocations().size()); }
protected synchronized void retrieveToken() { log.debug("OAuthTokenManager.retrieveToken"); if (token == null || (Long.valueOf(token.getExpiration()) < System.currentTimeMillis() / 1000L)) { log.debug("Token is null, retrieving initial token from provider"); boolean tokenRequest = true; int retryCount = 0; while (tokenRequest && retryCount < this.iamMaxRetry) { try { ++retryCount; token = provider.retrieveToken(); tokenRequest = false; } catch (OAuthServiceException exception) { log.debug("Exception retrieving IAM token. Returned status code " + exception.getStatusCode() + "Retry attempt " + retryCount); tokenRequest = shouldRetry(exception.getStatusCode()) ? true : false; if (!tokenRequest || retryCount == this.iamMaxRetry) { throw exception; } } } if(null == token) { throw new OAuthServiceException("Null token returned by the Token Provider"); } cacheToken(token); } }
DefaultTokenManager implements TokenManager { protected synchronized void retrieveToken() { log.debug("OAuthTokenManager.retrieveToken"); if (token == null || (Long.valueOf(token.getExpiration()) < System.currentTimeMillis() / 1000L)) { log.debug("Token is null, retrieving initial token from provider"); boolean tokenRequest = true; int retryCount = 0; while (tokenRequest && retryCount < this.iamMaxRetry) { try { ++retryCount; token = provider.retrieveToken(); tokenRequest = false; } catch (OAuthServiceException exception) { log.debug("Exception retrieving IAM token. Returned status code " + exception.getStatusCode() + "Retry attempt " + retryCount); tokenRequest = shouldRetry(exception.getStatusCode()) ? true : false; if (!tokenRequest || retryCount == this.iamMaxRetry) { throw exception; } } } if(null == token) { throw new OAuthServiceException("Null token returned by the Token Provider"); } cacheToken(token); } } }
DefaultTokenManager implements TokenManager { protected synchronized void retrieveToken() { log.debug("OAuthTokenManager.retrieveToken"); if (token == null || (Long.valueOf(token.getExpiration()) < System.currentTimeMillis() / 1000L)) { log.debug("Token is null, retrieving initial token from provider"); boolean tokenRequest = true; int retryCount = 0; while (tokenRequest && retryCount < this.iamMaxRetry) { try { ++retryCount; token = provider.retrieveToken(); tokenRequest = false; } catch (OAuthServiceException exception) { log.debug("Exception retrieving IAM token. Returned status code " + exception.getStatusCode() + "Retry attempt " + retryCount); tokenRequest = shouldRetry(exception.getStatusCode()) ? true : false; if (!tokenRequest || retryCount == this.iamMaxRetry) { throw exception; } } } if(null == token) { throw new OAuthServiceException("Null token returned by the Token Provider"); } cacheToken(token); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { protected synchronized void retrieveToken() { log.debug("OAuthTokenManager.retrieveToken"); if (token == null || (Long.valueOf(token.getExpiration()) < System.currentTimeMillis() / 1000L)) { log.debug("Token is null, retrieving initial token from provider"); boolean tokenRequest = true; int retryCount = 0; while (tokenRequest && retryCount < this.iamMaxRetry) { try { ++retryCount; token = provider.retrieveToken(); tokenRequest = false; } catch (OAuthServiceException exception) { log.debug("Exception retrieving IAM token. Returned status code " + exception.getStatusCode() + "Retry attempt " + retryCount); tokenRequest = shouldRetry(exception.getStatusCode()) ? true : false; if (!tokenRequest || retryCount == this.iamMaxRetry) { throw exception; } } } if(null == token) { throw new OAuthServiceException("Null token returned by the Token Provider"); } cacheToken(token); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { protected synchronized void retrieveToken() { log.debug("OAuthTokenManager.retrieveToken"); if (token == null || (Long.valueOf(token.getExpiration()) < System.currentTimeMillis() / 1000L)) { log.debug("Token is null, retrieving initial token from provider"); boolean tokenRequest = true; int retryCount = 0; while (tokenRequest && retryCount < this.iamMaxRetry) { try { ++retryCount; token = provider.retrieveToken(); tokenRequest = false; } catch (OAuthServiceException exception) { log.debug("Exception retrieving IAM token. Returned status code " + exception.getStatusCode() + "Retry attempt " + retryCount); tokenRequest = shouldRetry(exception.getStatusCode()) ? true : false; if (!tokenRequest || retryCount == this.iamMaxRetry) { throw exception; } } } if(null == token) { throw new OAuthServiceException("Null token returned by the Token Provider"); } cacheToken(token); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test(expected = OAuthServiceException.class) public void shouldHandleNullTokenWithCorrectExcpetion() { DefaultTokenManager defaultTokenManager = new DefaultTokenManager(new TokenProviderNull()); defaultTokenManager.getToken(); }
@Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { @Override public String getToken() { log.debug("DefaultTokenManager getToken()"); if (!checkCache()) { retrieveToken(); } if (token == null) { token = retrieveTokenFromCache(); } if (hasTokenExpired(token)) { token = retrieveTokenFromCache(); } if (isTokenExpiring(token) && !isAsyncInProgress()) { if (null != token.getRefresh_token()) { this.asyncInProgress = true; submitRefreshTask(); } else { retrieveToken(); token = retrieveTokenFromCache(); } } if (token.getAccess_token() != null && !token.getAccess_token().isEmpty()) { return token.getAccess_token(); } else if (token.getDelegated_refresh_token()!= null && !token.getDelegated_refresh_token().isEmpty()) { return token.getDelegated_refresh_token(); } else if (token.getIms_token() != null && !token.getIms_token().isEmpty()) { return token.getIms_token(); } else { return token.getUaa_token(); } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test public void shouldAddProxyToClient() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{ HttpClientBuilder builder = HttpClientBuilder.create(); ClientConfiguration config = new ClientConfiguration().withProxyHost("127.0.0.1").withProxyPort(8080); HttpClientSettings settings = HttpClientSettings.adapt(config); DefaultTokenManager.addProxyConfig(builder, settings); builder.build(); Field field = builder.getClass().getDeclaredField("routePlanner"); field.setAccessible(true); HttpRoutePlanner httpRoutePlanner = (HttpRoutePlanner) field.get(builder); assertNotNull(httpRoutePlanner); }
public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test public void shouldNotAddProxyToClient() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{ HttpClientBuilder builder = HttpClientBuilder.create(); ClientConfiguration config = new ClientConfiguration(); HttpClientSettings settings = HttpClientSettings.adapt(config); DefaultTokenManager.addProxyConfig(builder, settings); builder.build(); Field field = builder.getClass().getDeclaredField("routePlanner"); field.setAccessible(true); HttpRoutePlanner httpRoutePlanner = (HttpRoutePlanner) field.get(builder); assertNull(httpRoutePlanner); }
public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
DefaultTokenManager implements TokenManager { public static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings) { if (settings.isProxyEnabled()) { log.info("Configuring Proxy. Proxy Host: " + settings.getProxyHost() + " " + "Proxy Port: " + settings.getProxyPort()); builder.setRoutePlanner(new SdkProxyRoutePlanner( settings.getProxyHost(), settings.getProxyPort(), settings.getNonProxyHosts())); if (settings.isAuthenticatedProxy()) { builder.setDefaultCredentialsProvider(ApacheUtils.newProxyCredentialsProvider(settings)); } } } DefaultTokenManager(String apiKey); DefaultTokenManager(TokenProvider provider); void setIamEndpoint(String iamEndpoint); void setIamRefreshOffset(double offset); void setIamMaxRetry(int count); TokenProvider getProvider(); @Override String getToken(); ClientConfiguration getClientConfiguration(); void setClientConfiguration(ClientConfiguration clientConfiguration); static void addProxyConfig(HttpClientBuilder builder, HttpClientSettings settings); }
@Test public void testAsperaTransactionResume(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); assertTrue(asperaTransaction.resume()); }
@Override public boolean resume() { return asperaFaspManagerWrapper.resume(xferid); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean resume() { return asperaFaspManagerWrapper.resume(xferid); } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean resume() { return asperaFaspManagerWrapper.resume(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean resume() { return asperaFaspManagerWrapper.resume(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean resume() { return asperaFaspManagerWrapper.resume(xferid); } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void shouldAddBearerToken() { request = MockRequestBuilder.create() .withContent(new ByteArrayInputStream("{\"TableName\": \"foo\"}".getBytes())) .withHeader("Host", "demo.us-east-1.amazonaws.com") .withHeader("x-amz-archive-description", "test test") .withPath("/") .withEndpoint("http: TokenProvider tokenProvider = new TokenProviderUtil(); AWSCredentialsProvider testCredProvider = new CredentialProviderUtil(tokenProvider); IBMOAuthSigner signer = new IBMOAuthSigner(); signer.sign(request, testCredProvider.getCredentials()); assertEquals("Bearer ProviderAccessToken", request.getHeaders().get("Authorization")); }
@Override public void sign(SignableRequest<?> request, AWSCredentials credentials) { log.debug("++ OAuth signer"); IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)credentials; if (oAuthCreds.getTokenManager() instanceof DefaultTokenManager) { DefaultTokenManager tokenManager = (DefaultTokenManager)oAuthCreds.getTokenManager(); tokenManager.setClientConfiguration(clientConfiguration); request.addHeader( AUTHORIZATION,"Bearer " + tokenManager.getToken()); } else { request.addHeader( AUTHORIZATION,"Bearer " + oAuthCreds.getTokenManager().getToken()); } }
IBMOAuthSigner extends AbstractAWSSigner { @Override public void sign(SignableRequest<?> request, AWSCredentials credentials) { log.debug("++ OAuth signer"); IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)credentials; if (oAuthCreds.getTokenManager() instanceof DefaultTokenManager) { DefaultTokenManager tokenManager = (DefaultTokenManager)oAuthCreds.getTokenManager(); tokenManager.setClientConfiguration(clientConfiguration); request.addHeader( AUTHORIZATION,"Bearer " + tokenManager.getToken()); } else { request.addHeader( AUTHORIZATION,"Bearer " + oAuthCreds.getTokenManager().getToken()); } } }
IBMOAuthSigner extends AbstractAWSSigner { @Override public void sign(SignableRequest<?> request, AWSCredentials credentials) { log.debug("++ OAuth signer"); IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)credentials; if (oAuthCreds.getTokenManager() instanceof DefaultTokenManager) { DefaultTokenManager tokenManager = (DefaultTokenManager)oAuthCreds.getTokenManager(); tokenManager.setClientConfiguration(clientConfiguration); request.addHeader( AUTHORIZATION,"Bearer " + tokenManager.getToken()); } else { request.addHeader( AUTHORIZATION,"Bearer " + oAuthCreds.getTokenManager().getToken()); } } IBMOAuthSigner(ClientConfiguration clientConfiguration); IBMOAuthSigner(); }
IBMOAuthSigner extends AbstractAWSSigner { @Override public void sign(SignableRequest<?> request, AWSCredentials credentials) { log.debug("++ OAuth signer"); IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)credentials; if (oAuthCreds.getTokenManager() instanceof DefaultTokenManager) { DefaultTokenManager tokenManager = (DefaultTokenManager)oAuthCreds.getTokenManager(); tokenManager.setClientConfiguration(clientConfiguration); request.addHeader( AUTHORIZATION,"Bearer " + tokenManager.getToken()); } else { request.addHeader( AUTHORIZATION,"Bearer " + oAuthCreds.getTokenManager().getToken()); } } IBMOAuthSigner(ClientConfiguration clientConfiguration); IBMOAuthSigner(); @Override void sign(SignableRequest<?> request, AWSCredentials credentials); }
IBMOAuthSigner extends AbstractAWSSigner { @Override public void sign(SignableRequest<?> request, AWSCredentials credentials) { log.debug("++ OAuth signer"); IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)credentials; if (oAuthCreds.getTokenManager() instanceof DefaultTokenManager) { DefaultTokenManager tokenManager = (DefaultTokenManager)oAuthCreds.getTokenManager(); tokenManager.setClientConfiguration(clientConfiguration); request.addHeader( AUTHORIZATION,"Bearer " + tokenManager.getToken()); } else { request.addHeader( AUTHORIZATION,"Bearer " + oAuthCreds.getTokenManager().getToken()); } } IBMOAuthSigner(ClientConfiguration clientConfiguration); IBMOAuthSigner(); @Override void sign(SignableRequest<?> request, AWSCredentials credentials); }
@Test public void constructorShouldAcceptTokenManager() { TokenManager tokenManger = new TokenManagerUtil(); IBMOAuthCredentials oAuthCreds = new BasicIBMOAuthCredentials(tokenManger); assertTrue(oAuthCreds.getTokenManager().getToken().equals("TokenManagerAccessToken")); }
@Override public TokenManager getTokenManager() { return tokenManager; }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); @Override String getAWSAccessKeyId(); @Override String getAWSSecretKey(); @Override TokenManager getTokenManager(); @Override String getApiKey(); @Override String getServiceInstanceId(); }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); @Override String getAWSAccessKeyId(); @Override String getAWSSecretKey(); @Override TokenManager getTokenManager(); @Override String getApiKey(); @Override String getServiceInstanceId(); }
@Test public void constructorShouldAcceptTokenProvider() { TokenProvider tokenProvider = new TokenProviderUtil(); IBMOAuthCredentials oAuthCreds = new BasicIBMOAuthCredentials(tokenProvider); assertTrue(oAuthCreds.getTokenManager().getToken().equals("ProviderAccessToken")); }
@Override public TokenManager getTokenManager() { return tokenManager; }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); @Override String getAWSAccessKeyId(); @Override String getAWSSecretKey(); @Override TokenManager getTokenManager(); @Override String getApiKey(); @Override String getServiceInstanceId(); }
BasicIBMOAuthCredentials implements IBMOAuthCredentials { @Override public TokenManager getTokenManager() { return tokenManager; } BasicIBMOAuthCredentials(String apiKey, String serviceInstanceId); BasicIBMOAuthCredentials(TokenManager tokenManager); BasicIBMOAuthCredentials(TokenManager tokenManager, String serviceInstanceId); BasicIBMOAuthCredentials(TokenProvider tokenProvider); @Override String getAWSAccessKeyId(); @Override String getAWSSecretKey(); @Override TokenManager getTokenManager(); @Override String getApiKey(); @Override String getServiceInstanceId(); }
@Test public void testReusingLastProvider() throws Exception { MockCredentialsProvider provider1 = new MockCredentialsProvider(); provider1.throwException = true; MockCredentialsProvider provider2 = new MockCredentialsProvider(); AWSCredentialsProviderChain chain = new AWSCredentialsProviderChain(provider1, provider2); assertEquals(0, provider1.getCredentialsCallCount); assertEquals(0, provider2.getCredentialsCallCount); chain.getCredentials(); assertEquals(1, provider1.getCredentialsCallCount); assertEquals(1, provider2.getCredentialsCallCount); chain.getCredentials(); assertEquals(1, provider1.getCredentialsCallCount); assertEquals(2, provider2.getCredentialsCallCount); chain.getCredentials(); assertEquals(1, provider1.getCredentialsCallCount); assertEquals(3, provider2.getCredentialsCallCount); }
public AWSCredentials getCredentials() { if (reuseLastProvider && lastUsedProvider != null) { return lastUsedProvider.getCredentials(); } for (AWSCredentialsProvider provider : credentialsProviders) { try { AWSCredentials credentials = provider.getCredentials(); if (credentials instanceof IBMOAuthCredentials) { log.debug("Loading OAuth credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } if (credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) { log.debug("Loading credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } } catch (Exception e) { log.debug("Unable to load credentials from " + provider.toString() + ": " + e.getMessage()); } } throw new SdkClientException("Unable to load AWS credentials from any provider in the chain"); }
AWSCredentialsProviderChain implements AWSCredentialsProvider { public AWSCredentials getCredentials() { if (reuseLastProvider && lastUsedProvider != null) { return lastUsedProvider.getCredentials(); } for (AWSCredentialsProvider provider : credentialsProviders) { try { AWSCredentials credentials = provider.getCredentials(); if (credentials instanceof IBMOAuthCredentials) { log.debug("Loading OAuth credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } if (credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) { log.debug("Loading credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } } catch (Exception e) { log.debug("Unable to load credentials from " + provider.toString() + ": " + e.getMessage()); } } throw new SdkClientException("Unable to load AWS credentials from any provider in the chain"); } }
AWSCredentialsProviderChain implements AWSCredentialsProvider { public AWSCredentials getCredentials() { if (reuseLastProvider && lastUsedProvider != null) { return lastUsedProvider.getCredentials(); } for (AWSCredentialsProvider provider : credentialsProviders) { try { AWSCredentials credentials = provider.getCredentials(); if (credentials instanceof IBMOAuthCredentials) { log.debug("Loading OAuth credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } if (credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) { log.debug("Loading credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } } catch (Exception e) { log.debug("Unable to load credentials from " + provider.toString() + ": " + e.getMessage()); } } throw new SdkClientException("Unable to load AWS credentials from any provider in the chain"); } AWSCredentialsProviderChain(List<? extends AWSCredentialsProvider> credentialsProviders); AWSCredentialsProviderChain(AWSCredentialsProvider... credentialsProviders); }
AWSCredentialsProviderChain implements AWSCredentialsProvider { public AWSCredentials getCredentials() { if (reuseLastProvider && lastUsedProvider != null) { return lastUsedProvider.getCredentials(); } for (AWSCredentialsProvider provider : credentialsProviders) { try { AWSCredentials credentials = provider.getCredentials(); if (credentials instanceof IBMOAuthCredentials) { log.debug("Loading OAuth credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } if (credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) { log.debug("Loading credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } } catch (Exception e) { log.debug("Unable to load credentials from " + provider.toString() + ": " + e.getMessage()); } } throw new SdkClientException("Unable to load AWS credentials from any provider in the chain"); } AWSCredentialsProviderChain(List<? extends AWSCredentialsProvider> credentialsProviders); AWSCredentialsProviderChain(AWSCredentialsProvider... credentialsProviders); boolean getReuseLastProvider(); void setReuseLastProvider(boolean b); AWSCredentials getCredentials(); void refresh(); }
AWSCredentialsProviderChain implements AWSCredentialsProvider { public AWSCredentials getCredentials() { if (reuseLastProvider && lastUsedProvider != null) { return lastUsedProvider.getCredentials(); } for (AWSCredentialsProvider provider : credentialsProviders) { try { AWSCredentials credentials = provider.getCredentials(); if (credentials instanceof IBMOAuthCredentials) { log.debug("Loading OAuth credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } if (credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) { log.debug("Loading credentials from " + provider.toString()); lastUsedProvider = provider; return credentials; } } catch (Exception e) { log.debug("Unable to load credentials from " + provider.toString() + ": " + e.getMessage()); } } throw new SdkClientException("Unable to load AWS credentials from any provider in the chain"); } AWSCredentialsProviderChain(List<? extends AWSCredentialsProvider> credentialsProviders); AWSCredentialsProviderChain(AWSCredentialsProvider... credentialsProviders); boolean getReuseLastProvider(); void setReuseLastProvider(boolean b); AWSCredentials getCredentials(); void refresh(); }
@Test public void testHmac() { JsonCredentialsProvider provider = newProvider(); JsonCredentials credentials = (JsonCredentials) provider.getCredentials(); Assert.assertEquals("vaws_access_key_id", credentials.getAWSAccessKeyId()); Assert.assertEquals("vaws_secret_access_key", credentials.getAWSSecretKey()); Assert.assertEquals(null, credentials.getApiKey()); Assert.assertEquals(null, credentials.getServiceInstanceId()); }
@Override public AWSCredentials getCredentials() { if (jsonConfigFile == null) { synchronized (this) { if (jsonConfigFile == null) { jsonConfigFile = new JsonConfigFile(); lastRefreshed = System.nanoTime(); } } } long now = System.nanoTime(); long age = now - lastRefreshed; if (age > refreshForceIntervalNanos) { refresh(); } else if (age > refreshIntervalNanos) { if (refreshSemaphore.tryAcquire()) { try { refresh(); } finally { refreshSemaphore.release(); } } } return jsonConfigFile.getCredentials(); }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { if (jsonConfigFile == null) { synchronized (this) { if (jsonConfigFile == null) { jsonConfigFile = new JsonConfigFile(); lastRefreshed = System.nanoTime(); } } } long now = System.nanoTime(); long age = now - lastRefreshed; if (age > refreshForceIntervalNanos) { refresh(); } else if (age > refreshIntervalNanos) { if (refreshSemaphore.tryAcquire()) { try { refresh(); } finally { refreshSemaphore.release(); } } } return jsonConfigFile.getCredentials(); } }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { if (jsonConfigFile == null) { synchronized (this) { if (jsonConfigFile == null) { jsonConfigFile = new JsonConfigFile(); lastRefreshed = System.nanoTime(); } } } long now = System.nanoTime(); long age = now - lastRefreshed; if (age > refreshForceIntervalNanos) { refresh(); } else if (age > refreshIntervalNanos) { if (refreshSemaphore.tryAcquire()) { try { refresh(); } finally { refreshSemaphore.release(); } } } return jsonConfigFile.getCredentials(); } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { if (jsonConfigFile == null) { synchronized (this) { if (jsonConfigFile == null) { jsonConfigFile = new JsonConfigFile(); lastRefreshed = System.nanoTime(); } } } long now = System.nanoTime(); long age = now - lastRefreshed; if (age > refreshForceIntervalNanos) { refresh(); } else if (age > refreshIntervalNanos) { if (refreshSemaphore.tryAcquire()) { try { refresh(); } finally { refreshSemaphore.release(); } } } return jsonConfigFile.getCredentials(); } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); @Override AWSCredentials getCredentials(); @Override void refresh(); long getRefreshIntervalNanos(); void setRefreshIntervalNanos(long refreshIntervalNanos); long getRefreshForceIntervalNanos(); void setRefreshForceIntervalNanos(long refreshForceIntervalNanos); @Override String toString(); }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { if (jsonConfigFile == null) { synchronized (this) { if (jsonConfigFile == null) { jsonConfigFile = new JsonConfigFile(); lastRefreshed = System.nanoTime(); } } } long now = System.nanoTime(); long age = now - lastRefreshed; if (age > refreshForceIntervalNanos) { refresh(); } else if (age > refreshIntervalNanos) { if (refreshSemaphore.tryAcquire()) { try { refresh(); } finally { refreshSemaphore.release(); } } } return jsonConfigFile.getCredentials(); } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); @Override AWSCredentials getCredentials(); @Override void refresh(); long getRefreshIntervalNanos(); void setRefreshIntervalNanos(long refreshIntervalNanos); long getRefreshForceIntervalNanos(); void setRefreshForceIntervalNanos(long refreshForceIntervalNanos); @Override String toString(); }
@Test public void testRefresh() throws Exception { File modifiable = File.createTempFile("UpdatableCredentials", ".json"); copyFile(JsonResourceLoader.basicCredentials().asFile(), modifiable); JsonCredentialsProvider testProvider = new JsonCredentialsProvider(modifiable.getPath()); JsonCredentials credentials = (JsonCredentials) testProvider.getCredentials(); Assert.assertEquals("vaws_access_key_id", credentials.getAWSAccessKeyId()); Assert.assertEquals("vaws_secret_access_key", credentials.getAWSSecretKey()); Thread.sleep(1000); copyFile(JsonResourceLoader.basicCredentials2().asFile(), modifiable); testProvider.setRefreshIntervalNanos(1l); JsonCredentials updated = (JsonCredentials) testProvider.getCredentials(); Assert.assertEquals("vaws_access_key_id_2", updated.getAWSAccessKeyId()); Assert.assertEquals("vaws_secret_access_key_2", updated.getAWSSecretKey()); }
@Override public void refresh() { if (jsonConfigFile != null) { jsonConfigFile.refresh(); lastRefreshed = System.nanoTime(); } }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public void refresh() { if (jsonConfigFile != null) { jsonConfigFile.refresh(); lastRefreshed = System.nanoTime(); } } }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public void refresh() { if (jsonConfigFile != null) { jsonConfigFile.refresh(); lastRefreshed = System.nanoTime(); } } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public void refresh() { if (jsonConfigFile != null) { jsonConfigFile.refresh(); lastRefreshed = System.nanoTime(); } } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); @Override AWSCredentials getCredentials(); @Override void refresh(); long getRefreshIntervalNanos(); void setRefreshIntervalNanos(long refreshIntervalNanos); long getRefreshForceIntervalNanos(); void setRefreshForceIntervalNanos(long refreshForceIntervalNanos); @Override String toString(); }
JsonCredentialsProvider implements AWSCredentialsProvider { @Override public void refresh() { if (jsonConfigFile != null) { jsonConfigFile.refresh(); lastRefreshed = System.nanoTime(); } } JsonCredentialsProvider(); JsonCredentialsProvider(String jsonConfigFilePath); JsonCredentialsProvider(JsonConfigFile jsonConfigFile); @Override AWSCredentials getCredentials(); @Override void refresh(); long getRefreshIntervalNanos(); void setRefreshIntervalNanos(long refreshIntervalNanos); long getRefreshForceIntervalNanos(); void setRefreshForceIntervalNanos(long refreshForceIntervalNanos); @Override String toString(); }
@Test (expected = AmazonClientException.class) public void testEnvVariableNotSet() { ContainerCredentialsProvider credentialsProvider = new ContainerCredentialsProvider(); credentialsProvider.getCredentials(); }
@Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
@Test public void getCredentialsWithCorruptResponseDoesNotIncludeCredentialsInExceptionMessage() { stubForCorruptedSuccessResponse(); try { containerCredentialsProvider.getCredentials(); Assert.fail(); } catch (Exception e) { String stackTrace = ExceptionUtils.getStackTrace(e); Assert.assertFalse(stackTrace.contains("ACCESS_KEY_ID")); Assert.assertFalse(stackTrace.contains("SECRET_ACCESS_KEY")); Assert.assertFalse(stackTrace.contains("TOKEN_TOKEN_TOKEN")); } }
@Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
@Test public void testGetCredentialsThrowsAceFor404ErrorResponse() { stubForErrorResponse(404); try { containerCredentialsProvider.getCredentials(); fail("The test should throw an exception"); } catch (AmazonClientException exception) { assertNotNull(exception.getMessage()); } }
@Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
@Test public void testGetCredentialsThrowsAseForNon200AndNon404ErrorResponse() { stubForErrorResponse(401); try { containerCredentialsProvider.getCredentials(); fail("The test should have thrown an exception"); } catch (AmazonServiceException exception) { assertEquals(401, exception.getStatusCode()); assertNotNull(exception.getMessage()); } }
@Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } ContainerCredentialsProvider(); @SdkInternalApi ContainerCredentialsProvider(CredentialsEndpointProvider credentailsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration(); }
@Test public void testAsperaTransactionCancel(){ transferListener = TransferListener.getInstance(xferId, null); AsperaTransfer asperaTransaction = new AsperaTransactionImpl(xferId, null, null, null, null, null); transferListener.transferReporter(xferId, msgQueued); transferListener.transferReporter(xferId, msgStats); assertTrue(asperaTransaction.cancel()); }
@Override public boolean cancel() { if (asperaFaspManagerWrapper.cancel(xferid)) { transferListener.removeAllTransactionSessions(xferid); return true; } else { return false; } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean cancel() { if (asperaFaspManagerWrapper.cancel(xferid)) { transferListener.removeAllTransactionSessions(xferid); return true; } else { return false; } } }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean cancel() { if (asperaFaspManagerWrapper.cancel(xferid)) { transferListener.removeAllTransactionSessions(xferid); return true; } else { return false; } } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean cancel() { if (asperaFaspManagerWrapper.cancel(xferid)) { transferListener.removeAllTransactionSessions(xferid); return true; } else { return false; } } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
AsperaTransactionImpl implements AsperaTransaction { @Override public boolean cancel() { if (asperaFaspManagerWrapper.cancel(xferid)) { transferListener.removeAllTransactionSessions(xferid); return true; } else { return false; } } AsperaTransactionImpl(String xferid, String bucketName, String key, String fileName, TransferProgress transferProgress, ProgressListenerChain listenerChain); @Override boolean pause(); @Override boolean resume(); @Override boolean cancel(); @Override boolean isDone(); @Override boolean progress(); @Override boolean onQueue(); @Override String getBucketName(); @Override String getKey(); @Override AsperaResult waitForCompletion(); @Override void addProgressListener(ProgressListener listener); @Override void removeProgressListener(ProgressListener listener); @Override ProgressListenerChain getProgressListenerChain(); @Override TransferProgress getProgress(); @Override ITransferListener getTransferListener(); }
@Test public void testNoMetadataService() throws Exception { stubForErrorResponse(); TestCredentialsProvider credentialsProvider = new TestCredentialsProvider(); try { credentialsProvider.getCredentials(); fail("Expected an AmazonClientException, but wasn't thrown"); } catch (AmazonClientException ace) { assertNotNull(ace.getMessage()); } stubForSuccessResonseWithCustomExpirationDate(200, new Date(System.currentTimeMillis() + ONE_MINUTE * 4).toString()); credentialsProvider.getCredentials(); credentialsProvider.setLastInstanceProfileCheck(new Date(System.currentTimeMillis() - (ONE_MINUTE * 61))); stubForErrorResponse(); try { credentialsProvider.getCredentials(); fail("Expected an AmazonClientException, but wasn't thrown"); } catch (AmazonClientException ace) { assertNotNull(ace.getMessage()); } }
@Override public String toString() { return "ContainerCredentialsFetcher"; }
ContainerCredentialsFetcher extends BaseCredentialsFetcher { @Override public String toString() { return "ContainerCredentialsFetcher"; } }
ContainerCredentialsFetcher extends BaseCredentialsFetcher { @Override public String toString() { return "ContainerCredentialsFetcher"; } ContainerCredentialsFetcher(CredentialsEndpointProvider credentialsEndpointProvider); }
ContainerCredentialsFetcher extends BaseCredentialsFetcher { @Override public String toString() { return "ContainerCredentialsFetcher"; } ContainerCredentialsFetcher(CredentialsEndpointProvider credentialsEndpointProvider); @Override String toString(); }
ContainerCredentialsFetcher extends BaseCredentialsFetcher { @Override public String toString() { return "ContainerCredentialsFetcher"; } ContainerCredentialsFetcher(CredentialsEndpointProvider credentialsEndpointProvider); @Override String toString(); }
@Test public void emptyClient() { AmazonWebServiceClient client = new AmazonWebServiceClient(new ClientConfiguration()) { }; try { client.getServiceName(); } catch (IllegalStateException exception) { } }
public String getServiceName() { return getServiceNameIntern(); }
AmazonWebServiceClient { public String getServiceName() { return getServiceNameIntern(); } }
AmazonWebServiceClient { public String getServiceName() { return getServiceNameIntern(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); }
AmazonWebServiceClient { public String getServiceName() { return getServiceNameIntern(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); }
AmazonWebServiceClient { public String getServiceName() { return getServiceNameIntern(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); @Deprecated static final boolean LOGGING_AWS_REQUEST_METRIC; }
@Test public void testOverrideSigner() { ClientConfiguration config = new ClientConfiguration(); config.setSignerOverride("QueryStringSignerType"); AmazonTestClient client = new AmazonTestClient(config); Assert.assertTrue(client.getSigner() instanceof QueryStringSigner); }
@Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); }
AmazonWebServiceClient { @Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); } }
AmazonWebServiceClient { @Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); }
AmazonWebServiceClient { @Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); }
AmazonWebServiceClient { @Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); @Deprecated static final boolean LOGGING_AWS_REQUEST_METRIC; }
@Test public void setServiceNameIntern() { AmazonTestClient client = new AmazonTestClient(); assertEquals(client.getServiceName(), client.getServiceNameIntern()); String serviceNameOverride = "foo"; assertFalse(serviceNameOverride.equals(client.getServiceName())); client.setServiceNameIntern(serviceNameOverride); assertEquals(serviceNameOverride, client.getServiceName()); }
public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; }
AmazonWebServiceClient { public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; } }
AmazonWebServiceClient { public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); }
AmazonWebServiceClient { public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); }
AmazonWebServiceClient { public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); @Deprecated static final boolean LOGGING_AWS_REQUEST_METRIC; }
@Test public void setEndpointPrefix() { AmazonTestClient client = new AmazonTestClient(); Assert.assertEquals(client.getServiceName(), client.getEndpointPrefix()); String endpointPrefixOverride = "foo"; Assert.assertNotEquals(endpointPrefixOverride, client.getServiceName()); client.setEndpointPrefix(endpointPrefixOverride); Assert.assertEquals(endpointPrefixOverride, client.getEndpointPrefix()); Assert.assertNotEquals(client.getEndpointPrefix(), client.getServiceName()); }
protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; }
AmazonWebServiceClient { protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; } }
AmazonWebServiceClient { protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); }
AmazonWebServiceClient { protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); }
AmazonWebServiceClient { protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); @Deprecated static final boolean LOGGING_AWS_REQUEST_METRIC; }
@Test public void connectionManagersAreUnregisteredFromIdleConnectionReaper() { IdleConnectionReaper.shutdown(); for (int count = 0; count < 100; count++) { new AmazonWebServiceClient(new ClientConfiguration()) { }.shutdown(); } assertEquals(0, IdleConnectionReaper.getRegisteredConnectionManagers().size()); }
public void shutdown() { client.shutdown(); }
AmazonWebServiceClient { public void shutdown() { client.shutdown(); } }
AmazonWebServiceClient { public void shutdown() { client.shutdown(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); }
AmazonWebServiceClient { public void shutdown() { client.shutdown(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); }
AmazonWebServiceClient { public void shutdown() { client.shutdown(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification); protected AmazonWebServiceClient(AwsSyncClientParams clientParams); @Deprecated void setEndpoint(String endpoint); Signer getSignerByURI(URI uri); @Deprecated void setRegion(Region region); @Deprecated final void configureRegion(Regions region); void shutdown(); @Deprecated void addRequestHandler(RequestHandler requestHandler); @Deprecated void addRequestHandler(RequestHandler2 requestHandler2); @Deprecated void removeRequestHandler(RequestHandler requestHandler); @Deprecated void removeRequestHandler(RequestHandler2 requestHandler2); void setTimeOffset(int timeOffset); AmazonWebServiceClient withTimeOffset(int timeOffset); int getTimeOffset(); RequestMetricCollector getRequestMetricsCollector(); String getServiceName(); String getEndpointPrefix(); final void setServiceNameIntern(String serviceName); final String getSignerRegionOverride(); final void setSignerRegionOverride(String signerRegionOverride); @Deprecated T withRegion(Region region); @Deprecated T withRegion(Regions region); @Deprecated T withEndpoint(String endpoint); @Deprecated @SdkInternalApi final void makeImmutable(); String getSignerOverride(); ClientConfiguration getClientConfiguration(); @Deprecated static final boolean LOGGING_AWS_REQUEST_METRIC; }
@Test public void testNullKPHeadersAreHandled() throws Exception { Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false); S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller); HttpResponse httpResponse = new HttpResponse(null, null); httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, null); httpResponse.addHeader(Headers.IBM_SSE_KP_CRK, null); InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());; httpResponse.setContent(is); AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse); assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null); assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false); }
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
@Test public void testEmptyKPHeadersAreHandled() throws Exception { Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false); S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller); HttpResponse httpResponse = new HttpResponse(null, null); InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());; httpResponse.setContent(is); AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse); assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null); assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false); }
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
@Test public void testDelegatingDnsResolverCallsResolveOnDelegate() throws Exception { final AtomicInteger timesCalled = new AtomicInteger(); DnsResolver delegate = new DnsResolver() { @Override public InetAddress[] resolve(String host) throws UnknownHostException { timesCalled.incrementAndGet(); return new InetAddress[0]; } }; org.apache.http.conn.DnsResolver resolver = new DelegatingDnsResolver(delegate); resolver.resolve("localhost"); assertEquals("Delegate Resolver should have been executed", 1, timesCalled.get()); }
@Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); }
DelegatingDnsResolver implements DnsResolver { @Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); } }
DelegatingDnsResolver implements DnsResolver { @Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); } DelegatingDnsResolver(com.ibm.cloud.objectstorage.DnsResolver delegate); }
DelegatingDnsResolver implements DnsResolver { @Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); } DelegatingDnsResolver(com.ibm.cloud.objectstorage.DnsResolver delegate); @Override InetAddress[] resolve(String host); }
DelegatingDnsResolver implements DnsResolver { @Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); } DelegatingDnsResolver(com.ibm.cloud.objectstorage.DnsResolver delegate); @Override InetAddress[] resolve(String host); }
@Test public void testOnlyKPEnabledHeaderIsSet() throws Exception { Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false); S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller); HttpResponse httpResponse = new HttpResponse(null, null); httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True"); InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());; httpResponse.setContent(is); AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse); assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null); assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true); }
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
@Test public void testOnlyCRKHeaderIsSet() throws Exception { Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false); S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller); HttpResponse httpResponse = new HttpResponse(null, null); httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "34567"); InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());; httpResponse.setContent(is); AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse); assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "34567"); assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false); }
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
S3XmlResponseHandler extends AbstractS3ResponseHandler<T> { public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); if (result instanceof ObjectListing) { if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){ ((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))); } if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) { ((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN)); } } } return awsResponse; } S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller); AmazonWebServiceResponse<T> handle(HttpResponse response); Map<String, String> getResponseHeaders(); }
@Test public void testReportFailureIsCalled() throws Exception{ UploadMonitor monitor = mock(UploadMonitor.class); CompleteMultipartUpload completeMultipartCopy = new CompleteMultipartUpload(null, null, null, null, null, null, monitor); try{ completeMultipartCopy.call(); } catch (Exception e){ } verify(monitor, times(1)).uploadFailure(); }
@Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.uploadFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } UploadResult uploadResult = new UploadResult(); uploadResult.setBucketName(origReq .getBucketName()); uploadResult.setKey(origReq.getKey()); uploadResult.setETag(res.getETag()); uploadResult.setVersionId(res.getVersionId()); monitor.uploadComplete(); return uploadResult; }
CompleteMultipartUpload implements Callable<UploadResult> { @Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.uploadFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } UploadResult uploadResult = new UploadResult(); uploadResult.setBucketName(origReq .getBucketName()); uploadResult.setKey(origReq.getKey()); uploadResult.setETag(res.getETag()); uploadResult.setVersionId(res.getVersionId()); monitor.uploadComplete(); return uploadResult; } }
CompleteMultipartUpload implements Callable<UploadResult> { @Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.uploadFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } UploadResult uploadResult = new UploadResult(); uploadResult.setBucketName(origReq .getBucketName()); uploadResult.setKey(origReq.getKey()); uploadResult.setETag(res.getETag()); uploadResult.setVersionId(res.getVersionId()); monitor.uploadComplete(); return uploadResult; } CompleteMultipartUpload(String uploadId, AmazonS3 s3, PutObjectRequest putObjectRequest, List<Future<PartETag>> futures, List<PartETag> eTagsBeforeResume, ProgressListenerChain progressListenerChain, UploadMonitor monitor); }
CompleteMultipartUpload implements Callable<UploadResult> { @Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.uploadFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } UploadResult uploadResult = new UploadResult(); uploadResult.setBucketName(origReq .getBucketName()); uploadResult.setKey(origReq.getKey()); uploadResult.setETag(res.getETag()); uploadResult.setVersionId(res.getVersionId()); monitor.uploadComplete(); return uploadResult; } CompleteMultipartUpload(String uploadId, AmazonS3 s3, PutObjectRequest putObjectRequest, List<Future<PartETag>> futures, List<PartETag> eTagsBeforeResume, ProgressListenerChain progressListenerChain, UploadMonitor monitor); @Override UploadResult call(); }
CompleteMultipartUpload implements Callable<UploadResult> { @Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.uploadFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } UploadResult uploadResult = new UploadResult(); uploadResult.setBucketName(origReq .getBucketName()); uploadResult.setKey(origReq.getKey()); uploadResult.setETag(res.getETag()); uploadResult.setVersionId(res.getVersionId()); monitor.uploadComplete(); return uploadResult; } CompleteMultipartUpload(String uploadId, AmazonS3 s3, PutObjectRequest putObjectRequest, List<Future<PartETag>> futures, List<PartETag> eTagsBeforeResume, ProgressListenerChain progressListenerChain, UploadMonitor monitor); @Override UploadResult call(); }
@Test public void testReportFailureIsCalled() throws Exception{ CopyMonitor monitor = mock(CopyMonitor.class); CompleteMultipartCopy completeMultipartCopy = new CompleteMultipartCopy(null, null, null, null, null, monitor); try{ completeMultipartCopy.call(); } catch (Exception e){ } verify(monitor, times(1)).reportFailure(); }
@Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.reportFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } CopyResult copyResult = new CopyResult(); copyResult.setSourceBucketName(origReq.getSourceBucketName()); copyResult.setSourceKey(origReq.getSourceKey()); copyResult.setDestinationBucketName(res .getBucketName()); copyResult.setDestinationKey(res.getKey()); copyResult.setETag(res.getETag()); copyResult.setVersionId(res.getVersionId()); monitor.copyComplete(); return copyResult; }
CompleteMultipartCopy implements Callable<CopyResult> { @Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.reportFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } CopyResult copyResult = new CopyResult(); copyResult.setSourceBucketName(origReq.getSourceBucketName()); copyResult.setSourceKey(origReq.getSourceKey()); copyResult.setDestinationBucketName(res .getBucketName()); copyResult.setDestinationKey(res.getKey()); copyResult.setETag(res.getETag()); copyResult.setVersionId(res.getVersionId()); monitor.copyComplete(); return copyResult; } }
CompleteMultipartCopy implements Callable<CopyResult> { @Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.reportFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } CopyResult copyResult = new CopyResult(); copyResult.setSourceBucketName(origReq.getSourceBucketName()); copyResult.setSourceKey(origReq.getSourceKey()); copyResult.setDestinationBucketName(res .getBucketName()); copyResult.setDestinationKey(res.getKey()); copyResult.setETag(res.getETag()); copyResult.setVersionId(res.getVersionId()); monitor.copyComplete(); return copyResult; } CompleteMultipartCopy(String uploadId, AmazonS3 s3, CopyObjectRequest copyObjectRequest, List<Future<PartETag>> futures, ProgressListenerChain progressListenerChain, CopyMonitor monitor); }
CompleteMultipartCopy implements Callable<CopyResult> { @Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.reportFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } CopyResult copyResult = new CopyResult(); copyResult.setSourceBucketName(origReq.getSourceBucketName()); copyResult.setSourceKey(origReq.getSourceKey()); copyResult.setDestinationBucketName(res .getBucketName()); copyResult.setDestinationKey(res.getKey()); copyResult.setETag(res.getETag()); copyResult.setVersionId(res.getVersionId()); monitor.copyComplete(); return copyResult; } CompleteMultipartCopy(String uploadId, AmazonS3 s3, CopyObjectRequest copyObjectRequest, List<Future<PartETag>> futures, ProgressListenerChain progressListenerChain, CopyMonitor monitor); @Override CopyResult call(); }
CompleteMultipartCopy implements Callable<CopyResult> { @Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) .withRequesterPays(origReq.isRequesterPays()) .withGeneralProgressListener(origReq.getGeneralProgressListener()) .withRequestMetricCollector(origReq.getRequestMetricCollector()) ; res = s3.completeMultipartUpload(req); } catch (Exception e) { monitor.reportFailure(); publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw e; } CopyResult copyResult = new CopyResult(); copyResult.setSourceBucketName(origReq.getSourceBucketName()); copyResult.setSourceKey(origReq.getSourceKey()); copyResult.setDestinationBucketName(res .getBucketName()); copyResult.setDestinationKey(res.getKey()); copyResult.setETag(res.getETag()); copyResult.setVersionId(res.getVersionId()); monitor.copyComplete(); return copyResult; } CompleteMultipartCopy(String uploadId, AmazonS3 s3, CopyObjectRequest copyObjectRequest, List<Future<PartETag>> futures, ProgressListenerChain progressListenerChain, CopyMonitor monitor); @Override CopyResult call(); }
@Test public void testRouteSimilarity() { String[] urls = new String[]{ "navigation/view1", "navigation/view2", "navigation/view3", "navigation/view4", "navigation/view5", "navigation/view6", "navigation/view7", "navigation/view8", "navigation/view9", "navigation" }; String currentRoutePart = "navigation"; RouteSimilarity r = Arrays.stream(urls) .map(s -> new RouteSimilarity(currentRoutePart, s)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)).get(); String result2 = urls[9]; Assert.assertEquals(r.getRouteString(), result2); }
public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> calculateSimilarity(routeAliasData.getUrl(), currentRoute)).max(Integer::compareTo).orElse(0); similarity = Math.max(urlSimilarity, routeAliasSimilarity); }
RouteSimilarity { public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> calculateSimilarity(routeAliasData.getUrl(), currentRoute)).max(Integer::compareTo).orElse(0); similarity = Math.max(urlSimilarity, routeAliasSimilarity); } }
RouteSimilarity { public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> calculateSimilarity(routeAliasData.getUrl(), currentRoute)).max(Integer::compareTo).orElse(0); similarity = Math.max(urlSimilarity, routeAliasSimilarity); } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); }
RouteSimilarity { public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> calculateSimilarity(routeAliasData.getUrl(), currentRoute)).max(Integer::compareTo).orElse(0); similarity = Math.max(urlSimilarity, routeAliasSimilarity); } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
RouteSimilarity { public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> calculateSimilarity(routeAliasData.getUrl(), currentRoute)).max(Integer::compareTo).orElse(0); similarity = Math.max(urlSimilarity, routeAliasSimilarity); } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
@Test public void testRouteSimilarity2() { String[] urls = new String[]{ "view1", "view2", "view3", "view4", "view5", "view6", "view7", "view8", "view9", "" }; String currentRoutePart = ""; RouteSimilarity r = Arrays.stream(urls) .map(s -> new RouteSimilarity(currentRoutePart, s)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)).get(); String result1 = r.getRouteString(); String result2 = urls[9]; Assert.assertEquals(result1, result2); }
public String getRouteString() { return routeString; }
RouteSimilarity { public String getRouteString() { return routeString; } }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
@Test public void testRouteSimilarity3() { String[] urls = new String[]{ "navigation/view2", "navigation2/view1", "navigation/view1", "navigation/view4", "navigation/view5", "navigation/view6", "navigation/view7", "navigation/view8", "navigation/view9", "navigation", }; String currentRoutePart = "navigation/view1"; RouteSimilarity r = Arrays.stream(urls) .map(s -> new RouteSimilarity(currentRoutePart, s)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)).get(); String result1 = r.getRouteString(); String result2 = urls[2]; Assert.assertEquals(result1, result2); }
public String getRouteString() { return routeString; }
RouteSimilarity { public String getRouteString() { return routeString; } }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
@Test public void getClosestRoute() { String[] urls = new String[]{ "navigation/view1", "navigation/view2", "navigation/view2/subview", "navigation/view3", "navigation/view4", "navigation/view5", "navigation/view6", "navigation/view7", "navigation/view8", "navigation/view9", "navigation" }; String currentRoutePart = "navigation/view2/subview"; RouteSimilarity res = UpNavigationHelper.getClosestRoute(currentRoutePart, urls).get(); String ress = res.getRouteString(); Assert.assertEquals(res.getRouteString(), "navigation/view2"); }
public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarity(routeData, url)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)); if (result.isPresent()) { return result; } } return Optional.empty(); }
UpNavigationHelper implements Serializable { public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarity(routeData, url)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)); if (result.isPresent()) { return result; } } return Optional.empty(); } }
UpNavigationHelper implements Serializable { public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarity(routeData, url)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)); if (result.isPresent()) { return result; } } return Optional.empty(); } private UpNavigationHelper(); }
UpNavigationHelper implements Serializable { public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarity(routeData, url)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)); if (result.isPresent()) { return result; } } return Optional.empty(); } private UpNavigationHelper(); static boolean routeHasUpNavigation(Class<? extends Component> navigationTarget); static UpNavigationHelper getUpNavigationHelper(); static void setUpNavigationHelper(); static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes); static void performUpNavigation(Class<? extends Component> currentNavigation); static Optional<RouteData> getClosestRoute(String url); static boolean shouldHighlight(Class<? extends Component> className, Location location); static void registerNavigationRoute(Class<? extends Component> className); void register(Class<? extends Component> className); }
UpNavigationHelper implements Serializable { public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarity(routeData, url)) .max(Comparator.comparingInt(RouteSimilarity::getSimilarity)); if (result.isPresent()) { return result; } } return Optional.empty(); } private UpNavigationHelper(); static boolean routeHasUpNavigation(Class<? extends Component> navigationTarget); static UpNavigationHelper getUpNavigationHelper(); static void setUpNavigationHelper(); static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes); static void performUpNavigation(Class<? extends Component> currentNavigation); static Optional<RouteData> getClosestRoute(String url); static boolean shouldHighlight(Class<? extends Component> className, Location location); static void registerNavigationRoute(Class<? extends Component> className); void register(Class<? extends Component> className); }
@Test public void valueAnEventHigherThanAnEventThatStartedBefore() { assertEquals(1, comparator.compare(eventInApril, eventInMarch)); assertEquals(-1, comparator.compare(eventInMarch, eventInApril)); assertEquals(0, comparator.compare(eventInMarch, eventInMarch)); }
@Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } @Override int compare(EventAdapter.Item event1, EventAdapter.Item event2); @Override boolean equals(Object obj); }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } @Override int compare(EventAdapter.Item event1, EventAdapter.Item event2); @Override boolean equals(Object obj); }
@Test public void valueAnEventLowerThanAnEventWithoutStartDate() { assertEquals(-1, comparator.compare(eventInApril, eventWithoutStartDate)); assertEquals(1, comparator.compare(eventWithoutStartDate, eventInApril)); assertEquals(0, comparator.compare(eventWithoutStartDate, eventWithoutStartDate)); }
@Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } @Override int compare(EventAdapter.Item event1, EventAdapter.Item event2); @Override boolean equals(Object obj); }
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { return -1; } else { return event1.getEvent().getStart().compareTo(event2.getEvent().getStart()); } } @Override int compare(EventAdapter.Item event1, EventAdapter.Item event2); @Override boolean equals(Object obj); }
@Test public void verifyAuthenticateSuccess() throws Exception { final HandlerResult result = alwaysPassHandler.authenticate(new UsernamePasswordCredential("a", "b")); assertEquals("TestAlwaysPassAuthenticationHandler", result.getHandlerName()); }
@Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
@Test(expected = FailedLoginException.class) public void examineAuthenticateFailure() throws Exception { alwaysFailHandler.authenticate(new UsernamePasswordCredential("a", "b")); }
@Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
@Test public void verifySupports() throws Exception { assertTrue(alwaysPassHandler.supports(new UsernamePasswordCredential("a", "b"))); assertTrue(alwaysFailHandler.supports(new UsernamePasswordCredential("a", "b"))); }
@Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
@Test public void verifyGetName() throws Exception { assertEquals("TestAlwaysPassAuthenticationHandler", alwaysPassHandler.getName()); assertEquals("TestAlwaysFailAuthenticationHandler", alwaysFailHandler.getName()); }
@Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } } }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy); LegacyAuthenticationHandlerAdapter( final org.jasig.cas.authentication.handler.AuthenticationHandler legacy, final CredentialsAdapter adapter); @Override HandlerResult authenticate(final Credential credential); @Override boolean supports(final Credential credential); @Override String getName(); }
@Test public void verifyCanHandle() { request.addParameter("openid.mode", "associate"); final boolean canHandle = smartOpenIdController.canHandle(request, response); request.removeParameter("openid.mode"); assertEquals(true, canHandle); }
@Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
@Test public void verifyCannotHandle() { request.addParameter("openid.mode", "anythingElse"); final boolean canHandle = smartOpenIdController.canHandle(request, response); request.removeParameter("openid.mode"); assertEquals(false, canHandle); }
@Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)) { logger.info("Handling request. openid.mode : {}", openIdMode); return true; } logger.info("Cannot handle request. openid.mode : {}", openIdMode); return false; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
@Test public void verifyGetAssociationResponse() { request.addParameter("openid.mode", "associate"); request.addParameter("openid.session_type", "DH-SHA1"); request.addParameter("openid.assoc_type", "HMAC-SHA1"); request.addParameter("openid.dh_consumer_public", "NzKoFMyrzFn/5iJFPdX6MVvNA/BChV1/sJdnYbupDn7ptn+cerwEzyFfWFx25KsoLSkxQCaSMmYtc1GPy/2GI1BSKSDhpdJmDBb" + "QRa/9Gs+giV/5fHcz/mHz8sREc7RTGI+0Ka9230arwrWt0fnoaJLRKEGUsmFR71rCo4EUOew="); final Map<String, String> assocResponse = smartOpenIdController.getAssociationResponse(request); assertTrue(assocResponse.containsKey("assoc_handle")); assertTrue(assocResponse.containsKey("expires_in")); assertTrue(assocResponse.containsKey("dh_server_public")); assertTrue(assocResponse.containsKey("enc_mac_key")); request.removeParameter("openid.mode"); }
public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? parameters.getParameterValue(OpenIdConstants.OPENID_MODE) : null; Message response = null; if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) { response = serverManager.associationResponse(parameters); } final Map<String, String> responseParams = new HashMap<>(); if (response != null) { responseParams.putAll(response.getParameterMap()); } return responseParams; }
SmartOpenIdController extends DelegateController implements Serializable { public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? parameters.getParameterValue(OpenIdConstants.OPENID_MODE) : null; Message response = null; if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) { response = serverManager.associationResponse(parameters); } final Map<String, String> responseParams = new HashMap<>(); if (response != null) { responseParams.putAll(response.getParameterMap()); } return responseParams; } }
SmartOpenIdController extends DelegateController implements Serializable { public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? parameters.getParameterValue(OpenIdConstants.OPENID_MODE) : null; Message response = null; if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) { response = serverManager.associationResponse(parameters); } final Map<String, String> responseParams = new HashMap<>(); if (response != null) { responseParams.putAll(response.getParameterMap()); } return responseParams; } }
SmartOpenIdController extends DelegateController implements Serializable { public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? parameters.getParameterValue(OpenIdConstants.OPENID_MODE) : null; Message response = null; if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) { response = serverManager.associationResponse(parameters); } final Map<String, String> responseParams = new HashMap<>(); if (response != null) { responseParams.putAll(response.getParameterMap()); } return responseParams; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
SmartOpenIdController extends DelegateController implements Serializable { public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? parameters.getParameterValue(OpenIdConstants.OPENID_MODE) : null; Message response = null; if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) { response = serverManager.associationResponse(parameters); } final Map<String, String> responseParams = new HashMap<>(); if (response != null) { responseParams.putAll(response.getParameterMap()); } return responseParams; } Map<String, String> getAssociationResponse(final HttpServletRequest request); @Override boolean canHandle(final HttpServletRequest request, final HttpServletResponse response); void setSuccessView(final String successView); void setFailureView(final String failureView); @NotNull void setServerManager(final ServerManager serverManager); }
@Test void testBundle() { final var context = new Context(); BundleLoader.loadSingle(context, CompositionBundle.class); assertThat(context.functions(), hasKey("composition")); assertThat(context.composition(), nullValue()); assertThat(context.variables(), allOf( not(hasKey("Width")), not(hasKey("Height")), not(hasKey("HalfWidth")), not(hasKey("HalfHeight")) )); context.functions().get("composition").execute(); assertThat(context.composition(), notNullValue()); assertThat(context.variables(), allOf( hasEntry("Width", NumberValue.of(1920)), hasEntry("Height", NumberValue.of(1080)), hasEntry("HalfWidth", NumberValue.of(960)), hasEntry("HalfHeight", NumberValue.of(540)) )); }
private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; } }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; } }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; } @Override Map<String, FunctionInfo> functionsInfo(); }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; } @Override Map<String, FunctionInfo> functionsInfo(); }
@Test void testTokenizeText() { assertThat(t("1 \" 1\n2 3 '\""), contains( tokenId(HotaruTokenId.NUMBER), tokenId(HotaruTokenId.TEXT) )); assertThat(t("1 ' 1\n2 3 ' 2"), contains( tokenId(HotaruTokenId.NUMBER), tokenId(HotaruTokenId.TEXT), tokenId(HotaruTokenId.NUMBER) )); assertThrows(LexerException.class, () -> { all("' ... "); }); assertThat(single("'\\\''").getText(), is("'")); assertThat(single("\'\\\"\'").getText(), is("\\\"")); assertThat(single("\"\\\"\"").getText(), is("\"")); assertThat(single("\"\\\'\"").getText(), is("\\\'")); }
private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } switch (current) { case '0': current = next(); buffer.append('\0'); continue; case 'b': current = next(); buffer.append('\b'); continue; case 'f': current = next(); buffer.append('\f'); continue; case 'n': current = next(); buffer.append('\n'); continue; case 'r': current = next(); buffer.append('\r'); continue; case 't': current = next(); buffer.append('\t'); continue; case 'u': int rollbackPosition = getPos(); while (current == 'u') { current = next(); } int escapedValue = 0; for (int i = 12; i >= 0 && escapedValue != -1; i -= 4) { if (isHexNumber(current)) { escapedValue |= (Character.digit(current, 16) << i); } else { escapedValue = -1; } current = next(); } if (escapedValue >= 0) { buffer.append((char) escapedValue); } else { buffer.append("\\u"); setPos(rollbackPosition); } continue; } buffer.append('\\'); continue; } if (current == openChar) break; if (current == '\0') { throw error("Reached end of file while parsing text"); } getBuffer().append(current); current = next(); } next(); int actualLength = getPos() - startPos; return addToken(HotaruTokenId.TEXT, getBuffer().toString(), actualLength); }
HotaruLexer extends Lexer { private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } switch (current) { case '0': current = next(); buffer.append('\0'); continue; case 'b': current = next(); buffer.append('\b'); continue; case 'f': current = next(); buffer.append('\f'); continue; case 'n': current = next(); buffer.append('\n'); continue; case 'r': current = next(); buffer.append('\r'); continue; case 't': current = next(); buffer.append('\t'); continue; case 'u': int rollbackPosition = getPos(); while (current == 'u') { current = next(); } int escapedValue = 0; for (int i = 12; i >= 0 && escapedValue != -1; i -= 4) { if (isHexNumber(current)) { escapedValue |= (Character.digit(current, 16) << i); } else { escapedValue = -1; } current = next(); } if (escapedValue >= 0) { buffer.append((char) escapedValue); } else { buffer.append("\\u"); setPos(rollbackPosition); } continue; } buffer.append('\\'); continue; } if (current == openChar) break; if (current == '\0') { throw error("Reached end of file while parsing text"); } getBuffer().append(current); current = next(); } next(); int actualLength = getPos() - startPos; return addToken(HotaruTokenId.TEXT, getBuffer().toString(), actualLength); } }
HotaruLexer extends Lexer { private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } switch (current) { case '0': current = next(); buffer.append('\0'); continue; case 'b': current = next(); buffer.append('\b'); continue; case 'f': current = next(); buffer.append('\f'); continue; case 'n': current = next(); buffer.append('\n'); continue; case 'r': current = next(); buffer.append('\r'); continue; case 't': current = next(); buffer.append('\t'); continue; case 'u': int rollbackPosition = getPos(); while (current == 'u') { current = next(); } int escapedValue = 0; for (int i = 12; i >= 0 && escapedValue != -1; i -= 4) { if (isHexNumber(current)) { escapedValue |= (Character.digit(current, 16) << i); } else { escapedValue = -1; } current = next(); } if (escapedValue >= 0) { buffer.append((char) escapedValue); } else { buffer.append("\\u"); setPos(rollbackPosition); } continue; } buffer.append('\\'); continue; } if (current == openChar) break; if (current == '\0') { throw error("Reached end of file while parsing text"); } getBuffer().append(current); current = next(); } next(); int actualLength = getPos() - startPos; return addToken(HotaruTokenId.TEXT, getBuffer().toString(), actualLength); } HotaruLexer(String input); }
HotaruLexer extends Lexer { private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } switch (current) { case '0': current = next(); buffer.append('\0'); continue; case 'b': current = next(); buffer.append('\b'); continue; case 'f': current = next(); buffer.append('\f'); continue; case 'n': current = next(); buffer.append('\n'); continue; case 'r': current = next(); buffer.append('\r'); continue; case 't': current = next(); buffer.append('\t'); continue; case 'u': int rollbackPosition = getPos(); while (current == 'u') { current = next(); } int escapedValue = 0; for (int i = 12; i >= 0 && escapedValue != -1; i -= 4) { if (isHexNumber(current)) { escapedValue |= (Character.digit(current, 16) << i); } else { escapedValue = -1; } current = next(); } if (escapedValue >= 0) { buffer.append((char) escapedValue); } else { buffer.append("\\u"); setPos(rollbackPosition); } continue; } buffer.append('\\'); continue; } if (current == openChar) break; if (current == '\0') { throw error("Reached end of file while parsing text"); } getBuffer().append(current); current = next(); } next(); int actualLength = getPos() - startPos; return addToken(HotaruTokenId.TEXT, getBuffer().toString(), actualLength); } HotaruLexer(String input); static List<Token> tokenize(String input); Token nextToken(); }
HotaruLexer extends Lexer { private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } switch (current) { case '0': current = next(); buffer.append('\0'); continue; case 'b': current = next(); buffer.append('\b'); continue; case 'f': current = next(); buffer.append('\f'); continue; case 'n': current = next(); buffer.append('\n'); continue; case 'r': current = next(); buffer.append('\r'); continue; case 't': current = next(); buffer.append('\t'); continue; case 'u': int rollbackPosition = getPos(); while (current == 'u') { current = next(); } int escapedValue = 0; for (int i = 12; i >= 0 && escapedValue != -1; i -= 4) { if (isHexNumber(current)) { escapedValue |= (Character.digit(current, 16) << i); } else { escapedValue = -1; } current = next(); } if (escapedValue >= 0) { buffer.append((char) escapedValue); } else { buffer.append("\\u"); setPos(rollbackPosition); } continue; } buffer.append('\\'); continue; } if (current == openChar) break; if (current == '\0') { throw error("Reached end of file while parsing text"); } getBuffer().append(current); current = next(); } next(); int actualLength = getPos() - startPos; return addToken(HotaruTokenId.TEXT, getBuffer().toString(), actualLength); } HotaruLexer(String input); static List<Token> tokenize(String input); Token nextToken(); }
@Test void testMapAccess() { Context context = new Context(); eval("A = {x: 0, y: 22, z: 0, text: 'hello'}\n" + "A.x = 20\n" + "A.z = A.y\n" + "A.newKey = 'newValue'", context); Value value = context.variables().get("A"); assertThat(value, instanceOf(MapValue.class)); Map<String, Value> map = ((MapValue) value).getMap(); assertThat(map, allOf( hasEntry("x", NumberValue.of(20)), hasEntry("y", NumberValue.of(22)), hasEntry("z", NumberValue.of(22)) )); assertThat(map, allOf( hasEntry("text", new StringValue("hello")), hasEntry("newKey", new StringValue("newValue")) )); }
@Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", node.start(), node.end())); }
InterpreterVisitor implements ResultVisitor<Value, Context> { @Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", node.start(), node.end())); } }
InterpreterVisitor implements ResultVisitor<Value, Context> { @Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", node.start(), node.end())); } }
InterpreterVisitor implements ResultVisitor<Value, Context> { @Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", node.start(), node.end())); } @Override Value visit(AccessNode node, Context context); @Override Value visit(ArrayNode node, Context context); @Override Value visit(AssignNode node, Context context); @Override Value visit(BlockNode node, Context context); @Override Value visit(FunctionNode node, Context context); @Override Value visit(MapNode node, Context context); @Override Value visit(PropertyNode node, Context context); @Override Value visit(UnaryNode node, Context context); @Override Value visit(UnitNode node, Context context); @Override Value visit(ValueNode node, Context context); @Override Value visit(VariableNode node, Context context); @Override Value get(AccessNode node, Context context); @Override Value set(AccessNode node, Value value, Context context); @Override Value get(VariableNode node, Context context); @Override Value set(VariableNode node, Value value, Context context); }
InterpreterVisitor implements ResultVisitor<Value, Context> { @Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", node.start(), node.end())); } @Override Value visit(AccessNode node, Context context); @Override Value visit(ArrayNode node, Context context); @Override Value visit(AssignNode node, Context context); @Override Value visit(BlockNode node, Context context); @Override Value visit(FunctionNode node, Context context); @Override Value visit(MapNode node, Context context); @Override Value visit(PropertyNode node, Context context); @Override Value visit(UnaryNode node, Context context); @Override Value visit(UnitNode node, Context context); @Override Value visit(ValueNode node, Context context); @Override Value visit(VariableNode node, Context context); @Override Value get(AccessNode node, Context context); @Override Value set(AccessNode node, Value value, Context context); @Override Value get(VariableNode node, Context context); @Override Value set(VariableNode node, Value value, Context context); }