Skip to content

Commit

Permalink
Fix merge issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Feb 26, 2017
1 parent 3831945 commit 31b70fd
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 154 deletions.
2 changes: 1 addition & 1 deletion batch/pom.xml
Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.paho.client.mqttv3.IMqttClient;
import org.seedstack.mqtt.spi.MqttClientInfo;
import org.seedstack.mqtt.spi.MqttInfo;
import org.seedstack.mqtt.spi.MqttPoolConfiguration;
import org.seedstack.mqtt.spi.MqttPoolInfo;
import org.seedstack.seed.rest.Rel;
import org.seedstack.seed.rest.RelRegistry;
import org.seedstack.seed.security.RequiresPermissions;
Expand Down Expand Up @@ -121,12 +121,12 @@ private MqttClient buildClientRepresentation(String clientId, String instanceId)
representation.topics(clientInfo.getTopicFilters());
}

MqttPoolConfiguration poolConf;
if ((poolConf = clientInfo.getMqttPoolConfiguration()) != null) {
representation.poolCoreSize(poolConf.getCoreSize())
.poolKeepAlive(poolConf.getKeepAlive())
.poolMaxSize(poolConf.getMaxSize())
.poolQueueSize(poolConf.getQueueSize());
MqttPoolInfo mqttPoolInfo;
if ((mqttPoolInfo = clientInfo.getMqttPoolInfo()) != null) {
representation.poolCoreSize(mqttPoolInfo.getCoreSize())
.poolKeepAlive(mqttPoolInfo.getKeepAlive())
.poolMaxSize(mqttPoolInfo.getMaxSize())
.poolQueueSize(mqttPoolInfo.getQueueSize());
}
return representation;
}
Expand Down
@@ -1,146 +1,146 @@
/**
* Copyright (c) 2013-2016, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.monitoring.mqtt.internal.rest.clients;

import io.restassured.response.Response;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.seedstack.monitoring.mqtt.fixtures.BrokerFixture;
import org.seedstack.seed.it.AbstractSeedWebIT;

import java.net.URL;

import static io.restassured.RestAssured.expect;
import static io.restassured.path.json.JsonPath.from;
import static org.assertj.core.api.Assertions.assertThat;

public class MqttClientResourceTest extends AbstractSeedWebIT {

private static final String LOGIN = "reader";

private static final String PASSWORD = "password";

private static final String INSTANCE = "f00bar";

@ArquillianResource
private URL baseURL;

@BeforeClass
public static void beforeClass() {
BrokerFixture.startBroker();
}

@AfterClass
public static void afterClass() {
BrokerFixture.stopBroker();
}

@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class);
}

@Test
@RunAsClient
public void testGetClientList() {
Response response = expect().statusCode(200)
.given()
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients");
int resultSize = from(response.asString()).get("totalClients");
assertThat(resultSize).isEqualTo(1);
}

@Test
@RunAsClient
public void testGetClient() {
Response response = expect().statusCode(200)
.given().pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
}

@Test
@RunAsClient
public void testGetClientListWithInstance() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients");
int resultSize = from(response.asString()).get("totalClients");
assertThat(resultSize).isEqualTo(1);
}

@Test
@RunAsClient
public void testGetClientWithInstance() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
}

@Test
@RunAsClient
public void testGetClientListHal() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients");
String href = from(response.asString()).get("_links.self.href");
assertThat(href).startsWith(baseURL.getPath());
assertThat(href).contains(INSTANCE);
String embeddedHref = from(response.asString()).get("_embedded.clients[0]._links.self.href");
assertThat(embeddedHref).startsWith(baseURL.getPath());
assertThat(embeddedHref).contains(INSTANCE);
}

@Test
@RunAsClient
public void testGetClientHal() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
String href = from(response.asString()).get("_links.self.href");
assertThat(href).startsWith(baseURL.getPath());
assertThat(href).contains(INSTANCE);
}

@Test
@RunAsClient
public void testInvalidInstance() {
expect().statusCode(404)
.given().pathParam("instanceId", "***")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/{instanceId}/clients");
}

@Test
@RunAsClient
public void testGetClientNotFound() {
expect().statusCode(404)
.given().pathParam("clientId", "client_fake")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients/{clientId}");
}
}
/**
* Copyright (c) 2013-2016, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.monitoring.mqtt.internal.rest.clients;

import com.jayway.restassured.response.Response;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.seedstack.monitoring.mqtt.fixtures.BrokerFixture;
import org.seedstack.seed.it.AbstractSeedWebIT;

import java.net.URL;

import static com.jayway.restassured.RestAssured.expect;
import static com.jayway.restassured.path.json.JsonPath.from;
import static org.assertj.core.api.Assertions.assertThat;

public class MqttClientResourceIT extends AbstractSeedWebIT {

private static final String LOGIN = "reader";

private static final String PASSWORD = "password";

private static final String INSTANCE = "f00bar";

@ArquillianResource
private URL baseURL;

@BeforeClass
public static void beforeClass() {
BrokerFixture.startBroker();
}

@AfterClass
public static void afterClass() {
BrokerFixture.stopBroker();
}

@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class);
}

@Test
@RunAsClient
public void testGetClientList() {
Response response = expect().statusCode(200)
.given()
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients");
int resultSize = from(response.asString()).get("totalClients");
assertThat(resultSize).isEqualTo(1);
}

@Test
@RunAsClient
public void testGetClient() {
Response response = expect().statusCode(200)
.given().pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
}

@Test
@RunAsClient
public void testGetClientListWithInstance() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients");
int resultSize = from(response.asString()).get("totalClients");
assertThat(resultSize).isEqualTo(1);
}

@Test
@RunAsClient
public void testGetClientWithInstance() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
}

@Test
@RunAsClient
public void testGetClientListHal() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients");
String href = from(response.asString()).get("_links.self.href");
assertThat(href).startsWith(baseURL.getPath());
assertThat(href).contains(INSTANCE);
String embeddedHref = from(response.asString()).get("_embedded.clients[0]._links.self.href");
assertThat(embeddedHref).startsWith(baseURL.getPath());
assertThat(embeddedHref).contains(INSTANCE);
}

@Test
@RunAsClient
public void testGetClientHal() {
Response response = expect().statusCode(200)
.given().pathParam("instanceId", INSTANCE)
.pathParam("clientId", "client_test")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/instance/{instanceId}/clients/{clientId}");
String clientId = from(response.asString()).get("clientId");
assertThat(clientId).isEqualTo("client_test");
String href = from(response.asString()).get("_links.self.href");
assertThat(href).startsWith(baseURL.getPath());
assertThat(href).contains(INSTANCE);
}

@Test
@RunAsClient
public void testInvalidInstance() {
expect().statusCode(404)
.given().pathParam("instanceId", "***")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/{instanceId}/clients");
}

@Test
@RunAsClient
public void testGetClientNotFound() {
expect().statusCode(404)
.given().pathParam("clientId", "client_fake")
.auth().basic(LOGIN, PASSWORD)
.when().get(baseURL.toString() + "seed-monitoring/mqtt/clients/{clientId}");
}
}

0 comments on commit 31b70fd

Please sign in to comment.