From 2e05fc978bdb8b55b2abc5cc2ea4723ec4953c81 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 10:03:22 -0800 Subject: [PATCH 1/6] samples for rxjava --- README.md | 49 +++++++++++++++++++ azure-documentdb-examples/pom.xml | 23 +++++++-- ...baseAndCollectionCreationAsyncAPITest.java | 2 +- .../rx/examples/DocumentCRUDAsyncAPITest.java | 2 +- .../examples/DocumentQueryAsyncAPITest.java | 2 +- .../rx/examples/InMemoryGroupbyTest.java | 2 +- .../rx/examples/TestConfigurations.java | 19 +++++-- 7 files changed, 88 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c1fac138ade5..25f1f759d3f5 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 + LATEST + + +## Minimum Requirements +* Java Development Kit 7 +* (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..f351b2909426 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 + + com.microsoft.azure + azure-documentdb-parent + 1.0.0-SNAPSHOT + + azure-documentdb-examples - 0.0.1-SNAPSHOT jar azure-documentdb-examples - http://azure.microsoft.com/en-us/services/documentdb/ + 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/DatabaseAndCollectionCreationAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java index 1ea1cf0a7140..4cf8b04f78cb 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java @@ -80,7 +80,7 @@ public class DatabaseAndCollectionCreationAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseAndCollectionCreationAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db"; + private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); private DocumentCollection collectionDefinition; private Database databaseDefinition; diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java index fd9962c17117..68b65b223863 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java @@ -90,7 +90,7 @@ public class DocumentCRUDAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentCRUDAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db"; + private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); private AsyncDocumentClient asyncClient; private DocumentCollection createdCollection; diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java index 0802156d5742..d2a1bfc95902 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java @@ -93,7 +93,7 @@ public class DocumentQueryAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentQueryAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db"; + private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); private AsyncDocumentClient asyncClient; diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java index a0501eb43bb3..1b01a5790a45 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java @@ -52,7 +52,7 @@ public class InMemoryGroupbyTest { private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryGroupbyTest.class); - private static final String DATABASE_ID = "in-memory-groupby"; + private static final String DATABASE_ID = "in-memory-groupby-" + UUID.randomUUID().toString(); private AsyncDocumentClient asyncClient; 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); + } } From 9101f6d214124a563fc1af626cccb17460cac904 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 10:19:45 -0800 Subject: [PATCH 2/6] adding root pom.xml --- pom.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000000..b229af181d5d --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + com.microsoft.azure + azure-documentdb-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 + + + + + + From 11db1728c67110263ee4c25b97bf9b97efa2bc18 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 10:43:53 -0800 Subject: [PATCH 3/6] undo random database names avoiding the orphans --- .../rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java | 2 +- .../azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java | 2 +- .../azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java index 4cf8b04f78cb..1ea1cf0a7140 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DatabaseAndCollectionCreationAsyncAPITest.java @@ -80,7 +80,7 @@ public class DatabaseAndCollectionCreationAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseAndCollectionCreationAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); + private static final String DATABASE_ID = "async-test-db"; private DocumentCollection collectionDefinition; private Database databaseDefinition; diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java index 68b65b223863..fd9962c17117 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentCRUDAsyncAPITest.java @@ -90,7 +90,7 @@ public class DocumentCRUDAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentCRUDAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); + private static final String DATABASE_ID = "async-test-db"; private AsyncDocumentClient asyncClient; private DocumentCollection createdCollection; diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java index d2a1bfc95902..0802156d5742 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/DocumentQueryAsyncAPITest.java @@ -93,7 +93,7 @@ public class DocumentQueryAsyncAPITest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentQueryAsyncAPITest.class); - private static final String DATABASE_ID = "async-test-db-" + UUID.randomUUID().toString(); + private static final String DATABASE_ID = "async-test-db"; private AsyncDocumentClient asyncClient; From 82540760a09ac9fb38006358b34047f9f4a32f82 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 11:08:22 -0800 Subject: [PATCH 4/6] Changing artifact ids and also updated readme to JDK 8 --- README.md | 2 +- azure-documentdb-examples/pom.xml | 6 +++--- pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 25f1f759d3f5..019b196ff4d7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To get the binaries of the latest official Microsoft Azure DocumentDB Java SDK a ## Minimum Requirements -* Java Development Kit 7 +* Java Development Kit 8 * (Optional) Maven ### Dependencies diff --git a/azure-documentdb-examples/pom.xml b/azure-documentdb-examples/pom.xml index f351b2909426..1a0bb209c4a4 100644 --- a/azure-documentdb-examples/pom.xml +++ b/azure-documentdb-examples/pom.xml @@ -4,14 +4,14 @@ com.microsoft.azure - azure-documentdb-parent + azure-documentdb-rx-parent 1.0.0-SNAPSHOT - azure-documentdb-examples + azure-documentdb-rx-examples jar - azure-documentdb-examples + azure-documentdb-rx-examples https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sdk-java diff --git a/pom.xml b/pom.xml index b229af181d5d..d053523a4624 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.microsoft.azure - azure-documentdb-parent + azure-documentdb-rx-parent 1.0.0-SNAPSHOT pom Azure Cosmons DB Document API From fbc903337cb02b5a5c6197cce38f7852677f7218 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 14:05:40 -0800 Subject: [PATCH 5/6] fixing the maven rx lib reference --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 019b196ff4d7..3733452df3cf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To get the binaries of the latest official Microsoft Azure DocumentDB Java SDK a com.microsoft.azure - azure-documentdb + azure-documentdb-rx LATEST From 5e3fab33f72014a8bfe1989d6e64319f64c0b685 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kolli Date: Fri, 19 Jan 2018 14:27:54 -0800 Subject: [PATCH 6/6] undoing db name chnages to InMemoryGroupByTest --- .../azure/documentdb/rx/examples/InMemoryGroupbyTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java index 1b01a5790a45..a0501eb43bb3 100644 --- a/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java +++ b/azure-documentdb-examples/src/test/java/com/microsoft/azure/documentdb/rx/examples/InMemoryGroupbyTest.java @@ -52,7 +52,7 @@ public class InMemoryGroupbyTest { private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryGroupbyTest.class); - private static final String DATABASE_ID = "in-memory-groupby-" + UUID.randomUUID().toString(); + private static final String DATABASE_ID = "in-memory-groupby"; private AsyncDocumentClient asyncClient;