Skip to content

Commit

Permalink
Merge pull request Azure#14 from Azure/samples-readme
Browse files Browse the repository at this point in the history
Root pom.xml which can run samples
  • Loading branch information
kirankumarkolli authored Jan 19, 2018
2 parents c5a85b0 + 5e3fab3 commit b5d04a9
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 9 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb-rx</artifactId>
<version>LATEST</version>
</dependency>

## 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
Expand Down
27 changes: 21 additions & 6 deletions azure-documentdb-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb-examples</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb-rx-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>azure-documentdb-rx-examples</artifactId>
<packaging>jar</packaging>

<name>azure-documentdb-examples</name>
<url>http://azure.microsoft.com/en-us/services/documentdb/</url>
<name>azure-documentdb-rx-examples</name>
<url>https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sdk-java</url>
<licenses>
<license>
<name>MIT License</name>
Expand Down Expand Up @@ -44,13 +48,24 @@
</classpathContainers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Test*.java</include>
<include>**/*Sample*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb-rx</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,27 @@
*/
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
*/
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.
// <!--[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]-->
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);
}
}
31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb-rx-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Azure Cosmons DB Document API</name>
<url>https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sdk-java</url>

<modules>
<module>azure-documentdb-examples</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Test*.java</include>
<include>**/*Sample*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit b5d04a9

Please sign in to comment.