@Test
  @SuppressWarnings("unchecked")
  public void completeInstance() {
    assertTrue("Project doesn't exist.", Eclim.projectExists(DltkRuby.TEST_PROJECT));

    List<Map<String, Object>> results =
        (List<Map<String, Object>>)
            Eclim.execute(
                new String[] {
                  "ruby_complete",
                  "-p",
                  DltkRuby.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "42",
                  "-e",
                  "utf-8"
                });

    assertTrue("Wrong number of results", results.size() > 2);

    Map<String, Object> result = results.get(0);
    assertEquals(result.get("completion"), "testA");
    assertEquals(result.get("menu"), "testA() - TestClass");
    assertEquals(result.get("info"), "");

    result = results.get(1);
    assertEquals(result.get("completion"), "testB");
    assertEquals(result.get("menu"), "testB() - TestClass");
    assertEquals(result.get("info"), "");
  }
  @Test
  @SuppressWarnings("unchecked")
  public void completeStaticPrefix() {
    assertTrue("Project doesn't exist.", Eclim.projectExists(DltkRuby.TEST_PROJECT));

    List<Map<String, Object>> results =
        (List<Map<String, Object>>)
            Eclim.execute(
                new String[] {
                  "ruby_complete",
                  "-p",
                  DltkRuby.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "92",
                  "-e",
                  "utf-8"
                });

    assertEquals("Wrong number of results", 1, results.size());

    Map<String, Object> result = results.get(0);
    assertEquals(result.get("completion"), "moduleMethodA");
    assertEquals(result.get("menu"), "moduleMethodA() - TestModule");
    assertEquals(result.get("info"), "");
  }
예제 #3
0
  @Test
  @SuppressWarnings("unchecked")
  public void validate() {
    assertTrue("Project doesn't exist.", Eclim.projectExists(Wst.TEST_PROJECT));

    List<Map<String, Object>> results =
        (List<Map<String, Object>>)
            Eclim.execute(new String[] {"css_validate", "-p", Wst.TEST_PROJECT, "-f", TEST_FILE});

    assertEquals("Wrong number of errors.", 2, results.size());

    String file = Eclim.resolveFile(Wst.TEST_PROJECT, TEST_FILE);

    Map<String, Object> error = results.get(0);
    assertEquals(error.get("filename"), file);
    assertTrue(((String) error.get("message")).indexOf("bald is not a font-weight value") != -1);
    assertEquals(error.get("line"), 2);
    assertEquals(error.get("column"), 1);
    assertEquals(error.get("warning"), false);

    error = results.get(1);
    assertEquals(error.get("filename"), file);
    assertTrue(((String) error.get("message")).indexOf("Property fnt-size doesn't exist") != -1);
    assertEquals(error.get("line"), 6);
    assertEquals(error.get("column"), 1);
    assertEquals(error.get("warning"), false);
  }
  @Test
  @SuppressWarnings("unchecked")
  public void completeBuiltins() {
    assertTrue("Project doesn't exist.", Eclim.projectExists(DltkRuby.TEST_PROJECT));

    List<Map<String, Object>> results =
        (List<Map<String, Object>>)
            Eclim.execute(
                new String[] {
                  "ruby_complete",
                  "-p",
                  DltkRuby.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "63",
                  "-e",
                  "utf-8"
                });

    assertTrue("Wrong number of results", results.size() >= 2);

    Map<String, Object> result = results.get(0);
    assertEquals(result.get("completion"), "each");
    assertEquals(result.get("menu"), "each() - Array");
    assertEquals(result.get("info"), "");

    result = results.get(1);
    assertEquals(result.get("completion"), "each_index");
    assertEquals(result.get("menu"), "each_index() - Array");
    assertEquals(result.get("info"), "");

    results =
        (List<Map<String, Object>>)
            Eclim.execute(
                new String[] {
                  "ruby_complete",
                  "-p",
                  DltkRuby.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "70",
                  "-e",
                  "utf-8"
                });

    // DLTK returns times() and, for some reason:
    // timestamp_file(name, target_prefix) - MakeMakefile
    // This occurs both in eclim and in the eclipse gui. Probably another dltk
    // bug.
    // assertEquals("Wrong number of results", 1, results.size());
    assertTrue("Wrong number of results", results.size() >= 1);

    result = results.get(0);
    assertEquals(result.get("completion"), "times");
    assertEquals(result.get("menu"), "times() - Integer");
    assertEquals(result.get("info"), "");
  }
예제 #5
0
  @Test
  @SuppressWarnings("unchecked")
  public void execute() {
    assertTrue("Java project doesn't exist.", Eclim.projectExists(Jdt.TEST_PROJECT));

    List<String> results =
        (List<String>)
            Eclim.execute(new String[] {"java_import", "-n", Jdt.TEST_PROJECT, "-p", "List"});

    // remove any com.sun entries
    List<String> imports = new ArrayList<String>();
    for (String imprt : results) {
      if (imprt.matches("com\\.sun.*?")) {
        continue;
      }
      imports.add(imprt);
    }

    assertEquals(2, imports.size());
    assertEquals("java.awt.List", imports.get(0));
    assertEquals("java.util.List", imports.get(1));
  }
