diff --git a/README.md b/README.md index c1fac138ade5..3733452df3cf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,56 @@ [![Build Status](https://api.travis-ci.org/Azure/azure-documentdb-rxjava.svg?branch=master)](https://travis-ci.org/Azure/azure-documentdb-rxjava) [![Coverage Status](https://img.shields.io/codecov/c/github/Azure/azure-documentdb-rxjava.svg)](https://codecov.io/gh/Azure/azure-documentdb-rxjava) +## Disclaimer +The implementation in this project is intended for reference purpose only and does not reflect the latest official Azure DocumentDB Java SDK released on Maven repository. +## Consuming the official Microsoft Azure DocumentDB Java SDK + +To get the binaries of the latest official Microsoft Azure DocumentDB Java SDK as distributed by Microsoft, ready for use within your project, you can use Maven. + + + com.microsoft.azure + azure-documentdb-rx + LATEST + + +## Minimum Requirements +* Java Development Kit 8 +* (Optional) Maven + +### Dependencies +Dependencies will be added automatically if Maven is used. Otherwise, please download the dependencies from the pom.xml file and add them to your build path. + +## Samples +We have samples in form of small executable unit tests in [documentdb-examples](https://github.com/Azure/azure-documentdb-rxjava/tree/master/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples) sub project. + +* Clone the Repo +```bash +git clone https://github.com/Azure/azure-documentdb-rxjava.git +cd azure-documentdb-rxjava +``` + +You can run the samples either using Eclipse or from Command Line using Maven: + +### Eclipse + +* Load the main parent project pom file in Eclipse (That should automatically load documentdb-examples). +* For running the samples you need a proper Azure Cosmos DB Endpoint. The endpoints are picked up from [src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java](https://github.com/Azure/azure-documentdb-rxjava/blob/master/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java). +* You can pass your endpoint credentials as VM Arguments in Eclipse JUnit Run Config: +```bash + -DACCOUNT_HOST="https://REPLACE_ME.documents.azure.com:443/" -DACCOUNT_KEY="REPLACE_ME" + ``` +* or you can simply put your endpoint credentials in AccountCredentials.java +* Now you can run the samples as JUnit tests in Eclipse. + +### Command line + +The other way for running samples is to use maven: + +* Run Maven and pass your Azure Cosmos DB Endpoint credentials: +```bash +mvn test -DACCOUNT_HOST="https://REPLACE_ME_WITH_YOURS.documents.azure.com:443/" -DACCOUNT_KEY="REPLACE_ME_WITH_YOURS" +``` ## License MIT License diff --git a/azure-documentdb-examples/pom.xml b/azure-documentdb-examples/pom.xml index c4a3891f91ee..1a0bb209c4a4 100644 --- a/azure-documentdb-examples/pom.xml +++ b/azure-documentdb-examples/pom.xml @@ -2,13 +2,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.azure - azure-documentdb-examples - 0.0.1-SNAPSHOT + + com.microsoft.azure + azure-documentdb-rx-parent + 1.0.0-SNAPSHOT + + + azure-documentdb-rx-examples jar - azure-documentdb-examples - http://azure.microsoft.com/en-us/services/documentdb/ + azure-documentdb-rx-examples + https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sdk-java MIT License @@ -44,13 +48,24 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + **/*Test*.java + **/*Sample*.java + + + com.microsoft.azure azure-documentdb-rx - 0.9.0-SNAPSHOT + LATEST io.reactivex diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java index 15d8605b8dfc..27a8b52e98de 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/TestConfigurations.java @@ -22,6 +22,9 @@ */ package com.microsoft.azure.documentdb.rx.examples; +import org.apache.commons.lang3.StringUtils; +import com.google.common.base.Strings; + /** * Contains the configurations for test file */ @@ -29,7 +32,17 @@ public final class TestConfigurations { // Replace MASTER_KEY and HOST with values from your DocumentDB account. // The default values are credentials of the local emulator, which are not used in any production environment. // - public static final String MASTER_KEY = - "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; - public static final String HOST = "https://localhost:443/"; + public static String MASTER_KEY = + System.getProperty("ACCOUNT_KEY", StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("ACCOUNT_KEY")), + "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")); + + public static String HOST = + System.getProperty("ACCOUNT_HOST", + StringUtils.defaultString( + Strings.emptyToNull(System.getenv().get("ACCOUNT_HOST")), + "https://localhost:443/")); + + static { + System.out.println("host is " + HOST); + } } diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000000..d053523a4624 --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + com.microsoft.azure + azure-documentdb-rx-parent + 1.0.0-SNAPSHOT + pom + Azure Cosmons DB Document API + https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sdk-java + + + azure-documentdb-examples + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + **/*Test*.java + **/*Sample*.java + + + + + +