use of com.ibm.cloud.sdk.core.security.NoAuthAuthenticator in project cloudant-java-sdk by IBM.
the class SdkTimeoutTest method testNoAuthTimeout.
// Test implementations
@Test
void testNoAuthTimeout() throws NoSuchFieldException, IllegalAccessException {
NoAuthAuthenticator noAuth = new NoAuthAuthenticator();
CloudantBaseService myService = createCloudantBaseService(noAuth, "https://cloudant.example");
Request testRequest = createTestRequest(myService);
for (int i = 0; i < 2; i++) {
if (i == 1) {
setCustomTimeout(myService, testCases[i]);
}
RealCall testRequestCall = createServiceCall(myService, testRequest);
assertEquals(TimeUnit.MILLISECONDS.toSeconds(testRequestCall.getClient().readTimeoutMillis()), testCases[i]);
}
}
use of com.ibm.cloud.sdk.core.security.NoAuthAuthenticator in project cloudant-java-sdk by IBM.
the class ValidationTest method validatesDocumentIdAtLongServicePath.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".+_testDocument.+")
void validatesDocumentIdAtLongServicePath() {
CloudantBaseService cloudantBaseService = new CloudantBaseService(null, new NoAuthAuthenticator()) {
};
cloudantBaseService.setServiceUrl("https://cloudant.example/some/proxy/path");
HttpUrl requestUrl = HttpUrl.parse(cloudantBaseService.getServiceUrl()).newBuilder().addPathSegment(dbName).addPathSegment(docId).build();
Request.Builder rb = new Request.Builder().url(requestUrl).get();
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
rb.header(header.getKey(), header.getValue());
}
cloudantBaseService.createServiceCall(rb.build(), null);
}
use of com.ibm.cloud.sdk.core.security.NoAuthAuthenticator in project cloudant-java-sdk by IBM.
the class ValidationTest method validatesDocumentIdAtLongServicePathAfterChange.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".+_testDocument.+")
void validatesDocumentIdAtLongServicePathAfterChange() {
CloudantBaseService cloudantBaseService = new CloudantBaseService(null, new NoAuthAuthenticator()) {
};
cloudantBaseService.setServiceUrl("https://cloudant.example");
HttpUrl requestUrl = HttpUrl.parse(cloudantBaseService.getServiceUrl()).newBuilder().addPathSegment(dbName).addPathSegment(docId).build();
Request.Builder rb = new Request.Builder().url(requestUrl).get();
cloudantBaseService.createServiceCall(rb.build(), null);
cloudantBaseService.setServiceUrl("https://cloudant.example/some/proxy/path");
requestUrl = HttpUrl.parse(cloudantBaseService.getServiceUrl()).newBuilder().addPathSegment(dbName).addPathSegment(docId).build();
rb = new Request.Builder().url(requestUrl).get();
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
rb.header(header.getKey(), header.getValue());
}
cloudantBaseService.createServiceCall(rb.build(), null);
}
use of com.ibm.cloud.sdk.core.security.NoAuthAuthenticator in project cloudant-java-sdk by IBM.
the class ValidationTest method validatesDocumentId.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".+_testDocument.+")
void validatesDocumentId() {
CloudantBaseService cloudantBaseService = new CloudantBaseService(null, new NoAuthAuthenticator()) {
};
cloudantBaseService.setServiceUrl("https://cloudant.example");
HttpUrl requestUrl = HttpUrl.parse(cloudantBaseService.getServiceUrl()).newBuilder().addPathSegment(dbName).addPathSegment(docId).build();
Request.Builder rb = new Request.Builder().url(requestUrl).get();
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
rb.header(header.getKey(), header.getValue());
}
cloudantBaseService.createServiceCall(rb.build(), null);
}
use of com.ibm.cloud.sdk.core.security.NoAuthAuthenticator in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method constructClientService.
public void constructClientService() throws Throwable {
final String serviceName = "testService";
final Authenticator authenticator = new NoAuthAuthenticator();
naturalLanguageClassifierService = new NaturalLanguageClassifier(serviceName, authenticator);
String url = server.url("/").toString();
naturalLanguageClassifierService.setServiceUrl(url);
}
Aggregations