Program: 34544
Project: 34544
Buggy source:
/** 
 * Verify the following: <OL> <LI> An ear file that contains two war files. One war file contains two servlets, the other one contains one servlet. Each war files has one jar file. In this test case the following configuration will be used. 1. WAR 1 will use the LDAP Identity Store. 2. WAR 2 will use the LDAP2 Identity Store. </OL> <P> Users will fail to access the apps because of wrong realm. <OL> <LI> </OL>
 */
@Mode(TestMode.LITE) @Test public void testEJBAnnotatedLdapISRealmOnWar1andWar2IncorrectRealm() throws Exception {
  String response;
  String queryString;
  Log.info(logClass,getCurrentTestName(),"String_Node_Str" + getCurrentTestName());
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  WCApplicationHelper.createWar(myServer,TEMP_DIR,EJB_REALM1_WAR_NAME,true,EJB_BEAN_JAR_NAME,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  WCApplicationHelper.createWar(myServer,TEMP_DIR,EJB_REALM2_WAR_NAME,true,EJB_BEAN_JAR_NAME,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  WCApplicationHelper.packageWarsToEar(myServer,TEMP_DIR,EJB_EAR_REALM_NAME,true,EJB_REALM1_WAR_NAME);
  WCApplicationHelper.packageWarsToEar(myServer,TEMP_DIR,EJB_EAR_REALM2_NAME,true,EJB_REALM2_WAR_NAME);
  WCApplicationHelper.addEarToServerApps(myServer,TEMP_DIR,EJB_EAR_REALM_NAME);
  WCApplicationHelper.addEarToServerApps(myServer,TEMP_DIR,EJB_EAR_REALM2_NAME);
  WCApplicationHelper.addWarToServerApps(myServer,"String_Node_Str",true,JAR_NAME,false,"String_Node_Str","String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  startServer(XML_INCORRECT_REALM,EJB_REALM_APP_NAME,EJB_REALM2_APP_NAME);
  assertNotNull("String_Node_Str",myServer.waitForStringInLog("String_Node_Str"));
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  queryString=EJB_REALM1_WAR_PATH + SIMPLE_SERVLET_REALM1 + "String_Node_Str";
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  response=executeGetRequestBasicAuthCreds(httpclient,urlBase + queryString,LocalLdapServer.USER1,LocalLdapServer.PASSWORD,HttpServletResponse.SC_FORBIDDEN);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbErrorUserResponse(response,Constants.ejbAuthorizationFailed);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  httpclient.getConnectionManager().shutdown();
  setupConnection();
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  queryString=EJB_REALM2_WAR_PATH + SIMPLE_SERVLET_REALM2 + "String_Node_Str";
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  response=executeGetRequestBasicAuthCreds(httpclient,urlBase + queryString,LocalLdapServer.USER1,LocalLdapServer.ANOTHERPASSWORD,HttpServletResponse.SC_FORBIDDEN);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbErrorUserResponse(response,Constants.ejbAuthorizationFailed);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  httpclient.getConnectionManager().shutdown();
  setupConnection();
  myServer.removeInstalledAppForValidation(EJB_REALM_APP_NAME);
  myServer.removeInstalledAppForValidation(EJB_REALM2_APP_NAME);
  myServer.stopServer();
  Log.info(logClass,getCurrentTestName(),"String_Node_Str" + getCurrentTestName());
}

Fixed version (ground truth):
/** 
 * Verify the following: <OL> <LI> An ear file that contains two war files. One war file contains two servlets, the other one contains one servlet. Each war files has one jar file. In this test case the following configuration will be used. 1. WAR 1 will use the LDAP Identity Store. 2. WAR 2 will use the LDAP2 Identity Store. </OL> <P> Users will fail to access the apps because of wrong realm. <OL> <LI> </OL>
 */
@Mode(TestMode.LITE) @Test public void testEJBAnnotatedLdapISRealmOnWar1andWar2IncorrectRealm() throws Exception {
  String response;
  String queryString;
  Log.info(logClass,getCurrentTestName(),"String_Node_Str" + getCurrentTestName());
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  WCApplicationHelper.createWar(myServer,TEMP_DIR,EJB_REALM1_WAR_NAME,true,EJB_BEAN_JAR_NAME,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  WCApplicationHelper.createWar(myServer,TEMP_DIR,EJB_REALM2_WAR_NAME,true,EJB_BEAN_JAR_NAME,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  WCApplicationHelper.packageWarsToEar(myServer,TEMP_DIR,EJB_EAR_REALM_NAME,true,EJB_REALM1_WAR_NAME);
  WCApplicationHelper.packageWarsToEar(myServer,TEMP_DIR,EJB_EAR_REALM2_NAME,true,EJB_REALM2_WAR_NAME);
  WCApplicationHelper.addEarToServerApps(myServer,TEMP_DIR,EJB_EAR_REALM_NAME);
  WCApplicationHelper.addEarToServerApps(myServer,TEMP_DIR,EJB_EAR_REALM2_NAME);
  WCApplicationHelper.addWarToServerApps(myServer,"String_Node_Str",true,JAR_NAME,false,"String_Node_Str","String_Node_Str");
  Log.info(logClass,"String_Node_Str","String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  startServer(XML_INCORRECT_REALM,EJB_REALM_APP_NAME,EJB_REALM2_APP_NAME);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  queryString=EJB_REALM1_WAR_PATH + SIMPLE_SERVLET_REALM1 + "String_Node_Str";
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  response=executeGetRequestBasicAuthCreds(httpclient,urlBase + queryString,LocalLdapServer.USER1,LocalLdapServer.PASSWORD,HttpServletResponse.SC_FORBIDDEN);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbErrorUserResponse(response,Constants.ejbAuthorizationFailed);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  httpclient.getConnectionManager().shutdown();
  setupConnection();
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  queryString=EJB_REALM2_WAR_PATH + SIMPLE_SERVLET_REALM2 + "String_Node_Str";
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  response=executeGetRequestBasicAuthCreds(httpclient,urlBase + queryString,LocalLdapServer.USER1,LocalLdapServer.ANOTHERPASSWORD,HttpServletResponse.SC_FORBIDDEN);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbErrorUserResponse(response,Constants.ejbAuthorizationFailed);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  httpclient.getConnectionManager().shutdown();
  setupConnection();
  myServer.removeInstalledAppForValidation(EJB_REALM_APP_NAME);
  myServer.removeInstalledAppForValidation(EJB_REALM2_APP_NAME);
  myServer.stopServer();
  Log.info(logClass,getCurrentTestName(),"String_Node_Str" + getCurrentTestName());
}