Ejemplo n.º 1
0
  @Test
  public void testRejectInvalidWindowsPaths() throws Exception {
    SystemReader.setInstance(
        new MockSystemReader() {
          {
            setUnix();
          }
        });

    String path = "src/con.txt";
    DirCache dc = db.lockDirCache();
    DirCacheBuilder b = dc.builder();
    DirCacheEntry e = new DirCacheEntry(path);
    e.setFileMode(FileMode.REGULAR_FILE);
    try (ObjectInserter.Formatter formatter = new ObjectInserter.Formatter()) {
      e.setObjectId(formatter.idFor(Constants.OBJ_BLOB, Constants.encode(path)));
    }
    b.add(e);
    b.commit();
    db.readDirCache();

    SystemReader.setInstance(
        new MockSystemReader() {
          {
            setWindows();
          }
        });

    try {
      db.readDirCache();
      fail("should have rejected " + path);
    } catch (CorruptObjectException err) {
      assertEquals(MessageFormat.format(JGitText.get().invalidPath, path), err.getMessage());
      assertNotNull(err.getCause());
      assertEquals("invalid name 'CON'", err.getCause().getMessage());
    }
  }
Ejemplo n.º 2
0
  @BeforeClass
  public static void beforeClass() throws Exception {

    MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    mockSystemReader.setProperty(
        Constants.GIT_CEILING_DIRECTORIES_KEY,
        ResourcesPlugin.getWorkspace()
            .getRoot()
            .getLocation()
            .toFile()
            .getParentFile()
            .getAbsoluteFile()
            .toString());

    TestUtil.showExplorerView();

    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
  }
Ejemplo n.º 3
0
 @AfterClass
 public static void afterClass() {
   SystemReader.setInstance(null);
 }