Commit 319231c3 authored by Andre Freyssinet's avatar Andre Freyssinet

Fix JORAM-316: Due to the use of Form parameters for JMS authentication

information, the content-type of the POST shall be fixed.
parent b1fc1e4a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
* Copyright (C) 2016 - 2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -65,13 +65,17 @@ public class ClientRESTBytesMessage extends TestCase {
WebTarget target = client.target(Helper.getBaseJmsURI());
URI uriCreateProd = target.path("jms").path("queue").path("myQueue1").path("create-producer")
.queryParam("name", "prod1").getUri();
.queryParam("name", "prod1")
.getUri();
URI uriCreateCons = target.path("jms").path("queue").path("myQueue1").path("create-consumer")
.queryParam("name", "cons1")
.getUri();
// Create the producer
Response response = client.target(uriCreateProd).request().accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON).post(null);
Response response = client.target(uriCreateProd)
.request()
.accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer jms (myQueue1)", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -100,12 +104,17 @@ public class ClientRESTBytesMessage extends TestCase {
// System.out.println("send json = " + json);
// Send next message
response = client.target(uriSendNextMsg).request().accept(MediaType.TEXT_PLAIN).post(
Entity.entity(json, MediaType.APPLICATION_JSON));
response = client.target(uriSendNextMsg)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(json, MediaType.APPLICATION_JSON));
assertEquals("send-next-message", 200, response.getStatus());
// Create the consumer
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer jms (myQueue1)", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
* Copyright (C) 2016 - 2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -66,13 +66,17 @@ public class ClientRESTMapMessage extends TestCase {
WebTarget target = client.target(Helper.getBaseJmsURI());
URI uriCreateProd = target.path("jms").path("queue").path("myQueue1").path("create-producer")
.queryParam("name", "prod1").getUri();
.queryParam("name", "prod1")
.getUri();
URI uriCreateCons = target.path("jms").path("queue").path("myQueue1").path("create-consumer")
.queryParam("name", "cons1")
.getUri();
// Create the producer
Response response = client.target(uriCreateProd).request().accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON).post(null);
Response response = client.target(uriCreateProd)
.request()
.accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer jms (myQueue1)", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -98,12 +102,17 @@ public class ClientRESTMapMessage extends TestCase {
//System.out.println("send json = " + json);
// Send next message
response = client.target(uriSendNextMsg).request().accept(MediaType.TEXT_PLAIN).post(
Entity.entity(json, MediaType.APPLICATION_JSON));
response = client.target(uriSendNextMsg)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(json, MediaType.APPLICATION_JSON));
assertEquals("send-next-message", 200, response.getStatus());
// Create the consumer
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer jms (myQueue1)", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
......
......@@ -86,7 +86,8 @@ public class ClientRESTSSL extends TestCase {
response = client.target(uriCreateProd)
.queryParam("user", "anonymous")
.queryParam("password", "anonymous")
.request().accept(MediaType.TEXT_PLAIN).post(null);
.request().accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -94,19 +95,26 @@ public class ClientRESTSSL extends TestCase {
// Send next message
String message = "Test message.";
response = client.target(uriSendNextMsg).request().
accept(MediaType.TEXT_PLAIN).post(Entity.entity(message, MediaType.TEXT_PLAIN));
response = client.target(uriSendNextMsg)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(message, MediaType.TEXT_PLAIN));
assertEquals("send-next-message", 200, response.getStatus());
// Create the consumer
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
// receive the message
URI uriReceive = response.getLink("receive-next-message").getUri();
builder = client.target(uriReceive).request().accept(MediaType.TEXT_PLAIN);
builder = client.target(uriReceive)
.request()
.accept(MediaType.TEXT_PLAIN);
response = builder.get();
String msg = response.readEntity(String.class);
assertEquals("receive-next-message", 200, response.getStatus());
......
......@@ -69,7 +69,7 @@ public class ClientRESTSelector extends TestCase {
.getUri();
// Create the producer
Response response = client.target(uriCreateProd).request().accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON).post(null);
Response response = client.target(uriCreateProd).request().accept(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON).post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer jms (myQueue1)", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -94,8 +94,10 @@ public class ClientRESTSelector extends TestCase {
String json = gson.toJson(maps);
// Send next message 1
response = client.target(uriSendNextMsg).request().accept(MediaType.TEXT_PLAIN).post(
Entity.entity(json, MediaType.APPLICATION_JSON));
response = client.target(uriSendNextMsg)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(json, MediaType.APPLICATION_JSON));
assertEquals("send-next-message 1", 200, response.getStatus());
uriSendNextMsg = response.getLink("send-next-message").getUri();
// Send next message 2
......@@ -104,7 +106,10 @@ public class ClientRESTSelector extends TestCase {
assertEquals("send-next-message 2", 200, response.getStatus());
// Create the consumer
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer jms (myQueue1)", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
......@@ -118,7 +123,10 @@ public class ClientRESTSelector extends TestCase {
assertEquals("receive-next-message", body, msg);
// Create the consumer invalid selector
response = client.target(uriCreateConsInvalidSelector).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateConsInvalidSelector)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer jms (myQueue1) invalid selector", 201, response.getStatus());
URI uriCloseConsInvalid = response.getLink("close-context").getUri();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
* Copyright (C) 2016 - 2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -70,7 +70,10 @@ public class ClientRESTTextMessage extends TestCase {
URI uriCreateCons = response.getLink("create-consumer").getUri();
response = client.target(response.getLink("create-producer").getUri()).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(response.getLink("create-producer").getUri())
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -78,21 +81,30 @@ public class ClientRESTTextMessage extends TestCase {
String message = "my test message";
String messageNext = "my test message next";
response = client.target(response.getLink("send-message").getUri()).request().
accept(MediaType.TEXT_PLAIN).post(Entity.entity(message, MediaType.TEXT_PLAIN));
response = client.target(response.getLink("send-message").getUri())
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(message, MediaType.TEXT_PLAIN));
assertEquals("send-message", 200, response.getStatus());
response = client.target(response.getLink("send-next-message").getUri()).request().
accept(MediaType.TEXT_PLAIN).post(Entity.entity(messageNext, MediaType.TEXT_PLAIN));
response = client.target(response.getLink("send-next-message").getUri())
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(messageNext, MediaType.TEXT_PLAIN));
assertEquals("send-next-message", 200, response.getStatus());
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
URI uriConsume = response.getLink("receive-message").getUri();
builder = client.target(uriConsume).request().accept(MediaType.TEXT_PLAIN);
builder = client.target(uriConsume)
.request()
.accept(MediaType.TEXT_PLAIN);
response = builder.get();
String msg = response.readEntity(String.class);
assertEquals(200, response.getStatus());
......@@ -100,17 +112,25 @@ public class ClientRESTTextMessage extends TestCase {
assertEquals("receive-message", message, msg);
uriConsume = response.getLink("receive-next-message").getUri();
builder = client.target(uriConsume).request().accept(MediaType.TEXT_PLAIN);
builder = client.target(uriConsume)
.request()
.accept(MediaType.TEXT_PLAIN);
response = builder.get();
msg = response.readEntity(String.class);
assertEquals(200, response.getStatus());
assertNotNull("receive-next-message", msg);
assertEquals("receive-next-message", messageNext, msg);
response = client.target(uriCloseProd).request().accept(MediaType.TEXT_PLAIN).delete();
response = client.target(uriCloseProd)
.request()
.accept(MediaType.TEXT_PLAIN)
.delete();
assertEquals("close-producer", 200, response.getStatus());
response = client.target(uriCloseCons).request().accept(MediaType.TEXT_PLAIN).delete();
response = client.target(uriCloseCons)
.request()
.accept(MediaType.TEXT_PLAIN)
.delete();
assertEquals("close-consumer", 200, response.getStatus());
} catch (Throwable exc) {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 -2018 ScalAgent Distributed Technologies
* Copyright (C) 2016 -2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -174,7 +174,12 @@ public class ClientRESTTextPerf extends TestCase {
URI uri = target.path("admin").path("queue").path(queueName).getUri();
String encodedUserPassword = Base64.getEncoder().encodeToString("admin:admin".getBytes());
// Create a queue
Response response = client.target(uri).queryParam("bind", true).request().header("Authorization", encodedUserPassword).accept(MediaType.TEXT_PLAIN).get();
Response response = client.target(uri)
.queryParam("bind", true)
.request()
.header("Authorization", encodedUserPassword)
.accept(MediaType.TEXT_PLAIN)
.get();
if (response.getStatus() != Response.Status.CREATED.getStatusCode())
throw new Exception("admin createQueue " + response.getStatus());
}
......@@ -183,7 +188,11 @@ public class ClientRESTTextPerf extends TestCase {
URI uri = target.path("admin").path("queue").path(queueName).getUri();
String encodedUserPassword = Base64.getEncoder().encodeToString("admin:admin".getBytes());
// Create a queue
Response response = client.target(uri).request().header("Authorization", encodedUserPassword).accept(MediaType.TEXT_PLAIN).delete();
Response response = client.target(uri)
.request()
.header("Authorization", encodedUserPassword)
.accept(MediaType.TEXT_PLAIN)
.delete();
if (response.getStatus() != Response.Status.OK.getStatusCode())
throw new Exception("admin deleteQueue " + response.getStatus());
}
......@@ -283,7 +292,9 @@ public class ClientRESTTextPerf extends TestCase {
target = target.queryParam("client-id", clientId);
if (name != null)
target = target.queryParam("name", name);
Response response = target.request().accept(MediaType.TEXT_PLAIN).post(null);
Response response = target.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
if (response.getStatus() != Response.Status.CREATED.getStatusCode())
throw new Exception("createConsumer = " + response.getStatus() + ", target = " + target);
return response;
......@@ -295,14 +306,17 @@ public class ClientRESTTextPerf extends TestCase {
target = target.queryParam("client-id", clientId);
if (name != null)
target = target.queryParam("name", name);
Response response = target.request().accept(MediaType.TEXT_PLAIN).post(null);
Response response = target.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
if (response.getStatus() != Response.Status.CREATED.getStatusCode())
throw new Exception("createProducer = " + response.getStatus() + ", " + target);
return response;
}
private URI send(URI uriSendNext, int count, int modulo) throws Exception {
Response response = client.target(uriSendNext).request()
Response response = client.target(uriSendNext)
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity("mon message de test next " + count, MediaType.TEXT_PLAIN));
if (response.getStatus() != Response.Status.OK.getStatusCode())
......@@ -314,7 +328,10 @@ public class ClientRESTTextPerf extends TestCase {
}
private URI consume(URI uriConsume, int count, int modulo) throws Exception {
Response response = client.target(uriConsume).request().accept(MediaType.TEXT_PLAIN).get();
Response response = client.target(uriConsume)
.request()
.accept(MediaType.TEXT_PLAIN)
.get();
String msg = response.readEntity(String.class);
if (response.getStatus() == Response.Status.OK.getStatusCode() && msg != null) {
if (DEBUG &&count%modulo == 0)
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
* Copyright (C) 2016 - 2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -71,24 +71,31 @@ public class ClientRESTTopic extends TestCase {
URI uriCreateProd = response.getLink("create-producer").getUri();
URI uriCreateCons = response.getLink("create-consumer").getUri();
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons)
.request().accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
URI uriConsume = response.getLink("receive-message").getUri();
response = client.target(uriCreateProd).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateProd)
.request().accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
String message = "my text message";
response = client.target(response.getLink("send-message").getUri()).request().
accept(MediaType.TEXT_PLAIN).post(Entity.entity(message, MediaType.TEXT_PLAIN));
response = client.target(response.getLink("send-message").getUri())
.request().accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(message, MediaType.TEXT_PLAIN));
assertEquals("send-message", 200, response.getStatus());
String messageNext = "my text message next";
response = client.target(response.getLink("send-next-message").getUri()).request().
accept(MediaType.TEXT_PLAIN).post(Entity.entity(messageNext, MediaType.TEXT_PLAIN));
response = client.target(response.getLink("send-next-message").getUri())
.request()
.accept(MediaType.TEXT_PLAIN)
.post(Entity.entity(messageNext, MediaType.TEXT_PLAIN));
assertEquals("send-next-message", 200, response.getStatus());
builder = client.target(uriConsume).request().accept(MediaType.TEXT_PLAIN);
......
......@@ -97,7 +97,7 @@ public class ClientRESTTransacted extends TestCase {
URI prodTransacted = response.getLink("create-producer-transacted").getUri();
response = client.target(prodTransacted)
.queryParam("name", "prodTransacted")
.request().accept(MediaType.TEXT_PLAIN).post(null);
.request().accept(MediaType.TEXT_PLAIN).post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer-transacted", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -116,7 +116,7 @@ public class ClientRESTTransacted extends TestCase {
URI sendNextMsg = response.getLink("send-next-message").getUri();
// create a consumer
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateCons).request().accept(MediaType.TEXT_PLAIN).post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
......@@ -197,7 +197,7 @@ public class ClientRESTTransacted extends TestCase {
// create a transacted producer
response = client.target(response.getLink("create-producer").getUri())
.request().accept(MediaType.TEXT_PLAIN).post(null);
.request().accept(MediaType.TEXT_PLAIN).post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-producer", 201, response.getStatus());
URI uriCloseProd = response.getLink("close-context").getUri();
......@@ -217,7 +217,7 @@ public class ClientRESTTransacted extends TestCase {
assertEquals("send-next-message", 200, response.getStatus());
// create a transacted consumer
response = client.target(uriCreateConsTransacted).request().accept(MediaType.TEXT_PLAIN).post(null);
response = client.target(uriCreateConsTransacted).request().accept(MediaType.TEXT_PLAIN).post(Entity.entity(null, MediaType.APPLICATION_FORM_URLENCODED));
assertEquals("create-consumer-transacted", 201, response.getStatus());
URI uriCloseCons = response.getLink("close-context").getUri();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment