Author: vrubezhny
Date: 2008-01-23 09:48:17 -0500 (Wed, 23 Jan 2008)
New Revision: 5909
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.classpath
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.project
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.jsp
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.xhtml
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/ca/StrutsJspJbide1648Test.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1648 Content Assist falls with
NullPointerException
JUnit Test Case is added
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.classpath
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.classpath
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.classpath 2008-01-23
14:48:17 UTC (rev 5909)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="JavaSource"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_07"/>
+ <classpathentry kind="con"
path="org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer/JBoss
4.2 Runtime"/>
+ <classpathentry kind="output"
path="WebContent/WEB-INF/classes"/>
+</classpath>
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.project
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.project
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.project 2008-01-23
14:48:17 UTC (rev 5909)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>StrutsJbide1648Test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.jboss.tools.struts.strutsnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.jsp
===================================================================
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.xhtml
===================================================================
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/StrutsJbide1648Test/WebContent/pages/a.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2008-01-23
12:51:01 UTC (rev 5908)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2008-01-23
14:48:17 UTC (rev 5909)
@@ -1,6 +1,7 @@
package org.jboss.tools.jst.jsp.test;
import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1585Test;
+import org.jboss.tools.jst.jsp.test.ca.StrutsJspJbide1648Test;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -10,6 +11,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test");
suite.addTestSuite(JstJspJbide1585Test.class);
+ suite.addTestSuite(StrutsJspJbide1648Test.class);
return suite;
}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java 2008-01-23
14:48:17 UTC (rev 5909)
@@ -0,0 +1,64 @@
+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.
+ }
+ }
+ }
+
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspTestUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-23
12:51:01 UTC (rev 5908)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-01-23
14:48:17 UTC (rev 5909)
@@ -26,6 +26,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.test.util.xpl.EditorTestHelper;
import junit.framework.Test;
@@ -102,7 +103,7 @@
e.printStackTrace();
assertTrue("Waiting for the jobs to complete has failed.", false);
}
- delay(3000);
+ JstJspTestUtil.delay(3000);
JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
StructuredTextViewer viewer = jspTextEditor.getTextViewer();
@@ -125,7 +126,7 @@
ICompletionProposal[] result= null;
String errorMessage = null;
- IContentAssistProcessor p= getProcessor(viewer, offsetToTest, contentAssistant);
+ IContentAssistProcessor p= JstJspTestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
if (p != null) {
try {
result= p.computeCompletionProposals(viewer, offsetToTest);
@@ -160,44 +161,4 @@
.closeEditor(editorPart, false);
}
- private 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
- */
- protected 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.
- }
- }
- }
}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-01-23
14:48:17 UTC (rev 5909)
@@ -0,0 +1,136 @@
+package org.jboss.tools.jst.jsp.test.ca;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.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.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.test.util.xpl.EditorTestHelper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class StrutsJspJbide1648Test extends TestCase {
+ TestProjectProvider provider = null;
+ IProject project = null;
+ boolean makeCopy = false;
+ private static final String PROJECT_NAME = "StrutsJbide1648Test";
+ private static final String[] PAGE_NAMES = {
+ "/WebContent/pages/a.jsp",
+ "/WebContent/pages/a.xhtml"
+ };
+
+ public static Test suite() {
+ return new TestSuite(StrutsJspJbide1648Test.class);
+ }
+
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null,
PROJECT_NAME, makeCopy);
+ project = provider.getProject();
+ Throwable exception = null;
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (Exception x) {
+ exception = x;
+ x.printStackTrace();
+ }
+ assertNull("An exception caught: " + (exception != null?
exception.getMessage() : ""), exception);
+ }
+
+ protected void tearDown() throws Exception {
+ if(provider != null) {
+ provider.dispose();
+ }
+ }
+
+ public void testStrutsJspJbide1648() {
+ try {
+ EditorTestHelper.joinBackgroundActivities();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
+
+ for (int i = 0; i < PAGE_NAMES.length; i++) {
+ doTestOnPage(PAGE_NAMES[i]);
+ }
+
+ }
+
+ 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 couln'd 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);
+ }
+ JstJspTestUtil.delay(3000);
+
+ JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
+ StructuredTextViewer viewer = jspTextEditor.getTextViewer();
+ IDocument document = viewer.getDocument();
+ IContentAssistant contentAssistant =
jspTextEditor.getSVConfiguration().getContentAssistant(viewer);
+
+ ICompletionProposal[] result= null;
+ String errorMessage = null;
+
+ try {
+ IContentAssistProcessor p= JstJspTestUtil.getProcessor(viewer, 0, contentAssistant);
+ if (p != null) {
+ result= p.computeCompletionProposals(viewer, 0);
+ 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) {
+ assertTrue("Content Assistant failed with NullPointerException", false);
+ } else {
+ assertTrue("Content Assistant failed with exception: \n" +
x.getLocalizedMessage(), false);
+ }
+ }
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .closeEditor(editorPart, false);
+
+ }
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain