Author: vrubezhny
Date: 2011-09-20 12:06:39 -0400 (Tue, 20 Sep 2011)
New Revision: 34881
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAELInsideTagBodyInJspFileTest.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
Log:
JBIDE-9270
JSP editor should allow using el in text nodes for JSP 2.0
JUnit test is added for the issue
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAELInsideTagBodyInJspFileTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAELInsideTagBodyInJspFileTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAELInsideTagBodyInJspFileTest.java 2011-09-20
16:06:39 UTC (rev 34881)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.jsp.ca.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.jboss.tools.common.base.test.contentassist.CATestUtil;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
+import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+
+/**
+ * The JUnit test case for JBIDE-9270 issue
+ *
+ * @author Victor V. Rubezhny
+ *
+ */
+public class CAELInsideTagBodyInJspFileTest extends ContentAssistantTestCase {
+ private static final String PROJECT_NAME = "Jbide3845Test";
+ private static final String PAGE_NAME = "WebContent/pages/jsp_page.jsp";
+
+ private static final String PREFIX = "<f:view>";
+ private static final String INSERTION = "#{";
+
+ private static final String[] PROPOSAL_TO_COMPARE_BEFORE_INSERTION = {"#{}"};
+ private static final String[] PROPOSAL_TO_COMPARE_AFTER_INSERTION = {"user",
"Message"};
+
+ public void setUp() throws Exception {
+ project = ProjectImportTestSetup.loadProject(PROJECT_NAME);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
+
+ public static Test suite() {
+ return new TestSuite(CAELInsideTagBodyInJspFileTest.class);
+ }
+
+ private void doCAELInsideTagBodyInJspFileTest(String pageName, String attrPrefix,
String[] correctProposals) {
+ String documentContent = document.get();
+ int start = (documentContent == null ? -1 : documentContent.indexOf(attrPrefix));
+ assertFalse("Required prefix text '" + attrPrefix + "' not found
in document", (start == -1));
+ int offsetToTest = start + attrPrefix.length();
+
+ List<ICompletionProposal> res = CATestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
+
+ assertTrue("Content Assistant returned no proposals", (res != null &&
res.size() > 0));
+
+ for (String correct : correctProposals) {
+ assertTrue("Proposal '" + correct +"' not found, but it should
be amoung the proposals!", proposalExists(correct, res));
+ }
+ }
+
+ private boolean proposalExists(String proposal, List<ICompletionProposal>
proposals) {
+ for (ICompletionProposal p : proposals) {
+ if (!(p instanceof AutoContentAssistantProposal))
+ continue;
+ AutoContentAssistantProposal existingProposal = (AutoContentAssistantProposal)p;
+ String proposalString = existingProposal.getReplacementString();
+
+ if (proposal.equals(proposalString)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void testCAELInsideTagBodyInJspFile() {
+ assertNotNull("Test project '" + PROJECT_NAME + "' is not
prepared", project);
+
+ openEditor(PAGE_NAME);
+ try {
+ // Test EL CA for non-openned EL in tag body
+ doCAELInsideTagBodyInJspFileTest(PAGE_NAME, PREFIX,
PROPOSAL_TO_COMPARE_BEFORE_INSERTION);
+
+ String documentContent = document.get();
+ int start = (documentContent == null ? -1 : documentContent.indexOf(PREFIX));
+ assertFalse("Required prefix text '" + PREFIX + "' not found in
document", (start == -1));
+
+ String newDocumentContent = documentContent.substring(0, start + PREFIX.length()) +
+ INSERTION + documentContent.substring(start + PREFIX.length());
+ document.set(newDocumentContent);
+
+ // Test EL CA for openned EL in tag body
+ doCAELInsideTagBodyInJspFileTest(PAGE_NAME, PREFIX+INSERTION,
PROPOSAL_TO_COMPARE_AFTER_INSERTION);
+ } finally {
+ closeEditor();
+ }
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAELInsideTagBodyInJspFileTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-09-20
16:05:43 UTC (rev 34880)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-09-20
16:06:39 UTC (rev 34881)
@@ -17,6 +17,7 @@
import org.eclipse.wst.validation.ValidationFramework;
import org.jboss.tools.common.base.test.validation.ValidationProjectTestSetup;
import org.jboss.tools.jsf.jsp.ca.test.CADefaultELStartingCharTest;
+import org.jboss.tools.jsf.jsp.ca.test.CAELInsideTagBodyInJspFileTest;
import org.jboss.tools.jsf.jsp.ca.test.CAForCompositeComponentTest;
import org.jboss.tools.jsf.jsp.ca.test.CAForELinStyleTest;
import org.jboss.tools.jsf.jsp.ca.test.CAForIDTest;
@@ -132,6 +133,12 @@
new String[] { "projects/JSF2KickStartWithoutLibs", }, //$NON-NLS-1$
new String[] { "JSF2KickStartWithoutLibs" })); //$NON-NLS-1$
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(
+ CAELInsideTagBodyInJspFileTest.class), "org.jboss.tools.jsf.ui.test",
//$NON-NLS-1$
+ new String[] { "projects/Jbide3845Test", }, //$NON-NLS-1$
+ new String[] { "Jbide3845Test" })); //$NON-NLS-1$
+
+
// return new TestWizardsProject(suite);
return suite;
}