@@ -0,0 +1,3050 @@
+// Copyright (C) 2013 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.acceptance.rest.project;%0A%0Aimport static com.google.gerrit.acceptance.git.GitUtil.createProject;%0Aimport static com.google.gerrit.acceptance.git.GitUtil.initSsh;%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport com.google.gerrit.acceptance.AbstractDaemonTest;%0Aimport com.google.gerrit.acceptance.AccountCreator;%0Aimport com.google.gerrit.acceptance.RestResponse;%0Aimport com.google.gerrit.acceptance.RestSession;%0Aimport com.google.gerrit.acceptance.SshSession;%0Aimport com.google.gerrit.acceptance.TestAccount;%0Aimport com.google.gerrit.reviewdb.client.Branch;%0Aimport com.google.gerrit.reviewdb.client.Project;%0Aimport com.google.inject.Inject;%0A%0Aimport org.apache.http.HttpStatus;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.io.IOException;%0A%0Apublic class DeleteBranchIT extends AbstractDaemonTest %7B%0A%0A  @Inject%0A  private AccountCreator accounts;%0A%0A  private RestSession adminSession;%0A  private RestSession userSession;%0A%0A  private Project.NameKey project;%0A  private Branch.NameKey branch;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    TestAccount admin = accounts.admin();%0A    adminSession = new RestSession(server, admin);%0A%0A    TestAccount user = accounts.create(%22user%22, %22user@example.com%22, %22User%22);%0A    userSession = new RestSession(server, user);%0A%0A    project = new Project.NameKey(%22p%22);%0A    branch = new Branch.NameKey(project, %22test%22);%0A%0A    initSsh(admin);%0A    SshSession sshSession = new SshSession(server, admin);%0A    try %7B%0A      createProject(sshSession, project.get(), null, true);%0A    %7D finally %7B%0A      sshSession.close();%0A    %7D%0A%0A    adminSession.put(%22/projects/%22 + project.get()%0A        + %22/branches/%22 + branch.getShortName()).consume();%0A  %7D%0A%0A  @Test%0A  public void deleteBranch_Forbidden() throws IOException %7B%0A    RestResponse r =%0A        userSession.delete(%22/projects/%22 + project.get()%0A            + %22/branches/%22 + branch.getShortName());%0A    assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());%0A    r.consume();%0A  %7D%0A%0A  @Test%0A  public void deleteBranch() throws IOException %7B%0A    RestResponse r =%0A        adminSession.delete(%22/projects/%22 + project.get()%0A            + %22/branches/%22 + branch.getShortName());%0A    assertEquals(HttpStatus.SC_NO_CONTENT, r.getStatusCode());%0A    r.consume();%0A%0A    r = adminSession.get(%22/projects/%22 + project.get()%0A        + %22/branches/%22 + branch.getShortName());%0A    assertEquals(HttpStatus.SC_NOT_FOUND, r.getStatusCode());%0A    r.consume();%0A  %7D%0A%7D%0A

Add acceptance test for testing branch deletion via REST