Search in sources :

Example 41 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class SslAuthenticationTest method localSslAuthenticationDisabled.

/**
 * Connect to the local simple https server with SSL authentication disabled.
 */
@TestTemplate
public void localSslAuthenticationDisabled() throws Exception {
    // Build a client that connects to the mock server with SSL authentication disabled
    CloudantClient dbClient = CloudantClientHelper.newMockWebServerClientBuilder(server).disableSSLAuthentication().build();
    // Queue a 200 OK response
    server.enqueue(new MockResponse());
    // Make an arbitrary connection to the DB.
    dbClient.getAllDbs();
// Test is successful if no exception is thrown, so no explicit check is needed.
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) CloudantClient(com.cloudant.client.api.CloudantClient) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 42 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class SslAuthenticationTest method remoteSslAuthenticationEnabledTest.

/**
 * Connect to the remote Cloudant server with SSL Authentication enabled.
 * This shouldn't throw an exception as the Cloudant server has a valid
 * SSL certificate, so should be authenticated.
 */
@TestTemplate
@RequiresCloudantService
public void remoteSslAuthenticationEnabledTest() {
    CloudantClient dbClient = CloudantClientHelper.getClientBuilder().build();
    // Make an arbitrary connection to the DB.
    dbClient.getAllDbs();
// Test is successful if no exception is thrown, so no explicit check is needed.
}
Also used : CloudantClient(com.cloudant.client.api.CloudantClient) TestTemplate(org.junit.jupiter.api.TestTemplate) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Example 43 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class SslAuthenticationTest method remoteSslAuthenticationDisabledTest.

/**
 * Connect to the remote Cloudant server with SSL Authentication disabled.
 */
@TestTemplate
@RequiresCloudantService
public void remoteSslAuthenticationDisabledTest() {
    CloudantClient dbClient = CloudantClientHelper.getClientBuilder().disableSSLAuthentication().build();
    // Make an arbitrary connection to the DB.
    dbClient.getAllDbs();
// Test is successful if no exception is thrown, so no explicit check is needed.
}
Also used : CloudantClient(com.cloudant.client.api.CloudantClient) TestTemplate(org.junit.jupiter.api.TestTemplate) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Example 44 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildDocumentUri_options_optionsEncoded.

@TestTemplate
public void buildDocumentUri_options_optionsEncoded(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/path1%2Fpath2?detail=true&revs=%5B1-2%5D");
    Map<String, Object> options = new TreeMap<String, Object>();
    options.put("revs", "[1-2]");
    options.put("detail", true);
    URI actual = helper(path + "/test").documentId("path1/path2").query(options).build();
    Assertions.assertEquals(expected, actual);
}
Also used : TreeMap(java.util.TreeMap) URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 45 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildQuery_joinTwoQueries.

@TestTemplate
public void buildQuery_joinTwoQueries(String path) throws Exception {
    Map<String, Object> mapOptions = new TreeMap<String, Object>();
    mapOptions.put("revs", "[1-2]");
    mapOptions.put("detail", "/SDF@#%$#)");
    String query = "boolean=true";
    URI expectedQuery = new URI(uriBase + "?detail=/SDF@%23%25$%23)" + "&revs=%5B1-2%5D&boolean=true");
    URI actualQuery = helper(path).query(mapOptions).query(query).build();
    Assertions.assertEquals(expectedQuery.toASCIIString(), actualQuery.toASCIIString());
}
Also used : TreeMap(java.util.TreeMap) URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

TestTemplate (org.junit.jupiter.api.TestTemplate)51 CloudantClient (com.cloudant.client.api.CloudantClient)23 URI (java.net.URI)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)18 MockResponse (okhttp3.mockwebserver.MockResponse)16 HttpConnection (com.cloudant.http.HttpConnection)11 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 TreeMap (java.util.TreeMap)5 TestTimer (com.cloudant.tests.util.TestTimer)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 URL (java.net.URL)4 TooManyRequestsException (com.cloudant.client.org.lightcouch.TooManyRequestsException)3 Replay429Interceptor (com.cloudant.http.interceptors.Replay429Interceptor)3 CouchDbException (com.cloudant.client.org.lightcouch.CouchDbException)2 HttpConnectionInterceptorContext (com.cloudant.http.HttpConnectionInterceptorContext)2 RequiresCloudant (com.cloudant.test.main.RequiresCloudant)2 RequiresCloudantService (com.cloudant.test.main.RequiresCloudantService)2 Gson (com.google.gson.Gson)2 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2