Author: dazarov
Date: 2008-02-26 10:31:08 -0500 (Tue, 26 Feb 2008)
New Revision: 6578
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1759Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1812
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -0,0 +1,99 @@
+package org.jboss.tools.jst.jsp.test.ca;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
+import org.jboss.tools.jst.jsp.test.TestUtil;
+import org.jboss.tools.test.util.xpl.EditorTestHelper;
+
+public class ContentAssistantTestCase extends TestCase {
+ protected IProject project = null;
+ protected JSPMultiPageEditor jspEditor = null;
+ protected JSPTextEditor jspTextEditor = null;
+ protected StructuredTextViewer viewer = null;
+ protected IStructuredDocumentRegion[] regions = null;
+ protected IContentAssistant contentAssistant = null;
+ protected IDocument document = null;
+
+ protected void openEditor(String fileName) {
+
+ try {
+ EditorTestHelper.joinBackgroundActivities();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue("Waiting for the jobs to complete has failed.", false);
+ }
+
+ IFile jspFile = project.getFile(fileName);
+
+ assertTrue("The file \"" + fileName + "\" is not found",
+ (jspFile != null));
+ assertTrue("The file \"" + fileName + "\" is not found",
(jspFile
+ .exists()));
+
+ FileEditorInput editorInput = new FileEditorInput(jspFile);
+ IEditorPart editorPart = null;
+ try {
+ editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().openEditor(editorInput,
+ "org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
+ } catch (PartInitException ex) {
+ ex.printStackTrace();
+ assertTrue("The JSP Visual Editor couldn't be initialized.", false);
+ }
+
+ if (editorPart instanceof JSPMultiPageEditor)
+ jspEditor = (JSPMultiPageEditor) editorPart;
+
+ // Delay for 3 seconds so that
+ // the Favorites view can be seen.
+ try {
+ EditorTestHelper.joinBackgroundActivities();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue("Waiting for the jobs to complete has failed.", false);
+ }
+ TestUtil.delay(3000);
+
+ jspTextEditor = jspEditor.getJspEditor();
+ viewer = jspTextEditor.getTextViewer();
+ document = viewer.getDocument();
+ SourceViewerConfiguration config = TestUtil
+ .getSourceViewerConfiguration(jspTextEditor);
+ contentAssistant = (config == null ? null : config
+ .getContentAssistant(viewer));
+
+ assertTrue(
+ "Cannot get the Content Assistant instance for the editor for page
\""
+ + fileName + "\"", (contentAssistant != null));
+
+ assertTrue("The IDocument is not instance of IStructuredDocument",
+ (document instanceof IStructuredDocument));
+
+ IStructuredDocument sDocument = (IStructuredDocument) document;
+ regions = sDocument.getStructuredDocumentRegions();
+ }
+
+ protected void closeEditor() {
+ if (jspEditor != null) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().closeEditor(jspEditor, false);
+ jspEditor = null;
+ }
+
+ }
+
+}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -1,39 +1,24 @@
package org.jboss.tools.jst.jsp.test.ca;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JsfJspJbide1704Test extends TestCase {
+public class JsfJspJbide1704Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
+
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1704Test";
private static final String PAGE_NAME = "/WebContent/pages/greeting";
@@ -79,51 +64,10 @@
}
private void doTestJsfJspJbide1704(String pageName) {
- IFile jspFile = project.getFile(pageName);
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
+ openEditor(pageName);
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
- assertTrue("The IDocument is not instance of IStructuredDocument", (document
instanceof IStructuredDocument));
-
- IStructuredDocument sDocument = (IStructuredDocument)document;
- IStructuredDocumentRegion[] regions = sDocument.getStructuredDocumentRegions();
- String documentContent = document.get();
-
boolean fLoadBundleTagIsFound = false;
for (int i = 0; i < regions.length; i++) {
IStructuredDocumentRegion sdRegion = regions[i];
@@ -163,10 +107,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: "
+ errorMessage);
-// }
-
for (int k = 0; result != null && k < result.length; k++) {
// There should not be a proposal of type Red.Proposal in the result
assertFalse("Content Assistant peturned proposals of type (" +
result[k].getClass().getName() + ").", (result[k] instanceof
AutoContentAssistantProposal));
@@ -178,15 +118,14 @@
}
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// e.printStackTrace();
+// assertTrue("Waiting for the jobs to complete has failed.", false);
+// }
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -2,35 +2,21 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JsfJspJbide1717Test extends TestCase {
+public class JsfJspJbide1717Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1704Test";
private static final String PAGE_NAME = "/WebContent/pages/greeting.jsp";
@@ -63,52 +49,8 @@
}
public void testJstJspJbide1641() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- }
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
+ openEditor(PAGE_NAME);
- IFile jspFile = project.getFile(PAGE_NAME);
-
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
-
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
// Find start of <h:outputText> tag
String documentContent = document.get();
int start = (documentContent == null ? -1 :
documentContent.indexOf(INSERT_BEFORE_STRING));
@@ -138,9 +80,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
List<String> customCompletionProposals = new ArrayList<String>();
for (int i = 0; i < result.length; i++) {
@@ -182,9 +121,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
for (int i = 0; i < result.length; i++) {
// There should be the same proposals as in the saved result
@@ -196,8 +132,7 @@
}
assertTrue("Content Assistant didn't returned some
proposals.",customCompletionProposals.isEmpty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -1,42 +1,18 @@
package org.jboss.tools.jst.jsp.test.ca;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
+import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistantExtension;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
-import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JstJspJbide1585Test extends TestCase {
+public class JstJspJbide1585Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1585Test";
private static final String PAGE_NAME = "/WebContent/pages/inputname.xhtml";
@@ -68,53 +44,8 @@
}
public void testJstJspJbide1585() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- }
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
-
- IFile jspFile = project.getFile(PAGE_NAME);
-
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
+ openEditor(PAGE_NAME);
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
-
// Find start of <ui:define> tag
String documentContent = document.get();
int start = (documentContent == null ? -1 :
documentContent.indexOf("<ui:define"));
@@ -140,9 +71,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
assertTrue("Content Assistant peturned no proposals", (result != null
&& result.length > 0));
@@ -152,17 +80,13 @@
String proposalString = proposal.getReplacementString();
int proposalReplacementOffset = proposal.getReplacementOffset();
int proposalReplacementLength = proposal.getReplacementLength();
-// try {
-// System.out.println("Result#" + i + " ==> Offs: " +
offsetToTest + " RedHatCustomCompletionProposal[" + proposalString + "],
Offs: " + proposalReplacementOffset + ", Len: " + proposalReplacementLength
+ ", Doc: [" + document.get(proposalReplacementOffset,
proposalReplacementLength));
-// } catch (BadLocationException e) {
-// }
+
assertTrue("The proposal replacement Offset is not correct.",
proposalReplacementOffset == start + TAG_OPEN_STRING.length());
assertTrue("The proposal replacement Length is not correct.",
proposalReplacementLength == PREFIX_STRING.length());
assertTrue("The proposal isn\'t filtered properly in the Content
Assistant.", proposalString.startsWith(PREFIX_STRING));
}
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -1,33 +1,19 @@
package org.jboss.tools.jst.jsp.test.ca;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JstJspJbide1641Test extends TestCase {
+public class JstJspJbide1641Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1641Test";
private static final String PAGE_NAME = "/WebContent/pages/greeting.xhtml";
@@ -63,52 +49,9 @@
}
public void testJstJspJbide1641() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- }
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
-
- IFile jspFile = project.getFile(PAGE_NAME);
-
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
+ openEditor(PAGE_NAME);
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
// Find start of <ui:composition> tag
String documentContent = document.get();
int start = (documentContent == null ? -1 :
documentContent.indexOf(INSERT_BEFORE_STRING));
@@ -136,9 +79,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
assertTrue("Content Assistant peturned no proposals", (result != null
&& result.length > 0));
@@ -148,10 +88,7 @@
continue;
AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)result[i];
String proposalString = proposal.getReplacementString();
-// try {
-// System.out.println("Result#" + i + " ==> Offs: " +
offsetToTest + " RedHatCustomCompletionProposal[" + proposalString + "],
Offs: " + proposalReplacementOffset + ", Len: " + proposalReplacementLength
+ ", Doc: [" + document.get(proposalReplacementOffset,
proposalReplacementLength));
-// } catch (BadLocationException e) {
-// }
+
if (PROPOSAL_TO_APPLY_STRING.equals(proposalString)) {
bPropoosalToApplyFound = true;
proposal.apply(document);
@@ -170,8 +107,7 @@
String documentUpdatedContent = document.get();
assertTrue("The proposal replacement is failed.",
documentContentToCompare.equals(documentUpdatedContent));
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1759Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1759Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1759Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -3,33 +3,20 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JstJspJbide1759Test extends TestCase {
+public class JstJspJbide1759Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1704Test";
private static final String PAGE_NAME = "/WebContent/pages/greeting";
@@ -76,46 +63,9 @@
}
private void testJstJspJbide1641(String pageName) {
-
- IFile jspFile = project.getFile(pageName);
-
- assertTrue("The file \"" + pageName + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + pageName + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
+ openEditor(pageName);
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + pageName + "\"", (contentAssistant != null));
-
// Find start of <h:outputText> tag
String documentContent = document.get();
int start = (documentContent == null ? -1 :
documentContent.indexOf(INSERT_BEFORE_STRING));
@@ -130,10 +80,6 @@
int offsetToTest = start + INSERTION_BEGIN_STRING.length();
-// String visualizeCursorPosition = documentContentModified.substring(0, offsetToTest)
+
-// "|" + documentContentModified.substring(offsetToTest);
-
-// System.out.println(visualizeCursorPosition);
jspTextEditor.setText(documentContentModified);
@@ -150,9 +96,6 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
List<String> customCompletionProposals = new ArrayList<String>();
for (int i = 0; i < result.length; i++) {
@@ -179,11 +122,6 @@
offsetToTest = start + INSERTION_BEGIN_STRING.length();
-// visualizeCursorPosition = documentContentModified.substring(0, offsetToTest) +
-// "|" + documentContentModified.substring(offsetToTest);
-
-// System.out.println(visualizeCursorPosition);
-
jspTextEditor.setText(documentContentModified);
p= TestUtil.getProcessor(viewer, offsetToTest, contentAssistant);
@@ -195,10 +133,6 @@
}
errorMessage= p.getErrorMessage();
}
-
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
for (int i = 0; i < result.length; i++) {
// There should be the same proposals as in the saved result
@@ -210,7 +144,6 @@
}
assertTrue("Content Assistant didn't returned some
proposals.",customCompletionProposals.isEmpty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-02-26
15:05:30 UTC (rev 6577)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-02-26
15:31:08 UTC (rev 6578)
@@ -1,32 +1,18 @@
package org.jboss.tools.jst.jsp.test.ca;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class StrutsJspJbide1648Test extends TestCase {
+public class StrutsJspJbide1648Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "StrutsJbide1648Test";
private static final String[] PAGE_NAMES = {
@@ -72,45 +58,8 @@
}
private void doTestOnPage(String pageName) {
- IFile jspFile = project.getFile(pageName);
-
- assertTrue("The file \"" + pageName + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + pageName + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
+ openEditor(pageName);
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + pageName + "\"", (contentAssistant != null));
-
ICompletionProposal[] result= null;
String errorMessage = null;
@@ -121,9 +70,6 @@
errorMessage= p.getErrorMessage();
}
- // if (errorMessage != null && errorMessage.trim().length() > 0) {
- // System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
- // }
} catch (Throwable x) {
x.printStackTrace();
if (x instanceof NullPointerException) {
@@ -133,8 +79,7 @@
}
}
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}