Skip to content

Commit

Permalink
Fix #9043
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcialRosales committed Aug 14, 2023
1 parent f272eac commit fe00501
Show file tree
Hide file tree
Showing 30 changed files with 522 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ p(PathName) ->
Path.

q(Args) ->
string:join([escape(K, V) || {K, V} <- Args], "&").
string:join([escape(K, V) || {K, V} <- Args, not is_function(V)], "&").

escape(K, Map) when is_map(Map) ->
string:join([escape(rabbit_data_coercion:to_list(K) ++ "." ++ rabbit_data_coercion:to_list(Key), Value)
|| {Key, Value} <- maps:to_list(Map)], "&");
|| {Key, Value} <- maps:to_list(Map), not is_function(Value)], "&");
escape(K, V) ->
rabbit_data_coercion:to_list(K) ++ "=" ++ rabbit_http_util:quote_plus(V).

Expand Down
1 change: 1 addition & 0 deletions deps/rabbitmq_management/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ selenium/suites/logs/*
selenium/suites/screens/*
selenium/test/oauth/*/h2/*.trace.db
selenium/test/oauth/*/h2/*.lock.db
selenium/*/target/*
7 changes: 6 additions & 1 deletion deps/rabbitmq_management/selenium/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# syntax=docker/dockerfile:1
FROM node:16.19.0 as base
FROM atools/jdk-maven-node:mvn3-jdk11-node16 as base

WORKDIR /code

COPY package.json package.json
COPY run-amqp10-roundtriptest run-amqp10-roundtriptest

FROM base as test
RUN npm install
RUN mkdir -p /code/amqp10-roundtriptest
COPY amqp10-roundtriptest /code/amqp10-roundtriptest
RUN mvn -f /code/amqp10-roundtriptest package

ENTRYPOINT [ "npm" ]
CMD [ "" ]
103 changes: 103 additions & 0 deletions deps/rabbitmq_management/selenium/amqp10-roundtriptest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rabbitmq.amqp1_0</groupId>
<artifactId>amqp10-roundtriptest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>amqp10-roundtriptest</name>
<url>https://www.rabbitmq.com</url>
<properties>
<junit.jupiter.version>5.9.3</junit.jupiter.version>
<qpid-jms-client.version>2.3.0</qpid-jms-client.version>
<logback.version>1.2.11</logback.version>
<spotless.version>2.24.0</spotless.version>
<google-java-format.version>1.17.0</google-java-format.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>

</dependency>

<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>${qpid-jms-client.version}</version>

</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>

</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>com.rabbitmq.amqp1_0.RoundTripTest</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.rabbitmq.amqp1_0.RoundTripTest</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<googleJavaFormat>
<version>${google-java-format.version}</version>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// vim:sw=4:et:

package com.rabbitmq.amqp1_0;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.jms.*;
import java.util.*;
import javax.naming.Context;

/** Unit test for simple App. */
public class RoundTripTest {

public static String getEnv(String property, String defaultValue) {
return System.getenv(property) == null ? defaultValue : System.getenv(property);
}
public static void main(String args[]) throws Exception {
String hostname = getEnv("RABBITMQ_HOSTNAME", "localhost");
String port = getEnv("RABBITMQ_AMQP_PORT", "5672");
String scheme = getEnv("RABBITMQ_AMQP_SCHEME", "amqp");
String username = getEnv("RABBITMQ_AMQP_USERNAME", "guest");
String password = getEnv("RABBITMQ_AMQP_PASSWORD", "guest");
String uri = scheme + "://" + hostname + ":" + port;

Hashtable<Object, Object> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
env.put("connectionfactory.myFactoryLookup", uri);
env.put("queue.myQueueLookup", "my-queue");
env.put("jms.sendTimeout", 5);
env.put("jms.requestTimeout", 5);
javax.naming.Context context = new javax.naming.InitialContext(env);

assertNotNull(uri);

ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
Destination queue = (Destination) context.lookup("myQueueLookup");

try (Connection connection = factory.createConnection(username, password)) {
connection.start();

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

MessageProducer messageProducer = session.createProducer(queue);
MessageConsumer messageConsumer = session.createConsumer(queue);

TextMessage message = session.createTextMessage("Hello world!");
messageProducer.send(
message,
DeliveryMode.NON_PERSISTENT,
Message.DEFAULT_PRIORITY,
Message.DEFAULT_TIME_TO_LIVE);
TextMessage receivedMessage = (TextMessage) messageConsumer.receive(2000L);

assertEquals(message.getText(), receivedMessage.getText());
}
}
}
32 changes: 32 additions & 0 deletions deps/rabbitmq_management/selenium/bin/gen-advanced-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

#set -x

TEST_PATH=${1:?First parameter is the directory env and config files are relative to}
ENV_FILE=${2:?Second parameter is a comma-separated list of .env file which has exported template variables}
FINAL_CONFIG_FILE=${3:?Forth parameter is the name of the final config file. It is relative to where this script is run from}

source $ENV_FILE

parentdir="$(dirname "$FINAL_CONFIG_FILE")"
mkdir -p $parentdir

echo "" > $FINAL_CONFIG_FILE

FOUND_TEMPLATES_COUNT=0
for f in $($SCRIPT/find-template-files $TEST_PATH "advanced" "config")
do
envsubst < $f >> $FINAL_CONFIG_FILE
FOUND_TEMPLATES_COUNT+=1
done

if [ "$FOUND_TEMPLATES_COUNT" -gt 1 ]
then
echo "Matched $FOUND_TEMPLATES_COUNT advanced.config files. There should only match one"
exit -1
fi
if [ "$FOUND_TEMPLATES_COUNT" -lt 1 ]
then
exit -1
fi
Loading

0 comments on commit fe00501

Please sign in to comment.