Author: vrubezhny
Date: 2008-01-25 13:48:33 -0500 (Fri, 25 Jan 2008)
New Revision: 5978
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1645 Seam EL Content Assist suggests wrong
proposals if we have an uncompleted EL in text.
JUnit TestCase is added for the issue
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2008-01-25
18:44:56 UTC (rev 5977)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2008-01-25
18:48:33 UTC (rev 5978)
@@ -15,6 +15,7 @@
import junit.framework.TestSuite;
import org.jboss.tools.seam.ui.test.preferences.SeamPreferencesPageTest;
+import org.jboss.tools.seam.ui.test.ca.SeamELContentAssistJbide1645Test;
import org.jboss.tools.seam.ui.test.ca.SeamELContentAssistJbide1676Test;
import org.jboss.tools.seam.ui.test.ca.SeamELContentAssistTest;
import org.jboss.tools.seam.ui.test.hyperlink.SeamViewHyperlinkPartitionerTest;
@@ -39,6 +40,7 @@
suite.addTestSuite(SeamViewHyperlinkPartitionerTest.class);
suite.addTestSuite(SeamELContentAssistTest.class);
suite.addTestSuite(SeamELContentAssistJbide1676Test.class);
+ suite.addTestSuite(SeamELContentAssistJbide1645Test.class);
return suite;
}
}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java 2008-01-25
18:48:33 UTC (rev 5978)
@@ -0,0 +1,168 @@
+package org.jboss.tools.seam.ui.test.ca;
+
+import javax.crypto.SealedObject;
+
+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.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.RedHatCustomCompletionProposal;
+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.seam.ui.text.java.SeamELProposalProcessor;
+import org.jboss.tools.test.util.xpl.EditorTestHelper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class SeamELContentAssistJbide1645Test extends TestCase {
+ TestProjectProvider provider = null;
+ IProject project = null;
+ boolean makeCopy = false;
+ private static final String PROJECT_NAME = "TestSeamELContentAssist";
+ private static final String PAGE_NAME = "/WebContent/home.xhtml";
+ private static final String PREFIX_STRING = "<h:commandButton
action=\"#{actor\" value=\"\">";
+ private static final String POSTFIX_STRING = " </h:commandButton>";
+ private static final String INSERT_BEFORE_STRING = "<rich:panel";
+ private static final String INSERTION_STRING = PREFIX_STRING + POSTFIX_STRING;
+
+ public static Test suite() {
+ return new TestSuite(SeamELContentAssistJbide1645Test.class);
+ }
+
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.seam.ui.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 testSeamELContentAssistJbide1645() {
+ 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;
+
+ // 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 <rich:panel> tag
+ String documentContent = document.get();
+ int start = (documentContent == null ? -1 :
documentContent.indexOf(INSERT_BEFORE_STRING));
+ int offsetToTest = start + PREFIX_STRING.length();
+
+ assertTrue("Cannot find the starting point in the test file \"" +
PAGE_NAME + "\"", (start != -1));
+
+ String documentContentModified = documentContent.substring(0, start) +
+ INSERTION_STRING + documentContent.substring(start);
+
+ jspTextEditor.setText(documentContentModified);
+
+ ICompletionProposal[] result= null;
+ String errorMessage = null;
+
+ IContentAssistProcessor p= TestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
+ if (p != null) {
+ try {
+ result= p.computeCompletionProposals(viewer, offsetToTest);
+ } catch (Throwable x) {
+ x.printStackTrace();
+ }
+ 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));
+
+ for (int i = 0; i < result.length; i++) {
+ // There should not be a proposal of type SeamELProposalProcessor.Proposal in the
result
+ assertFalse("Content Assistant peturned proposals of type (" +
result[i].getClass().getName() + ").", (result[i] instanceof
SeamELProposalProcessor.Proposal));
+// if (!(result[i] instanceof RedHatCustomCompletionProposal))
+// continue;
+// RedHatCustomCompletionProposal proposal =
(RedHatCustomCompletionProposal)result[i];
+// 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) {
+// }
+ }
+
+ 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);
+ }
+}
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain