Author: dgolovin
Date: 2008-11-07 00:18:50 -0500 (Fri, 07 Nov 2008)
New Revision: 11603
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/Jbide1791Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide2437Test.java
Log:
simplify tests and fix for test errors
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 2008-11-07
05:18:30 UTC (rev 11602)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-11-07
05:18:50 UTC (rev 11603)
@@ -35,16 +35,6 @@
if (editorPart instanceof JSPMultiPageEditor)
jspEditor = (JSPMultiPageEditor) editorPart;
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- JobUtils.waitForIdle();;
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
jspTextEditor = jspEditor.getJspEditor();
viewer = jspTextEditor.getTextViewer();
document = viewer.getDocument();
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java 2008-11-07
05:18:30 UTC (rev 11602)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java 2008-11-07
05:18:50 UTC (rev 11603)
@@ -13,7 +13,9 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.jboss.tools.common.test.util.TestProjectProvider;
@@ -31,6 +33,7 @@
public static Test suite() {
return new TestSuite(Jbide1791Test.class);
}
+
public void setUp() throws Exception {
provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test",
null, PROJECT_NAME,false);
project = provider.getProject();
@@ -52,9 +55,17 @@
"h6",
"hr"
};
- final ICompletionProposal[] rst = checkProposals(PAGE_NAME,353, proposals,
false);
+ openEditor(PAGE_NAME);
+ IRegion reg=null;
+ try {
+ reg = new FindReplaceDocumentAdapter(this.document).find(0,
"</style>", true, false, false, false);
+ } catch (BadLocationException e) {
+ fail(e.getMessage());
+ }
+ final ICompletionProposal[] rst = checkProposals(PAGE_NAME,reg.getOffset(),
proposals, false);
checkResult(rst,proposals);
+ closeEditor();
}
/**
* @param rst
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide2437Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide2437Test.java 2008-11-07
05:18:30 UTC (rev 11602)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide2437Test.java 2008-11-07
05:18:50 UTC (rev 11603)
@@ -4,6 +4,9 @@
import junit.framework.TestSuite;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
@@ -21,11 +24,8 @@
boolean makeCopy = false;
private static final String PROJECT_NAME = "JsfJbide1704Test";
- private static final String PAGE_NAME = "/WebContent/pages/greeting.xhtml";
+ private static final String PAGE_NAME = "/WebContent/pages/greeting1.xhtml";
- private static final String TAG_NAME = "ui:composition";
- private static final String ATTR_NAME = "template";
-
public static Test suite() {
return new TestSuite(JsfJspJbide2437Test.class);
}
@@ -36,108 +36,46 @@
}
protected void tearDown() throws Exception {
- if(provider != null) {
- provider.dispose();
- }
+ provider.dispose();
}
- public void testJsfJspJbide2437 () {
- try {
- JobUtils.waitForIdle();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
-
+ public void testJsfJspJbide2437 () throws BadLocationException {
openEditor(PAGE_NAME);
+
+ ICompletionProposal[] result= null;
+ String errorMessage = null;
- IStructuredDocumentRegion[] regions =
((IStructuredDocument)document).getStructuredDocumentRegions();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
"/templates/common.xhtml", true, false, false, false);
- boolean fUiCompositionTagFound = false;
- for (int i = 0; i < regions.length && !fUiCompositionTagFound; i++) {
- IStructuredDocumentRegion sdRegion = regions[i];
- ITextRegionList list = sdRegion.getRegions();
-
- // find <ui:composition tag
- if (!fUiCompositionTagFound) {
- if (DOMRegionContext.XML_TAG_OPEN == list.get(0).getType() &&
- DOMRegionContext.XML_TAG_NAME == list.get(1).getType() &&
- TAG_NAME.equals(sdRegion.getFullText(list.get(1)).trim())) {
- fUiCompositionTagFound = true;
-
- // find TEMPLATE attribute of <ui:composition tag
- boolean fUiCompositionTemplateAttributeFound = false;
- for (int j = 2; j < list.size(); j++) {
- ITextRegion region = list.get(j);
- if (!fUiCompositionTemplateAttributeFound) {
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME == region.getType() &&
- ATTR_NAME.equalsIgnoreCase(sdRegion.getFullText(list.get(j)).trim())) {
- fUiCompositionTemplateAttributeFound = true;
- }
- continue;
- } else {
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE == region.getType()) {
- String valueText = sdRegion.getFullText(region);
- int openQuoteIndex = valueText == null ? 0 :
valueText.indexOf('\"');
- if (openQuoteIndex == -1)
- openQuoteIndex = valueText == null ? 0 : valueText.indexOf('\'');
-
- assertFalse("There is no value defined for template attribute of tag
ui:composition.", (openQuoteIndex == -1));
-
- int offsetToTest = sdRegion.getStartOffset(region) + openQuoteIndex + 1;
-
- 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();
- }
-
- boolean bELProposalsFound = false;
- boolean bTemplatePathProposalsFound = false;
- for (int k = 0;
- result != null && k < result.length &&
- (!bELProposalsFound || !bTemplatePathProposalsFound); k++) {
- if (result[k] instanceof AutoContentAssistantProposal) {
- AutoContentAssistantProposal proposal =
(AutoContentAssistantProposal)result[k];
-
- // Test the display string for the proposals - it has to shown the thmplate
path beginning or EL-expression beginning
- // because the CA is started the calculation from the very beginning of the
attribute value.
- String dispString = proposal.getDisplayString();
-
- assertFalse("The CA proposal returned NULL display string.",
(dispString == null));
-
- if (dispString.startsWith("#{") ||
dispString.startsWith("${")) {
- bELProposalsFound = true;
- } else if (dispString.indexOf("/") != -1) {
- bTemplatePathProposalsFound = true;
- }
- }
- }
-
- // There should be proposals for template paths
- assertTrue("Content Assistant peturned no proposals for template
paths.", bTemplatePathProposalsFound);
- // There should be proposals for EL-expresions
- assertTrue("Content Assistant peturned no proposals for template
paths.", bELProposalsFound);
-
- break;
- }
- }
- }
-
+ IContentAssistProcessor p= TestUtil.getProcessor(viewer, reg.getOffset(),
contentAssistant);
+ assertNotNull("Cannot obtain IContentAssistProcessor instance",p);
+ result= p.computeCompletionProposals(viewer, reg.getOffset());
+
+ boolean bELProposalsFound = false;
+ boolean bTemplatePathProposalsFound = false;
+ for (int k = 0; result != null && k < result.length &&
+ (!bELProposalsFound || !bTemplatePathProposalsFound); k++) {
+ if (result[k] instanceof AutoContentAssistantProposal) {
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)result[k];
+
+ // Test the display string for the proposals - it has to shown the thmplate path
beginning or EL-expression beginning
+ // because the CA is started the calculation from the very beginning of the attribute
value.
+ String dispString = proposal.getDisplayString();
+
+ assertFalse("The CA proposal returned NULL display string.", (dispString ==
null));
+
+ if (dispString.startsWith("#{") || dispString.startsWith("${"))
{
+ bELProposalsFound = true;
+ } else if (dispString.indexOf("/") != -1) {
+ bTemplatePathProposalsFound = true;
}
- continue;
}
-
- break;
}
+
+ // There should be proposals for template paths
+ assertTrue("Content Assistant peturned no proposals for template paths.",
bTemplatePathProposalsFound);
+ // There should be proposals for EL-expresions
+ assertTrue("Content Assistant peturned no proposals for template paths.",
bELProposalsFound);
closeEditor();
}