Program: 20710
Project: 20710
Buggy source:
public void testPutWithValidUserWithWriteAccess() throws Exception {
  setupCleanRepo(repoRootInternal);
  assertTrue(repoRootInternal.exists());
  String putUrl="String_Node_Str";
  InputStream is=getClass().getResourceAsStream("String_Node_Str");
  assertNotNull("String_Node_Str",is);
  WebRequest request=new PutMethodWebRequest(putUrl,is,"String_Node_Str");
  InvocationContext ic=sc.newInvocation(request);
  servlet=(RepositoryServlet)ic.getServlet();
  servlet.setDavSessionProvider(davSessionProvider);
  ArchivaDavResourceFactory archivaDavResourceFactory=(ArchivaDavResourceFactory)servlet.getResourceFactory();
  archivaDavResourceFactory.setHttpAuth(httpAuth);
  archivaDavResourceFactory.setServletAuth(servletAuth);
  TestAuditListener listener=new TestAuditListener();
  archivaDavResourceFactory.addAuditListener(listener);
  servlet.setResourceFactory(archivaDavResourceFactory);
  AuthenticationResult result=new AuthenticationResult();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,null),true);
  User user=new SimpleUser();
  user.setUsername("String_Node_Str");
  SecuritySession session=new DefaultSecuritySession();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  httpAuthControl.expectAndReturn(httpAuth.getSecuritySession(ic.getRequest().getSession(true)),session);
  httpAuthControl.expectAndReturn(httpAuth.getSessionUser(ic.getRequest().getSession()),user);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),true);
  httpAuthControl.replay();
  servletAuthControl.replay();
  servlet.service(ic.getRequest(),ic.getResponse());
  httpAuthControl.verify();
  servletAuthControl.verify();
  assertEquals("String_Node_Str",listener.getEvents().get(0).getUserId());
}

Fixed version (ground truth):
@Test public void testPutWithValidUserWithWriteAccess() throws Exception {
  setupCleanRepo(repoRootInternal);
  assertTrue(repoRootInternal.exists());
  String putUrl="String_Node_Str";
  InputStream is=getClass().getResourceAsStream("String_Node_Str");
  assertNotNull("String_Node_Str",is);
  WebRequest request=new PutMethodWebRequest(putUrl,is,"String_Node_Str");
  InvocationContext ic=sc.newInvocation(request);
  servlet=(RepositoryServlet)ic.getServlet();
  servlet.setDavSessionProvider(davSessionProvider);
  ArchivaDavResourceFactory archivaDavResourceFactory=(ArchivaDavResourceFactory)servlet.getResourceFactory();
  archivaDavResourceFactory.setHttpAuth(httpAuth);
  archivaDavResourceFactory.setServletAuth(servletAuth);
  TestAuditListener listener=new TestAuditListener();
  archivaDavResourceFactory.addAuditListener(listener);
  servlet.setResourceFactory(archivaDavResourceFactory);
  AuthenticationResult result=new AuthenticationResult();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,null),true);
  User user=new SimpleUser();
  user.setUsername("String_Node_Str");
  SecuritySession session=new DefaultSecuritySession();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  httpAuthControl.expectAndReturn(httpAuth.getSecuritySession(ic.getRequest().getSession(true)),session);
  httpAuthControl.expectAndReturn(httpAuth.getSessionUser(ic.getRequest().getSession()),user);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),true);
  httpAuthControl.replay();
  servletAuthControl.replay();
  servlet.service(ic.getRequest(),ic.getResponse());
  httpAuthControl.verify();
  servletAuthControl.verify();
  assertEquals("String_Node_Str",listener.getEvents().get(0).getUserId());
}