Exemplo n.º 1
0
 public void compareGoldenFile() throws IOException, InterruptedException {
   File fGolden = null;
   if (!generateGoldenFiles) {
     fGolden = getGoldenFile(testClass + ".pass");
   } else {
     fGolden = getNewGoldenFile();
   }
   String refFileName = getName() + ".ref";
   String diffFileName = getName() + ".diff";
   File fRef = new File(getWorkDir(), refFileName);
   Thread.sleep(1000);
   FileWriter fw = new FileWriter(fRef);
   fw.write(oper.getText());
   fw.close();
   Thread.sleep(1000);
   // LineDiff diff = new LineDiff(false);
   if (!generateGoldenFiles) {
     File fDiff = new File(getWorkDir(), diffFileName);
     System.out.println("fRef file is: " + fRef);
     System.out.println("fGolden file is: " + fGolden);
     System.out.println("fDiff file is: " + fDiff);
     assertFile(fRef, fGolden, fDiff);
     Thread.sleep(1000);
     // if(diff.diff(fGolden, fRef, fDiff)) fail("Golden files differ");
   } else {
     FileWriter fwgolden = new FileWriter(fGolden);
     fwgolden.write(oper.getText());
     fwgolden.close();
     fail("Golden file generated");
   }
 }
Exemplo n.º 2
0
 public void testPhp54TraitsSameFile() {
   EditorOperator file = CreatePHPFile(TEST_PHP_NAME, "PHP File", null);
   startTest();
   file.setCaretPosition("*/", false);
   TypeCode(
       file,
       "trait Test{ \n public function test(){} \n } \n class Foo{ \n use Test; \n function bar(){\n $this->");
   file.typeKey(' ', InputEvent.CTRL_MASK);
   new EventTool().waitNoEvent(1000);
   CompletionInfo jCompl = GetCompletion();
   String[] ideal = {"test", "bar"};
   CheckCompletionItems(jCompl.listItself, ideal);
   endTest();
 }
  protected void expandFoldAtCaretPosition(EditorOperator editor, int line, int column) {
    // 1. move to adequate place
    editor.setCaretPosition(line, column);

    // 2. hit CTRL +
    JEditorPaneOperator txtOper = editor.txtEditorPane();
    txtOper.pushKey(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK);

    JTextComponentOperator text = new JTextComponentOperator(editor);
    JTextComponent target = (JTextComponent) text.getSource();

    // give max 500 milis to fold to expand
    waitMaxMilisForValue(500, getResolver(target), Boolean.FALSE);
  }
Exemplo n.º 4
0
 public void testPhp54TraitsDifferentFile() {
   EditorOperator file = CreatePHPFile(TEST_PHP_NAME, "PHP File", "TraitTest");
   startTest();
   file.setCaretPosition("*/", false);
   TypeCode(file, "\n namespace testA; \n trait Test{ \n public function test(){}");
   file.save();
   file = CreatePHPFile(TEST_PHP_NAME, "PHP File", "TraitTest2");
   file.setCaretPosition("*/", false);
   TypeCode(file, "\n class Bar{ \n use testA\\Test; \n public function testfoo(){\n $this->");
   file.typeKey(' ', InputEvent.CTRL_MASK);
   new EventTool().waitNoEvent(1000);
   CompletionInfo jCompl = GetCompletion();
   String[] ideal = {"test", "testfoo"};
   CheckCompletionItems(jCompl.listItself, ideal);
   endTest();
 }
 @Override
 public void initialize() {
   EditorOperator.closeDiscardAll();
   new OpenAction()
       .performPopup(
           new Node(
               new SourcePackagesNode("PerformanceTestData"),
               "org.netbeans.test.performance|Main.java"));
   editorOperator = new EditorOperator("Main.java");
 }
