gt:             final String[] pathParts = path.split("/");
context: /*******************************************************************************
   * Copyright (c) 2012-2016 Codenvy, S.A.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
   * which accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   *
   * Contributors:
   *   Codenvy, S.A. - initial API and implementation
   *******************************************************************************/
  package org.eclipse.che.plugin.svn.server.utils;
  
  import com.google.common.base.Joiner;
  import com.google.common.io.Files;
  
  import org.eclipse.che.api.core.util.LineConsumer;
  import org.eclipse.che.api.core.util.LineConsumerFactory;
  import org.eclipse.che.api.user.server.dao.Profile;
  import org.eclipse.che.api.user.server.dao.UserProfileDao;
  import org.eclipse.che.api.vfs.VirtualFileSystem;
  import org.eclipse.che.api.vfs.VirtualFileSystemProvider;
  import org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider;
  import org.eclipse.che.commons.env.EnvironmentContext;
  import org.eclipse.che.commons.user.UserImpl;
  import org.eclipse.che.dto.server.DtoFactory;
  import org.eclipse.che.plugin.svn.server.SubversionApi;
  import org.eclipse.che.plugin.svn.server.SubversionException;
  import org.eclipse.che.plugin.svn.server.credentials.CredentialsException;
  import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider;
  import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider;
  import org.eclipse.che.plugin.svn.server.upstream.CommandLineResult;
  import org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils;
  import org.eclipse.che.plugin.svn.shared.AddRequest;
  import org.eclipse.che.plugin.svn.shared.CLIOutputResponse;
  import org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse;
  import org.eclipse.che.plugin.svn.shared.CheckoutRequest;
  import org.eclipse.che.plugin.svn.shared.CommitRequest;
  import org.eclipse.che.plugin.svn.shared.Depth;
  import org.eclipse.che.plugin.svn.shared.PropertySetRequest;
  import org.hamcrest.BaseMatcher;
  import org.hamcrest.Description;
  import org.hamcrest.Matcher;
  import org.mockito.Mockito;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertTrue;
  
  /**
   * Test utilities.
   */
  public class TestUtils {
  
      private static DtoFactory dtoFactory = DtoFactory.getInstance();
  
      private static SubversionApi subversionApi = new SubversionApi(new CredentialsProvider() {
          @Override
          public Credentials getCredentials(final String repositoryUrl) {
              return null;
          }
  
          @Override
          public void storeCredential(final String repositoryUrl, final Credentials credentials) throws CredentialsException {
          }
      }, new RepositoryUrlProvider() {
          @Override
          public String getRepositoryUrl(final String projectPath) throws IOException {
              return "";
          }
      });
  
      public static final String[] GREEK_TREE = new String[]{
              "/",
              "/iota",
              "/A/",
              "/A/mu",
              "/A/B/",
              "/A/B/lambda",
              "/A/B/E/",
              "/A/B/E/alpha",
              "/A/B/E/beta",
              "/A/B/F/",
              "/A/C/",
              "/A/D/",
              "/A/D/gamma",
              "/A/D/H/",
              "/A/D/H/chi",
              "/A/D/H/psi",
              "/A/D/H/omega",
              "/A/D/G/",
              "/A/D/G/pi",
              "/A/D/G/rho",
              "/A/D/G/tau"
      };
  
      private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
  
      /**
       * Creates a virtual file system.
       *
       * @return the virtual file system
       * @throws Exception
       *         if anything goes wrong
       */
      public static VirtualFileSystem createVirtualFileSystem() throws Exception {
          File rootDirectory = java.nio.file.Files.createTempDirectory(null).toFile();
          VirtualFileSystemProvider vfsProvider = new LocalVirtualFileSystemProvider(rootDirectory, null);
          return vfsProvider.getVirtualFileSystem();
      }
  
      public static class SystemOutLineConsumer implements LineConsumer {
          @Override
          public void writeLine(String line) throws IOException {
              LOG.debug(line);
          }
  
          @Override
          public void close() throws IOException {
          }
      }
  
      public static class SystemOutLineConsumerFactory implements LineConsumerFactory {
          @Override
          public LineConsumer newLineConsumer() {
              return new SystemOutLineConsumer();
          }
      }
  
      /**
       * Throws an exception if the CLI result is no a valid "success" response.
       * <p/>
       * <b>Note:</b> Might make sense to move this to a core API instead of a test API
       *
       * @param result
       *         the CLI result
       * @throws Exception
       *         if the CLI result indicates an error
       */
      public static void handleCLIResult(final CommandLineResult result) throws Exception {
          if (result.getExitCode() != 0) {
              throw new SubversionException(Joiner.on("\n")
                                                  .join(result.getStderr().size() != 0 ?
                                                        result.getStderr()
                                                              .toArray(new String[result.getStderr().size()]) :
                                                        result.getStdout()
                                                              .toArray(new String[result.getStdout().size()])));
          }
      }
  
      /**
       * Creates a user and makes that user be the current user.
       *
       * @param userProfileDao
       *         the User Profile DAO
       * @throws Exception
       *         if anything goes wrong
       */
      public static void createTestUser(final UserProfileDao userProfileDao) throws Exception {
          // set current user
          EnvironmentContext.getCurrent().setUser(new UserImpl("codenvy", "codenvy", null,
                                                               Arrays.asList("workspace/developer"), false));
  
          // rules for mock
          final Map<String, String> profileAttributes = new HashMap<>();
  
          profileAttributes.put("firstName", "Codenvy");
          profileAttributes.put("lastName", "Codenvy");
          profileAttributes.put("email", "che@eclipse.org");
  
          Mockito.when(userProfileDao.getById("codenvy"))
                 .thenReturn(new Profile().withId("codenvy").withUserId("codenvy").withAttributes(profileAttributes));
      }
  
      /**
       * Creates a new Subversion repository in a temporary location with the Greek Tree structure within it.
       *
       * @return the path to the repository root
       * @throws Exception
       *         if anything goes wrong
       */
      public static File createGreekTreeRepository() throws Exception {
          final File repoRoot = Files.createTempDir();
          final File wcRoot = Files.createTempDir();
  
          // Clean up after execution
          repoRoot.deleteOnExit();
          wcRoot.deleteOnExit();
  
          // Create the repository
          final CommandLineResult result = UpstreamUtils.executeCommandLine(null, "svnadmin", new String[]{
                  "create",
                  repoRoot.getAbsolutePath()
          }, -1, repoRoot);
  
          // Make sure the result is fine
          handleCLIResult(result);
  
          // Checkout the repository
          final CLIOutputWithRevisionResponse coResponse =
                  subversionApi.checkout(dtoFactory.createDto(CheckoutRequest.class)
                                                   .withProjectPath(wcRoot.getAbsolutePath())
                                                   .withUrl("file:///" + repoRoot.getAbsolutePath()));
  
          assertTrue(coResponse.getRevision() > -1);
  
          final List<String> pathsToAdd = new ArrayList<>();
  
          // Create the directory structure
          for (final String path : GREEK_TREE) {
              final File fileForPath = new File(wcRoot, path);
  