slfan1989 commented on code in PR #7019:
URL: https://github.com/apache/hadoop/pull/7019#discussion_r1903240972
##########
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java:
##########
@@ -68,215 +68,212 @@
*/
public class TestAMWebServices extends JerseyTestBase {
- private static Configuration conf = new Configuration();
+ private static final Configuration CONF = new Configuration();
private static MockAppContext appContext;
- private static class WebServletModule extends ServletModule {
- @Override
- protected void configureServlets() {
+ @Override
+ protected Application configure() {
+ ResourceConfig config = new ResourceConfig();
+ config.register(new JerseyBinder());
+ config.register(AMWebServices.class);
+ config.register(GenericExceptionHandler.class);
+ config.register(new JettisonFeature()).register(JAXBContextResolver.class);
+ return config;
+ }
+ private static class JerseyBinder extends AbstractBinder {
+ @Override
+ protected void configure() {
appContext = new MockAppContext(0, 1, 1, 1);
appContext.setBlacklistedNodes(Sets.newHashSet("badnode1", "badnode2"));
-
- bind(JAXBContextResolver.class);
- bind(AMWebServices.class);
- bind(GenericExceptionHandler.class);
- bind(AppContext.class).toInstance(appContext);
- bind(Configuration.class).toInstance(conf);
-
- serve("/*").with(GuiceContainer.class);
+ App app = new App(appContext);
+ bind(appContext).to(AppContext.class).named("am");
+ bind(app).to(App.class).named("app");
+ bind(CONF).to(Configuration.class).named("conf");
+ final HttpServletResponse response = mock(HttpServletResponse.class);
+ bind(response).to(HttpServletResponse.class);
}
}
- static {
- GuiceServletConfig.setInjector(
- Guice.createInjector(new WebServletModule()));
- }
-
- @Before
@Override
public void setUp() throws Exception {
Review Comment:
I will prepare a comprehensive document to explain all my improvement ideas.
The part you mentioned will be included in the document.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]