Skip to content

Commit

Permalink
Restructuring and new files for automated testing of JS client using …
Browse files Browse the repository at this point in the history
…node and jasmine, part of bug 418081
  • Loading branch information
Al S-M authored and Ian Craggs committed Mar 9, 2014
1 parent 4634f31 commit 0bf143c
Show file tree
Hide file tree
Showing 4 changed files with 2,108 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package.json
@@ -0,0 +1,9 @@
{
"name": "paho-client",
"description": "Pre reqs for the Paho JS client",
"dependencies": {
"websocket": "1.x.x",
"node-localstorage": "0.x.x",
"jasmine-node": "1.11.x"
}
}
146 changes: 146 additions & 0 deletions pom.xml
@@ -0,0 +1,146 @@
<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>org.eclipse.paho</groupId>
<artifactId>js-client</artifactId>
<packaging>pom</packaging>
<version>0.4.1-SNAPSHOT</version>
<url>http://www.eclipse.org/paho</url>
<licenses>
<license>
<name>Eclipse Public License - Version 1.0</name>
<url>http://www.eclipse.org/org/documents/epl-v10.php</url>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<build.level>${maven.build.timestamp}</build.level>
</properties>
<scm>
<url>http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.javascript.git</url>
<connection>scm:git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.javascript.git</connection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<executions>
<execution>
<id>filter-tests</id>
<goals>
<goal>filter-test-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>generate-js-output</id>
<phase>process-resources</phase>
<configuration>
<tasks>
<copy file="src/main/javascript-templates/mqttws31s.js" toFile="target/src/javascript/mqttws31.js">
<filterset>
<filter token="VERSION" value="${project.version}"/>
<filter token="BUILDLEVEL" value="${build.level}"/>
<filter token="client.nodeBuf" value=""/>
<filter token="client.send" value="this.socket.send(wireMessage.encode());"/>
<filter token="clientimpl.checkDeps" value='// Check dependencies are satisfied in this browser.${line.separator}if (!("WebSocket" in global &amp;&amp; global["WebSocket"] !== null)) {${line.separator}throw new Error(format(ERROR.UNSUPPORTED, ["WebSocket"]));${line.separator}}${line.separator}if (!("localStorage" in global &amp;&amp; global["localStorage"] !== null)) {${line.separator}throw new Error(format(ERROR.UNSUPPORTED, ["localStorage"]));${line.separator}}${line.separator}if (!("ArrayBuffer" in global &amp;&amp; global["ArrayBuffer"] !== null)) {${line.separator}throw new Error(format(ERROR.UNSUPPORTED, ["ArrayBuffer"]));${line.separator}}'/>
<filter token="clientimpl.socket" value='this.socket = new WebSocket(wsurl, "mqttv3.1");'/>
<filter token="nodeDeps" value=""/>
<filter token="clientimpl.nodews" value=""/>
</filterset>
</copy>
<copy file="src/main/javascript-templates/mqttws31s.js" toFile="target/src/javascript/mqttws31n.js">
<filterset>
<filter token="VERSION" value="${project.version}"/>
<filter token="BUILDLEVEL" value="${build.level}"/>
<filter token="client.nodeBuf" value="var nodeBuf = new Buffer(new Uint8Array(wireMessage.encode()));"/>
<filter token="client.send" value="this.connection.send(nodeBuf);"/>
<filter token="clientimpl.checkDeps" value=""/>
<filter token="clientimpl.socket" value='var ref = this;${line.separator}this.socket = new WebSocketClient;'/>
<filter token="nodeDeps" value="var WebSocketClient = require('websocket').client;${line.separator}var LocalStorage = require('node-localstorage').LocalStorage;${line.separator}var localStorage = new LocalStorage('./persistence');${line.separator}var window = global;"/>
<filter token="clientimpl.nodews" value='this.socket.connect(wsurl, "mqttv3.1");${line.separator}this.socket.on("connectFailed", function (description) {${line.separator}console.log("failure " + description);${line.separator}});${line.separator}this.socket.on("connect", function (connection) {${line.separator}ref.connection = connection;${line.separator}connection.on("error", function (error) {${line.separator}console.log("socket error " + error);${line.separator}if (ref.socket.onerror != null) ref.socket.onerror();${line.separator}});${line.separator}connection.on("close", function (reasonCode, description) {${line.separator}console.log("socket closed " + description);${line.separator}if (ref.socket.onclose != null) ref.socket.onclose();${line.separator}});${line.separator}connection.on("message", function (message) {${line.separator}if (message.type === "binary") {${line.separator}if (ref.socket.onmessage != null) ref.socket.onmessage({data:message.binaryData});${line.separator}}${line.separator}});${line.separator}if (ref.socket.onopen != null) ref.socket.onopen();${line.separator}});'/>
</filterset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.2</version>
<configuration>
<jsSrcDir>${basedir}/target/src/javascript</jsSrcDir>
<sourceExcludes>
<exclude>**/mqttws31n.js</exclude>
</sourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<executions>
<execution>
<id>filter-tests</id>
<goals>
<goal>filter-test-sources</goal>
</goals>
<configuration>
<testSourceDirectory>${basedir}/src/test/javascript-templates</testSourceDirectory>
<testOutputDirectory>${basedir}/src/test/javascript</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>node_modules/jasmine-node/bin/jasmine-node</executable>
<arguments>
<argument>--forceexit</argument>
<argument>src/test/javascript</argument>
<argument>--junitreport</argument>
<argument>--output</argument>
<argument>target/failsafe-reports/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 0bf143c

Please sign in to comment.