Skip to content

Commit

Permalink
We shouldn't test error messages we don't control (these messages are…
Browse files Browse the repository at this point in the history
… generated by the JAX-RS impl)
  • Loading branch information
tsegismont authored and Stefan Negrea committed Aug 13, 2015
1 parent 65b1c07 commit 8b2ff44
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions rest-tests/src/test/java/org/hawkular/metrics/test/ErrorsITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/
package org.hawkular.metrics.test;

import static org.junit.Assert.assertEquals;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.junit.After;
import org.junit.Assert;
import org.junit.Test;

/**
Expand All @@ -44,10 +45,9 @@ public void testNotAllowedException() {
.request(MediaType.APPLICATION_JSON_TYPE)
.header(TENANT_HEADER_NAME, "test")
.post(null);
Assert.assertEquals(405, response.getStatus());
assertEquals(405, response.getStatus());
ApiErrorJson apiErrorJson = response.readEntity(ApiErrorJson.class);
Assert.assertEquals("No resource method found for POST, return 405 with Allow header",
apiErrorJson.getErrorMsg());
assertEquals("No resource method found for POST, return 405 with Allow header", apiErrorJson.getErrorMsg());
}

@Test
Expand All @@ -58,11 +58,7 @@ public void testNotFoundException() {
.request(MediaType.APPLICATION_JSON_TYPE)
.header(TENANT_HEADER_NAME, "test")
.get();
Assert.assertEquals(404, response.getStatus());
ApiErrorJson apiErrorJson = response.readEntity(ApiErrorJson.class);
Assert.assertEquals("Could not find resource for full path: http://"+baseURI
+ "/gaugesssss/test/data?buckets=999",
apiErrorJson.getErrorMsg());
assertEquals(404, response.getStatus());
}

@Test
Expand All @@ -73,10 +69,9 @@ public void testNumberFormatException() {
.request(MediaType.APPLICATION_JSON_TYPE)
.header(TENANT_HEADER_NAME, "test")
.get();
Assert.assertEquals(400, response.getStatus());
assertEquals(400, response.getStatus());
ApiErrorJson apiErrorJson = response.readEntity(ApiErrorJson.class);
Assert.assertEquals("For input string: \"999999999999999999999999\"",
apiErrorJson.getErrorMsg());
assertEquals("For input string: \"999999999999999999999999\"", apiErrorJson.getErrorMsg());
}

@Test
Expand All @@ -86,10 +81,7 @@ public void testNotAcceptableException() {
.request(MediaType.TEXT_PLAIN)
.header(TENANT_HEADER_NAME, "test")
.get();
Assert.assertEquals(406, response.getStatus());
ApiErrorJson apiErrorJson = response.readEntity(ApiErrorJson.class);
Assert.assertEquals("No match for accept header",
apiErrorJson.getErrorMsg());
assertEquals(406, response.getStatus());
}

@Test
Expand All @@ -99,9 +91,8 @@ public void testNotSupportedException() {
.request(MediaType.TEXT_PLAIN)
.header(TENANT_HEADER_NAME, "test")
.post(null);
Assert.assertEquals(415, response.getStatus());
assertEquals(415, response.getStatus());
ApiErrorJson apiErrorJson = response.readEntity(ApiErrorJson.class);
Assert.assertEquals("Cannot consume content type",
apiErrorJson.getErrorMsg());
assertEquals("Cannot consume content type", apiErrorJson.getErrorMsg());
}
}

0 comments on commit 8b2ff44

Please sign in to comment.