Author: vrubezhny
Date: 2008-01-24 14:08:11 -0500 (Thu, 24 Jan 2008)
New Revision: 5952
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
Removed:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF
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/StrutsJspJbide1648Test.java
Log:
The JstJspTestUtil is moved to TestUtil.
public static SourceViewerConfiguration getSourceViewerConfiguration(AbstractTextEditor
editor) method is added to TestUtil class. Use this method to get the
SourceViewerConfiguration object on the given editor.
The TestUtil.getSourceViewerConfiguration is used instead of
JSPTextEditor.getSourceViewerConfiguationForTest() method.
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF 2008-01-24 19:03:54
UTC (rev 5951)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF 2008-01-24 19:08:11
UTC (rev 5952)
@@ -16,3 +16,4 @@
org.jboss.tools.jst.jsp,
org.jboss.tools.common.text.ext,
org.jboss.tools.jst.web
+Export-Package: org.jboss.tools.jst.jsp.test
Deleted:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java 2008-01-24
19:03:54 UTC (rev 5951)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java 2008-01-24
19:08:11 UTC (rev 5952)
@@ -1,64 +0,0 @@
-package org.jboss.tools.jst.jsp.test;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistantExtension;
-import org.eclipse.swt.widgets.Display;
-
-public class JstJspTestUtil {
-
-
- /**
- * Returns the CA Processor from content assistant for the given offset in the
document.
- *
- *
- * @param viewer
- * @param offset
- * @param ca
- */
-
- public static IContentAssistProcessor getProcessor(ITextViewer viewer, int offset,
IContentAssistant ca) {
- try {
- IDocument document= viewer.getDocument();
- String type= TextUtilities.getContentType(document,
((IContentAssistantExtension)ca).getDocumentPartitioning(), offset, true);
- return ca.getContentAssistProcessor(type);
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Process UI input but do not return for the specified time interval.
- *
- * @param waitTimeMillis
- * the number of milliseconds
- */
- public static void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
-
- // If this is the UI thread,
- // then process input.
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while (System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.update();
- }
- // Otherwise, perform a simple sleep.
- else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored.
- }
- }
- }
-
-}
Copied:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
(from rev 5909,
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java)
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java 2008-01-24
19:08:11 UTC (rev 5952)
@@ -0,0 +1,88 @@
+package org.jboss.tools.jst.jsp.test;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextUtilities;
+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.texteditor.AbstractTextEditor;
+
+public class TestUtil {
+
+
+ /**
+ * Returns the CA Processor from content assistant for the given offset in the
document.
+ *
+ *
+ * @param viewer
+ * @param offset
+ * @param ca
+ */
+
+ public static IContentAssistProcessor getProcessor(ITextViewer viewer, int offset,
IContentAssistant ca) {
+ try {
+ IDocument document= viewer.getDocument();
+ String type= TextUtilities.getContentType(document,
((IContentAssistantExtension)ca).getDocumentPartitioning(), offset, true);
+ return ca.getContentAssistProcessor(type);
+ } catch (BadLocationException x) {
+ }
+
+ return null;
+ }
+
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ public static void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+
+ // If this is the UI thread,
+ // then process input.
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+
+ public static SourceViewerConfiguration getSourceViewerConfiguration(AbstractTextEditor
editor) {
+ Class editorClass = editor.getClass();
+ while (editorClass != null) {
+ try {
+ Method m = editorClass.getDeclaredMethod("getSourceViewerConfiguration",
new Class[] {});
+
+ if(m != null) {
+ m.setAccessible(true);
+ Object result = m.invoke(editor, new Object[]{});
+ return (result instanceof SourceViewerConfiguration ?
(SourceViewerConfiguration)result : null);
+ }
+ } catch (NoSuchMethodException ne) {
+ } catch (Exception e) {
+ }
+ editorClass = editorClass.getSuperclass();
+ }
+ return null;
+
+ }
+
+}
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-01-24
19:03:54 UTC (rev 5951)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-01-24
19:08:11 UTC (rev 5952)
@@ -16,6 +16,7 @@
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;
@@ -26,7 +27,7 @@
import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
-import org.jboss.tools.jst.jsp.test.JstJspTestUtil;
+import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
import junit.framework.Test;
@@ -87,7 +88,7 @@
} catch (PartInitException ex) {
exception = ex;
ex.printStackTrace();
- assertTrue("The JSP Visual Editor couln'd be initialized.", false);
+ assertTrue("The JSP Visual Editor couldn't be initialized.", false);
}
JSPMultiPageEditor jspEditor = null;
@@ -103,13 +104,16 @@
e.printStackTrace();
assertTrue("Waiting for the jobs to complete has failed.", false);
}
- JstJspTestUtil.delay(3000);
+ TestUtil.delay(3000);
JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
StructuredTextViewer viewer = jspTextEditor.getTextViewer();
IDocument document = viewer.getDocument();
- IContentAssistant contentAssistant =
jspTextEditor.getSourceViewerConfigurationForTest().getContentAssistant(viewer);
+ 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();
@@ -126,7 +130,7 @@
ICompletionProposal[] result= null;
String errorMessage = null;
- IContentAssistProcessor p= JstJspTestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
+ IContentAssistProcessor p= TestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
if (p != null) {
try {
result= p.computeCompletionProposals(viewer, offsetToTest);
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-01-24
19:03:54 UTC (rev 5951)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-01-24
19:08:11 UTC (rev 5952)
@@ -7,6 +7,7 @@
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;
@@ -16,7 +17,7 @@
import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
-import org.jboss.tools.jst.jsp.test.JstJspTestUtil;
+import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
import junit.framework.Test;
@@ -84,7 +85,7 @@
} catch (PartInitException ex) {
exception = ex;
ex.printStackTrace();
- assertTrue("The JSP Visual Editor couln'd be initialized.", false);
+ assertTrue("The JSP Visual Editor couldn't be initialized.", false);
}
JSPMultiPageEditor jspEditor = null;
@@ -100,18 +101,21 @@
e.printStackTrace();
assertTrue("Waiting for the jobs to complete has failed.", false);
}
- JstJspTestUtil.delay(3000);
+ TestUtil.delay(3000);
JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
StructuredTextViewer viewer = jspTextEditor.getTextViewer();
IDocument document = viewer.getDocument();
- IContentAssistant contentAssistant =
jspTextEditor.getSourceViewerConfigurationForTest().getContentAssistant(viewer);
+ 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;
try {
- IContentAssistProcessor p= JstJspTestUtil.getProcessor(viewer, 0, contentAssistant);
+ IContentAssistProcessor p= TestUtil.getProcessor(viewer, 0, contentAssistant);
if (p != null) {
result= p.computeCompletionProposals(viewer, 0);
errorMessage= p.getErrorMessage();