Program: 34543
Project: 34543
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 be able to access the application since they are using the correct realm. <OL> <LI> </OL>
 */
@Mode(TestMode.LITE) @Test public void testEJBAnnotatedLdapISRealmOnWar1andWar2CorrectRealm() 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_REALM_NAME,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_OK);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbUserResponse(response,Constants.getEJBBeanResponse + Constants.ejb03Bean,Constants.getEjbBeanMethodName + Constants.ejbBeanMethodManager,Constants.getEjbCallerPrincipal + LocalLdapServer.USER1);
  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_OK);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbUserResponse(response,Constants.getEJBBeanResponse + Constants.ejb03Bean,Constants.getEjbBeanMethodName + Constants.ejbBeanMethodManager,Constants.getEjbCallerPrincipal + LocalLdapServer.USER1);
  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 be able to access the application since they are using the correct realm. <OL> <LI> </OL>
 */
@Mode(TestMode.LITE) @Test public void testEJBAnnotatedLdapISRealmOnWar1andWar2CorrectRealm() 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_REALM_NAME,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_OK);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbUserResponse(response,Constants.getEJBBeanResponse + Constants.ejb03Bean,Constants.getEjbBeanMethodName + Constants.ejbBeanMethodManager,Constants.getEjbCallerPrincipal + LocalLdapServer.USER1);
  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_OK);
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  Log.info(logClass,getCurrentTestName(),"String_Node_Str");
  verifyEjbUserResponse(response,Constants.getEJBBeanResponse + Constants.ejb03Bean,Constants.getEjbBeanMethodName + Constants.ejbBeanMethodManager,Constants.getEjbCallerPrincipal + LocalLdapServer.USER1);
  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());
}