예제 #6
0
  @Test
  public void execute() {
    assertTrue("Java project doesn't exist.", Eclim.projectExists(Jdt.TEST_PROJECT));

    String result =
        Eclim.execute(
            new String[] {
              "java_delegate", "-p", Jdt.TEST_PROJECT, "-f", TEST_FILE, "-o", "124", "-e", "utf-8"
            });

    // handle difference between 1.5 and 1.6
    result = result.replaceAll("Double \\w\\b", "Double o");

    System.out.println(result);

    assertTrue("Wrong first line.", result.startsWith("org.eclim.test.delegate.TestDelegate"));
    assertTrue(
        "Interface not in results.",
        result.indexOf("package java.util;\npublic interface List<Double> {") != -1);
    assertTrue(
        "Method not in results.",
        result.indexOf("\tpublic abstract Iterator<Double> iterator()") != -1);
    assertTrue(
        "Method not in results.", result.indexOf("\tpublic abstract boolean add(Double o)") != -1);

    result =
        Eclim.execute(
            new String[] {
              "java_delegate",
              "-p",
              Jdt.TEST_PROJECT,
              "-f",
              TEST_FILE,
              "-o",
              "124",
              "-e",
              "utf-8",
              "-t",
              "org.eclim.test.delegate.TestDelegate",
              "-s",
              "java.util.List%3CDouble%3E",
              "-m",
              "add(Double)"
            });

    // handle difference between 1.5 and 1.6
    result = result.replaceAll("Double \\w\\b", "Double o");

    System.out.println(result);

    String contents = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertTrue(
        "Method not found or invalid.",
        Pattern.compile(
                "public boolean add\\(Double \\w\\)\n  \\{\n  " + "\treturn list.add\\(\\w\\);")
            .matcher(contents)
            .find());

    assertTrue(
        "Method not commented out in results.",
        result.indexOf("//public abstract boolean add(Double o)") != -1);
  }
예제 #7
0
  @Test
  @SuppressWarnings("unchecked")
  public void execute() {
    assertTrue("Java project doesn't exist.", Eclim.projectExists(Jdt.TEST_PROJECT));

    Pattern listImport = Pattern.compile("import\\s+java\\.util\\.List;");
    String file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertFalse(listImport.matcher(file).find());

    List<String> results =
        (List<String>)
            Eclim.execute(
                new String[] {
                  "java_import", "-p", Jdt.TEST_PROJECT, "-f", TEST_FILE, "-o", "72", "-e", "utf-8",
                });

    assertEquals(2, results.size());
    assertEquals("java.awt.List", results.get(0));
    assertEquals("java.util.List", results.get(1));
    file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertFalse(listImport.matcher(file).find());

    Map<String, Object> position =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_import",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "72",
                  "-e",
                  "utf-8",
                  "-t",
                  "java.util.List",
                });
    file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertTrue(listImport.matcher(file).find());
    assertEquals(96, position.get("offset"));
    assertEquals(7, position.get("line"));
    assertEquals(14, position.get("column"));

    position =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_import",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "109",
                  "-e",
                  "utf-8",
                });
    Pattern arrayListImport = Pattern.compile("import\\s+java\\.util\\.ArrayList;");
    file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertTrue(arrayListImport.matcher(file).find());
    assertEquals(137, position.get("offset"));
    assertEquals(8, position.get("line"));
    assertEquals(27, position.get("column"));

    position =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_import",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "163",
                  "-e",
                  "utf-8",
                });
    Pattern patternImport = Pattern.compile("import\\s+java\\.util\\.regex\\.Pattern;");
    file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertTrue(patternImport.matcher(file).find());
    assertEquals(196, position.get("offset"));
    assertEquals(11, position.get("line"));
    assertEquals(14, position.get("column"));

    position =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_import",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST_FILE,
                  "-o",
                  "220",
                  "-e",
                  "utf-8",
                });
    Pattern fileImport = Pattern.compile("import\\s+java\\.io\\.File;");
    file = Eclim.fileToString(Jdt.TEST_PROJECT, TEST_FILE);
    assertTrue(fileImport.matcher(file).find());
    assertEquals(242, position.get("offset"));
    assertEquals(14, position.get("line"));
    assertEquals(11, position.get("column"));
  }
예제 #8
0
 @BeforeClass
 public static void setUp() {
   Eclim.setProjectSetting(
       Jdt.TEST_PROJECT, "org.eclim.java.import.package_separation_level", "-1");
 }
예제 #9
0
  @Test
  @SuppressWarnings("unchecked")
  public void executeTestToClass() {
    assertTrue("Java project doesn't exist.", Eclim.projectExists(Jdt.TEST_PROJECT));

    Map<String, Object> result =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_junit_find_test",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST,
                  "-o",
                  "0",
                  "-e",
                  "utf-8",
                });
    assertEquals(Eclim.resolveFile(Jdt.TEST_PROJECT, CLASS), result.get("filename"));
    assertEquals("Foo", result.get("message"));
    assertEquals(3, result.get("line"));
    assertEquals(1, result.get("column"));

    result =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_junit_find_test",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST,
                  "-o",
                  "178",
                  "-e",
                  "utf-8",
                });
    assertEquals(Eclim.resolveFile(Jdt.TEST_PROJECT, CLASS), result.get("filename"));
    assertEquals("foo", result.get("message"));
    assertEquals(5, result.get("line"));
    assertEquals(3, result.get("column"));

    result =
        (Map<String, Object>)
            Eclim.execute(
                new String[] {
                  "java_junit_find_test",
                  "-p",
                  Jdt.TEST_PROJECT,
                  "-f",
                  TEST,
                  "-o",
                  "374",
                  "-e",
                  "utf-8",
                });
    assertEquals(Eclim.resolveFile(Jdt.TEST_PROJECT, CLASS), result.get("filename"));
    assertEquals("foo", result.get("message"));
    assertEquals(10, result.get("line"));
    assertEquals(3, result.get("column"));
  }