コード例 #1
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());
  }
コード例 #2
0
 public void testRubyResolver() throws IOException {
   FileObject fo = FileUtil.createMemoryFileSystem().getRoot().createData("ruby");
   String[] validHeaders = {
     "#!/usr/bin/ruby",
     "#!/usr/bin/ruby1.8",
     "#!/usr/bin/jruby",
     "#! /usr/bin/ruby",
     "#! /usr/bin/ruby\n",
     "#! /usr/bin/ruby.exe",
     "#! /usr/bin/ruby.exe ",
     "#!C:\\programs\\ruby.exe",
     "#!C:\\programs\\ruby.exe",
     "#!/Users/tor/dev/ruby/install/ruby-1.8.5/bin/ruby\n",
     "#!/space/ruby/ruby-1.8.6-p110/bin/ruby1.8.6-p110",
     "#!/usr/bin/env jruby -J-Xmx512M",
     "#!/usr/bin/env ruby",
     "#!/usr/bin/env jruby",
     "#!/usr/bin/env.exe jruby",
     "#!D:/Development/Ruby/ruby-1.8.6-dist/bin/ruby"
   };
   String[] invalidHeaders = {
     "# !C:\\programs\\ruby.exe",
     "#!/bin/sh",
     // "#!/bin/rubystuff/bin/ksh", // mistakenly resolved as ruby file
     "#!/usr/bin/rub",
     "#!/usr/bin/",
     "#! /usr/bin/rub\ny",
     // "#! /usr/b\nin/ruby", // mistakenly resolved as ruby file
     "#/usr/bin/ruby",
     "#!/usr/bin/env.exe jrub"
   };
   for (String header : validHeaders) {
     assertHeader(fo, header, "text/x-ruby");
   }
   for (String header : invalidHeaders) {
     assertHeader(fo, header, "content/unknown");
   }
   fo = FileUtil.createMemoryFileSystem().getRoot().createData("rakefile");
   assertEquals("rakefile should be resolved.", "text/x-ruby", fo.getMIMEType());
   fo = FileUtil.createMemoryFileSystem().getRoot().createData("Rakefile");
   assertEquals("rakefile should be resolved.", "text/x-ruby", fo.getMIMEType());
   fo = FileUtil.createMemoryFileSystem().getRoot().createData("a.rb");
   assertEquals("All .rb should be resolved.", "text/x-ruby", fo.getMIMEType());
 }
コード例 #3
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    MockServices.setServices(DL.class);

    fo = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "data.dat");
    obj = DataObject.find(fo);
    assertEquals("MDO: " + obj, MDO.class, obj.getClass());
    node = obj.getNodeDelegate();
  }
コード例 #4
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));
  }
コード例 #5
0
 public void initValues(ProjectProperties props, String configuration) {
   this.vps = VisualPropertySupport.getDefault(props);
   this.properties = props;
   this.configuration = configuration;
   this.srcRoot = props.getSourceRoot();
   if (srcRoot == null) {
     // Issue 153666 - getting projects instantiated w/ nonexistent source
     // roots.  props.toString() will call project.toString(), hopefully
     // provide some better info
     Logger.getLogger(getClass().getName())
         .log(Level.INFO, "Source root null for " + props); // NOI18N
     srcRoot = FileUtil.createMemoryFileSystem().getRoot();
   }
   treeView.setSrcRoot(srcRoot);
   vps.register(defaultCheck, configuration, this);
 }
コード例 #6
0
ファイル: ClickModelTest.java プロジェクト: hantsy/click4nb
 @Before
 public void setUp() {
   fs = FileUtil.createMemoryFileSystem();
   fsRoot = fs.getRoot();
 }