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(expectedExceptions = UnrecoverableStoreException.class) public void shouldFailWhenValidatingPostProcessingUpdatingApplicationModelVersion() { SerializableSnapshot initialSnapshot = new SerializableSnapshot(); long initialSnapshotModelVersion = 10L; long finalSnapshotModelVersion = 9L; initialSnapshot.setApplicati...
SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model version differs among the stores"); Serial...
SnapshotPostProcessor { SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model version differs am...
SnapshotPostProcessor { SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model version differs am...
SnapshotPostProcessor { SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model version differs am...
SnapshotPostProcessor { SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model version differs am...
@Test public void shouldReleaseLatchOnSuccess() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, ALL_GOOD_RESPONSE_CONVERTER); final com.ning.http.client.Response response = new MockResponse(200, "ok", new FluentCaseInsensitiveStringsMap(), new byte[0]); handler.onCompleted(response); assertNotN...
@Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new StringBuilder(); for (String str : header.getValue()) { value.a...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfBaseStringIsEmpty() { service.getSignature(" ", "apiSecret", "tokenSecret"); }
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); return doSign(baseString, OAuthEncoder.encod...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfApiSecretIsNull() { service.getSignature("base string", null, "tokenSecret"); }
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); return doSign(baseString, OAuthEncoder.encod...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfApiSecretIsEmpty() { service.getSignature("base string", " ", "tokenSecret"); }
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); return doSign(baseString, OAuthEncoder.encod...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
@Test public void shouldReturnSignatureMethodString() { final String expected = "RSA-SHA1"; assertEquals(expected, service.getSignatureMethod()); }
@Override public String getSignatureMethod() { return METHOD; }
RSASha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } }
RSASha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } RSASha1SignatureService(PrivateKey privateKey); }
RSASha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } RSASha1SignatureService(PrivateKey privateKey); @Override String getSignature(String baseString, String apiSecret, String tokenSecret); @Override String getSignatureMethod(); }
RSASha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } RSASha1SignatureService(PrivateKey privateKey); @Override String getSignature(String baseString, String apiSecret, String tokenSecret); @Override String getSignatureMethod(); }
@Test public void shouldReturnSignature() { final String apiSecret = "api secret"; final String tokenSecret = "token secret"; final String baseString = "base string"; final String signature = "LUNRzQAlpdNyM9mLXm96Va6g/qVNnEAb7p7K1KM0g8IopOFQJPoOO7cvppgt7w3QyhijWJnCmvqXaaIAGrqvd" + "yr3fIzBULh8D/iZQUNLMi08GCOA34P81XBvsc...
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_64_ENCODER.encodeToString(signature.sign()); } catch (NoSuchAlgorith...
RSASha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_64_ENCODER.enc...
RSASha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_64_ENCODER.enc...
RSASha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_64_ENCODER.enc...
RSASha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_64_ENCODER.enc...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenAppendingNullMapToQuerystring() { params.appendTo(null); }
public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SEPARATOR) + query...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
@Test public void shouldAppendNothingToQuerystringIfGivenEmptyMap() { final String url = "http: Assert.assertEquals(url, params.appendTo(url)); }
public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SEPARATOR) + query...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SE...
@Test public void shouldReturnUrlParam() { final Token actual = new OAuth1AccessToken("acccess", "secret", "user_id=3107154759&screen_name=someuser&empty=&="); assertEquals("someuser", actual.getParameter("screen_name")); assertEquals("3107154759", actual.getParameter("user_id")); assertEquals(null, actual.getParameter...
public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; }
Token implements Serializable { public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; } }
Token implements Serializable { public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; } protected Token(String...
Token implements Serializable { public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; } protected Token(String...
Token implements Serializable { public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; } protected Token(String...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfParameterIsNotOAuth() { request.addOAuthParameter("otherParam", "value"); }
public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); }
OAuthRequest { public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); } }
OAuthRequest { public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); } OAuthRequest(Verb verb, String url); }
OAuthRequest { public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); } OAuthRequest(Verb verb, String url); void addOAuthParameter(String key, String value); Map<String, String> getOauthParameters(); void setRealm(String realm); String getRealm(); String getCompleteUrl(); ...
OAuthRequest { public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); } OAuthRequest(Verb verb, String url); void addOAuthParameter(String key, String value); Map<String, String> getOauthParameters(); void setRealm(String realm); String getRealm(); String getCompleteUrl(); ...
@Test public void testEmptyMultipartPayload() throws IOException { final MultipartPayload mP = new MultipartPayload(); final StringBuilder headersString = new StringBuilder(); for (Map.Entry<String, String> header : mP.getHeaders().entrySet()) { headersString.append(header.getKey()) .append(": ") .append(header.getValu...
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<BodyPartPayload> bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
@Test public void shouldReportOAuthException() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, OAUTH_EXCEPTION_RESPONSE_CONVERTER); final com.ning.http.client.Response response = new MockResponse(200, "ok", new FluentCaseInsensitiveStringsMap(), new byte[0]); handler.onCompleted(response); asse...
@Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new StringBuilder(); for (String str : header.getValue()) { value.a...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuilder value = new...
@Test public void testSimpleMultipartPayload() throws IOException { final Map<String, String> headers = new LinkedHashMap<>(); headers.put("X-Header", "X-Value"); headers.put("Content-Disposition", "Content-Disposition-Value"); final MultipartPayload mP = new MultipartPayload("mixed", "simple boundary", headers); mP.se...
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<BodyPartPayload> bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
@Test public void testCRLFMultipartPayload() throws IOException { final MultipartPayload mP = new MultipartPayload("simple-boundary"); mP.addBodyPart(new ByteArrayBodyPartPayload("It does NOT end with a linebreak.".getBytes())); mP.addBodyPart(new ByteArrayBodyPartPayload("It does end with a \\r linebreak.\r".getBytes(...
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<BodyPartPayload> bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
@Test public void testFileByteArrayBodyPartPayloadMultipartPayload() throws IOException { final MultipartPayload mP = new MultipartPayload("testFileByteArrayBodyPartPayloadMultipartPayload boundary"); mP.addBodyPart(new FileByteArrayBodyPartPayload("fileContent".getBytes(), "name", "filename.ext")); final StringBuilder...
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<BodyPartPayload> bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
@Test public void testComplexMultipartPayload() throws IOException { final MultipartPayload mP = new MultipartPayload("mixed", "unique-boundary-1"); mP.setPreamble("This is the preamble area of a multipart message.\n" + "Mail readers that understand multipart format\n" + "should ignore this preamble.\n" + "\n" + "If yo...
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<BodyPartPayload> bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
MultipartUtils { public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final String preamble = multipartPayload.getPreamble(); if (preamble != null) { os.write((preamble + "\r\n").getBytes()); } final List<Bod...
@Test public void testParseBoundaryFromHeader() { assertNull(MultipartUtils.parseBoundaryFromHeader(null)); assertEquals("0aA'()+_,-./:=?", MultipartUtils.parseBoundaryFromHeader("multipart/subtype; boundary=\"0aA'()+_,-./:=?\"")); assertEquals("0aA'()+_, -./:=?", MultipartUtils.parseBoundaryFromHeader("multipart/subty...
public static String parseBoundaryFromHeader(String contentTypeHeader) { if (contentTypeHeader == null) { return null; } final Matcher matcher = BOUNDARY_FROM_HEADER_REGEXP.matcher(contentTypeHeader); return matcher.find() ? matcher.group(1) : null; }
MultipartUtils { public static String parseBoundaryFromHeader(String contentTypeHeader) { if (contentTypeHeader == null) { return null; } final Matcher matcher = BOUNDARY_FROM_HEADER_REGEXP.matcher(contentTypeHeader); return matcher.find() ? matcher.group(1) : null; } }
MultipartUtils { public static String parseBoundaryFromHeader(String contentTypeHeader) { if (contentTypeHeader == null) { return null; } final Matcher matcher = BOUNDARY_FROM_HEADER_REGEXP.matcher(contentTypeHeader); return matcher.find() ? matcher.group(1) : null; } private MultipartUtils(); }
MultipartUtils { public static String parseBoundaryFromHeader(String contentTypeHeader) { if (contentTypeHeader == null) { return null; } final Matcher matcher = BOUNDARY_FROM_HEADER_REGEXP.matcher(contentTypeHeader); return matcher.find() ? matcher.group(1) : null; } private MultipartUtils(); static void checkBoundar...
MultipartUtils { public static String parseBoundaryFromHeader(String contentTypeHeader) { if (contentTypeHeader == null) { return null; } final Matcher matcher = BOUNDARY_FROM_HEADER_REGEXP.matcher(contentTypeHeader); return matcher.find() ? matcher.group(1) : null; } private MultipartUtils(); static void checkBoundar...
@Test public void testValidCheckBoundarySyntax() { MultipartUtils.checkBoundarySyntax("0aA'()+_,-./:=?"); MultipartUtils.checkBoundarySyntax("0aA'()+_,- ./:=?"); MultipartUtils.checkBoundarySyntax(" 0aA'()+_,-./:=?"); MultipartUtils.checkBoundarySyntax("123456789012345678901234567890123456789012345678901234567890123456...
public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } }
MultipartUtils { public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } } }
MultipartUtils { public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } } private MultipartUtils(); }
MultipartUtils { public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } } private MultipartUtils(); static void c...
MultipartUtils { public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } } private MultipartUtils(); static void c...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForNullObjects() { Preconditions.checkNotNull(null, ERROR_MSG); }
public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); }
Preconditions { public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); } }
Preconditions { public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); } }
Preconditions { public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
Preconditions { public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForNullStrings() { Preconditions.checkEmptyString(null, ERROR_MSG); }
public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForEmptyStrings() { Preconditions.checkEmptyString("", ERROR_MSG); }
public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForSpacesOnlyStrings() { Preconditions.checkEmptyString(" ", ERROR_MSG); }
public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
Preconditions { public static void checkEmptyString(String string, String errorMsg) { check(hasText(string), errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }
@Test public void testErrorExtraction() throws IOException { final FitBitJsonTokenExtractor extractor = new FitBitJsonTokenExtractor(); final OAuth2AccessTokenErrorResponse thrown = assertThrows(OAuth2AccessTokenErrorResponse.class, new ThrowingRunnable() { @Override public void run() throws Throwable { extractor.gener...
@Override public void generateError(String rawResponse) throws IOException { final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse) .get("errors").get(0); OAuth2Error errorCode; try { errorCode = OAuth2Error.parseFrom(extractRequiredParameter(errorNode, "errorType", rawResponse).a...
FitBitJsonTokenExtractor extends OAuth2AccessTokenJsonExtractor { @Override public void generateError(String rawResponse) throws IOException { final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse) .get("errors").get(0); OAuth2Error errorCode; try { errorCode = OAuth2Error.parseFr...
FitBitJsonTokenExtractor extends OAuth2AccessTokenJsonExtractor { @Override public void generateError(String rawResponse) throws IOException { final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse) .get("errors").get(0); OAuth2Error errorCode; try { errorCode = OAuth2Error.parseFr...
FitBitJsonTokenExtractor extends OAuth2AccessTokenJsonExtractor { @Override public void generateError(String rawResponse) throws IOException { final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse) .get("errors").get(0); OAuth2Error errorCode; try { errorCode = OAuth2Error.parseFr...
FitBitJsonTokenExtractor extends OAuth2AccessTokenJsonExtractor { @Override public void generateError(String rawResponse) throws IOException { final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse) .get("errors").get(0); OAuth2Error errorCode; try { errorCode = OAuth2Error.parseFr...
@Test public void shouldPercentEncodeString() { final String plain = "this is a test &^"; final String encoded = "this%20is%20a%20test%20%26%5E"; assertEquals(encoded, OAuthEncoder.encode(plain)); }
public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee); } for (Map.Ent...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
@Test public void shouldFormURLDecodeString() { final String encoded = "this+is+a+test+%26%5E"; final String plain = "this is a test &^"; assertEquals(plain, OAuthEncoder.decode(encoded)); }
public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } static ...
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } static ...
@Test public void shouldNotPercentEncodeReservedCharacters() { final String plain = "abcde123456-._~"; final String encoded = plain; assertEquals(encoded, OAuthEncoder.encode(plain)); }
public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee); } for (Map.Ent...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfStringToEncodeIsNull() { OAuthEncoder.encode(null); }
public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee); } for (Map.Ent...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfStringToDecodeIsNull() { OAuthEncoder.decode(null); }
public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } }
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } static ...
OAuthEncoder { public static String decode(String encoded) { Preconditions.checkNotNull(encoded, "Cannot decode null object"); try { return URLDecoder.decode(encoded, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while decoding string: " + CHARSET, uee); } } static ...
@Test public void shouldPercentEncodeCorrectlyTwitterCodingExamples() { final String[] sources = {"Ladies + Gentlemen", "An encoded string!", "Dogs, Cats & Mice"}; final String[] encoded = {"Ladies%20%2B%20Gentlemen", "An%20encoded%20string%21", "Dogs%2C%20Cats%20%26%20Mice"}; for (int i = 0; i < sources.length; i++) {...
public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee); } for (Map.Ent...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
OAuthEncoder { public static String encode(String plain) { Preconditions.checkNotNull(plain, "Cannot encode null object"); String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);...
@Test public void shouldCorrectlyDecodeAStream() throws IOException { final String value = "expected"; final InputStream is = new ByteArrayInputStream(value.getBytes()); final String decoded = StreamUtils.getStreamContents(is); assertEquals("expected", decoded); }
public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { read = in.read...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
@Test(expected = IllegalArgumentException.class) public void shouldFailForNullParameter() throws IOException { StreamUtils.getStreamContents(null); fail("Must throw exception before getting here"); }
public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { read = in.read...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
@Test(expected = IOException.class) public void shouldFailWithBrokenStream() throws IOException { StreamUtils.getStreamContents(ALLWAYS_ERROR_INPUT_STREAM); fail("Must throw exception before getting here"); }
public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { read = in.read...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
StreamUtils { public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { ...
@Test public void shouldExtractTokenFromOAuthStandardResponse() throws IOException { final String responseBody = "access_token=166942940015970|2.2ltzWXYNDjCtg5ZDVVJJeg__.3600.1295816400-548517159" + "|RsXNdKrpxg8L6QNLWcs2TVTmcaE"; final OAuth2AccessToken extracted; try (Response response = ok(responseBody)) { extracted...
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test public void shouldReleaseLatchOnSuccess() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, ALL_GOOD_RESPONSE_CONVERTER, future); call.enqueue(handler); final Request request = new Request.Builder().url("http: final okhttp3.Response response = new okhttp3.Response.Builder() .request(request...
@Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(response); okHttpFuture.setResult(t); if (callback != nul...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
@Test public void shouldExtractTokenFromResponseWithExpiresParam() throws IOException { final String responseBody = "access_token=166942940015970|2.2ltzWXYNDjCtg5ZDVVJJeg__.3600.1295816400-548517159" + "|RsXNdKrpxg8L6QNLWcs2TVTmcaE&expires_in=5108"; final OAuth2AccessToken extracted; try (Response response = ok(respons...
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test public void shouldExtractTokenFromResponseWithExpiresAndRefreshParam() throws IOException { final String responseBody = "access_token=166942940015970|2.2ltzWXYNDjCtg5ZDVVJJeg__.3600.1295816400-548517159" + "|RsXNdKrpxg8L6QNLWcs2TVTmcaE&expires_in=5108&token_type=bearer&refresh_token=166942940015970"; final OAuth2...
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test public void shouldExtractTokenFromResponseWithManyParameters() throws IOException { final String responseBody = "access_token=foo1234&other_stuff=yeah_we_have_this_too&number=42"; final OAuth2AccessToken extracted; try (Response response = ok(responseBody)) { extracted = extractor.extract(response); } assertEqual...
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfErrorResponse() throws IOException { final String responseBody = ""; try (Response response = error(responseBody)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfTokenIsAbsent() throws IOException { final String responseBody = "&expires=5108"; try (Response response = ok(responseBody)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfResponseIsNull() throws IOException { try (Response response = ok(null)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfResponseIsEmptyString() throws IOException { final String responseBody = ""; try (Response response = ok(responseBody)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't ex...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
OAuth2AccessTokenExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { if (response.getCode() != 200) { throw new OAuthException("Response code is not 200 but '" + response.getCode() + '\''); } final String body = response.getBody(); ...
@Test public void shouldParseResponse() throws IOException { final String responseBody = "{ \"access_token\":\"I0122HHJKLEM21F3WLPYHDKGKZULAUO4SGMV3ABKFTDT3T3X\", " + "\"token_type\":\"example\"}"; final OAuth2AccessToken token; try (Response response = ok(responseBody)) { token = extractor.extract(response); } assertE...
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test public void shouldParseScopeFromResponse() throws IOException { final String responseBody = "{ \"access_token\":\"I0122HHJKLEM21F3WLPYHDKGKZULAUO4SGMV3ABKFTDT3T4X\", " + "\"token_type\":\"example\"," + "\"scope\":\"s1\"}"; final OAuth2AccessToken token; try (Response response = ok(responseBody)) { token = extract...
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfForNullParameters() throws IOException { try (Response response = ok(null)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test public void shouldReleaseLatchOnIOException() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, EXCEPTION_RESPONSE_CONVERTER, future); call.enqueue(handler); final Request request = new Request.Builder().url("http: final okhttp3.Response response = new okhttp3.Response.Builder() .request(re...
@Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(response); okHttpFuture.setResult(t); if (callback != nul...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfForEmptyStrings() throws IOException { final String responseBody = ""; try (Response response = ok(responseBody)) { extractor.extract(response); } }
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test public void shouldThrowExceptionIfResponseIsError() throws IOException { final String responseBody = "{" + "\"error_description\":\"unknown, invalid, or expired refresh token\"," + "\"error\":\"invalid_grant\"" + "}"; try (Response response = error(responseBody)) { extractor.extract(response); fail(); } catch (OA...
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test public void testEscapedJsonInResponse() throws IOException { final String responseBody = "{ \"access_token\":\"I0122HKLEM2\\/MV3ABKFTDT3T5X\"," + "\"token_type\":\"example\"}"; final OAuth2AccessToken token; try (Response response = ok(responseBody)) { token = extractor.extract(response); } assertEquals("I0122HKL...
@Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (response.getCode() != 200) { generateError(body); } return createToken(body); }
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
OAuth2AccessTokenJsonExtractor implements TokenExtractor<OAuth2AccessToken> { @Override public OAuth2AccessToken extract(Response response) throws IOException { final String body = response.getBody(); Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string"); if (res...
@Test public void shouldProduceCorrectRequestSync() throws IOException, InterruptedException, ExecutionException { final OAuth20Service service = new ServiceBuilder("your_api_key") .apiSecret("your_api_secret") .build(new OAuth20ApiUnit()); final OAuth2AccessToken token = service.getAccessTokenPasswordGrant("user1", "p...
public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException { final OAuthRequest request = createAccessTokenPasswordGrantRequest(username, password, null); return sendAccessTokenRequestSync(request); }
OAuth20Service extends OAuthService { public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException { final OAuthRequest request = createAccessTokenPasswordGrantRequest(username, password, null); return sendAccessTokenRequestSync(requ...
OAuth20Service extends OAuthService { public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException { final OAuthRequest request = createAccessTokenPasswordGrantRequest(username, password, null); return sendAccessTokenRequestSync(requ...
OAuth20Service extends OAuthService { public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException { final OAuthRequest request = createAccessTokenPasswordGrantRequest(username, password, null); return sendAccessTokenRequestSync(requ...
OAuth20Service extends OAuthService { public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException { final OAuthRequest request = createAccessTokenPasswordGrantRequest(username, password, null); return sendAccessTokenRequestSync(requ...
@Test public void shouldProduceCorrectRequestAsync() throws ExecutionException, InterruptedException, IOException { final OAuth20Service service = new ServiceBuilder("your_api_key") .apiSecret("your_api_secret") .build(new OAuth20ApiUnit()); final OAuth2AccessToken token = service.getAccessTokenPasswordGrantAsync("user...
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password) { return getAccessTokenPasswordGrantAsync(username, password, (OAuthAsyncRequestCallback<OAuth2AccessToken>) null); }
OAuth20Service extends OAuthService { public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password) { return getAccessTokenPasswordGrantAsync(username, password, (OAuthAsyncRequestCallback<OAuth2AccessToken>) null); } }
OAuth20Service extends OAuthService { public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password) { return getAccessTokenPasswordGrantAsync(username, password, (OAuthAsyncRequestCallback<OAuth2AccessToken>) null); } OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret...
OAuth20Service extends OAuthService { public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password) { return getAccessTokenPasswordGrantAsync(username, password, (OAuthAsyncRequestCallback<OAuth2AccessToken>) null); } OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret...
OAuth20Service extends OAuthService { public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password) { return getAccessTokenPasswordGrantAsync(username, password, (OAuthAsyncRequestCallback<OAuth2AccessToken>) null); } OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret...
@Test public void testOAuthExtractAuthorization() { final OAuth20Service service = new ServiceBuilder("your_api_key") .apiSecret("your_api_secret") .build(new OAuth20ApiUnit()); OAuth2Authorization authorization = service.extractAuthorization("https: assertEquals("SplxlOB", authorization.getCode()); assertEquals("xyz",...
public OAuth2Authorization extractAuthorization(String redirectLocation) { final OAuth2Authorization authorization = new OAuth2Authorization(); int end = redirectLocation.indexOf('#'); if (end == -1) { end = redirectLocation.length(); } for (String param : redirectLocation.substring(redirectLocation.indexOf('?') + 1, e...
OAuth20Service extends OAuthService { public OAuth2Authorization extractAuthorization(String redirectLocation) { final OAuth2Authorization authorization = new OAuth2Authorization(); int end = redirectLocation.indexOf('#'); if (end == -1) { end = redirectLocation.length(); } for (String param : redirectLocation.substrin...
OAuth20Service extends OAuthService { public OAuth2Authorization extractAuthorization(String redirectLocation) { final OAuth2Authorization authorization = new OAuth2Authorization(); int end = redirectLocation.indexOf('#'); if (end == -1) { end = redirectLocation.length(); } for (String param : redirectLocation.substrin...
OAuth20Service extends OAuthService { public OAuth2Authorization extractAuthorization(String redirectLocation) { final OAuth2Authorization authorization = new OAuth2Authorization(); int end = redirectLocation.indexOf('#'); if (end == -1) { end = redirectLocation.length(); } for (String param : redirectLocation.substrin...
OAuth20Service extends OAuthService { public OAuth2Authorization extractAuthorization(String redirectLocation) { final OAuth2Authorization authorization = new OAuth2Authorization(); int end = redirectLocation.indexOf('#'); if (end == -1) { end = redirectLocation.length(); } for (String param : redirectLocation.substrin...
@Test public void shouldReportOAuthException() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, OAUTH_EXCEPTION_RESPONSE_CONVERTER, future); call.enqueue(handler); final Request request = new Request.Builder().url("http: final okhttp3.Response response = new okhttp3.Response.Builder() .request(r...
@Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(response); okHttpFuture.setResult(t); if (callback != nul...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
OAuthAsyncCompletionHandler implements Callback { @Override public void onResponse(Call call, okhttp3.Response okHttpResponse) { try { final Response response = OkHttpHttpClient.convertResponse(okHttpResponse); try { @SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(respons...
@Test public void shouldReleaseLatchOnFailure() throws Exception { handler = new OAuthAsyncCompletionHandler<>(callback, ALL_GOOD_RESPONSE_CONVERTER, future); call.enqueue(handler); handler.onFailure(call, new IOException()); assertNull(callback.getResponse()); assertNotNull(callback.getThrowable()); assertTrue(callbac...
@Override public void onFailure(Call call, IOException exception) { try { okHttpFuture.setException(exception); if (callback != null) { callback.onThrowable(exception); } } finally { okHttpFuture.finish(); } }
OAuthAsyncCompletionHandler implements Callback { @Override public void onFailure(Call call, IOException exception) { try { okHttpFuture.setException(exception); if (callback != null) { callback.onThrowable(exception); } } finally { okHttpFuture.finish(); } } }
OAuthAsyncCompletionHandler implements Callback { @Override public void onFailure(Call call, IOException exception) { try { okHttpFuture.setException(exception); if (callback != null) { callback.onThrowable(exception); } } finally { okHttpFuture.finish(); } } OAuthAsyncCompletionHandler(OAuthAsyncRequestCallback<T> cal...
OAuthAsyncCompletionHandler implements Callback { @Override public void onFailure(Call call, IOException exception) { try { okHttpFuture.setException(exception); if (callback != null) { callback.onThrowable(exception); } } finally { okHttpFuture.finish(); } } OAuthAsyncCompletionHandler(OAuthAsyncRequestCallback<T> cal...
OAuthAsyncCompletionHandler implements Callback { @Override public void onFailure(Call call, IOException exception) { try { okHttpFuture.setException(exception); if (callback != null) { callback.onThrowable(exception); } } finally { okHttpFuture.finish(); } } OAuthAsyncCompletionHandler(OAuthAsyncRequestCallback<T> cal...
@Test public void shouldReturnSignatureMethodString() { final String expected = "HMAC-SHA1"; assertEquals(expected, service.getSignatureMethod()); }
@Override public String getSignatureMethod() { return METHOD; }
HMACSha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } }
HMACSha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } }
HMACSha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } @Override String getSignature(String baseString, String apiSecret, String tokenSecret); @Override String getSignatureMethod(); }
HMACSha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } @Override String getSignature(String baseString, String apiSecret, String tokenSecret); @Override String getSignatureMethod(); }
@Test public void shouldReturnSignature() { final String apiSecret = "api secret"; final String tokenSecret = "token secret"; final String baseString = "base string"; final String signature = "uGymw2KHOTWI699YEaoi5xyLT50="; assertEquals(signature, service.getSignature(baseString, apiSecret, tokenSecret)); }
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); return doSign(baseString, OAuthEncoder.encod...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
@Test(expected = OAuthException.class) public void shouldThrowExceptionIfBaseStringIsNull() { service.getSignature(null, "apiSecret", "tokenSecret"); }
@Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); return doSign(baseString, OAuthEncoder.encod...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty...
@Test public void testPOSTRequestsWithWrongToken() throws Exception { this.mockMvc.perform(post("/test/csrf").param(TEST_TOKEN.getParameterName(), "WRONG_TOKEN")).andExpect( status().isBadRequest()); }
public String getParameterName() { return parameterName; }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
@Test public void testPUTRequestsWithWrongToken() throws Exception { this.mockMvc.perform(put("/test/csrf").param(TEST_TOKEN.getParameterName(), "WRONG_TOKEN")).andExpect( status().isBadRequest()); }
public String getParameterName() { return parameterName; }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
@Test public void testDELETERequestsWithWrongToken() throws Exception { this.mockMvc.perform(delete("/test/csrf").param(TEST_TOKEN.getParameterName(), "WRONG_TOKEN")).andExpect( status().isBadRequest()); }
public String getParameterName() { return parameterName; }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
CSRFToken implements Serializable { public String getParameterName() { return parameterName; } CSRFToken(String token); CSRFToken(String headerName, String parameterName, String token); String getHeaderName(); String getParameterName(); String getToken(); }
@Test public void testUpdate() { ExecutionLog original = ExecutionLog.newExecutionFor(TASK_NAME); repository.newExecution(original); assertEquals(original, repository.getLog(original.getTaskName(), original.getId()).get()); ExecutionLog log = original.withSuccess(); repository.update(log); assertEquals(log, repository....
@Override public void update(ExecutionLog log) { store(log, readJson(logFileFor(log.getTaskName(), log.getId())).map(obj -> obj.getAsJsonPrimitive("previous")).map( JsonPrimitive::getAsString)); }
FileSystemLogRepository implements ExecutionLogRepository { @Override public void update(ExecutionLog log) { store(log, readJson(logFileFor(log.getTaskName(), log.getId())).map(obj -> obj.getAsJsonPrimitive("previous")).map( JsonPrimitive::getAsString)); } }
FileSystemLogRepository implements ExecutionLogRepository { @Override public void update(ExecutionLog log) { store(log, readJson(logFileFor(log.getTaskName(), log.getId())).map(obj -> obj.getAsJsonPrimitive("previous")).map( JsonPrimitive::getAsString)); } FileSystemLogRepository(String basePath, int dispersionFactor);...
FileSystemLogRepository implements ExecutionLogRepository { @Override public void update(ExecutionLog log) { store(log, readJson(logFileFor(log.getTaskName(), log.getId())).map(obj -> obj.getAsJsonPrimitive("previous")).map( JsonPrimitive::getAsString)); } FileSystemLogRepository(String basePath, int dispersionFactor);...
FileSystemLogRepository implements ExecutionLogRepository { @Override public void update(ExecutionLog log) { store(log, readJson(logFileFor(log.getTaskName(), log.getId())).map(obj -> obj.getAsJsonPrimitive("previous")).map( JsonPrimitive::getAsString)); } FileSystemLogRepository(String basePath, int dispersionFactor);...
@Test public void testExecutionsFor() { ExecutionLog original = ExecutionLog.newExecutionFor(TASK_NAME); repository.newExecution(original); ExecutionLog newLog = ExecutionLog.newExecutionFor(TASK_NAME); repository.newExecution(newLog); assertTrue(repository.executionsFor(original.getTaskName(), Optional.empty(), Intege...
@Override public Stream<ExecutionLog> executionsFor(String taskName, Optional<String> start, int max) { String id; if (start.isPresent()) { id = start.get(); } else { JsonObject index = readIndexJson(); if (!index.has(taskName)) { return Stream.empty(); } id = index.get(taskName).getAsString(); } List<ExecutionLog> log...
FileSystemLogRepository implements ExecutionLogRepository { @Override public Stream<ExecutionLog> executionsFor(String taskName, Optional<String> start, int max) { String id; if (start.isPresent()) { id = start.get(); } else { JsonObject index = readIndexJson(); if (!index.has(taskName)) { return Stream.empty(); } id =...
FileSystemLogRepository implements ExecutionLogRepository { @Override public Stream<ExecutionLog> executionsFor(String taskName, Optional<String> start, int max) { String id; if (start.isPresent()) { id = start.get(); } else { JsonObject index = readIndexJson(); if (!index.has(taskName)) { return Stream.empty(); } id =...
FileSystemLogRepository implements ExecutionLogRepository { @Override public Stream<ExecutionLog> executionsFor(String taskName, Optional<String> start, int max) { String id; if (start.isPresent()) { id = start.get(); } else { JsonObject index = readIndexJson(); if (!index.has(taskName)) { return Stream.empty(); } id =...
FileSystemLogRepository implements ExecutionLogRepository { @Override public Stream<ExecutionLog> executionsFor(String taskName, Optional<String> start, int max) { String id; if (start.isPresent()) { id = start.get(); } else { JsonObject index = readIndexJson(); if (!index.has(taskName)) { return Stream.empty(); } id =...
@Test(expected = NullPointerException.class) public void testNullTaskName() { ExecutionLog.newExecutionFor(null); }
public static ExecutionLog newExecutionFor(String taskName) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.empty(), Optional.empty()); }
ExecutionLog { public static ExecutionLog newExecutionFor(String taskName) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.empty(), Option...
ExecutionLog { public static ExecutionLog newExecutionFor(String taskName) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.empty(), Option...
ExecutionLog { public static ExecutionLog newExecutionFor(String taskName) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.empty(), Option...
ExecutionLog { public static ExecutionLog newExecutionFor(String taskName) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.empty(), Option...
@Test(expected = NullPointerException.class) public void testNullTaskNameOnCustomTask() { ExecutionLog.newCustomExecution(null, "code", "myself"); }
public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.o...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
@Test(expected = NullPointerException.class) public void testNullCode() { ExecutionLog.newCustomExecution(TASK_NAME, null, "myself"); }
public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.o...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
@Test(expected = NullPointerException.class) public void testNullTaskNamesDontWork() { ExecutionLog.newCustomExecution(TASK_NAME, "code", null); }
public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostName(), Optional.o...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
ExecutionLog { public static ExecutionLog newCustomExecution(String taskName, String code, String user) { return new ExecutionLog(UUID.randomUUID().toString().replace("-", ""), DateTime.now(), Optional.empty(), TaskState.RUNNING, Objects.requireNonNull(taskName), Optional.empty(), Collections.emptySet(), computeHostNam...
@Test public void testEquals() { ExecutionLog log = ExecutionLog.newExecutionFor(TASK_NAME); ExecutionLog custom = ExecutionLog.newCustomExecution(TASK_NAME, "mycode", "myself"); assertEquals(log, log); assertNotEquals(log, log.withSuccess()); assertNotEquals(log, log.withFile("xpto")); assertNotEquals(log, log.withErr...
@Override public boolean equals(Object obj) { if (obj instanceof ExecutionLog) { ExecutionLog other = (ExecutionLog) obj; return Objects.equals(id, other.id) && Objects.equals(start, other.start) && Objects.equals(end, other.end) && Objects.equals(state, other.state) && Objects.equals(taskName, other.taskName) && Objec...
ExecutionLog { @Override public boolean equals(Object obj) { if (obj instanceof ExecutionLog) { ExecutionLog other = (ExecutionLog) obj; return Objects.equals(id, other.id) && Objects.equals(start, other.start) && Objects.equals(end, other.end) && Objects.equals(state, other.state) && Objects.equals(taskName, other.tas...
ExecutionLog { @Override public boolean equals(Object obj) { if (obj instanceof ExecutionLog) { ExecutionLog other = (ExecutionLog) obj; return Objects.equals(id, other.id) && Objects.equals(start, other.start) && Objects.equals(end, other.end) && Objects.equals(state, other.state) && Objects.equals(taskName, other.tas...
ExecutionLog { @Override public boolean equals(Object obj) { if (obj instanceof ExecutionLog) { ExecutionLog other = (ExecutionLog) obj; return Objects.equals(id, other.id) && Objects.equals(start, other.start) && Objects.equals(end, other.end) && Objects.equals(state, other.state) && Objects.equals(taskName, other.tas...
ExecutionLog { @Override public boolean equals(Object obj) { if (obj instanceof ExecutionLog) { ExecutionLog other = (ExecutionLog) obj; return Objects.equals(id, other.id) && Objects.equals(start, other.start) && Objects.equals(end, other.end) && Objects.equals(state, other.state) && Objects.equals(taskName, other.tas...
@Test public void testTic() { GuitarString s = new GuitarString(11025); s.pluck(); double s1 = s.sample(); s.tic(); double s2 = s.sample(); s.tic(); double s3 = s.sample(); s.tic(); double s4 = s.sample(); s.tic(); double s5 = s.sample(); double expected = 0.996 * 0.5 * (s1 + s2); assertEquals(expected, s5, 0.001); }
public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); }
GuitarString { public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); } }
GuitarString { public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); } GuitarString(double frequency); }
GuitarString { public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); } GuitarString(double frequency); void pluck(); void tic(); double sample(); }
GuitarString { public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); } GuitarString(double frequency); void pluck(); void tic(); double sample(); }
@Test public void testChoose() { Plip p = new Plip(1.2); HashMap<Direction, Occupant> surrounded = new HashMap<Direction, Occupant>(); surrounded.put(Direction.TOP, new Impassible()); surrounded.put(Direction.BOTTOM, new Impassible()); surrounded.put(Direction.LEFT, new Impassible()); surrounded.put(Direction.RIGHT, ne...
public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> cloruses = getNeighborsOfType(neighbors, "clorus"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (energy > 1) { Direction moveDir = HugLi...
Plip extends Creature { public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> cloruses = getNeighborsOfType(neighbors, "clorus"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (energy > 1) { D...
Plip extends Creature { public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> cloruses = getNeighborsOfType(neighbors, "clorus"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (energy > 1) { D...
Plip extends Creature { public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> cloruses = getNeighborsOfType(neighbors, "clorus"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (energy > 1) { D...
Plip extends Creature { public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> cloruses = getNeighborsOfType(neighbors, "clorus"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (energy > 1) { D...
@Test public void verifyImmutability() { int r = 2; int c = 2; int[][] x = new int[r][c]; int cnt = 0; for (int i = 0; i < r; i += 1) { for (int j = 0; j < c; j += 1) { x[i][j] = cnt; cnt += 1; } } Board b = new Board(x); assertEquals("Your Board class is not being initialized with the right values.", 0, b.tileAt(0, 0)...
public int tileAt(int i, int j) { if (i < 0 || i >= N || j < 0 || j >= N) { throw new IndexOutOfBoundsException("Invalid row and/or column"); } return tiles[i][j]; }
Board implements WorldState { public int tileAt(int i, int j) { if (i < 0 || i >= N || j < 0 || j >= N) { throw new IndexOutOfBoundsException("Invalid row and/or column"); } return tiles[i][j]; } }
Board implements WorldState { public int tileAt(int i, int j) { if (i < 0 || i >= N || j < 0 || j >= N) { throw new IndexOutOfBoundsException("Invalid row and/or column"); } return tiles[i][j]; } Board(int[][] tiles); }
Board implements WorldState { public int tileAt(int i, int j) { if (i < 0 || i >= N || j < 0 || j >= N) { throw new IndexOutOfBoundsException("Invalid row and/or column"); } return tiles[i][j]; } Board(int[][] tiles); int tileAt(int i, int j); int size(); int hamming(); int manhattan(); int hashCode(); boolean equals(O...
Board implements WorldState { public int tileAt(int i, int j) { if (i < 0 || i >= N || j < 0 || j >= N) { throw new IndexOutOfBoundsException("Invalid row and/or column"); } return tiles[i][j]; } Board(int[][] tiles); int tileAt(int i, int j); int size(); int hamming(); int manhattan(); int hashCode(); boolean equals(O...
@Test public void testList() { IntList one = new IntList(1, null); IntList twoOne = new IntList(2, one); IntList threeTwoOne = new IntList(3, twoOne); IntList x = IntList.list(3, 2, 1); assertEquals(threeTwoOne, x); }
public static IntList list(Integer... args) { IntList result, p; if (args.length > 0) { result = new IntList(args[0], null); } else { return null; } int k; for (k = 1, p = result; k < args.length; k += 1, p = p.rest) { p.rest = new IntList(args[k], null); } return result; }
IntList { public static IntList list(Integer... args) { IntList result, p; if (args.length > 0) { result = new IntList(args[0], null); } else { return null; } int k; for (k = 1, p = result; k < args.length; k += 1, p = p.rest) { p.rest = new IntList(args[k], null); } return result; } }
IntList { public static IntList list(Integer... args) { IntList result, p; if (args.length > 0) { result = new IntList(args[0], null); } else { return null; } int k; for (k = 1, p = result; k < args.length; k += 1, p = p.rest) { p.rest = new IntList(args[k], null); } return result; } IntList(int first0, IntList rest0);...
IntList { public static IntList list(Integer... args) { IntList result, p; if (args.length > 0) { result = new IntList(args[0], null); } else { return null; } int k; for (k = 1, p = result; k < args.length; k += 1, p = p.rest) { p.rest = new IntList(args[k], null); } return result; } IntList(int first0, IntList rest0);...
IntList { public static IntList list(Integer... args) { IntList result, p; if (args.length > 0) { result = new IntList(args[0], null); } else { return null; } int k; for (k = 1, p = result; k < args.length; k += 1, p = p.rest) { p.rest = new IntList(args[k], null); } return result; } IntList(int first0, IntList rest0);...
@Test public void testdSquareList() { IntList L = IntList.list(1, 2, 3); IntList.dSquareList(L); assertEquals(IntList.list(1, 4, 9), L); }
public static void dSquareList(IntList L) { while (L != null) { L.first = L.first * L.first; L = L.rest; } }
IntList { public static void dSquareList(IntList L) { while (L != null) { L.first = L.first * L.first; L = L.rest; } } }
IntList { public static void dSquareList(IntList L) { while (L != null) { L.first = L.first * L.first; L = L.rest; } } IntList(int first0, IntList rest0); IntList(); }
IntList { public static void dSquareList(IntList L) { while (L != null) { L.first = L.first * L.first; L = L.rest; } } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenat...
IntList { public static void dSquareList(IntList L) { while (L != null) { L.first = L.first * L.first; L = L.rest; } } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenat...
@Test public void testSquareListRecursive() { IntList L = IntList.list(1, 2, 3); IntList res = IntList.squareListRecursive(L); assertEquals(IntList.list(1, 2, 3), L); assertEquals(IntList.list(1, 4, 9), res); }
public static IntList squareListRecursive(IntList L) { if (L == null) { return null; } return new IntList(L.first * L.first, squareListRecursive(L.rest)); }
IntList { public static IntList squareListRecursive(IntList L) { if (L == null) { return null; } return new IntList(L.first * L.first, squareListRecursive(L.rest)); } }
IntList { public static IntList squareListRecursive(IntList L) { if (L == null) { return null; } return new IntList(L.first * L.first, squareListRecursive(L.rest)); } IntList(int first0, IntList rest0); IntList(); }
IntList { public static IntList squareListRecursive(IntList L) { if (L == null) { return null; } return new IntList(L.first * L.first, squareListRecursive(L.rest)); } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareL...
IntList { public static IntList squareListRecursive(IntList L) { if (L == null) { return null; } return new IntList(L.first * L.first, squareListRecursive(L.rest)); } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareL...
@Test public void testDcatenate() { IntList A = IntList.list(1, 2, 3); IntList B = IntList.list(4, 5, 6); IntList exp = IntList.list(1, 2, 3, 4, 5, 6); assertEquals(exp, IntList.dcatenate(A, B)); assertEquals(IntList.list(1, 2, 3, 4, 5, 6), A); }
public static IntList dcatenate(IntList A, IntList B) { return null; }
IntList { public static IntList dcatenate(IntList A, IntList B) { return null; } }
IntList { public static IntList dcatenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); }
IntList { public static IntList dcatenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenate(IntList A, IntList B); static IntLis...
IntList { public static IntList dcatenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenate(IntList A, IntList B); static IntLis...
@Test public void testCatenate() { IntList A = IntList.list(1, 2, 3); IntList B = IntList.list(4, 5, 6); IntList exp = IntList.list(1, 2, 3, 4, 5, 6); assertEquals(exp, IntList.catenate(A, B)); assertEquals(IntList.list(1, 2, 3), A); }
public static IntList catenate(IntList A, IntList B) { return null; }
IntList { public static IntList catenate(IntList A, IntList B) { return null; } }
IntList { public static IntList catenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); }
IntList { public static IntList catenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenate(IntList A, IntList B); static IntList...
IntList { public static IntList catenate(IntList A, IntList B) { return null; } IntList(int first0, IntList rest0); IntList(); static void dSquareList(IntList L); static IntList squareListIterative(IntList L); static IntList squareListRecursive(IntList L); static IntList dcatenate(IntList A, IntList B); static IntList...
@Test public void solveBoard() { List<String> boardLines = null; List<String> dictionaryWords = null; try { boardLines = Files.readAllLines(Paths.get("testBoggle")); dictionaryWords = Files.readAllLines(Paths.get("words")); } catch (IOException e) { e.printStackTrace(); } Board board = new Board(boardLines, dictionaryW...
public static String answerString(List<String> answers, int numberOfAnswers) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < answers.size() && i < numberOfAnswers; i++) { sb.append(answers.get(i)).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); }
Boggle { public static String answerString(List<String> answers, int numberOfAnswers) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < answers.size() && i < numberOfAnswers; i++) { sb.append(answers.get(i)).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } }
Boggle { public static String answerString(List<String> answers, int numberOfAnswers) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < answers.size() && i < numberOfAnswers; i++) { sb.append(answers.get(i)).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } }
Boggle { public static String answerString(List<String> answers, int numberOfAnswers) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < answers.size() && i < numberOfAnswers; i++) { sb.append(answers.get(i)).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } static void main(String[] ar...
Boggle { public static String answerString(List<String> answers, int numberOfAnswers) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < answers.size() && i < numberOfAnswers; i++) { sb.append(answers.get(i)).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } static void main(String[] ar...
@Test public void testProduct() { assertEquals(30, Arithmetic.product(5, 6)); assertEquals(-30, Arithmetic.product(5, -6)); assertEquals(0, Arithmetic.product(0, -6)); }
public static int product(int a, int b) { return a * b; }
Arithmetic { public static int product(int a, int b) { return a * b; } }
Arithmetic { public static int product(int a, int b) { return a * b; } }
Arithmetic { public static int product(int a, int b) { return a * b; } static int product(int a, int b); static int sum(int a, int b); }
Arithmetic { public static int product(int a, int b) { return a * b; } static int product(int a, int b); static int sum(int a, int b); }
@Test public void testSum() { assertEquals(11, Arithmetic.sum(5, 6)); assertEquals(-1, Arithmetic.sum(5, -6)); assertEquals(-6, Arithmetic.sum(0, -6)); assertEquals(0, Arithmetic.sum(6, -6)); }
public static int sum(int a, int b) { return a * b; }
Arithmetic { public static int sum(int a, int b) { return a * b; } }
Arithmetic { public static int sum(int a, int b) { return a * b; } }
Arithmetic { public static int sum(int a, int b) { return a * b; } static int product(int a, int b); static int sum(int a, int b); }
Arithmetic { public static int sum(int a, int b) { return a * b; } static int product(int a, int b); static int sum(int a, int b); }
@Test public void getWordsContainingPrefix() { Trie trie = new Trie(); trie.add("app"); trie.add("appearance"); trie.add("apple"); trie.add("appliance"); trie.add("application"); trie.add("montclair"); trie.add("mountain"); List<String> wordsContainingPrefix = trie.getWordsContainingPrefix("foster"); assertEquals(0, wo...
public List<String> getWordsContainingPrefix(String prefix) { LinkedList<String> words = new LinkedList<>(); Node pointer = root; for (int i = 0; i < prefix.length(); i++) { char currentChar = prefix.charAt(i); if (!pointer.children.containsKey(currentChar)) { return words; } pointer = pointer.children.get(currentChar)...
Trie { public List<String> getWordsContainingPrefix(String prefix) { LinkedList<String> words = new LinkedList<>(); Node pointer = root; for (int i = 0; i < prefix.length(); i++) { char currentChar = prefix.charAt(i); if (!pointer.children.containsKey(currentChar)) { return words; } pointer = pointer.children.get(curre...
Trie { public List<String> getWordsContainingPrefix(String prefix) { LinkedList<String> words = new LinkedList<>(); Node pointer = root; for (int i = 0; i < prefix.length(); i++) { char currentChar = prefix.charAt(i); if (!pointer.children.containsKey(currentChar)) { return words; } pointer = pointer.children.get(curre...
Trie { public List<String> getWordsContainingPrefix(String prefix) { LinkedList<String> words = new LinkedList<>(); Node pointer = root; for (int i = 0; i < prefix.length(); i++) { char currentChar = prefix.charAt(i); if (!pointer.children.containsKey(currentChar)) { return words; } pointer = pointer.children.get(curre...
Trie { public List<String> getWordsContainingPrefix(String prefix) { LinkedList<String> words = new LinkedList<>(); Node pointer = root; for (int i = 0; i < prefix.length(); i++) { char currentChar = prefix.charAt(i); if (!pointer.children.containsKey(currentChar)) { return words; } pointer = pointer.children.get(curre...
@Test public void bestPrefixMatchWithExactMatches() { System.out.println("Testing that bestPrefixMatch works with exact matches."); Map<Character, Integer> frequencyTable = new HashMap<Character, Integer>(); frequencyTable.put('a', 1); frequencyTable.put('b', 2); frequencyTable.put('c', 4); frequencyTable.put('d', 5); ...
public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer = pointer.leftChild; } else if (query...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
@Test public void bestPrefixMatchWithLongerBitSequences() { System.out.println("Testing that bestPrefixMatch works with long string matches."); Map<Character, Integer> frequencyTable = new HashMap<Character, Integer>(); frequencyTable.put('a', 1); frequencyTable.put('b', 2); frequencyTable.put('c', 4); frequencyTable.p...
public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer = pointer.leftChild; } else if (query...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
BinaryTrie implements Serializable { public Match longestPrefixMatch(BitSequence querySequence) { StringBuilder currentBitSeq = new StringBuilder(); Node pointer = root; for (int i = 0; i < querySequence.length(); i++) { if (querySequence.bitAt(i) == 0 && pointer.leftChild != null) { currentBitSeq.append('0'); pointer ...
@Test public void testYourLookupTable() { System.out.println("Testing that your code outputs the right lookup table."); Map<Character, Integer> frequencyTable = new HashMap<Character, Integer>(); frequencyTable.put('a', 1); frequencyTable.put('b', 2); frequencyTable.put('c', 4); frequencyTable.put('d', 5); frequencyTab...
public Map<Character, BitSequence> buildLookupTable() { Map<Character, BitSequence> lookupTable = new HashMap<>(); Map<Node, String> nodeBitPrefixTable = new HashMap<>(); nodeBitPrefixTable.put(root, ""); Stack<Node> nodeStack = new Stack<>(); nodeStack.push(root); while (!nodeStack.isEmpty()) { Node pointer = nodeStac...
BinaryTrie implements Serializable { public Map<Character, BitSequence> buildLookupTable() { Map<Character, BitSequence> lookupTable = new HashMap<>(); Map<Node, String> nodeBitPrefixTable = new HashMap<>(); nodeBitPrefixTable.put(root, ""); Stack<Node> nodeStack = new Stack<>(); nodeStack.push(root); while (!nodeStack...
BinaryTrie implements Serializable { public Map<Character, BitSequence> buildLookupTable() { Map<Character, BitSequence> lookupTable = new HashMap<>(); Map<Node, String> nodeBitPrefixTable = new HashMap<>(); nodeBitPrefixTable.put(root, ""); Stack<Node> nodeStack = new Stack<>(); nodeStack.push(root); while (!nodeStack...
BinaryTrie implements Serializable { public Map<Character, BitSequence> buildLookupTable() { Map<Character, BitSequence> lookupTable = new HashMap<>(); Map<Node, String> nodeBitPrefixTable = new HashMap<>(); nodeBitPrefixTable.put(root, ""); Stack<Node> nodeStack = new Stack<>(); nodeStack.push(root); while (!nodeStack...
BinaryTrie implements Serializable { public Map<Character, BitSequence> buildLookupTable() { Map<Character, BitSequence> lookupTable = new HashMap<>(); Map<Node, String> nodeBitPrefixTable = new HashMap<>(); nodeBitPrefixTable.put(root, ""); Stack<Node> nodeStack = new Stack<>(); nodeStack.push(root); while (!nodeStack...
@Test public void testSmall() { Dog d = new Dog(3); assertEquals("yip", d.noise()); }
public String noise() { if (size < 10) { return "yip"; } return "bark"; }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); String noise(); }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); String noise(); }
@Test public void testLarge() { Dog d = new Dog(20); assertEquals("bark", d.noise()); }
public String noise() { if (size < 10) { return "yip"; } return "bark"; }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); String noise(); }
Dog { public String noise() { if (size < 10) { return "yip"; } return "bark"; } Dog(int s); String noise(); }
@Test public void testEquals() { SimpleOomage ooA = new SimpleOomage(5, 10, 20); SimpleOomage ooA2 = new SimpleOomage(5, 10, 20); SimpleOomage ooB = new SimpleOomage(50, 50, 50); assertEquals(ooA, ooA2); assertNotEquals(ooA, ooB); assertNotEquals(ooA2, ooB); assertNotEquals(ooA, "ketchup"); }
@Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } if (this == o || this.hashCode() == o.hashCode()) { return true; } return false; }
SimpleOomage implements Oomage { @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } if (this == o || this.hashCode() == o.hashCode()) { return true; } return false; } }
SimpleOomage implements Oomage { @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } if (this == o || this.hashCode() == o.hashCode()) { return true; } return false; } SimpleOomage(int r, int g, int b); }
SimpleOomage implements Oomage { @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } if (this == o || this.hashCode() == o.hashCode()) { return true; } return false; } SimpleOomage(int r, int g, int b); @Override boolean equals(Object o); @Override int hashCode(); ...
SimpleOomage implements Oomage { @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } if (this == o || this.hashCode() == o.hashCode()) { return true; } return false; } SimpleOomage(int r, int g, int b); @Override boolean equals(Object o); @Override int hashCode(); ...
@Test public void testRandomOomagesHashCodeSpread() { List<Oomage> oomages = new ArrayList<>(); int N = 10000; for (int i = 0; i < N; i += 1) { oomages.add(SimpleOomage.randomSimpleOomage()); } assertTrue(OomageTestUtility.haveNiceHashCodeSpread(oomages, 10)); }
public static SimpleOomage randomSimpleOomage() { int red = StdRandom.uniform(0, 51) * 5; int green = StdRandom.uniform(0, 51) * 5; int blue = StdRandom.uniform(0, 51) * 5; return new SimpleOomage(red, green, blue); }
SimpleOomage implements Oomage { public static SimpleOomage randomSimpleOomage() { int red = StdRandom.uniform(0, 51) * 5; int green = StdRandom.uniform(0, 51) * 5; int blue = StdRandom.uniform(0, 51) * 5; return new SimpleOomage(red, green, blue); } }
SimpleOomage implements Oomage { public static SimpleOomage randomSimpleOomage() { int red = StdRandom.uniform(0, 51) * 5; int green = StdRandom.uniform(0, 51) * 5; int blue = StdRandom.uniform(0, 51) * 5; return new SimpleOomage(red, green, blue); } SimpleOomage(int r, int g, int b); }
SimpleOomage implements Oomage { public static SimpleOomage randomSimpleOomage() { int red = StdRandom.uniform(0, 51) * 5; int green = StdRandom.uniform(0, 51) * 5; int blue = StdRandom.uniform(0, 51) * 5; return new SimpleOomage(red, green, blue); } SimpleOomage(int r, int g, int b); @Override boolean equals(Object o)...
SimpleOomage implements Oomage { public static SimpleOomage randomSimpleOomage() { int red = StdRandom.uniform(0, 51) * 5; int green = StdRandom.uniform(0, 51) * 5; int blue = StdRandom.uniform(0, 51) * 5; return new SimpleOomage(red, green, blue); } SimpleOomage(int r, int g, int b); @Override boolean equals(Object o)...
@Test public void testRandomOomagesHashCodeSpread() { List<Oomage> oomages = new ArrayList<>(); int N = 10000; for (int i = 0; i < N; i += 1) { oomages.add(ComplexOomage.randomComplexOomage()); } assertTrue(OomageTestUtility.haveNiceHashCodeSpread(oomages, 10)); }
public static ComplexOomage randomComplexOomage() { int N = StdRandom.uniform(1, 10); ArrayList<Integer> params = new ArrayList<>(N); for (int i = 0; i < N; i += 1) { params.add(StdRandom.uniform(0, 255)); } return new ComplexOomage(params); }
ComplexOomage implements Oomage { public static ComplexOomage randomComplexOomage() { int N = StdRandom.uniform(1, 10); ArrayList<Integer> params = new ArrayList<>(N); for (int i = 0; i < N; i += 1) { params.add(StdRandom.uniform(0, 255)); } return new ComplexOomage(params); } }
ComplexOomage implements Oomage { public static ComplexOomage randomComplexOomage() { int N = StdRandom.uniform(1, 10); ArrayList<Integer> params = new ArrayList<>(N); for (int i = 0; i < N; i += 1) { params.add(StdRandom.uniform(0, 255)); } return new ComplexOomage(params); } ComplexOomage(List<Integer> params); }
ComplexOomage implements Oomage { public static ComplexOomage randomComplexOomage() { int N = StdRandom.uniform(1, 10); ArrayList<Integer> params = new ArrayList<>(N); for (int i = 0; i < N; i += 1) { params.add(StdRandom.uniform(0, 255)); } return new ComplexOomage(params); } ComplexOomage(List<Integer> params); @Over...
ComplexOomage implements Oomage { public static ComplexOomage randomComplexOomage() { int N = StdRandom.uniform(1, 10); ArrayList<Integer> params = new ArrayList<>(N); for (int i = 0; i < N; i += 1) { params.add(StdRandom.uniform(0, 255)); } return new ComplexOomage(params); } ComplexOomage(List<Integer> params); @Over...
@Test public void testReplicate() { Clorus c = new Clorus(2); Clorus offspring = c.replicate(); assertEquals(1, c.energy(), 0.01); assertEquals(1, offspring.energy(), 0.01); assertNotSame(c, offspring); }
@Override public Clorus replicate() { energy /= 2; return new Clorus(energy); }
Clorus extends Creature { @Override public Clorus replicate() { energy /= 2; return new Clorus(energy); } }
Clorus extends Creature { @Override public Clorus replicate() { energy /= 2; return new Clorus(energy); } Clorus(double energy); }
Clorus extends Creature { @Override public Clorus replicate() { energy /= 2; return new Clorus(energy); } Clorus(double energy); @Override void move(); @Override void attack(Creature c); @Override Clorus replicate(); @Override void stay(); @Override Action chooseAction(Map<Direction, Occupant> neighbors); @Override Col...
Clorus extends Creature { @Override public Clorus replicate() { energy /= 2; return new Clorus(energy); } Clorus(double energy); @Override void move(); @Override void attack(Creature c); @Override Clorus replicate(); @Override void stay(); @Override Action chooseAction(Map<Direction, Occupant> neighbors); @Override Col...
@Test public void testChoose() { Clorus c = new Clorus(5); HashMap<Direction, Occupant> noEmptySpaces = new HashMap<Direction, Occupant>(); noEmptySpaces.put(Direction.TOP, new Plip()); noEmptySpaces.put(Direction.BOTTOM, new Impassible()); noEmptySpaces.put(Direction.LEFT, new Plip()); noEmptySpaces.put(Direction.RIGH...
@Override public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> plips = getNeighborsOfType(neighbors, "plip"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (!plips.isEmpty()) { Direction move...
Clorus extends Creature { @Override public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> plips = getNeighborsOfType(neighbors, "plip"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (!plips.i...
Clorus extends Creature { @Override public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> plips = getNeighborsOfType(neighbors, "plip"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (!plips.i...
Clorus extends Creature { @Override public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> plips = getNeighborsOfType(neighbors, "plip"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (!plips.i...
Clorus extends Creature { @Override public Action chooseAction(Map<Direction, Occupant> neighbors) { List<Direction> emptySpaces = getNeighborsOfType(neighbors, "empty"); List<Direction> plips = getNeighborsOfType(neighbors, "plip"); if (emptySpaces.isEmpty()) { return new Action(Action.ActionType.STAY); } if (!plips.i...
@Test public void testReplicate() { Plip p = new Plip(2); Plip offspring = p.replicate(); assertEquals(1, p.energy(), 0.01); assertEquals(1, offspring.energy(), 0.01); assertNotSame(p, offspring); }
public Plip replicate() { energy /= 2; return new Plip(energy); }
Plip extends Creature { public Plip replicate() { energy /= 2; return new Plip(energy); } }
Plip extends Creature { public Plip replicate() { energy /= 2; return new Plip(energy); } Plip(double e); Plip(); }
Plip extends Creature { public Plip replicate() { energy /= 2; return new Plip(energy); } Plip(double e); Plip(); Color color(); void attack(Creature c); void move(); void stay(); Plip replicate(); Action chooseAction(Map<Direction, Occupant> neighbors); }
Plip extends Creature { public Plip replicate() { energy /= 2; return new Plip(energy); } Plip(double e); Plip(); Color color(); void attack(Creature c); void move(); void stay(); Plip replicate(); Action chooseAction(Map<Direction, Occupant> neighbors); }
@Test public void writeToNullOrEmpty() { assertTrue(StringWritableCsv.writeTo(new StringBuffer()).length() == 0); assertTrue(StringWritableCsv.writeTo(new StringBuffer(), new CharAttributeValue[]{}).length() == 0); }
public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { sb.append(','); writeStringWritableToSt...
StringWritableCsv { public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { sb.append(','); wri...
StringWritableCsv { public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { sb.append(','); wri...
StringWritableCsv { public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { sb.append(','); wri...
StringWritableCsv { public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { sb.append(','); wri...
@Test public void toPrintableNonASCII() { String[] nonASCIIStrings = new String[] { "abcdé", "ñ", "€", "Наташа", (char) 127 + "" }; int n = 0; for(String s : nonASCIIStrings) { try { UsAsciiUtils.toPrintable(s); } catch(IllegalArgumentException ex) { n++; } } assertTrue( "String(s) with non-ASCII characters not throwin...
public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains character '" + chr +...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
@Test public void toPrintableNonPrintable() { String[] original = new String[] { " u ", "a" + (char) 12, (char) 0 + "ttt" + (char) 31 }; String[] expected = new String[] { "u", "a", "ttt" }; for(int i = 0; i < original.length; i++) { assertEquals("", expected[i], UsAsciiUtils.toPrintable(original[i])); } }
public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains character '" + chr +...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
@Test public void toPrintableAllPrintable() { List<String> values = new ArrayList<String>(); values.addAll(Arrays.asList( new String[] { (char) 33 + "", "user", "!", "-,.=?", (char) 126 + "" }) ); for(int c = 33; c < 127; c++) { values.add("---" + (char) c + "---"); } for(String s : values) { assertEquals( "All printab...
public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains character '" + chr +...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
UsAsciiUtils { public static String toPrintable(String value) throws IllegalArgumentException { checkNotNull(value, "value"); char[] printable = new char[value.length()]; int i = 0; for(char chr : value.toCharArray()) { int c = (int) chr; if (c < 0 || c >= 127) { throw new IllegalArgumentException("value contains chara...
@Test public void validConstructor() { ServerFirstMessage serverFirstMessage = new ServerFirstMessage( CLIENT_NONCE, "3rfcNHYJY1ZVvWVs7j", "QSXCR+Q6sek8bf92", 4096 ); assertEquals(SERVER_FIRST_MESSAGE, serverFirstMessage.toString()); }
@Override public String toString() { return writeTo(new StringBuffer()).toString(); }
ServerFirstMessage implements StringWritable { @Override public String toString() { return writeTo(new StringBuffer()).toString(); } }
ServerFirstMessage implements StringWritable { @Override public String toString() { return writeTo(new StringBuffer()).toString(); } ServerFirstMessage( String clientNonce, String serverNonce, String salt, int iteration ); }
ServerFirstMessage implements StringWritable { @Override public String toString() { return writeTo(new StringBuffer()).toString(); } ServerFirstMessage( String clientNonce, String serverNonce, String salt, int iteration ); String getClientNonce(); String getServerNonce(); String getNonce(); String getSa...
ServerFirstMessage implements StringWritable { @Override public String toString() { return writeTo(new StringBuffer()).toString(); } ServerFirstMessage( String clientNonce, String serverNonce, String salt, int iteration ); String getClientNonce(); String getServerNonce(); String getNonce(); String getSa...
@Test public void parseFromInvalidValues() { String[] invalidValues = new String[] { "n,,r=user,r=" + CLIENT_NONCE, "n,,z=user,r=" + CLIENT_NONCE, "n,,n=user", "n,", "n,,", "n,,n=user,r", "n,,n=user,r=" }; int n = 0; for(String s : invalidValues) { try { assertNotNull(ClientFirstMessage.parseFrom(s)); } catch (ScramPar...
public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException { checkNotEmpty(clientFirstMessage, "clientFirstMessage"); Gs2Header gs2Header = Gs2Header.parseFrom(clientFirstMessage); String[] userNonceString; try { userNonceString = StringWritableCsv.parseFr...
ClientFirstMessage implements StringWritable { public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException { checkNotEmpty(clientFirstMessage, "clientFirstMessage"); Gs2Header gs2Header = Gs2Header.parseFrom(clientFirstMessage); String[] userNonceString; tr...
ClientFirstMessage implements StringWritable { public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException { checkNotEmpty(clientFirstMessage, "clientFirstMessage"); Gs2Header gs2Header = Gs2Header.parseFrom(clientFirstMessage); String[] userNonceString; tr...
ClientFirstMessage implements StringWritable { public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException { checkNotEmpty(clientFirstMessage, "clientFirstMessage"); Gs2Header gs2Header = Gs2Header.parseFrom(clientFirstMessage); String[] userNonceString; tr...
ClientFirstMessage implements StringWritable { public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException { checkNotEmpty(clientFirstMessage, "clientFirstMessage"); Gs2Header gs2Header = Gs2Header.parseFrom(clientFirstMessage); String[] userNonceString; tr...
@Test public void toSaslNameNoCharactersToBeEscaped() { for(String s : VALUES_NO_CHARS_TO_BE_ESCAPED) { assertEquals(s, ScramStringFormatting.toSaslName(s)); } }
public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0) { return value; } char[...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
@Test public void toSaslNameWithCharactersToBeEscaped() { for(int i = 0; i < VALUES_TO_BE_ESCAPED.length; i++) { assertEquals(ESCAPED_VALUES[i], ScramStringFormatting.toSaslName(VALUES_TO_BE_ESCAPED[i])); } }
public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0) { return value; } char[...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
ScramStringFormatting { public static String toSaslName(String value) { if(null == value || value.isEmpty()) { return value; } int nComma = 0, nEqual = 0; char[] originalChars = value.toCharArray(); for(char c : originalChars) { if(',' == c) { nComma++; } else if('=' == c) { nEqual++; } } if(nComma == 0 && nEqual == 0)...
@Test public void fromSaslNameNoCharactersToBeEscaped() { for(String s : VALUES_NO_CHARS_TO_BE_ESCAPED) { assertEquals(s, ScramStringFormatting.fromSaslName(s)); } }
public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' character present in sas...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
@Test public void fromSaslNameWithCharactersToBeUnescaped() { for(int i = 0; i < ESCAPED_VALUES.length; i++) { assertEquals(VALUES_TO_BE_ESCAPED[i], ScramStringFormatting.fromSaslName(ESCAPED_VALUES[i])); } }
public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' character present in sas...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...
ScramStringFormatting { public static String fromSaslName(String value) throws IllegalArgumentException { if(null == value || value.isEmpty()) { return value; } int nEqual = 0; char[] orig = value.toCharArray(); for(int i = 0; i < orig.length; i++) { if(orig[i] == ',') { throw new IllegalArgumentException("Invalid ',' ...