Skip to content

Commit 1a6ab71

Browse files
committed
HADOOP-19405. Fix Junit Tests.
1 parent c1274ff commit 1a6ab71

File tree

9 files changed

+97
-48
lines changed

9 files changed

+97
-48
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
import java.util.Set;
2929

3030
import javax.ws.rs.core.MediaType;
31+
import javax.ws.rs.NotAcceptableException;
3132
import javax.ws.rs.NotFoundException;
32-
import javax.ws.rs.ServiceUnavailableException;
3333
import javax.ws.rs.client.WebTarget;
3434
import javax.ws.rs.core.Application;
3535
import javax.ws.rs.core.Response;
36+
import static javax.ws.rs.core.Response.Status.NOT_ACCEPTABLE;
3637
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
37-
import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE;
3838
import javax.xml.parsers.DocumentBuilder;
3939
import javax.xml.parsers.DocumentBuilderFactory;
4040

@@ -231,15 +231,15 @@ public void testInvalidUri2() throws JSONException, Exception {
231231

232232
@Test
233233
public void testInvalidAccept() throws JSONException, Exception {
234-
WebTarget r = target();
234+
WebTarget r = targetWithJsonObject();
235235
String responseStr = "";
236236
try {
237237
responseStr = r.path("ws").path("v1").path("mapreduce")
238238
.request(MediaType.TEXT_PLAIN).get(String.class);
239239
fail("should have thrown exception on invalid uri");
240-
} catch (ServiceUnavailableException sue) {
240+
} catch (NotAcceptableException sue) {
241241
Response response = sue.getResponse();
242-
assertResponseStatusCode(SERVICE_UNAVAILABLE, response.getStatusInfo());
242+
assertResponseStatusCode(NOT_ACCEPTABLE, response.getStatusInfo());
243243
WebServicesTestUtils.checkStringMatch(
244244
"error string exists and shouldn't", "", responseStr);
245245
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020

2121
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
2222
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.fail;
2324
import static org.mockito.Mockito.mock;
2425

2526
import java.io.StringReader;
2627

2728
import javax.servlet.http.HttpServletResponse;
29+
import javax.ws.rs.NotAcceptableException;
2830
import javax.ws.rs.NotFoundException;
29-
import javax.ws.rs.ServiceUnavailableException;
3031
import javax.ws.rs.client.WebTarget;
3132
import javax.ws.rs.core.Application;
3233
import javax.ws.rs.core.MediaType;
@@ -232,12 +233,12 @@ public void testInvalidAccept() throws JSONException, Exception {
232233
WebTarget r = target();
233234
String responseStr = "";
234235
try {
235-
Response response =
236-
r.path("ws").path("v1").path("history").request(MediaType.TEXT_PLAIN).get();
237-
throw new ServiceUnavailableException(response);
238-
} catch (ServiceUnavailableException ue) {
236+
responseStr = r.path("ws").path("v1").path("history").
237+
request(MediaType.TEXT_PLAIN).get(String.class);
238+
fail("should have thrown exception on invalid uri");
239+
} catch (NotAcceptableException ue) {
239240
Response response = ue.getResponse();
240-
assertResponseStatusCode(Response.Status.SERVICE_UNAVAILABLE,
241+
assertResponseStatusCode(Response.Status.NOT_ACCEPTABLE,
241242
response.getStatusInfo());
242243
WebServicesTestUtils.checkStringMatch(
243244
"error string exists and shouldn't", "", responseStr);

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
--add-opens=java.base/sun.security.x509=ALL-UNNAMED
186186
</extraJavaTestArgs>
187187
<!-- Plugin versions and config -->
188-
<maven-surefire-plugin.argLine>-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError ${extraJavaTestArgs}</maven-surefire-plugin.argLine>
188+
<maven-surefire-plugin.argLine>-Xmx2048m -Xss2m -XX:+HeapDumpOnOutOfMemoryError ${extraJavaTestArgs}</maven-surefire-plugin.argLine>
189189
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
190190
<maven-surefire-report-plugin.version>${maven-surefire-plugin.version}</maven-surefire-report-plugin.version>
191191
<maven-failsafe-plugin.version>${maven-surefire-plugin.version}</maven-failsafe-plugin.version>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/ApplicationEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public ApplicationEntity(TimelineEntity entity) {
4343
}
4444

4545
public String getQueue() {
46-
return getInfo().get(QUEUE_INFO_KEY).toString();
46+
if (getInfo() != null) {
47+
if (getInfo().containsKey(QUEUE_INFO_KEY)) {
48+
return getInfo().get(QUEUE_INFO_KEY).toString();
49+
}
50+
}
51+
return "";
4752
}
4853

4954
public void setQueue(String queue) {

0 commit comments

Comments
 (0)