Exemplo n.º 6
0
  public void testDeployment() throws IOException {
    final String CONTROL_TEXT = "ControlTextABC";
    Node openFile =
        new Node(
            new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
            Bundle.getStringTrimmed(
                    "org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node")
                + "|TestingSession");
    new OpenAction().performAPI(openFile);
    EditorOperator editorOper = new EditorOperator("TestingSessionBean.java");
    editorOper.replace("return null;", "return \"" + CONTROL_TEXT + "\";");

    openFile =
        new Node(new SourcePackagesNode(EJBValidation.WEB_PROJECT_NAME), "test|TestingServlet");
    new OpenAction().performAPI(openFile);
    editorOper = new EditorOperator("TestingServlet.java");
    editorOper.replace(
        "out.println(\"</body>\");",
        "out.println(lookupTestingSessionBeanLocal().testBusinessMethod1());");

    // select in Files view to prevent unstable scrolling in low display resolution
    openFile =
        new Node(
            FilesTabOperator.invoke().getProjectNode(EJBValidation.EJB_PROJECT_NAME),
            "src|java|test|TestingEntityRemote.java");
    new OpenAction().performAPI(openFile);
    editorOper = new EditorOperator("TestingEntityRemote.java");
    editorOper.replace("int getCmpTestField2x();", "int getCmpTestField2x() throws Exception;");
    editorOper.replace(
        "void setCmpTestField2x(int cmpTestField2x);",
        "void setCmpTestField2x(int cmpTestField2x) throws Exception;");

    String page =
        Utils.deploy(
            EAR_PROJECT_NAME, "http://localhost:8080/TestingEntApp-WebModule/TestingServlet", true);
    log(page);
    assertTrue(
        "TestingServlet doesn't contain expected text '"
            + CONTROL_TEXT
            + "'. See log for page content.",
        page.contains(CONTROL_TEXT));
  }
  protected void expandAllFolds(EditorOperator editor) {
    // hit CTRL Shift +
    JEditorPaneOperator txtOper = editor.txtEditorPane();
    txtOper.pushKey(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);

    // wait a while
    try {
      Thread.currentThread().sleep(COLLAPSE_EXPAND_DELAY);
    } catch (InterruptedException ex) {
    }
  }
Exemplo n.º 8
0
  @Override
  public void setUp() throws IOException {
    super.setUp();
    testClass = getName();
    System.out.println(testClass);
    System.out.println(curPackage);
    setTestPackageName(curPackage);
    openFile(testClass);
    FormDesignerOperator fdo = new FormDesignerOperator(testClass);

    oper = fdo.editor();
    oper.txtEditorPane().setVerification(false);
  }
Exemplo n.º 9
0
 public void testAdvancedIndentation() {
   oper.setCaretPosition(120, 1);
   end();
   enter();
   enter();
   type("public void method(");
   end();
   type(" {");
   enter();
   type("while(true");
   end();
   type(" {");
   enter();
   type("if(true");
   end();
   enter();
   type("if(false");
   end();
   type(" {");
   enter();
   type("int i = ");
   enter();
   type("1;");
 }
Exemplo n.º 10
0
 private void enter() {
   oper.pushKey(KeyEvent.VK_ENTER);
 }
Exemplo n.º 11
0
 public void closeProjects() {
   EditorOperator.closeDiscardAll();
   J2eeProjectSupport.closeProject(EAR_PROJECT_NAME);
   J2eeProjectSupport.closeProject(EJB_PROJECT_NAME);
   J2eeProjectSupport.closeProject(WEB_PROJECT_NAME);
 }
 public void prepare() {
   editorOperator.txtEditorPane().typeText("XXX");
 }
 @Override
 public void shutdown() {
   EditorOperator.closeDiscardAll();
 }
 @Override
 public void initialize() {
   log(":: initialize");
   EditorOperator.closeDiscardAll();
   pto = ProjectsTabOperator.invoke();
 }
Exemplo n.º 15
0
 private void type(String text) {
   oper.txtEditorPane().typeText(text);
 }
Exemplo n.º 16
0
 private void end() {
   oper.pushEndKey();
 }
Exemplo n.º 17
0
 public void testBasicIndentation() {
   oper.setCaretPosition(279, 1);
   oper.pushEndKey();
   oper.pushKey(KeyEvent.VK_ENTER);
   oper.pushKey(KeyEvent.VK_ENTER);
   oper.txtEditorPane().typeText("public void method(boolean cond1");
   oper.pushEndKey();
   oper.txtEditorPane().typeText("{");
   oper.pushKey(KeyEvent.VK_ENTER);
   oper.txtEditorPane().typeText("if(cond1");
   oper.pushEndKey();
   oper.txtEditorPane().typeText("sout");
   oper.pushTabKey();
   oper.txtEditorPane().typeText("Hello");
   oper.pushEndKey();
 }