Author: vrubezhny
Date: 2010-09-17 09:53:12 -0400 (Fri, 17 Sep 2010)
New Revision: 24987
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
Log:
JBIDE-6529 : jsf test failures
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF 2010-09-17 13:06:20
UTC (rev 24986)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/META-INF/MANIFEST.MF 2010-09-17 13:53:12
UTC (rev 24987)
@@ -16,7 +16,13 @@
org.jboss.tools.common.text.ext,
org.jboss.tools.jst.web,
org.jboss.tools.common.text.xml;bundle-version="2.0.0",
- org.jboss.tools.jst.web.kb;bundle-version="3.1.0"
+ org.jboss.tools.jst.web.kb;bundle-version="3.1.0",
+ org.jboss.tools.jmx.core;bundle-version="1.2.0",
+ org.jboss.tools.jsf;bundle-version="3.2.0",
+ org.jboss.tools.seam.core;bundle-version="3.2.0",
+ org.jboss.tools.seam.pages.xml;bundle-version="3.1.0",
+ org.jboss.tools.seam.xml;bundle-version="3.2.0",
+ org.jboss.tools.struts;bundle-version="3.2.0"
Export-Package:
org.jboss.tools.jst.jsp.test,
org.jboss.tools.jst.jsp.test.ca
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java 2010-09-17
13:06:20 UTC (rev 24986)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java 2010-09-17
13:53:12 UTC (rev 24987)
@@ -1,6 +1,9 @@
package org.jboss.tools.jst.jsp.test;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.BadLocationException;
@@ -8,6 +11,7 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.contentassist.ContentAssistant;
+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.contentassist.IContentAssistantExtension;
@@ -114,4 +118,21 @@
ca.showPossibleCompletions();
}
+
+ public static int MAX_CATEGORIES_COUNT = 10;
+ public static List<ICompletionProposal> collectProposals(IContentAssistant ca,
ITextViewer viewer, int offset) {
+ prepareCAInvokation(ca, viewer, offset);
+
+ final IContentAssistProcessor p= TestUtil.getProcessor(viewer, offset, ca);
+ List<ICompletionProposal> res= new ArrayList<ICompletionProposal>();
+ // Try to acquire all the proposal categories assuming that there are less than 10 or
equal
+ for (int i = 0; i < MAX_CATEGORIES_COUNT && p != null; i++) {
+ ICompletionProposal[] result= p.computeCompletionProposals(viewer, offset);
+ for (int j = 0; result != null && j < result.length; j++) {
+ res.add(result[j]);
+ }
+ }
+ return res;
+ }
+
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2010-09-17
13:06:20 UTC (rev 24986)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2010-09-17
13:53:12 UTC (rev 24987)
@@ -1,5 +1,7 @@
package org.jboss.tools.jst.jsp.test.ca;
+import java.util.List;
+
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
@@ -72,30 +74,15 @@
position = documentContent.indexOf(substring);
}
- ICompletionProposal[] result = null;
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, position+offset);
-// System.out.println("checkProposals >>> invoking TestUtil.getProcessor()
for position " + (position + offset));
+ assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0));
- IContentAssistProcessor p = TestUtil.getProcessor(viewer, position + offset,
contentAssistant);
- TestUtil.prepareCAInvokation(contentAssistant, viewer, position+offset);
- // System.out.println("checkProposals >>> TestUtil.getProcessor() is
invoked for " + (position + offset));
- if (p != null) {
- try {
- // System.out.println("checkProposals >>> invoking
p.computeCompletionProposals() for position " + (position + offset));
- result = p.computeCompletionProposals(viewer, position + offset);
- // System.out.println("checkProposals >>>
p.computeCompletionProposals() is invoked for " + (position + offset));
- } catch (Throwable x) {
- x.printStackTrace();
- }
- }
- // System.out.println("checkProposals >>> Performing the values check
up");
-
- assertTrue("Content Assistant returned no proposals", (result != null
&& result.length > 0));
-
// for (int i = 0; i < result.length; i++) {
// System.out.println("proposal - "+result[i].getDisplayString());
// }
+ ICompletionProposal[] result = res.toArray(new ICompletionProposal[res.size()]);
int foundCounter = 0;
for (int i = 0; i < proposals.length; i++) {
boolean found = compareProposal(proposals[i], result);
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2010-09-17
13:06:20 UTC (rev 24986)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2010-09-17
13:53:12 UTC (rev 24987)
@@ -1,5 +1,8 @@
package org.jboss.tools.jst.jsp.test.ca;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -9,6 +12,7 @@
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.TestProjectProvider;
@@ -45,7 +49,7 @@
doTestJsfJspJbide1704(PAGE_NAME + ".xhtml");
}
- private static final String THE_ONLY_ALLOWED_TEMPLATE = "New JSF EL Expression -
Create a new attribute value with #{}".toLowerCase();
+ private static final String TEST_RESOURCES_VALUE = "\"resources\"";
private void doTestJsfJspJbide1704(String pageName) {
@@ -53,28 +57,51 @@
try {
- ICompletionProposal[] result= null;
final IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
" var=\"msg\"", true, true, false, false);
+ String text = document.get();
String errorMessage = null;
- TestUtil.prepareCAInvokation(contentAssistant, viewer, reg.getOffset());
-
- final IContentAssistProcessor p= TestUtil.getProcessor(viewer, reg.getOffset(),
contentAssistant);
- if (p != null) {
- result= p.computeCompletionProposals(viewer, reg.getOffset());
- }
- for (int k = 0; result != null && k < result.length; k++) {
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, reg.getOffset());
+
+ assertTrue("Content Assist returned no proposals: ", (res != null &&
res.size() > 0));
+
+ for (ICompletionProposal proposal : res) {
// There should not be a proposal of type AutoContentAssistantProposal in the result
// (the only exclusion is EL-proposals)
- if ((result[k] instanceof AutoContentAssistantProposal) &&
- ((AutoContentAssistantProposal)result[k]).getReplacementString().startsWith("#{"))
{
- // The only EL template proposal is allowed to be shown here
- continue;
+ if (proposal instanceof AutoContentAssistantProposal) {
+ if(((AutoContentAssistantProposal)proposal).getReplacementString().startsWith("#{"))
{
+ // The only EL template proposal is allowed to be shown here
+ continue;
+ }
}
- assertFalse("Content Assistant peturned proposals of type (" +
result[k].getClass().getName() + ").", (result[k] instanceof
AutoContentAssistantProposal));
+
+ if (proposal instanceof CustomCompletionProposal) {
+ // There are two cases are allowed to be shown
+ // AutoContentAssistantProposal which returns the "resources" string as
replacement
+ // CustomCompletionProposal which returns the current value string as replacement
+
+ if (!(proposal instanceof AutoContentAssistantProposal)) {
+ int equalSignIndex = text.lastIndexOf('=', reg.getOffset());
+ if (equalSignIndex != -1) {
+ String prevAttrValue = text.substring(equalSignIndex+1,
reg.getOffset()).trim();
+ if
(((CustomCompletionProposal)proposal).getReplacementString().equals(prevAttrValue)){
+ // The old value for the attribute is allowed to be shown here
+ continue;
+ }
+ }
+ } else {
+ if
(((CustomCompletionProposal)proposal).getReplacementString().equals(TEST_RESOURCES_VALUE)){
+ // The old value for the attribute is allowed to be shown here
+ continue;
+ }
+
+ }
+ }
+
+ assertFalse("Content Assistant peturned proposals of type (" +
proposal.getClass().getName() + ").", (proposal instanceof
AutoContentAssistantProposal));
}
} catch (BadLocationException e) {
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2010-09-17
13:06:20 UTC (rev 24986)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2010-09-17
13:53:12 UTC (rev 24987)
@@ -57,25 +57,18 @@
jspTextEditor.setText(documentContentModified);
- ICompletionProposal[] result= null;
String errorMessage = null;
- TestUtil.prepareCAInvokation(contentAssistant, viewer, offsetToTest);
- IContentAssistProcessor p= TestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
- if (p != null) {
- try {
- result= p.computeCompletionProposals(viewer, offsetToTest);
- } catch (Throwable x) {
- x.printStackTrace();
- }
- errorMessage= p.getErrorMessage();
- }
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
List<String> customCompletionProposals = new ArrayList<String>();
- for (int i = 0; i < result.length; i++) {
- // There should be at least one proposal of type CustomCompletionProposal in the
result
- if (result[i] instanceof CustomCompletionProposal) {
- customCompletionProposals.add(((CustomCompletionProposal)result[i]).getReplacementString());
+
+ if (res != null) {
+ for (ICompletionProposal proposal : res) {
+ // There should be at least one proposal of type CustomCompletionProposal in the
result
+ if (proposal instanceof CustomCompletionProposal) {
+ customCompletionProposals.add(((CustomCompletionProposal)proposal).getReplacementString());
+ }
}
}
assertFalse("Content Assistant returned no proposals of type
CustomCompletionProposal.",customCompletionProposals.isEmpty());
@@ -100,24 +93,17 @@
"|" + documentContentModified.substring(offsetToTest);
jspTextEditor.setText(documentContentModified);
-
- p= TestUtil.getProcessor(viewer, offsetToTest, contentAssistant);
- if (p != null) {
- try {
- result= p.computeCompletionProposals(viewer, offsetToTest);
- } catch (Throwable x) {
- x.printStackTrace();
- }
- errorMessage= p.getErrorMessage();
- }
-
- for (int i = 0; i < result.length; i++) {
- // There should be the same proposals as in the saved result
- if (result[i] instanceof CustomCompletionProposal) {
- assertTrue("Content Assistant returned additional proposal (proposal returned
doesn't exist in the saved list).",
- customCompletionProposals.contains(((CustomCompletionProposal)result[i]).getReplacementString()));
- customCompletionProposals.remove(((CustomCompletionProposal)result[i]).getReplacementString());
+ res = TestUtil.collectProposals(contentAssistant, viewer, offsetToTest);
+
+ if (res != null) {
+ for (ICompletionProposal proposal : res) {
+ // There should be the same proposals as in the saved result
+ if (proposal instanceof CustomCompletionProposal) {
+ assertTrue("Content Assistant returned additional proposal (proposal returned
doesn't exist in the saved list).",
+ customCompletionProposals.contains(((CustomCompletionProposal)proposal).getReplacementString()));
+ customCompletionProposals.remove(((CustomCompletionProposal)proposal).getReplacementString());
+ }
}
}
assertTrue("Content Assistant didn't returned some
proposals.",customCompletionProposals.isEmpty());
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 2010-09-17
13:06:20 UTC (rev 24986)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2010-09-17
13:53:12 UTC (rev 24987)
@@ -1,5 +1,7 @@
package org.jboss.tools.jst.jsp.test.ca;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -52,43 +54,26 @@
jspTextEditor.setText(documentContentModified);
- // sets cursor position
- viewer.getTextWidget().setCaretOffset(offsetToTest);
-
- TestUtil.waitForIdle(TestUtil.MAX_IDLE);
- TestUtil.delay(1000);
-
- ICompletionProposal[] result= null;
- String errorMessage = null;
-
- if (contentAssistant instanceof ContentAssistant) {
- TestUtil.prepareCAInvokation(contentAssistant, viewer, offsetToTest);
- IContentAssistProcessor p= TestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
- if (p != null) {
- try {
- result= p.computeCompletionProposals(viewer, offsetToTest);
- } catch (Throwable x) {
- x.printStackTrace();
- }
- errorMessage= p.getErrorMessage();
+ try {
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
+
+ assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0));
+
+ for (ICompletionProposal p : res) {
+ assertTrue("Content Assistant returned proposals which type (" +
p.getClass().getName() + ") differs from AutoContentAssistantProposal", (p
instanceof AutoContentAssistantProposal));
+
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
+ String proposalString = proposal.getReplacementString();
+ int proposalReplacementOffset = proposal.getReplacementOffset();
+ int proposalReplacementLength = proposal.getReplacementLength();
+
+ assertTrue("The proposal replacement Offset is not correct.",
proposalReplacementOffset == start + TAG_OPEN_STRING.length());
+ assertTrue("The proposal replacement Length is not correct.",
proposalReplacementLength == PREFIX_STRING.length());
+ assertTrue("The proposal isn\'t filtered properly in the Content
Assistant.", proposalString.startsWith(PREFIX_STRING));
}
+ } finally {
+ closeEditor();
}
-
- assertTrue("Content Assistant returned no proposals", (result != null
&& result.length > 0));
-
- for (int i = 0; i < result.length; i++) {
- assertTrue("Content Assistant returned proposals which type (" +
result[i].getClass().getName() + ") differs from AutoContentAssistantProposal",
(result[i] instanceof AutoContentAssistantProposal));
- AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)result[i];
- String proposalString = proposal.getReplacementString();
- int proposalReplacementOffset = proposal.getReplacementOffset();
- int proposalReplacementLength = proposal.getReplacementLength();
-
- assertTrue("The proposal replacement Offset is not correct.",
proposalReplacementOffset == start + TAG_OPEN_STRING.length());
- assertTrue("The proposal replacement Length is not correct.",
proposalReplacementLength == PREFIX_STRING.length());
- assertTrue("The proposal isn\'t filtered properly in the Content
Assistant.", proposalString.startsWith(PREFIX_STRING));
- }
-
- closeEditor();
}
}