コード例 #1
0
  /**
   * Simulates deadlock issue 133616 - create MultiFileSystem - create lookup to set our
   * MultiFileSystem and system filesystem - create handler to manage threads - put test FileObject
   * to 'potentialLock' set - call hasLocks - it call LocalFileSystemEx.getInvalid which ends in our
   * DeadlockHandler - it starts lockingThread which calls FileObject.lock which locks our
   * FileObject - when we in LocalFileSystemEx.lock, we notify main thread which continues in
   * getInvalid and tries to accuire lock on FileObject and it dead locks
   */
  public void testLocalFileSystemEx133616() throws Exception {
    System.setProperty("workdir", getWorkDirPath());
    clearWorkDir();

    FileSystem lfs =
        TestUtilHid.createLocalFileSystem("mfs1" + getName(), new String[] {"/fold/file1"});
    LocalFileSystemEx exfs = new LocalFileSystemEx();
    exfs.setRootDirectory(FileUtil.toFile(lfs.getRoot()));
    FileSystem xfs = TestUtilHid.createXMLFileSystem(getName(), new String[] {});
    FileSystem mfs = new MultiFileSystem(exfs, xfs);
    testedFS = mfs;
    System.setProperty(
        "org.openide.util.Lookup", LocalFileSystemEx133616Test.class.getName() + "$Lkp");
    Lookup l = Lookup.getDefault();
    if (!(l instanceof Lkp)) {
      fail("Wrong lookup: " + l);
    }

    final FileObject file1FO = mfs.findResource("/fold/file1");
    File file1File = FileUtil.toFile(file1FO);

    Logger.getLogger(LocalFileSystemEx.class.getName()).setLevel(Level.FINEST);
    Logger.getLogger(LocalFileSystemEx.class.getName()).addHandler(new DeadlockHandler(file1FO));
    LocalFileSystemEx.potentialLock(file1FO.getPath());
    LocalFileSystemEx.hasLocks();
  }
コード例 #2
0
  /**
   * Test of validateDirectory method, of class YiiCustomizerValidator.
   *
   * @throws java.io.IOException
   */
  @Test
  public void testValidateDirectory() throws IOException {
    FileSystem fileSystem = FileUtil.createMemoryFileSystem();
    FileObject sourceDirectory = fileSystem.getRoot();
    sourceDirectory.createFolder("myfolder");
    sourceDirectory.createData("test.php");

    // existing directory
    YiiCustomizerValidator validator =
        new YiiCustomizerValidator().validateDirectory(sourceDirectory, "myfolder");
    ValidationResult result = validator.getResult();
    assertFalse(result.hasErrors());
    assertFalse(result.hasWarnings());

    // not existing directory
    validator = new YiiCustomizerValidator().validateDirectory(sourceDirectory, "dummy");
    result = validator.getResult();
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());

    // file
    validator = new YiiCustomizerValidator().validateDirectory(sourceDirectory, "test.php");
    result = validator.getResult();
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());
  }
コード例 #3
0
  public void testSetModifiedRemovesSaveCookie() throws Exception {
    FileSystem fs = FileUtil.createMemoryFileSystem();
    FileObject f = fs.getRoot().createData("index.test");
    DataObject dob = DataObject.find(f);
    assertEquals("The right object", GsfDataObject.class, dob.getClass());

    dob.getLookup().lookup(EditorCookie.class).openDocument().insertString(0, "modified", null);
    assertTrue("Should be modified.", dob.isModified());
    dob.setModified(false);
    assertFalse("Should not be modified.", dob.isModified());
    assertNull("Should not have SaveCookie.", dob.getLookup().lookup(SaveCookie.class));
  }
コード例 #4
0
 @Override
 protected FileSystem createFS(String... resources) throws IOException {
   for (String s : resources) {
     FileObject fo = FileUtil.getConfigFile(s.replaceAll("/.*", ""));
     if (fo != null) {
       fo.delete();
     }
   }
   FileSystem sfs = FileUtil.getConfigRoot().getFileSystem();
   for (String s : resources) {
     assertNotNull("creating: " + s, FileUtil.createData(sfs.getRoot(), s));
   }
   return sfs;
 }
コード例 #5
0
ファイル: ClickModelTest.java プロジェクト: hantsy/click4nb
 @Before
 public void setUp() {
   fs = FileUtil.createMemoryFileSystem();
   fsRoot = fs.getRoot();
 }