From a5ebccd7bc947e7356574e1cadd7c72174873155 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Tue, 9 Oct 2012 22:54:11 +0000 Subject: [PATCH] YARN-30. Fixed tests verifying web-services to work on JDK7. Contributed by Thomas Graves. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1396391 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../hadoop/yarn/webapp/WebServicesTestUtils.java | 7 +++++++ .../nodemanager/webapp/TestNMWebServicesApps.java | 12 ++++++------ .../webapp/TestRMWebServicesApps.java | 8 ++++---- .../webapp/TestRMWebServicesNodes.java | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 37cdc5c3409..558c632fe2a 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -71,6 +71,9 @@ Release 2.0.3-alpha - Unreleased YARN-134. ClientToAMSecretManager creates keys without checking for validity of the appID. (Vinod Kumar Vavilapalli via sseth) + YARN-30. Fixed tests verifying web-services to work on JDK7. (Thomas Graves + via vinodkv) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java index abcca519132..d82771b8415 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java @@ -79,4 +79,11 @@ public class WebServicesTestUtils { got.matches(expected)); } + public static void checkStringContains(String print, String expected, String got) { + assertTrue( + print + " doesn't contain expected string, got: " + got + " expected: " + expected, + got.contains(expected)); + } + + } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java index e5d90b2c8c1..f0c5272ce98 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java @@ -382,7 +382,7 @@ public class TestNMWebServicesApps extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - verifyStatInvalidException(message, type, classname); + verifyStateInvalidException(message, type, classname); } } @@ -412,7 +412,7 @@ public class TestNMWebServicesApps extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - verifyStatInvalidException(message, type, classname); + verifyStateInvalidException(message, type, classname); } } @@ -450,16 +450,16 @@ public class TestNMWebServicesApps extends JerseyTest { String type = WebServicesTestUtils.getXmlString(element, "exception"); String classname = WebServicesTestUtils.getXmlString(element, "javaClassName"); - verifyStatInvalidException(message, type, classname); + verifyStateInvalidException(message, type, classname); } } - private void verifyStatInvalidException(String message, String type, + private void verifyStateInvalidException(String message, String type, String classname) { WebServicesTestUtils - .checkStringMatch( + .checkStringContains( "exception message", - "No enum const class org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState.FOO_STATE", + "org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState.FOO_STATE", message); WebServicesTestUtils.checkStringMatch("exception type", "IllegalArgumentException", type); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java index 3bb9e56cb5b..b81237d0b8c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java @@ -280,9 +280,9 @@ public class TestRMWebServicesApps extends JerseyTest { String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); WebServicesTestUtils - .checkStringMatch( + .checkStringContains( "exception message", - "No enum const class org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState.INVALID_test", + "org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState.INVALID_test", message); WebServicesTestUtils.checkStringMatch("exception type", "IllegalArgumentException", type); @@ -359,9 +359,9 @@ public class TestRMWebServicesApps extends JerseyTest { String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); WebServicesTestUtils - .checkStringMatch( + .checkStringContains( "exception message", - "No enum const class org.apache.hadoop.yarn.api.records.FinalApplicationStatus.INVALID_test", + "org.apache.hadoop.yarn.api.records.FinalApplicationStatus.INVALID_test", message); WebServicesTestUtils.checkStringMatch("exception type", "IllegalArgumentException", type); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java index 084dcffe4cb..533ea11b68b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java @@ -229,9 +229,9 @@ public class TestRMWebServicesNodes extends JerseyTest { String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); WebServicesTestUtils - .checkStringMatch( + .checkStringContains( "exception message", - "No enum const class org.apache.hadoop.yarn.api.records.NodeState.BOGUSSTATE", + "org.apache.hadoop.yarn.api.records.NodeState.BOGUSSTATE", message); WebServicesTestUtils.checkStringMatch("exception type", "IllegalArgumentException", type);