java_SUITE: Fetch dependencies using Maven

Thus, we do not use to clone and build org.eclipse.paho.client.mqttv3,
nor we depend on a local clone of rabbitmq-java-client.

While here, move all java_SUITE-specific files to `java_SUITE_data`.
This commit is contained in:
Jean-Sébastien Pédron 2016-08-31 10:11:11 +02:00
parent 1978ed506a
commit 08c29be1cf
16 changed files with 95 additions and 85 deletions

View File

@ -12,8 +12,3 @@ plugins/
/xrefr
rabbitmq_mqtt.d
# Testsuite artifacts.
test/build/
test/test_client/
test/junit*

View File

@ -2,7 +2,7 @@ PROJECT = rabbitmq_mqtt
DEPS = amqp_client
TEST_DEPS = rabbit rabbitmq_java_client emqttc ct_helper
TEST_DEPS = rabbit emqttc ct_helper
dep_ct_helper = git https://github.com/extend/ct_helper.git master
dep_emqttc = git https://github.com/emqtt/emqttc.git master

View File

@ -1,48 +0,0 @@
UPSTREAM_GIT=https://github.com/eclipse/paho.mqtt.java
REVISION=00b5b2f99ae8410b7d96d106e080a092c5f92546
JC=javac
TEST_SRC=src
CHECKOUT_DIR=test_client
PAHO_JAR_NAME=org.eclipse.paho.client.mqttv3.jar
PAHO_JAR=$(CHECKOUT_DIR)/org.eclipse.paho.client.mqttv3/$(PAHO_JAR_NAME)
JUNIT_JAR=../lib/junit.jar
JAVA_AMQP_DIR=$(DEPS_DIR)/rabbitmq_java_client
JAVA_AMQP_CLASSES=$(JAVA_AMQP_DIR)/build/classes/
ALL_CLASSES:=$(foreach f,$(shell find src -name '*.class'),'$(f)')
CP:=$(PAHO_JAR):$(JUNIT_JAR):$(TEST_SRC):$(JAVA_AMQP_CLASSES)
HOSTNAME:=$(shell hostname)
define class_from_path
$(subst .class,,$(subst src.,,$(subst /,.,$(1))))
endef
.PHONY: test
test: build_java_amqp
ant test \
-Dhostname=$(HOSTNAME) \
-Dcerts.dir=$(SSL_CERTS_DIR) \
-Dmqtt.ssl.port=$(MQTT_SSL_PORT) \
-Dmqtt.port=$(MQTT_PORT) \
-Damqp.port=$(AMQP_PORT) \
-Dbuild.out=$(DATA_DIR)/build
clean:
ant clean
rm -rf test_client
distclean: clean
rm -rf $(CHECKOUT_DIR)
$(CHECKOUT_DIR):
git clone $(UPSTREAM_GIT) $@
(cd $@ && git checkout $(REVISION)) || rm -rf $@
.PHONY: build_java_amqp
build_java_amqp: $(CHECKOUT_DIR)
$(MAKE) -C $(JAVA_AMQP_DIR) jar

View File

@ -96,18 +96,12 @@ java(Config) ->
MqttPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_mqtt),
MqttSslPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_mqtt_tls),
AmqpPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp),
DataDir = rabbit_ct_helpers:get_config(Config, priv_dir),
os:putenv("DATA_DIR", DataDir),
os:putenv("SSL_CERTS_DIR", CertsDir),
os:putenv("MQTT_SSL_PORT", erlang:integer_to_list(MqttSslPort)),
os:putenv("MQTT_PORT", erlang:integer_to_list(MqttPort)),
os:putenv("AMQP_PORT", erlang:integer_to_list(AmqpPort)),
{ok, _} = rabbit_ct_helpers:make(Config, make_dir(), ["test"]).
make_dir() ->
{Src, _} = filename:find_src(?MODULE),
filename:dirname(Src).
DataDir = rabbit_ct_helpers:get_config(Config, data_dir),
{ok, _} = rabbit_ct_helpers:make(Config, DataDir, ["tests"]).
rpc(Config, M, F, A) ->
rabbit_ct_broker_helpers:rpc(Config, 0, M, F, A).

