Author: vrubezhny
Date: 2008-01-25 10:14:37 -0500 (Fri, 25 Jan 2008)
New Revision: 5971
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.classpath
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.project
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/greeting.xhtml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1641 Problems with inserting atributes using CA on
xhtml pages.
JUnit TestCase is added for the issue
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.classpath
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.classpath
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.classpath 2008-01-25
15:14:37 UTC (rev 5971)
@@ -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/JsfJbide1641Test/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.project
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.project
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/.project 2008-01-25
15:14:37 UTC (rev 5971)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JsfJbide1641Test</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.jsf.jsfnature</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/JsfJbide1641Test/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/greeting.xhtml
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/greeting.xhtml
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/greeting.xhtml 2008-01-25
15:14:37 UTC (rev 5971)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core">
+
+ <f:loadBundle basename="resources" var="msg" />
+
+ <ui:composition template="/templates/common.xhtml">
+ <ui:define name="pageTitle">Greeting to User</ui:define>
+ <ui:define name="pageHeader">Facelets Greeting Page</ui:define>
+ <ui:define name="body">
+ #{msg.greeting} #{person.name}!
+ </ui:define>
+ </ui:composition>
+</html>
\ No newline at end of file
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1641Test/WebContent/pages/greeting.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-25
15:07:07 UTC (rev 5970)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2008-01-25
15:14:37 UTC (rev 5971)
@@ -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.JstJspJbide1641Test;
import org.jboss.tools.jst.jsp.test.ca.StrutsJspJbide1648Test;
import junit.framework.Test;
@@ -12,6 +13,7 @@
TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test");
suite.addTestSuite(JstJspJbide1585Test.class);
suite.addTestSuite(StrutsJspJbide1648Test.class);
+ suite.addTestSuite(JstJspJbide1641Test.class);
return suite;
}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2008-01-25
15:14:37 UTC (rev 5971)
@@ -0,0 +1,177 @@
+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.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.test.util.xpl.EditorTestHelper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class JstJspJbide1641Test extends TestCase {
+ 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";
+ private static final String PREFIX_STRING = "<h:commandButton a";
+ private static final String PROPOSAL_TO_APPLY_STRING =
"action=\"\"";
+ private static final String ATTRIBUTE_TO_INSERT_STRING =
"ction=\"\"";
+ private static final String POSTFIX_STRING = "></h:commandButton>";
+ private static final String INSERT_BEFORE_STRING = "<ui:composition";
+ private static final String INSERTION_STRING = PREFIX_STRING + POSTFIX_STRING;
+ private static final String COMPARE_STRING = PREFIX_STRING + ATTRIBUTE_TO_INSERT_STRING
+ POSTFIX_STRING;
+
+ public static Test suite() {
+ return new TestSuite(JstJspJbide1641Test.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 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;
+
+ // 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));
+ 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);
+ String documentContentToCompare = documentContent.substring(0, start) +
+ COMPARE_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));
+
+ boolean bPropoosalToApplyFound = false;
+ for (int i = 0; i < result.length; i++) {
+ if (!(result[i] instanceof RedHatCustomCompletionProposal))
+ continue;
+ RedHatCustomCompletionProposal proposal = (RedHatCustomCompletionProposal)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);
+ break;
+ }
+ }
+ assertTrue("The proposal to apply not found.", bPropoosalToApplyFound);
+
+ try {
+ EditorTestHelper.joinBackgroundActivities();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue("Waiting for the jobs to complete has failed.", false);
+ }
+
+ String documentUpdatedContent = document.get();
+ assertTrue("The proposal replacement is failed.",
documentContentToCompare.equals(documentUpdatedContent));
+
+ 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/JstJspJbide1641Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain