Author: vrubezhny
Date: 2010-11-19 08:04:48 -0500 (Fri, 19 Nov 2010)
New Revision: 26759
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1676Test.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
Log:
JBIDE-7576
testSeamELContentAssistJbide1676 failure
Clean up some test cases due to close the openned editors at the end of testing
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java 2010-11-19
12:54:52 UTC (rev 26758)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java 2010-11-19
13:04:48 UTC (rev 26759)
@@ -53,36 +53,38 @@
ELCorePlugin.getDefault().getPreferenceStore().setValue(ELContentAssistPreferences.SHOW_METHODS_WITH_PARENTHESES_ONLY,
false);
openEditor(PAGE_NAME);
- // Find start of <rich:panel> 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);
-
- jspTextEditor.setText(documentContentModified);
-
- ICompletionProposal[] result= null;
- String errorMessage = null;
-
- List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
- assertTrue("Content Assistant peturned no proposals", (res != null &&
res.size() > 0));
-
- for (ICompletionProposal proposal : res) {
- // There should not be a proposal of type SeamELProposalProcessor.Proposal in the
result
- assertFalse("Content Assistant peturned proposals of type (" +
proposal.getClass().getName() + ").", (proposal instanceof
ELProposalProcessor.Proposal));
+ try {
+ // Find start of <rich:panel> 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);
+
+ jspTextEditor.setText(documentContentModified);
+
+ ICompletionProposal[] result= null;
+ String errorMessage = null;
+
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
+ assertTrue("Content Assistant peturned no proposals", (res != null
&& res.size() > 0));
+
+ for (ICompletionProposal proposal : res) {
+ // There should not be a proposal of type SeamELProposalProcessor.Proposal in the
result
+ assertFalse("Content Assistant peturned proposals of type (" +
proposal.getClass().getName() + ").", (proposal instanceof
ELProposalProcessor.Proposal));
+ }
+
+ try {
+ JobUtils.waitForIdle();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue("Waiting for the jobs to complete has failed.", false);
+ }
+ } finally {
+ closeEditor();
}
-
- try {
- JobUtils.waitForIdle();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
-
- closeEditor();
}
}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1676Test.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1676Test.java 2010-11-19
12:54:52 UTC (rev 26758)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1676Test.java 2010-11-19
13:04:48 UTC (rev 26759)
@@ -254,77 +254,79 @@
assertTrue("The Java Editor couldn't be initialized.", false);
}
- CompilationUnitEditor javaEditor = null;
-
- if (editorPart instanceof CompilationUnitEditor)
- javaEditor = (CompilationUnitEditor)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);
+ CompilationUnitEditor javaEditor = null;
+
+ if (editorPart instanceof CompilationUnitEditor)
+ javaEditor = (CompilationUnitEditor)editorPart;
- ISourceViewer viewer = javaEditor.getViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config = TestUtil.getSourceViewerConfiguration(javaEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for file
\"" + JAVA_FILENAME + "\"", (contentAssistant != null));
-
- String documentContent = document.get();
- int start = (documentContent == null ? -1 :
documentContent.indexOf(EL_START_TEMPLATE));
- int offsetToTest = start + EL_START_TEMPLATE.length();
-
- assertTrue("Cannot find the starting point in the test file \"" +
JAVA_FILENAME + "\"", (start != -1));
-
- ICompletionProposal[] result= null;
- String errorMessage = null;
-
- IContentAssistProcessor p= TestUtil.getProcessor(viewer, offsetToTest,
contentAssistant);
- if (p != null) {
+ // Delay for 3 seconds so that
+ // the Favorites view can be seen.
try {
- result= p.computeCompletionProposals(viewer, offsetToTest);
- } catch (Throwable x) {
- x.printStackTrace();
+ JobUtils.waitForIdle();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue("Waiting for the jobs to complete has failed.", false);
+ }
+ TestUtil.delay(3000);
+
+ ISourceViewer viewer = javaEditor.getViewer();
+ IDocument document = viewer.getDocument();
+ SourceViewerConfiguration config = TestUtil.getSourceViewerConfiguration(javaEditor);
+ IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
+
+ assertTrue("Cannot get the Content Assistant instance for the editor for file
\"" + JAVA_FILENAME + "\"", (contentAssistant != null));
+
+ String documentContent = document.get();
+ int start = (documentContent == null ? -1 :
documentContent.indexOf(EL_START_TEMPLATE));
+ int offsetToTest = start + EL_START_TEMPLATE.length();
+
+ assertTrue("Cannot find the starting point in the test file \"" +
JAVA_FILENAME + "\"", (start != -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();
}
- 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));
-
- // compare SeamELCompletionProposals in the result to the filtered valid proposals
- Set<String> existingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Set<String> nonExistingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Set<String> filteredValidProposals = getJavaStringValidELProposals();
-
- for (int j = 0; j < result.length; j++) {
- // Look only for SeamELProposalProcessor proposals
- if (result[j] instanceof ELProposalProcessor.Proposal) {
- ELProposalProcessor.Proposal proposal = (ELProposalProcessor.Proposal)result[j];
- String proposalString = proposal.getPrefixCompletionText(document,
offsetToTest).toString();
-
- if (filteredValidProposals.contains(proposalString)) {
- existingProposals.add(proposalString);
- filteredValidProposals.remove(proposalString);
- } else {
- nonExistingProposals.add(proposalString);
+
+ // 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));
+
+ // compare SeamELCompletionProposals in the result to the filtered valid proposals
+ Set<String> existingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Set<String> nonExistingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Set<String> filteredValidProposals = getJavaStringValidELProposals();
+
+ for (int j = 0; j < result.length; j++) {
+ // Look only for SeamELProposalProcessor proposals
+ if (result[j] instanceof ELProposalProcessor.Proposal) {
+ ELProposalProcessor.Proposal proposal = (ELProposalProcessor.Proposal)result[j];
+ String proposalString = proposal.getPrefixCompletionText(document,
offsetToTest).toString();
+
+ if (filteredValidProposals.contains(proposalString)) {
+ existingProposals.add(proposalString);
+ filteredValidProposals.remove(proposalString);
+ } else {
+ nonExistingProposals.add(proposalString);
+ }
}
}
+ assertTrue("Some Seam EL proposals werent\'t shown in the Content
Assistant", filteredValidProposals.isEmpty());
+ assertTrue("Some Seam EL proposals were shown in the Content Assistant but they
shouldn\'t", nonExistingProposals.isEmpty());
+ } finally {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .closeEditor(editorPart, false);
}
- assertTrue("Some Seam EL proposals werent\'t shown in the Content
Assistant", filteredValidProposals.isEmpty());
- assertTrue("Some Seam EL proposals were shown in the Content Assistant but they
shouldn\'t", nonExistingProposals.isEmpty());
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
}
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java 2010-11-19
12:54:52 UTC (rev 26758)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java 2010-11-19
13:04:48 UTC (rev 26759)
@@ -448,148 +448,55 @@
* Test for
https://jira.jboss.org/jira/browse/JBIDE-3528
*/
public void testInterface() {
- checkProposals("/WebContent/interfaceTest.xhtml", 359, new
String[]{"interfaceTest.test.text"}, false);
+ try {
+ checkProposals("/WebContent/interfaceTest.xhtml", 359, new
String[]{"interfaceTest.test.text"}, false);
+ } finally {
+ closeEditor();
+ }
}
public void testSeamELContentAssist() {
ELCorePlugin.getDefault().getPreferenceStore().setValue(ELContentAssistPreferences.SHOW_METHODS_WITH_PARENTHESES_ONLY,
false);
openEditor(PAGE_NAME);
-
- List<IRegion> regionsToTest = getELRegionsToTest(document);
-
- if (regionsToTest != null && regionsToTest.size() >= 1) {
-// for (IRegion region : regionsToTest) {
- IRegion region = regionsToTest.get(0);
- try {
-// System.out.println("Seam EL Region To Test: [" + region.getOffset() +
"/" + region.getLength() + "] ==> [" +
-// document.get(region.getOffset(), region.getLength()) + "]");
-
- int startOffset = region.getOffset() + 2;
- for (int i = 2; i < region.getLength(); i++) {
- int offset = region.getOffset() + i;
+ try {
+ List<IRegion> regionsToTest = getELRegionsToTest(document);
+
+ if (regionsToTest != null && regionsToTest.size() >= 1) {
+ // for (IRegion region : regionsToTest) {
+ IRegion region = regionsToTest.get(0);
+ try {
+ // System.out.println("Seam EL Region To Test: [" + region.getOffset() +
"/" + region.getLength() + "] ==> [" +
+ // document.get(region.getOffset(), region.getLength()) + "]");
- String filter = document.get(startOffset, offset - startOffset);
- Set<String> filteredValidProposals =
getFilteredProposals(getPageValidProposals(), filter);
-
- ICompletionProposal[] result= null;
- String errorMessage = null;
-
- List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offset);
- assertTrue("Content Assist returned no proposals: ", (res != null
&& res.size() > 0));
-
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offset + ": ERROR MESSAGE: " +
errorMessage);
-// }
-
- // compare SeamELCompletionProposals in the result to the filtered valid proposals
- Set<String> existingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-
- for (ICompletionProposal p : res) {
-// System.out.println("Result#" + i + "-" + j + " ==>
" + result[j].getClass().getName());
- // Cannot separate Seam EL proposals from all the others,
- // so check only the required proposals existance
- //
- if (p instanceof AutoContentAssistantProposal) {
- AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
-
- String proposalString = proposal.getReplacementString();
- if (filteredValidProposals.contains(proposalString)) {
- existingProposals.add(proposalString);
- filteredValidProposals.remove(proposalString);
- } else {
- String validProposal = null;
- if (proposalString.indexOf("(") > -1) {
- String methodName = proposalString.substring(0,
proposalString.indexOf("(")).trim();
- // Find method with the same name in filtered valid proposals
- for (String valid : filteredValidProposals) {
- if (valid.indexOf("(") > -1) {
- String validName = valid.substring(0, valid.indexOf("(")).trim();
-
- if (methodName.equals(validName)) {
- validProposal = valid;
- break;
- }
- }
- }
- }
- if (validProposal != null) {
- existingProposals.add(validProposal);
- filteredValidProposals.remove(validProposal);
- }
-
- }
- }
- }
- assertTrue("Some Seam EL proposals werent\'t shown in the Content
Assistant", filteredValidProposals.isEmpty());
- }
-
- } catch (BadLocationException e) {
- assertNull("An exception caught: " + (e != null? e.getMessage() :
""), e);
- }
-// }
- }
- regionsToTest = getAttributeValueRegions(viewer);
- if (regionsToTest != null && regionsToTest.size() >= 1) {
-// for (IRegion region : regionsToTest) {
- IRegion region = regionsToTest.get(0);
- try {
-// System.out.println("Attribute Region To Test: [" + region.getOffset() +
"/" + region.getLength() + "] ==> [" +
-// document.get(region.getOffset(), region.getLength()) + "]");
-
- String attributeText = document.get(region.getOffset(), region.getLength());
- int openQuoteIndex = attributeText.indexOf('"');
- if (openQuoteIndex == -1)
- openQuoteIndex = attributeText.indexOf('\'');
- else {
- int openQuoteIndex2 = attributeText.indexOf('\'');
- if (openQuoteIndex2 != -1) {
- openQuoteIndex = (openQuoteIndex < openQuoteIndex2 ? openQuoteIndex :
openQuoteIndex2);
- }
- }
-
- int closeQuoteIndex = (openQuoteIndex == -1 ? -1 :
attributeText.lastIndexOf(attributeText.charAt(openQuoteIndex)));
-
- int startOffset = region.getOffset();
- for (int i = 0; i < region.getLength(); i++) {
- int offset = startOffset + i;
- if ((openQuoteIndex != -1 && i <= openQuoteIndex) ||
- (closeQuoteIndex != -1 && i >= closeQuoteIndex)) {
- // - Before and at opening quotation mark (single or double quote)
- // - or at and after closing quotation mark (single or double quote)
- // There is no prompting acceptable
- } else {
- String filter = document.get(startOffset + openQuoteIndex + 1, offset -
startOffset - openQuoteIndex - 1);
+ int startOffset = region.getOffset() + 2;
+ for (int i = 2; i < region.getLength(); i++) {
+ int offset = region.getOffset() + i;
- String clearedFilter = filter;
- if (filter.startsWith("#{")) {
- clearedFilter = filter.substring(2);
- } else {
- clearedFilter = null;
- }
-
- Set<String> filteredValidProposals =
getFilteredProposals(getPageValidProposals(), clearedFilter);
+ String filter = document.get(startOffset, offset - startOffset);
+ Set<String> filteredValidProposals =
getFilteredProposals(getPageValidProposals(), filter);
ICompletionProposal[] result= null;
String errorMessage = null;
List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offset);
assertTrue("Content Assist returned no proposals: ", (res != null
&& res.size() > 0));
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offset + ": ERROR MESSAGE: " +
errorMessage);
-// }
+
+ // if (errorMessage != null && errorMessage.trim().length() > 0) {
+ // System.out.println("#" + offset + ": ERROR MESSAGE: " +
errorMessage);
+ // }
// compare SeamELCompletionProposals in the result to the filtered valid
proposals
Set<String> existingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-
+
for (ICompletionProposal p : res) {
-// System.out.println("Result#" + i + "/" + j + " ==>
" + result[j].getClass().getName());
- // Cannot separate Seam EL proposals from all the others,
- // so check only the required proposals existance
- //
+ // System.out.println("Result#" + i + "-" + j + " ==>
" + result[j].getClass().getName());
+ // Cannot separate Seam EL proposals from all the others,
+ // so check only the required proposals existance
+ //
if (p instanceof AutoContentAssistantProposal) {
AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
+
String proposalString = proposal.getReplacementString();
-
if (filteredValidProposals.contains(proposalString)) {
existingProposals.add(proposalString);
filteredValidProposals.remove(proposalString);
@@ -613,20 +520,118 @@
existingProposals.add(validProposal);
filteredValidProposals.remove(validProposal);
}
+
}
}
}
- assertTrue("Some in-attribute Seam EL proposals werent\'t shown in the
Content Assistant", filteredValidProposals.isEmpty());
+ assertTrue("Some Seam EL proposals werent\'t shown in the Content
Assistant", filteredValidProposals.isEmpty());
}
+
+ } catch (BadLocationException e) {
+ assertNull("An exception caught: " + (e != null? e.getMessage() :
""), e);
}
- } catch (BadLocationException e) {
- e.printStackTrace();
- assertNull("An exception caught: " + (e != null? e.getMessage() :
""), e);
- }
-// }
+ // }
+ }
+ regionsToTest = getAttributeValueRegions(viewer);
+ if (regionsToTest != null && regionsToTest.size() >= 1) {
+ // for (IRegion region : regionsToTest) {
+ IRegion region = regionsToTest.get(0);
+ try {
+ // System.out.println("Attribute Region To Test: [" + region.getOffset() +
"/" + region.getLength() + "] ==> [" +
+ // document.get(region.getOffset(), region.getLength()) + "]");
+
+ String attributeText = document.get(region.getOffset(), region.getLength());
+ int openQuoteIndex = attributeText.indexOf('"');
+ if (openQuoteIndex == -1)
+ openQuoteIndex = attributeText.indexOf('\'');
+ else {
+ int openQuoteIndex2 = attributeText.indexOf('\'');
+ if (openQuoteIndex2 != -1) {
+ openQuoteIndex = (openQuoteIndex < openQuoteIndex2 ? openQuoteIndex :
openQuoteIndex2);
+ }
+ }
+
+ int closeQuoteIndex = (openQuoteIndex == -1 ? -1 :
attributeText.lastIndexOf(attributeText.charAt(openQuoteIndex)));
+
+ int startOffset = region.getOffset();
+ for (int i = 0; i < region.getLength(); i++) {
+ int offset = startOffset + i;
+ if ((openQuoteIndex != -1 && i <= openQuoteIndex) ||
+ (closeQuoteIndex != -1 && i >= closeQuoteIndex)) {
+ // - Before and at opening quotation mark (single or double quote)
+ // - or at and after closing quotation mark (single or double quote)
+ // There is no prompting acceptable
+ } else {
+ String filter = document.get(startOffset + openQuoteIndex + 1, offset -
startOffset - openQuoteIndex - 1);
+
+ String clearedFilter = filter;
+ if (filter.startsWith("#{")) {
+ clearedFilter = filter.substring(2);
+ } else {
+ clearedFilter = null;
+ }
+
+ Set<String> filteredValidProposals =
getFilteredProposals(getPageValidProposals(), clearedFilter);
+
+ ICompletionProposal[] result= null;
+ String errorMessage = null;
+
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offset);
+ assertTrue("Content Assist returned no proposals: ", (res != null
&& res.size() > 0));
+ // if (errorMessage != null && errorMessage.trim().length() > 0) {
+ // System.out.println("#" + offset + ": ERROR MESSAGE: " +
errorMessage);
+ // }
+
+ // compare SeamELCompletionProposals in the result to the filtered valid
proposals
+ Set<String> existingProposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+
+ for (ICompletionProposal p : res) {
+ // System.out.println("Result#" + i + "/" + j + "
==> " + result[j].getClass().getName());
+ // Cannot separate Seam EL proposals from all the others,
+ // so check only the required proposals existance
+ //
+ if (p instanceof AutoContentAssistantProposal) {
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
+ String proposalString = proposal.getReplacementString();
+
+ if (filteredValidProposals.contains(proposalString)) {
+ existingProposals.add(proposalString);
+ filteredValidProposals.remove(proposalString);
+ } else {
+ String validProposal = null;
+ if (proposalString.indexOf("(") > -1) {
+ String methodName = proposalString.substring(0,
proposalString.indexOf("(")).trim();
+ // Find method with the same name in filtered valid proposals
+ for (String valid : filteredValidProposals) {
+ if (valid.indexOf("(") > -1) {
+ String validName = valid.substring(0,
valid.indexOf("(")).trim();
+
+ if (methodName.equals(validName)) {
+ validProposal = valid;
+ break;
+ }
+ }
+ }
+ }
+ if (validProposal != null) {
+ existingProposals.add(validProposal);
+ filteredValidProposals.remove(validProposal);
+ }
+ }
+ }
+ }
+ assertTrue("Some in-attribute Seam EL proposals werent\'t shown in the
Content Assistant", filteredValidProposals.isEmpty());
+ }
+ }
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+ assertNull("An exception caught: " + (e != null? e.getMessage() :
""), e);
+ }
+ // }
+ }
+ } finally {
+ closeEditor();
}
-
- closeEditor();
}
@@ -634,21 +639,22 @@
public void testContentAssistForInvocationOnString() {
openEditor(PAGE_HOME_NAME);
-
- List<IRegion> regionsToTest = getELRegionsToTest(document);
- if (regionsToTest != null) {
- for (IRegion region : regionsToTest) {
- int startOffset = region.getOffset() + 2;
- int offset = startOffset + 10;
-
- String errorMessage = null;
-
- List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offset);
- assertNotNull("Proposals were not created.", res);
- assertEquals("Incorrect number of proposals for
#{'aa'.subst|ring(1)}", 3, res.size());
+ try {
+ List<IRegion> regionsToTest = getELRegionsToTest(document);
+ if (regionsToTest != null) {
+ for (IRegion region : regionsToTest) {
+ int startOffset = region.getOffset() + 2;
+ int offset = startOffset + 10;
+
+ String errorMessage = null;
+
+ List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offset);
+ assertNotNull("Proposals were not created.", res);
+ assertEquals("Incorrect number of proposals for
#{'aa'.subst|ring(1)}", 3, res.size());
+ }
}
-
+ } finally {
+ closeEditor();
}
- closeEditor();
}
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2010-11-19
12:54:52 UTC (rev 26758)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2010-11-19
13:04:48 UTC (rev 26759)
@@ -61,6 +61,10 @@
}
}
+ FileEditorInput editorInput = null;
+ IDocumentProvider documentProvider = null;
+ IStructuredModel model = null;
+
public void testSeamViewPartitioner() throws CoreException {
JobUtils.waitForIdle();
@@ -72,103 +76,106 @@
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);
+ editorInput = new FileEditorInput(jspFile);
- IDocumentProvider documentProvider = null;
Throwable exception = null;
-
- documentProvider =
DocumentProviderRegistry.getDefault().getDocumentProvider(editorInput);
- assertNotNull("The document provider for the file \"" + PAGE_NAME +
"\" is not loaded", documentProvider);
-
-
- documentProvider.connect(editorInput);
- IDocument document = documentProvider.getDocument(editorInput);
-
- assertTrue("The document for the file \"" + PAGE_NAME + "\" is
not loaded", (document != null));
-
- assertTrue("Document should be instance of IStructuredDocument",document
instanceof IStructuredDocument);
- IStructuredModel model =
StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) document);
- assertTrue("The document model for the file \"" + PAGE_NAME +
"\" is not loaded", (model != null));
-
- EditorModelUtil.addFactoriesTo(model);
-
- SeamViewHyperlinkPartitioner seamViewPartitioner = new SeamViewHyperlinkPartitioner();
-
- TestHyperlinkDetector detector = new TestHyperlinkDetector();
- HashMap<Object, ArrayList> recognitionTest = new HashMap<Object,
ArrayList>();
-
- ArrayList<Region> regionList = new ArrayList<Region>();
- regionList.add(new Region(1888, 11));
- regionList.add(new Region(1943, 11));
- recognitionTest.put("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK",
regionList);
-
- int counter = 0;
- for (int i = 0; i < document.getLength(); i++) {
- TestData testData = new TestData(document, i);
+ try {
+ documentProvider =
DocumentProviderRegistry.getDefault().getDocumentProvider(editorInput);
+ assertNotNull("The document provider for the file \"" + PAGE_NAME +
"\" is not loaded", documentProvider);
+
+
+ documentProvider.connect(editorInput);
- String[] partitionTypes = detector.getPartitionTypes(document, i);
-
- boolean recognized = false;
+ IDocument document = documentProvider.getDocument(editorInput);
+
+ assertTrue("The document for the file \"" + PAGE_NAME + "\"
is not loaded", (document != null));
- if (partitionTypes != null && partitionTypes.length > 0) {
- recognized =
("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK".equals(partitionTypes[0]));
- }
-
- if (recognized) {
- recognized &= seamViewPartitioner.recognize(testData.document,
testData.getHyperlinkRegion());
- }
+ assertTrue("Document should be instance of IStructuredDocument",document
instanceof IStructuredDocument);
+ model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument)
document);
+ assertTrue("The document model for the file \"" + PAGE_NAME +
"\" is not loaded", (model != null));
- if (recognized) {
- String childPartitionType =
seamViewPartitioner.getChildPartitionType(testData.document,
testData.getHyperlinkRegion());
-// if (childPartitionType != null)
-// System.out.println("position #" + i + " partitionType: " +
childPartitionType);
-
- if (childPartitionType != null) {
- ArrayList test = (ArrayList)recognitionTest.get(childPartitionType);
+ EditorModelUtil.addFactoriesTo(model);
+
+ SeamViewHyperlinkPartitioner seamViewPartitioner = new
SeamViewHyperlinkPartitioner();
+
+ TestHyperlinkDetector detector = new TestHyperlinkDetector();
+ HashMap<Object, ArrayList> recognitionTest = new HashMap<Object,
ArrayList>();
+
+ ArrayList<Region> regionList = new ArrayList<Region>();
+ regionList.add(new Region(1888, 11));
+ regionList.add(new Region(1943, 11));
+ recognitionTest.put("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK",
regionList);
+
+ int counter = 0;
+ for (int i = 0; i < document.getLength(); i++) {
+ TestData testData = new TestData(document, i);
+
+ String[] partitionTypes = detector.getPartitionTypes(document, i);
+
+ boolean recognized = false;
+
+ if (partitionTypes != null && partitionTypes.length > 0) {
+ recognized =
("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK".equals(partitionTypes[0]));
+ }
+
+ if (recognized) {
+ recognized &= seamViewPartitioner.recognize(testData.document,
testData.getHyperlinkRegion());
+ }
+
+ if (recognized) {
+ String childPartitionType =
seamViewPartitioner.getChildPartitionType(testData.document,
testData.getHyperlinkRegion());
+ // if (childPartitionType != null)
+ // System.out.println("position #" + i + " partitionType: " +
childPartitionType);
+
+ if (childPartitionType != null) {
+ ArrayList test = (ArrayList)recognitionTest.get(childPartitionType);
+ boolean testResult = false;
+ Iterator regions = test.iterator();
+ Region r = null;
+ while (!testResult && regions.hasNext()) {
+ r = (Region)regions.next();
+ if (r.getOffset() <= testData.offset && testData.offset <
(r.getOffset() + r.getLength()))
+ testResult = true;
+ }
+ assertTrue("Wrong recognition for the region: " +
testData.getHyperlinkRegion().toString()
+ + " doesn't matches the region [" + r.getOffset() + "-" +
(r.getOffset() + r.getLength()) + "]" , testResult);
+ counter++;
+ } else {
+ recognized = false;
+ }
+
+ }
+
+ if (!recognized) {
+
boolean testResult = false;
- Iterator regions = test.iterator();
+ Iterator keys = recognitionTest.keySet().iterator();
Region r = null;
- while (!testResult && regions.hasNext()) {
- r = (Region)regions.next();
- if (r.getOffset() <= testData.offset && testData.offset <
(r.getOffset() + r.getLength()))
- testResult = true;
+ while (keys != null && keys.hasNext()) {
+ Object key = keys.next();
+ ArrayList test = (ArrayList)recognitionTest.get(key);
+ Iterator regions = test.iterator();
+ while (!testResult && regions.hasNext()) {
+ r = (Region)regions.next();
+ if (r.getOffset() <= testData.offset && testData.offset <
(r.getOffset() + r.getLength()))
+ testResult = true;
+ // System.out.println(testData.getHyperlinkRegion().toString());
+ }
}
assertTrue("Wrong recognition for the region: " +
testData.getHyperlinkRegion().toString()
- + " doesn't matches the region [" + r.getOffset() + "-" +
(r.getOffset() + r.getLength()) + "]" , testResult);
- counter++;
- } else {
- recognized = false;
+ + " matches the wrong region [" + r.getOffset() + "-" +
(r.getOffset() + r.getLength()) + "] in file \"" + PAGE_NAME +
"\"" , (testResult == false));
}
-
}
+
+ assertEquals("Wrong recognized region count", 22 , counter);
+ } finally {
+ if (model != null)
+ model.releaseFromEdit();
- if (!recognized) {
-
- boolean testResult = false;
- Iterator keys = recognitionTest.keySet().iterator();
- Region r = null;
- while (keys != null && keys.hasNext()) {
- Object key = keys.next();
- ArrayList test = (ArrayList)recognitionTest.get(key);
- Iterator regions = test.iterator();
- while (!testResult && regions.hasNext()) {
- r = (Region)regions.next();
- if (r.getOffset() <= testData.offset && testData.offset <
(r.getOffset() + r.getLength()))
- testResult = true;
-// System.out.println(testData.getHyperlinkRegion().toString());
- }
- }
- assertTrue("Wrong recognition for the region: " +
testData.getHyperlinkRegion().toString()
- + " matches the wrong region [" + r.getOffset() + "-" +
(r.getOffset() + r.getLength()) + "] in file \"" + PAGE_NAME +
"\"" , (testResult == false));
- }
+ if (editorInput != null && documentProvider != null)
+ documentProvider.disconnect(editorInput);
}
-
- assertEquals("Wrong recognized region count", 22 , counter);
-
- model.releaseFromEdit();
-
- documentProvider.disconnect(editorInput);
}
class TestData {
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2010-11-19
12:54:52 UTC (rev 26758)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2010-11-19
13:04:48 UTC (rev 26759)
@@ -82,25 +82,34 @@
*
*/
public void testSeamProjectNewWizardInstanceIsCreated() {
- IWizardPage startSeamPrjWzPg = wizard.getStartingPage();
- wizard.getDataModel().setStringProperty("IProjectCreationPropertiesNew.PROJECT_NAME","testName");
- assertNotNull("Cannot create seam start wizard page", startSeamPrjWzPg);
- IWizardPage webModuleWizPg = wizard.getNextPage(startSeamPrjWzPg);
- assertNotNull("Cannot create dynamic web project wizard
page",webModuleWizPg);
- IWizardPage jsfCapabilitiesWizPg = wizard.getNextPage(webModuleWizPg);
- assertNotNull("Cannot create JSF capabilities wizard
page",jsfCapabilitiesWizPg);
- IWizardPage seamWizPg = wizard.getNextPage(jsfCapabilitiesWizPg);
- assertNotNull("Cannot create seam facet wizard page",seamWizPg);
- wizard.performCancel();
+ try {
+ IWizardPage startSeamPrjWzPg = wizard.getStartingPage();
+ wizard.getDataModel().setStringProperty("IProjectCreationPropertiesNew.PROJECT_NAME","testName");
+ assertNotNull("Cannot create seam start wizard page", startSeamPrjWzPg);
+ IWizardPage webModuleWizPg = wizard.getNextPage(startSeamPrjWzPg);
+ assertNotNull("Cannot create dynamic web project wizard
page",webModuleWizPg);
+ IWizardPage jsfCapabilitiesWizPg = wizard.getNextPage(webModuleWizPg);
+ assertNotNull("Cannot create JSF capabilities wizard
page",jsfCapabilitiesWizPg);
+ IWizardPage seamWizPg = wizard.getNextPage(jsfCapabilitiesWizPg);
+ assertNotNull("Cannot create seam facet wizard page",seamWizPg);
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
}
public void testSeamProjectNewWizardFinisDisableByDefaul() {
- // Disable Library Configuration
- disableLibraryConfiguration();
- JobUtils.delay(1000);
-
- boolean canFinish = wizard.canFinish();
- assertFalse("Finish button is enabled at first wizard page before all requerd
fileds are valid.", canFinish);
+ try {
+ // Disable Library Configuration
+ disableLibraryConfiguration();
+ JobUtils.delay(1000);
+
+ boolean canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled at first wizard page before all requerd
fileds are valid.", canFinish);
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
}
/**
@@ -109,15 +118,20 @@
* See
http://jira.jboss.com/jira/browse/JBIDE-1111
*/
public void testJiraJbide1111() {
- // Disable Library Configuration
- disableLibraryConfiguration();
- JobUtils.delay(1000);
-
- // Set project name
- wizard.getDataModel().setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
"testSeamProject");
- JobUtils.delay(1000);
-
- assertTrue("Finish button is disabled at first wizard page in spite of created
JBoss AS Runtime, Server, DB Connection and Seam Runtime and valid project name.",
wizard.canFinish());
+ try {
+ // Disable Library Configuration
+ disableLibraryConfiguration();
+ JobUtils.delay(2000);
+
+ // Set project name
+ wizard.getDataModel().setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
"testSeamProject");
+ JobUtils.delay(2000);
+
+ assertTrue("Finish button is disabled at first wizard page in spite of created
JBoss AS Runtime, Server, DB Connection and Seam Runtime and valid project name.",
wizard.canFinish());
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
}
private void disableLibraryConfiguration(){
@@ -170,8 +184,7 @@
@Override
protected void tearDown() throws Exception {
- wizard.performCancel();
- dialog.close();
+
}
public static final String INIT_ERROR_MESSAGE = "System property
''{0}'' must be configured with -D to run these tests";