Author: vrubezhny
Date: 2011-09-09 12:29:33 -0400 (Fri, 09 Sep 2011)
New Revision: 34608
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/elValidation1.xhtml
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CAELProposalFilteringTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfMessagesProposalsFilteringTest.java
Log:
JBIDE-9633
Create JUnit tests to cover JBIDE-9515 issue
JUnit Test is added for proposals filtering and proposals applying check
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/elValidation1.xhtml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/elValidation1.xhtml
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/elValidation1.xhtml 2011-09-09
16:29:33 UTC (rev 34608)
@@ -0,0 +1,13 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html">
+
+ <ui:define name="body">
+ <h:outputText value="#{namedBean.foo}"/>
+ <h:outputText value="#{sheep.name}"
+ rendered="#{(game.value == 'foo' and game.value == 'foo')
? game.value == 'foo' : false}"/>
+ </ui:define>
+</ui:composition>
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/ca/elValidation1.xhtml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-09-09 16:22:59
UTC (rev 34607)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-09-09 16:29:33
UTC (rev 34608)
@@ -30,5 +30,6 @@
org.jboss.tools.jst.web.kb,
org.eclipse.wst.validation;bundle-version="1.2.300",
org.jboss.tools.jst.web.kb.test,
- org.jboss.tools.common.validation
+ org.jboss.tools.common.validation,
+ org.jboss.tools.jst.jsp;bundle-version="3.3.0"
Export-Package: org.jboss.tools.cdi.ui.test
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CAELProposalFilteringTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CAELProposalFilteringTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CAELProposalFilteringTest.java 2011-09-09
16:29:33 UTC (rev 34608)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * 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.cdi.ui.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IDocument;
+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.JobUtils;
+
+/**
+ * Test case testing
http://jira.jboss.com/jira/browse/JBIDE-9633 issue.
+ *
+ * @author Victor V. Rubezhny
+ *
+ */
+public class CAELProposalFilteringTest extends TestCase {
+
+ private IProject project;
+ private ContentAssistantTestCase caTest = new ContentAssistantTestCase();
+ private static final String JSP_PAGE_NAME = "WebContent/test.jsp";
+ private static final String XHTML_PAGE_NAME =
"WebContent/elValidation1.xhtml";
+
+ public CAELProposalFilteringTest() {
+ super();
+ try {
+ project = TCKUITest.importPreparedProject("/tests/lookup");
+ project = TCKUITest.importPreparedProject("/tests/ca");
+ caTest.setProject(project);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testCAELProposalFilteringInJSP () {
+ caTest.openEditor(JSP_PAGE_NAME);
+ try {
+ doCAELProposalFilteringTest(JSP_PAGE_NAME, "rendered=\"#{(game.",
"value : String - Game", "value");
+ doCAELProposalFilteringTest(JSP_PAGE_NAME, "value=\"#{sheep.",
"name : String - Sheep", "name");
+ } finally {
+ caTest.closeEditor();
+ }
+ }
+
+ public void testCAELProposalFilteringInXHTML () {
+ caTest.openEditor(XHTML_PAGE_NAME);
+ try {
+ doCAELProposalFilteringTest(XHTML_PAGE_NAME, "value=\"#{sheep.",
"name : String - Sheep", "name");
+ } finally {
+ caTest.closeEditor();
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ private void doCAELProposalFilteringTest(String pageName, String prefix, String
proposalToApply, String compareString) {
+ IDocument document = caTest.getDocument();
+ String documentContent = document.get();
+ int start = (documentContent == null ? -1 : documentContent.indexOf(prefix));
+ assertFalse("Required text '" + prefix + "' not found in
document", (start == -1));
+ int offsetToTest = start + prefix.length();
+
+ String documentContentToCompare = documentContent.substring(0, start + prefix.length())
+
+ compareString + documentContent.substring(start + prefix.length());
+
+ JobUtils.waitForIdle();
+
+ List<ICompletionProposal> res =
CATestUtil.collectProposals(caTest.getContentAssistant(), caTest.getViewer(),
offsetToTest);
+
+ assertTrue("Content Assistant returned no proposals", (res != null &&
res.size() > 0));
+
+ boolean bPropoosalToApplyFound = false;
+ for (ICompletionProposal p : res) {
+ if (!(p instanceof AutoContentAssistantProposal))
+ continue;
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
+ String proposalString = proposal.getDisplayString();
+
+ if (proposalToApply.equals(proposalString)) {
+ if (!bPropoosalToApplyFound) {
+ bPropoosalToApplyFound = true;
+ proposal.apply(document);
+ } else {
+ fail("Duplicate proposal '" + proposalToApply + "' found in
CA Proposal List");
+ }
+ }
+ }
+ assertTrue("The proposal to apply not found.", bPropoosalToApplyFound);
+
+ try {
+ JobUtils.waitForIdle();
+ } 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));
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CAELProposalFilteringTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-09-09
16:22:59 UTC (rev 34607)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-09-09
16:29:33 UTC (rev 34608)
@@ -58,7 +58,7 @@
}
TestSuite suiteAll = new TestSuite("CDI UI Tests");
TestSuite suite = new TestSuite("TCK Tests");
-
+
suiteAll.addTestSuite(CDIMarkerResolutionTest.class);
suiteAll.addTestSuite(CDIPerspectiveTest.class);
@@ -66,8 +66,8 @@
suiteAll.addTestSuite(CDIPreferencePageTest.class);
suiteAll.addTestSuite(NewCDIWizardTest.class);
suiteAll.addTestSuite(CATest.class);
-
-
+ suiteAll.addTestSuite(CAELProposalFilteringTest.class);
+
suite.addTestSuite(CDISearchParticipantTest.class);
suite.addTestSuite(ELReferencesQueryParticipantTest.class);
suiteAll.addTest(new CDICoreTestSetup(suite) {
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfMessagesProposalsFilteringTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfMessagesProposalsFilteringTest.java 2011-09-09
16:22:59 UTC (rev 34607)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfMessagesProposalsFilteringTest.java 2011-09-09
16:29:33 UTC (rev 34608)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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;
@@ -9,12 +19,17 @@
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.common.base.test.validation.TestUtil;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ProjectImportTestSetup;
+/**
+ * Test case testing
http://jira.jboss.com/jira/browse/JBIDE-9633 issue.
+ *
+ * @author Victor V. Rubezhny
+ *
+ */
public class CAJsfMessagesProposalsFilteringTest extends ContentAssistantTestCase {
private static final String PROJECT_NAME = "JSF2KickStartWithoutLibs";
private static final String PAGE_NAME = "WebContent/pages/inputname.xhtml";