Skip to content

Commit

Permalink
Pushing initial Changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
krmahadevan committed Jan 26, 2017
1 parent 4b16a6d commit cca40b0
Show file tree
Hide file tree
Showing 21 changed files with 1,029 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.md]
trim_trailing_whitespace = false

[*.{java,xml}]
indent_style = space
indent_size = 4
continuation_indent_size = 4

[*.{json,yml,yaml.json}]
indent_style = space
indent_size = 2
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
hs_err_pid*
*.jar
.settings/
.project
.classpath
test-output/
target/
*.swp
bin/
logs/
*.DS_Store
.idea/
*.iml

# Gradle files
.gradle/
build/
/*/build/
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: java
jdk:
- oraclejdk8
notifications:
email:
- krishnan.mahadevan1978@gmail.com
branches:
only:
- master
cache:
directories:
- "$HOME/.m2"
after_success:
- openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in $GPG_DIR/pubring.gpg.enc
-out $GPG_DIR/pubring.gpg -d
- openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in $GPG_DIR/secring.gpg.enc
-out $GPG_DIR/secring.gpg -d
- "$GPG_DIR/publish.sh"
env:
global:
- GPG_DIR="`pwd`/deploy"
- secure: BGx/CufFzVLMeWhU1XwqjP5esIbcidiXo4KabmbXjHEx0Uxaxjxm2YrV5d1oN77h0S2QofcqlhJ1QKf9dGiMesOPXDLDT66TpCbXSMNQg1EbLE+dJ3xSXO8fSkt8KRpuuRXqj8/zvXeASI8Xm2HbsuS4+vh06YfNhXBt0S2up4WT1kqeGtNUMKG2CWMqosrEby1Ymv52smK1R45P1rja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& 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Talk 2 Grid

**Talk 2 Grid** is a very simple library that exposes some of the straight forward Http APIs that a Selenium Hub/Node
provides.

This library was built with an intention of interacting with the Hub/Node to get some useful information.

## Pre-requisites

**Talk 2 Grid** requires :
* **JDK 8**.
* An already running Selenium Grid.
* Tests should be making use of a Selenium Grid.
* Test are not running against a remote execution environment service provider such as Sauce Labs (this is because
Sauce Labs does
not allow users to query its actual node's IP address. The same might be true for other execution environment
service providers as well.)

## How to use.

**Talk 2 Grid** is a [Maven](https://maven.apache.org/guides/getting-started/) artifact. In order to
consume it, you merely need to add the following as a dependency in your pom file.

```xml
<dependency>
<groupId>com.rationaleemotions</groupId>
<artifactId>talk2grid</artifactId>
<version>1.0.0</version>
</dependency>
```

### Viewing the Hub's configuration.

The below sample shows how to access the Hub's configuration.

```java
public void showHubConfiguration() {
Host hub = new Host("localhost", "4444");
GridApiAssistant assistant = new GridApiAssistant(hub);
HubConfiguration hubConfig = assistant.getHubConfiguration();
assertEquals("org.openqa.grid.internal.utils.DefaultCapabilityMatcher", hubConfig.getCapabilityMatcher());
}
```

### How to find out the node to which a test was routed to ?

The below sample shows how to find out the node to which a test was routed to and to retrieve the node's configuration.

```java
public void demonstrateToWhichNodeWasMyTestRoutedTo() throws Exception {
RemoteWebDriver rwd = null;
Host hub = new Host("localhost", "4444");
try {
String url = String.format("http://%s:%d/wd/hub", hub.getIpAddress(), hub.getPort());
rwd = new RemoteWebDriver(new URL(url), DesiredCapabilities.chrome());
//First lets get hold of the session id for our test.
String sessionId = rwd.getSessionId().toString();
GridApiAssistant assistant = new GridApiAssistant(hub);
//Now lets query the Hub to figure out to which node did the hub route our test to.
Host node = assistant.getNodeDetailsForSession(sessionId);
assertNotNull(node);
Reporter.log("Test routed to " + node.toString(), true);
//Lets check what does the node configuration look like.
NodeConfiguration nodeConfig = assistant.getNodeConfigForSession(node);
//Here's how we get hold of the capabilities that are supported by this node.
assertNotNull(nodeConfig.getCapabilities());
} finally {
if (rwd != null) {
rwd.quit();
}
}
}
```
6 changes: 6 additions & 0 deletions deploy/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
mvn deploy --settings $GPG_DIR/settings.xml -DperformRelease=true -DskipTests=true
exit $?
fi
Binary file added deploy/pubring.gpg.enc
Binary file not shown.
Binary file added deploy/secring.gpg.enc
Binary file not shown.
9 changes: 9 additions & 0 deletions deploy/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings>
<servers>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
200 changes: 200 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rationaleemotions</groupId>
<artifactId>talk2grid</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>talk2grid</name>
<description>A Grid Helper library that exposes the Grid's http APIs via simple to use APIs</description>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:RationaleEmotions/talk2grid.git</connection>
<developerConnection>scm:git:git@github.com:RationaleEmotions/talk2grid.git</developerConnection>
<url>https://github.com/RationaleEmotions/talk2grid</url>
</scm>
<developers>
<developer>
<id>krmahadevan</id>
<name>Krishnan Mahadevan</name>
<url>https://github.com/krmahadevan</url>
<roles>
<role>Owner</role>
</roles>
</developer>
</developers>
<issueManagement>
<url>https://github.com/RationaleEmotions/talk2grid/issues</url>
<system>GitHub Issues</system>
</issueManagement>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.5</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<!--
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
-->
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>release</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
<gpg.defaultKeyring>false</gpg.defaultKeyring>
<gpg.publicKeyring>${env.GPG_DIR}/pubring.gpg</gpg.publicKeyring>
<gpg.secretKeyring>${env.GPG_DIR}/secring.gpg</gpg.secretKeyring>
</properties>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<testResources>
<testResource>
<directory>src/test/resources/artifacts</directory>
<excludes>
<exclude>*.txt</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit cca40b0

Please sign in to comment.