Skip to content

Latest commit

 

History

History
123 lines (87 loc) · 3.09 KB

CONTRIBUTING.md

File metadata and controls

123 lines (87 loc) · 3.09 KB

Contributing

Cloudant-client is written in Java and uses maven as its build tool.

Requirements

  • gradle
  • Java 1.6

Installing requirements

Java

Follow the instructions for your platform.

Gradle

The project uses the gradle wrapper to download specified version of gradle. The gradle wrapper is run by using the following command:

$ ./gradlew

Note: on windows the command to run is gradlew.bat rather than gradlew

Coding guidelines

Adopting the Google Java Style with the following changes:

4.2
    Our block indent is +4 characters

4.4
    Our line length is 100 characters.

4.5.2
    Indent continuation of +4 characters fine, but I think
    IDEA defaults to 8, which is okay too.

Code Style

An IDEA code style matching these guidelines is included in the project, in the .idea folder.

If you already have the project, to enable the code style follow these steps:

  1. Go to Preferences -> Editor -> Code Style.
  2. In the Scheme dropdown, select Project.

IDEA will then use the style when reformatting, refactoring and so on.

Building the library

The project should build out of the box with:

$ ./gradlew compileJava

###Running the tests

Configuration

The tests can be configured before running, by default they use the local CouchDB. To run tests with a remote CouchDB or Cloudant, you need set the details of this CouchDB server, including access credentials:

systemProp.test.couch.username=yourUsername
systemProp.test.couch.password=yourPassword
systemProp.test.couch.host=couchdbHost # default localhost
systemProp.test.couch.port=couchdbPort # default 5984
systemProp.test.couch.http=[http|https] # default http

Alternatively, provide a URL containing all the above information:

systemProp.test.couch.uri=https://example.couch.db

You can leave out the port (it will use the protocol's default) and username and password (if the server does not require one)

Note: using the uri config option will override all the individual options such as "test.couch.username"

Add these properties to a gradle.properties file, this can be either:

  1. in the GRADLE_USER_HOME folder
  2. in the same folder as build.gradle

Take care not to commit your credentials. Using the GRADLE_USER_HOME folder will make it harder to do this accidentally!

Execution

The default tests (that require a running DB) can be run with:

$ ./gradlew check

The tests are categorized based on the resources they need. In addition to the default check and test tasks there are gradle tasks to run tests from these selected categories:

  1. Tests that do not need a database
$ ./gradlew noDBTest
  1. For tests which run against Cloudant Local or the Cloudant Service
$ ./gradlew cloudantTest
  1. For tests which run only against the Cloudant Service
$ ./gradlew cloudantServiceTest

Note: you will need a Cloudant account to run tests against the Cloudant service. Additionally the ReplicatorTest cases require the _replicator DB to exist.