.mailmap
| 5
etc/dev-utils/setup-rest/setup.sh
| 17 -
etc/scripts/createRelasenotes.pl
| 5
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AbstractBase.java
| 89 +++++++
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java
| 38 +--
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/EventTest.java
| 20 -
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/GroupTest.java
| 14 -
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/MetricsTest.java
| 9
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
| 21 -
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ReportsTest.java
| 7
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
| 122 ++++++----
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/UserTest.java
| 34 +-
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
| 30 ++
13 files changed, 284 insertions(+), 127 deletions(-)
New commits:
commit ac0be216834e9fc362f4ba5fa006fdd2001609b1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Feb 27 11:19:13 2013 +0100
Add some more mappings and improve generator.
diff --git a/.mailmap b/.mailmap
index 67f51f8..384ec04 100644
--- a/.mailmap
+++ b/.mailmap
@@ -30,6 +30,8 @@ Jason Dobies <jason.dobies(a)redhat.com> <jdobies(a)redhat.com>
Jay Shaughnessy <jshaughn(a)redhat.com>
Jay Shaughnessy <jshaughn(a)redhat.com> <jshaughnessy@jshaughnessy-PC>
Jay Shaughnessy <jshaughn(a)redhat.com> <jshaughnessy@.(none)>
+Jay Shaughnessy <jshaughn(a)redhat.com> <jshaughn(a)jshaughn.csb>
+Jay Shaughnessy <jshaughn(a)redhat.com> Jay Shaughnessy
<jshaughn(a)jshaughn.csb>
Jeff Ortel <jortel(a)redhat.com>
Jessica Sant <jsant(a)redhat.com>
Jijun Liu <lxjijun(a)gmail.com>
@@ -64,6 +66,7 @@ Shannon Hughes <shughes(a)redhat.com>
<shughes(a)fred.hughes.lan>
Simeon Pinder <spinder(a)redhat.com> <simeonpinder(a)gmail.com>
Simeon Pinder <spinder(a)redhat.com> <spinder(a)cacaphonix.conchfritter.com>
Simeon Pinder <spinder(a)redhat.com> <spinder(a)fulliautomatix.conchfritter.com>
+Simeon Pinder <spinder(a)redhat.com> <spinder(a)spinder.csb>
Simeon Pinder <spinder(a)redhat.com>
Stefan Negrea <snegrea(a)redhat.com>
Steve Millidge <smillidge(a)c2b2.co.uk>
@@ -71,4 +74,6 @@ Ted Won 원종석 <tedd824(a)gmail.com>
Test JON User <test_jon(a)jon01.qa.atl2.redhat.com>
Todd B Sanders <tsanders(a)dhcp231-67.rdu.redhat.com>
Torben Jäger <torben(a)jit-central.com>
+Thomas Segismont <tsegismo(a)redhat.com> Thomas SEGISMONT
<tsegismo(a)redhat.com>
+Thomas Segismont <tsegismo(a)redhat.com>
hudson auto <wnstb(a)yahoo.com>
diff --git a/etc/scripts/createRelasenotes.pl b/etc/scripts/createRelasenotes.pl
index 7984d8f..fe42631 100644
--- a/etc/scripts/createRelasenotes.pl
+++ b/etc/scripts/createRelasenotes.pl
@@ -27,7 +27,10 @@ while(<GIT>) {
# print "IN: ", $_;
next if /^$/;
- s/^[\s\[]*BZ\s([0-9]{5,7})(\]? .*)$/ [BZ
$1|https:\/\/bugzilla.redhat.com\/show_bug.cgi\?id\=$1] $2/;
+ s/\${/\$\\{/g;
+ s/^[\s\[]*BZ\s([0-9]{5,7})\s?(\]? .*)$/ [BZ
$1|https:\/\/bugzilla.redhat.com\/show_bug.cgi\?id\=$1] $2/;
+ s/^[\s\[]*BZ-([0-9]{5,7})\s?(\]? .*)$/ [BZ
$1|https:\/\/bugzilla.redhat.com\/show_bug.cgi\?id\=$1] $2/;
+ s/^[\s\[]*BZ([0-9]{5,7})\s?(\]? .*)$/ [BZ
$1|https:\/\/bugzilla.redhat.com\/show_bug.cgi\?id\=$1] $2/;
s/^[\s\[]*Bug\s([0-9]{5,7})(\]? .*)$/ [BZ
$1|https:\/\/bugzilla.redhat.com\/show_bug.cgi\?id\=$1] $2/;
if (/ .*/) {
s/^ (.*)/** $1/;
commit 8f1cc42d33c5221e1e37df61fcb663ee27554d2d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Feb 26 17:27:40 2013 +0100
No longer needed
diff --git a/etc/dev-utils/setup-rest/setup.sh b/etc/dev-utils/setup-rest/setup.sh
deleted file mode 100644
index 0634cd9..0000000
--- a/etc/dev-utils/setup-rest/setup.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-# Set the DEV_CONTAINER to your dev container location
-DEV_CONTAINER=/im/dev-container
-
-
-cd $DEV_CONTAINER/jbossas/server/default/lib
-cp
~/.m2/repository/org/jboss/resteasy/resteasy-jaxrs/2.2.1.GA/resteasy-jaxrs-2.2.1.GA.jar .
-cp
~/.m2/repository/org/jboss/resteasy/resteasy-links/2.2.0.GA/resteasy-links-2.2.0.GA.jar .
-cp
~/.m2/repository/org/jboss/resteasy/resteasy-jettison-provider/2.2.0.GA/resteasy-jettison-provider-2.2.0.GA.jar
.
-cp
~/.m2/repository/org/jboss/resteasy/resteasy-jaxb-provider/2.2.1.GA/resteasy-jaxb-provider-2.2.1.GA.jar
.
-cp ~/.m2/repository/org/scannotation/scannotation/1.0.3/scannotation-1.0.3.jar .
-cp ~/.m2/repository/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar .
-cp ~/.m2/repository/org/codehaus/jettison/1.2/jessison-1.2.jar .
-cp ~/.m2/repository/org/codehaus/jettison/jettison/1.2/jettison-1.2.jar .
-cp ~/.m2/repository/org/jboss/el/jboss-el/2.0.1.GA/jboss-el-2.0.1.GA.jar .
-cp ~/.m2/repository/org/freemarker/freemarker/2.3.18/freemarker-2.3.18.jar .
commit 3eb0ac487e92e5f26174deb2b19eaffc1729937a
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Feb 25 16:37:15 2013 +0100
Make tests independent of a specific id for the platform
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AbstractBase.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AbstractBase.java
index 3d06335..1794062 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AbstractBase.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AbstractBase.java
@@ -18,12 +18,22 @@
*/
package org.rhq.modules.integrationTests.restApi;
+import java.util.List;
+import java.util.Map;
+
import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.response.Header;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
+
+import org.rhq.modules.integrationTests.restApi.d.Resource;
import static com.jayway.restassured.RestAssured.basic;
+import static com.jayway.restassured.RestAssured.given;
/**
* Common setup for the tests
@@ -35,11 +45,15 @@ public abstract class AbstractBase {
private static final String APPLICATION_XML = "application/xml";
private static final String TEXT_CSV = "text/csv";
private static final String TEXT_HTML = "text/html";
+ static final String REST_TEST_DUMMY = "-rest-test-dummy-";
static Header acceptJson = new Header("Accept", APPLICATION_JSON);
static Header acceptXml = new Header("Accept", APPLICATION_XML);
static Header acceptHtml = new Header("Accept", TEXT_HTML);
static Header acceptCsv = new Header("Accept", TEXT_CSV);
+ int _platformId ;
+ int _platformTypeId;
+
@Before
public void setUp() throws Exception {
@@ -48,5 +62,80 @@ public abstract class AbstractBase {
RestAssured.basePath = "/rest/";
RestAssured.authentication = basic("rhqadmin","rhqadmin");
+ Resource resource = new Resource();
+ resource.setResourceName(REST_TEST_DUMMY);
+ resource.setTypeName("Linux");
+
+ Resource platform =
+ given()
+ .header(acceptJson)
+ .contentType(ContentType.JSON)
+ .body(resource)
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms")
+ .as(Resource.class);
+
+ _platformId = platform.getResourceId();
+ _platformTypeId = platform.getTypeId();
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+
+ List res =
+ given()
+ .header(acceptJson)
+ .queryParam("q",REST_TEST_DUMMY)
+ .expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .get("/resource")
+ .as(List.class);
+
+ if (res!=null && res.get(0)!=null) {
+
+ String tmp = ((Map
<String,String>)res.get(0)).get("resourceId");
+ int pid =Integer.valueOf(tmp);
+
+ given()
+ .pathParam("id", pid)
+ .expect()
+ .statusCode(204)
+ .log().ifError()
+ .when()
+ .delete("/resource/{id}");
+
+ }
+ }
+
+ protected int findIdOfARealPlatform() {
+ List res =
+ given()
+ .header(acceptJson)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/platforms")
+ .as(List.class);
+
+ assert res != null;
+ for (Object entry : res) {
+ if (entry instanceof Map) {
+ Map<String,String> map = (Map<String, String>) entry;
+ if (!map.get("resourceName").equals(REST_TEST_DUMMY)) {
+ return Integer.valueOf(map.get("resourceId"));
+ }
+ }
+ }
+
+ assert true : "No real platform found in inventory. Please add one";
+
+ return 0;
}
}
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java
index aa56a46..c3accf3 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java
@@ -259,7 +259,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(201)
.body("dampeningCategory",is("NONE"))
@@ -289,7 +289,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(406)
.log().everything()
@@ -316,7 +316,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(201)
.body("dampeningCategory",is("PARTIAL_COUNT"))
@@ -351,7 +351,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId", 10001)
+ .queryParam("resourceId", _platformId)
.expect()
.statusCode(201)
.body("dampeningCategory",is("DURATION_COUNT"))
@@ -800,7 +800,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(201)
.log().ifError()
@@ -933,7 +933,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.body(alertDefinition)
.log().everything()
- .queryParam("resourceId", 10001)
+ .queryParam("resourceId", _platformId)
.expect()
.statusCode(201)
.log().ifError()
@@ -999,7 +999,7 @@ public class AlertTest extends AbstractBase {
.contentType(ContentType.JSON)
.header(acceptJson)
.body(alertDefinition)
- .queryParam("resourceId", 10001)
+ .queryParam("resourceId", _platformId)
.expect()
.statusCode(201)
.body("priority", is("HIGH"))
@@ -1146,10 +1146,12 @@ public class AlertTest extends AbstractBase {
@Test
public void testCreateDefinitionForGroup() throws Exception {
+ assert _platformTypeId!=0 : "Set up did not run or failed";
+
// Create a group
Group group = new Group("test-group-" +
System.currentTimeMillis()/1000);
group.setCategory("COMPATIBLE");
- group.setResourceTypeId(10001);
+ group.setResourceTypeId(_platformTypeId);
String groupUri =
given()
@@ -1204,7 +1206,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceTypeId",10001)
+ .queryParam("resourceTypeId",_platformTypeId)
.expect()
.statusCode(201)
.log().ifError()
@@ -1242,10 +1244,10 @@ public class AlertTest extends AbstractBase {
// Send a avail down/up sequence -> alert definition should fire
long now = System.currentTimeMillis();
- Availability a = new Availability(10001,now-2000,"DOWN");
+ Availability a = new Availability(_platformId,now-2000,"DOWN");
given()
.contentType(ContentType.JSON)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.body(a)
.expect()
.statusCode(204)
@@ -1253,10 +1255,10 @@ public class AlertTest extends AbstractBase {
.when()
.put("/resource/{id}/availability");
- a = new Availability(10001,now-1000,"UP");
+ a = new Availability(_platformId,now-1000,"UP");
given()
.contentType(ContentType.JSON)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.body(a)
.expect()
.statusCode(204)
@@ -1370,10 +1372,10 @@ public class AlertTest extends AbstractBase {
// Send a avail down/up sequence -> alert definition should fire
long now = System.currentTimeMillis();
- Availability a = new Availability(10001,now-2000,"DOWN");
+ Availability a = new Availability(_platformId,now-2000,"DOWN");
given()
.contentType(ContentType.JSON)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.body(a)
.expect()
.statusCode(204)
@@ -1381,10 +1383,10 @@ public class AlertTest extends AbstractBase {
.when()
.put("/resource/{id}/availability");
- a = new Availability(10001,now-1000,"UP");
+ a = new Availability(_platformId,now-1000,"UP");
given()
.contentType(ContentType.JSON)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.body(a)
.expect()
.statusCode(204)
@@ -1479,7 +1481,7 @@ public class AlertTest extends AbstractBase {
.header(acceptJson)
.contentType(ContentType.JSON)
.body(alertDefinition)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(201)
.log().ifError()
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/EventTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/EventTest.java
index 20caca4..2e74181 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/EventTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/EventTest.java
@@ -43,7 +43,7 @@ public class EventTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("id",10001)
+ .pathParam("id",_platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -57,7 +57,7 @@ public class EventTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("id",10001)
+ .pathParam("id",_platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -89,14 +89,14 @@ public class EventTest extends AbstractBase {
public void testAddEventSourceForUnknownDefinition() throws Exception {
EventSource es = new EventSource();
- es.setResourceId(10001);
+ es.setResourceId(_platformId);
es.setName("Frobnitz"); // Name of the event definition
es.setLocation("-x-test-location");
given()
.header(acceptJson)
.contentType(ContentType.JSON)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.body(es)
.expect()
.statusCode(404)
@@ -108,7 +108,7 @@ public class EventTest extends AbstractBase {
public void testAddGetDeleteEventSource() throws Exception {
EventSource es = new EventSource();
- es.setResourceId(10001);
+ es.setResourceId(_platformId);
es.setName("Event Log"); // Name of the event definition
es.setLocation("-x-test-location");
@@ -116,7 +116,7 @@ public class EventTest extends AbstractBase {
given()
.header(acceptJson)
.contentType(ContentType.JSON)
- .pathParam("id",10001)
+ .pathParam("id",_platformId)
.body(es)
.expect()
.statusCode(200)
@@ -148,7 +148,7 @@ public class EventTest extends AbstractBase {
response =
given()
.header(acceptJson)
- .pathParam("id",10001)
+ .pathParam("id",_platformId)
.expect()
.statusCode(200)
.when()
@@ -178,7 +178,7 @@ public class EventTest extends AbstractBase {
public void testAddGetEventOnSource() throws Exception {
EventSource es = new EventSource();
- es.setResourceId(10001);
+ es.setResourceId(_platformId);
es.setName("Event Log"); // Name of the event definition
es.setLocation("-x-test-location");
@@ -186,7 +186,7 @@ public class EventTest extends AbstractBase {
given()
.header(acceptJson)
.contentType(ContentType.JSON)
- .pathParam("id",10001)
+ .pathParam("id",_platformId)
.body(es)
.expect()
.statusCode(200)
@@ -235,7 +235,7 @@ public class EventTest extends AbstractBase {
response =
given()
.header(acceptJson)
- .pathParam("id", 10001)
+ .pathParam("id", _platformId)
.queryParam("startTime",now - 10)
.queryParam("endTime",now + 10)
.expect()
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/GroupTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/GroupTest.java
index f6ffbe7..646f81c 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/GroupTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/GroupTest.java
@@ -46,7 +46,6 @@ public class GroupTest extends AbstractBase {
private static final String X_TEST_GROUP = "-x-test-group";
- @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -214,6 +213,9 @@ public class GroupTest extends AbstractBase {
@Test
public void testAddResourceToGroup() throws Exception {
+
+ assert _platformId !=0 : "Set up did not run or was not successful";
+
Group group = new Group(X_TEST_GROUP);
// Generate the group
@@ -237,7 +239,7 @@ public class GroupTest extends AbstractBase {
.contentType(ContentType.JSON)
.body(group)
.pathParam("id", id)
- .pathParam("resourceId",10001)
+ .pathParam("resourceId",_platformId)
.expect()
.statusCode(HttpStatus.SC_OK)
.log().ifError()
@@ -281,7 +283,7 @@ public class GroupTest extends AbstractBase {
.contentType(ContentType.JSON)
.body(group)
.pathParam("gid", groupId)
- .pathParam("resourceId",10001)
+ .pathParam("resourceId",_platformId)
.expect()
.statusCode(HttpStatus.SC_OK)
.log().ifError()
@@ -390,7 +392,7 @@ public class GroupTest extends AbstractBase {
.contentType(ContentType.JSON)
.body(group)
.pathParam("id",id)
- .pathParam("resourceId",10001)
+ .pathParam("resourceId",_platformId)
.expect()
.statusCode(HttpStatus.SC_OK)
.log().ifError()
@@ -401,7 +403,7 @@ public class GroupTest extends AbstractBase {
given()
.header(acceptJson)
.pathParam("id",id)
- .pathParam("resourceId",10001)
+ .pathParam("resourceId",_platformId)
.expect()
.statusCode(HttpStatus.SC_OK)
.log().ifError()
@@ -425,7 +427,7 @@ public class GroupTest extends AbstractBase {
public void testGetMetricDefinitionsForGroup() throws Exception {
Group group = new Group(X_TEST_GROUP);
group.setCategory("COMPATIBLE");
- group.setResourceTypeId(10001);
+ group.setResourceTypeId(_platformTypeId);
// Generate the group
Response response =
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/MetricsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/MetricsTest.java
index 28fa806..0e7506d 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/MetricsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/MetricsTest.java
@@ -46,21 +46,21 @@ public class MetricsTest extends AbstractBase {
private int numericScheduleId;
private long defaultInterval;
- @Override
@Before
public void setUp() throws Exception {
- super.setUp();// is not called by junit before this one
+ super.setUp();
// Determine a schedule id for the common cases
Response r =
given()
.header(acceptJson)
.queryParam("type", "metric")
+ .pathParam("rid",_platformId)
.expect()
.statusCode(200)
.log().ifError()
.when()
- .get("/resource/10001/schedules");
+ .get("/resource/{rid}/schedules");
JsonPath jp = r.jsonPath();
numericScheduleId = jp.getInt("[0].scheduleId");
@@ -216,11 +216,12 @@ public class MetricsTest extends AbstractBase {
given()
.header(acceptJson)
.queryParam("type", "trait")
+ .pathParam("rid",_platformId)
.expect()
.statusCode(200)
.log().ifError()
.when()
- .get("/resource/10001/schedules");
+ .get("/resource/{rid}/schedules");
JsonPath jp = r.jsonPath();
int tsId = jp.getInt("[0].scheduleId");
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
index 18b0297..b4dc580 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -43,14 +43,14 @@ public class OperationsTest extends AbstractBase {
private int definitionId;
- @Override
@Before
public void setUp() throws Exception {
- super.setUp(); // Junit does not call that for us
+ super.setUp();
+
Response r =
given()
.header(acceptJson)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -90,7 +90,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
.pathParam("definitionId",definitionId)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -118,7 +118,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
.pathParam("definitionId",definitionId)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",_platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -156,11 +156,13 @@ public class OperationsTest extends AbstractBase {
@Test
public void testCreateDraftOperationAndScheduleExecution() throws Exception {
+ int platformId = findIdOfARealPlatform();
+
Operation draft =
given()
.header(acceptJson)
.pathParam("definitionId",definitionId)
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",platformId)
.expect()
.statusCode(200)
.log().ifError()
@@ -174,7 +176,7 @@ public class OperationsTest extends AbstractBase {
int draftId = draft.getId();
draft.setReadyToSubmit(true);
- draft.getParams().put("detailed", true);
+ draft.getParams().put("detailedDiscovery", false);
// update to schedule
Operation scheduled =
@@ -213,7 +215,7 @@ public class OperationsTest extends AbstractBase {
// See if we also find it when we are looking for histories on the resource
Response response =
given()
- .queryParam("resourceId",10001)
+ .queryParam("resourceId",platformId)
.header(acceptJson)
.expect()
.statusCode(200)
@@ -269,7 +271,6 @@ public class OperationsTest extends AbstractBase {
.delete("/operation/history/{hid}");
}
-
}
}
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ReportsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ReportsTest.java
index a76a640..2c16ba2 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ReportsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ReportsTest.java
@@ -38,13 +38,6 @@ public class ReportsTest extends AbstractBase {
private static final int NUMBER_REPORTS = 9;
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- }
-
@Test
public void testReportListJson() throws Exception {
given()
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
index 27bf5a2..a889ffc 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,7 @@ import org.apache.http.HttpStatus;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
+import org.rhq.modules.integrationTests.restApi.d.Availability;
import org.rhq.modules.integrationTests.restApi.d.Resource;
import static com.jayway.restassured.RestAssured.expect;
@@ -61,12 +62,14 @@ public class ResourcesTest extends AbstractBase {
given()
.header("Accept","application/json")
+ .pathParam("id",_platformId)
.expect()
.statusCode(200)
.contentType(ContentType.JSON)
+ .log().ifError()
.body("links.rel", CoreMatchers.hasItem("self"))
.when()
- .get("/resource/10001");
+ .get("/resource/{id}");
}
@@ -132,33 +135,40 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformXml() {
+
+ assert _platformId!=0 : "Setup did not run or was no success";
+
given()
.header("Accept", "application/xml")
+ .pathParam("id",_platformId)
.expect()
.statusCode(200)
.contentType(ContentType.XML)
.when()
- .get("/resource/10001");
+ .get("/resource/{id}");
}
@Test
public void testGetPlatformSchedules() {
given()
.header("Accept", "application/json")
+ .pathParam("id", _platformId)
.expect()
.statusCode(200)
+ .log().ifError()
.when()
- .get("/resource/10001/schedules");
+ .get("/resource/{id}/schedules");
}
@Test
public void testGetPlatformChildren() {
given()
- .header("Accept","application/json")
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
.expect()
.statusCode(200)
.when()
- .get("/resource/10001/children");
+ .get("/resource/{id}/children");
}
@Test
@@ -421,60 +431,81 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testAlertsForResource() throws Exception {
given()
- .header("Accept","application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/alerts");
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/alerts");
}
@Test
public void testSchedulesForResource() throws Exception {
given()
- .header("Accept","application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/schedules");
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/schedules");
}
@Test
public void testAvailabilityForResource() throws Exception {
given()
- .header("Accept", "application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/availability");
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/availability");
}
@Test
public void testAvailabilityHistoryForResource() throws Exception {
given()
- .header("Accept", "application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/availability/history");
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/availability/history");
}
@Test
public void testUpdateAvailability() throws Exception {
- Response response = given()
+ Response response =
+ given()
.header("Accept", "application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/availability");
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/availability");
String oldType = response.jsonPath().get("type");
try {
long now = System.currentTimeMillis()-100;
- given().body("{\"since\":" + now +
",\"type\":\"DOWN\",\"resourceId\":10001}")
- .header("Content-Type","application/json")
- .header("Accept","application/json")
- .pathParam("id",10001)
+ given()
+ .body("{\"since\":" + now +
",\"type\":\"DOWN\",\"resourceId\":" + _platformId
+ "}")
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
.expect()
- .statusCode(HttpStatus.SC_NO_CONTENT)
- .log().ifError()
- .when().put("/resource/{id}/availability");
+ .statusCode(HttpStatus.SC_NO_CONTENT)
+ .log().ifError()
+ .when()
+ .put("/resource/{id}/availability");
response = given()
.header("Accept", "application/json")
- .expect().statusCode(200)
- .when().get("/resource/10001/availability");
+ .pathParam("id", _platformId)
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource/{id}/availability");
String currentType = response.jsonPath().get("type");
assert currentType.equals("DOWN"); // TODO small window where an
agent may have sent an update
@@ -482,13 +513,14 @@ public class ResourcesTest extends AbstractBase {
// Set back to original value
long now = System.currentTimeMillis()-100;
- given().body("{\"since\":" + now +
",\"type\":\""+oldType+"\",\"resourceId\":10001}")
- .header("Content-Type","application/json")
- .header("Accept","application/json")
- .pathParam("id",10001)
+ given()
+ .body("{\"since\":" + now +
",\"type\":\"" + oldType +
"\",\"resourceId\":" + _platformId + "}")
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
.expect()
- .statusCode(HttpStatus.SC_NO_CONTENT)
- .log().ifError()
+ .statusCode(HttpStatus.SC_NO_CONTENT)
+ .log().ifError()
.when().put("/resource/{id}/availability");
}
@@ -500,14 +532,18 @@ public class ResourcesTest extends AbstractBase {
// Platforms should not be set to DISABLED according ot JSHAUGHN
long now = System.currentTimeMillis()-100;
- given().body("{\"since\":" + now +
",\"type\":\"DISABLED\",\"resourceId\":10001}")
- .header("Content-Type","application/json")
- .header("Accept","application/json")
- .pathParam("id",10001)
+ Availability avail = new Availability(_platformId,now,"DISABLED");
+
+ given()
+ .body(avail)
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .pathParam("id", _platformId)
.expect()
- .statusCode(HttpStatus.SC_NOT_ACCEPTABLE)
- .log().ifError()
- .when().put("/resource/{id}/availability");
+ .statusCode(HttpStatus.SC_NOT_ACCEPTABLE)
+ .log().ifError()
+ .when()
+ .put("/resource/{id}/availability");
}
}
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/UserTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/UserTest.java
index 07e2f29..e199dc5 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/UserTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/UserTest.java
@@ -40,38 +40,50 @@ public class UserTest extends AbstractBase {
@Test
public void testGetFavoritesResources() throws Exception {
- expect().statusCode(200)
- .log().ifError()
- .when().get("/user/favorites/resource");
+ expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .get("/user/favorites/resource");
}
@Test
public void testGetFavoriteGroups() throws Exception {
- expect().statusCode(200)
- .log().ifError()
- .when().get("/user/favorites/group");
+ expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .get("/user/favorites/group");
}
@Test
public void testAddRemoveFavoriteResources() throws Exception {
- expect().statusCode(204)
- .when().put("/user/favorites/resource/10001");
+ given()
+ .pathParam("rid",_platformId)
+ .expect()
+ .statusCode(204)
+ .when()
+ .put("/user/favorites/resource/{rid}");
try {
Response r =
expect()
.statusCode(200)
+ .log().everything()
.when()
.get("/user/favorites/resource");
JsonPath jp = r.jsonPath();
- assert jp.getList("resourceId").contains("10001");
+ assert
jp.getList("resourceId").contains(String.valueOf(_platformId));
}
finally {
- expect()
+ given()
+ .pathParam("rid",_platformId)
+ .expect()
.statusCode(204)
- .when().delete("/user/favorites/resource/10001");
+ .when()
+ .delete("/user/favorites/resource/{rid}");
}
}
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
index 9c3c1a3..6cbcea0 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
@@ -19,6 +19,9 @@
package org.rhq.modules.integrationTests.restApi.d;
+import java.util.List;
+import java.util.Map;
+
/**
* A resource for testing purposes
* @author Heiko W. Rupp
@@ -30,6 +33,9 @@ public class Resource {
String typeName;
String pluginName;
Integer parentId;
+ int typeId;
+ List<Map> links;
+ String ancestry;
public Resource() {
}
@@ -73,4 +79,28 @@ public class Resource {
public void setTypeName(String typeName) {
this.typeName = typeName;
}
+
+ public int getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(int typeId) {
+ this.typeId = typeId;
+ }
+
+ public List<Map> getLinks() {
+ return links;
+ }
+
+ public void setLinks(List<Map> links) {
+ this.links = links;
+ }
+
+ public String getAncestry() {
+ return ancestry;
+ }
+
+ public void setAncestry(String ancestry) {
+ this.ancestry = ancestry;
+ }
}