[jbosstools-commits] JBoss Tools SVN: r43811 - trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Sep 18 19:23:25 EDT 2012
Author: dazarov
Date: 2012-09-18 19:23:25 -0400 (Tue, 18 Sep 2012)
New Revision: 43811
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java
Log:
org.jboss.tools.jsf.text.ext.test failure https://issues.jboss.org/browse/JBIDE-12626
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java 2012-09-18 21:34:48 UTC (rev 43810)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java 2012-09-18 23:23:25 UTC (rev 43811)
@@ -19,9 +19,9 @@
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlink;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlinkDetector;
-import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestHyperlink;
-import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestRegion;
-import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil;
+import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestRegion;
+import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestHyperlink;
/**
*
@@ -51,19 +51,23 @@
public void testJSF2MessagesHyperlink() throws Exception{
ArrayList<TestRegion> regionList = new ArrayList<TestRegion>();
- regionList.add(new TestRegion(881, 13, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(896, 5, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'prompt' of bundle 'resources'", "resources.properties")}));
-
- regionList.add(new TestRegion(1004, 13, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(1019, 25, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'demo.long.named.property' of bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("${", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("registeredMsg"/*881, 13*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("promp"/*896, 5*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'prompt' of bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(1078, 7, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(1087, 5, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'prompt' of bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("${", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("registeredMsg"/*1004, 13*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("demo.long.named.propert"/*1019, 25*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'demo.long.named.property' of bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(1125, 7, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
- regionList.add(new TestRegion(1134, 25, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'demo.long.named.property' of bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("${", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("pageMsgs"/*1078, 7*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("prompt"/*1087, 5*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'prompt' of bundle 'resources'", "resources.properties")}));
+
+ regionList.add(new TestRegion("${", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("pageMsg"/*1125, 7*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'resources'", "resources.properties")}));
+ regionList.add(new TestRegion("demo.long.named.propert"/*1134, 25*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'demo.long.named.property' of bundle 'resources'", "resources.properties")}));
- JSFHyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
+ HyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java 2012-09-18 21:34:48 UTC (rev 43810)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java 2012-09-18 23:23:25 UTC (rev 43811)
@@ -10,6 +10,8 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -35,6 +37,8 @@
import org.jboss.tools.common.text.ext.util.AxisUtil;
import org.jboss.tools.jsf.ui.editor.FacesConfigEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestHyperlink;
+import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestRegion;
import org.jboss.tools.jst.web.ui.editors.WebCompoundEditor;
import org.jboss.tools.common.model.ui.texteditors.XMLTextEditorComponent;
@@ -68,7 +72,10 @@
IDocument document = documentProvider.getDocument(editorInput);
assertNotNull("The document for the file \"" + fileName + "\" is not loaded", document);
-
+
+ if(regionList.get(0).region == null)
+ loadRegions(regionList, document);
+
int expected = 0;
for(TestRegion testRegion : regionList) {
@@ -105,6 +112,8 @@
int counter = 0;
for (int i = 0; i < document.getLength(); i++) {
+ int lineNumber = document.getLineOfOffset(i);
+ int position = i - document.getLineOffset(lineNumber)+1;
TestData testData = new TestData(document, i);
IHyperlink[] links = elDetector.detectHyperlinks(viewer, testData.getHyperlinkRegion(), true);
@@ -124,8 +133,7 @@
else {
for(TestRegion testRegion : regionList){
if(i >= testRegion.region.getOffset() && i <= testRegion.region.getOffset()+testRegion.region.getLength()) {
- int line = document.getLineOfOffset(testRegion.region.getOffset());
- fail("Wrong detection for region - "+testRegion.region.getOffset()+" : "+testRegion.region.getLength()+" region - "+i);
+ fail("Wrong detection for region - "+getRegionInformation(document, testRegion)+" offset - "+i+" (line - "+lineNumber+" position - "+position+")");
}
}
}
@@ -136,6 +144,20 @@
documentProvider.disconnect(editorInput);
}
+ private static String getRegionInformation(IDocument document, TestRegion region) throws BadLocationException{
+ String info = "";
+ int lineNumber = document.getLineOfOffset(region.region.getOffset());
+ int position = region.region.getOffset() - document.getLineOffset(lineNumber)+1;
+ lineNumber++;
+
+ if(region.regionText != null)
+ info += "<"+region.regionText+"> ";
+
+ info += region.region.getOffset()+" - "+(region.region.getOffset()+region.region.getLength())+" line - "+lineNumber+" position - "+position;
+
+ return info;
+ }
+
private static void checkTestRegion(IHyperlink[] links, TestRegion testRegion){
for(IHyperlink link : links){
TestHyperlink testLink = findTestHyperlink(testRegion.hyperlinks, link);
@@ -180,7 +202,28 @@
}
return null;
}
-
+
+ private static void loadRegions(List<TestRegion> regionList, IDocument document) throws BadLocationException{
+ FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(document);
+ //IRegion region = adapter.find(0, "{", true, true, false, false);
+ //if(region == null)
+ IRegion region = new Region(0,0);
+ for(TestRegion testRegion : regionList){
+ IRegion newRegion = adapter.find(region.getOffset()+region.getLength(), testRegion.regionText, true, true, false, false);
+ if(newRegion != null){
+ testRegion.region = newRegion;
+ region = newRegion;
+ }else
+ fail("Can not find string - "+testRegion.regionText);
+ }
+
+ for(int i = regionList.size()-1; i >= 0; i--){
+ TestRegion r = regionList.get(i);
+ if(r.hyperlinks.size() == 0)
+ regionList.remove(r);
+ }
+ }
+
public static IEditorPart openFileInEditor(IFile input) {
return openFileInEditor(input, null);
}
@@ -303,7 +346,8 @@
}
public static class TestRegion{
- Region region;
+ IRegion region = null;
+ String regionText = null;
ArrayList<TestHyperlink> hyperlinks = new ArrayList<TestHyperlink>();
public TestRegion(int offset, int length, TestHyperlink[] testHyperlinks){
@@ -313,8 +357,8 @@
}
}
- public TestRegion(Region region, TestHyperlink[] testHyperlinks){
- region = new Region(region.getOffset(),region.getLength());
+ public TestRegion(String regionText, TestHyperlink[] testHyperlinks){
+ this.regionText = regionText;
for(TestHyperlink testHyperlink : testHyperlinks){
hyperlinks.add(testHyperlink);
}
More information about the jbosstools-commits
mailing list