View File

@ -0,0 +1,2 @@
/build/
/lib/

View File

@ -0,0 +1,21 @@
HOSTNAME := $(shell hostname)
.PHONY: deps tests clean distclean
deps:
mkdir -p lib
mvn dependency:copy-dependencies -DoutputDirectory=lib
tests: deps
ant test \
-Dhostname=$(HOSTNAME) \
-Dcerts.dir=$(SSL_CERTS_DIR) \
-Dmqtt.ssl.port=$(MQTT_SSL_PORT) \
-Dmqtt.port=$(MQTT_PORT) \
-Damqp.port=$(AMQP_PORT)
clean:
ant clean
distclean: clean
rm -f lib/*.jar

View File

@ -7,33 +7,18 @@
<property file="build.properties"/>
<property environment="env"/>
<property name="java-amqp-client-path" location="${env.DEPS_DIR}/rabbitmq_java_client" />
<path id="test.javac.classpath">
<!-- cf dist target, infra -->
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="test_client">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${java-amqp-client-path}">
<include name="**/rabbitmq-client.jar" />
</fileset>
</path>
<target name="clean-paho" description="Clean compiled Eclipe Paho Test Client jars" >
<ant antfile="test_client/org.eclipse.paho.client.mqttv3/build.xml" useNativeBasedir="true" target="clean"/>
</target>
<target name="clean" >
<delete dir="${build.out}"/>
</target>
<target name="build-paho" depends="clean-paho" description="Build the Eclipse Paho Test Client">
<ant antfile="test_client/org.eclipse.paho.client.mqttv3/build.xml" useNativeBasedir="true" />
</target>
<target name="detect-ssl">
<available property="SSL_AVAILABLE" file="${certs.dir}/client"/>
<echo message="certsdir:${certs.dir}" />
@ -96,7 +81,7 @@
</exec>
</target>
<target name="test-build" depends="clean,build-paho">
<target name="test-build" depends="clean">
<mkdir dir="${test.javac.out}"/>
<javac srcdir="./src"

View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.7.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>RabbitMQ MQTT plugin dependencies list</name>
<description>Fetches test dependencies only.</description>
<url>http://www.rabbitmq.com</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.6.5</version>
</dependency>
</dependencies>
</project>

View File

@ -29,12 +29,15 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttTopic;
import org.eclipse.paho.client.mqttv3.internal.NetworkModule;
import org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttPingReq;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage;
import javax.net.SocketFactory;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.Socket;
@ -157,12 +160,38 @@ public class MqttTest extends TestCase implements MqttCallback {
public void testConnectFirst() throws MqttException, IOException, InterruptedException {
NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, getPort(), "");
networkModule.start();
MqttInputStream mqttIn = new MqttInputStream (networkModule.getInputStream());
MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
DataInputStream in = new DataInputStream(networkModule.getInputStream());
OutputStream out = networkModule.getOutputStream();
MqttWireMessage message = new MqttPingReq();
try {
mqttOut.write(new MqttPingReq());
mqttOut.flush();
mqttIn.readMqttWireMessage();
// ---8<---
// Copy/pasted from write() in MqttOutputStream.java.
byte[] bytes = message.getHeader();
byte[] pl = message.getPayload();
out.write(bytes,0,bytes.length);
int offset = 0;
int chunckSize = 1024;
while (offset < pl.length) {
int length = Math.min(chunckSize, pl.length - offset);
out.write(pl, offset, length);
offset += chunckSize;
}
// ---8<---
// ---8<---
// Copy/pasted from flush() in MqttOutputStream.java.
out.flush();
// ---8<---
// ---8<---
// Copy/pasted from readMqttWireMessage() in MqttInputStream.java.
ByteArrayOutputStream bais = new ByteArrayOutputStream();
byte first = in.readByte();
// ---8<---
fail("Error expected if CONNECT is not first packet");
} catch (IOException ignored) {}
}

Binary file not shown.