[jbosstools-commits] JBoss Tools SVN: r42222 - in trunk: common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation and 7 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jun 26 10:22:44 EDT 2012


Author: vrubezhny
Date: 2012-06-26 10:22:44 -0400 (Tue, 26 Jun 2012)
New Revision: 42222

Added:
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.jsp
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.xhtml
Modified:
   trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
   trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAsYouTypeValidationTest.java
   trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/java/BaseAsYouTypeInJavaValidationTest.java
   trunk/jsf/tests/org.jboss.tools.jsf.base.test/projects/JSF2KickStartWithoutLibs/JavaSource/demo/User.java
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/JSFAsYouTypeValidationTest.java
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/java/JSFAsYouTypeInJavaValidationTest.java
   trunk/jst/tests/org.jboss.tools.jst.jsp.base.test/src/org/jboss/tools/jst/jsp/test/validation/BaseAsYouTypeValidationTest.java
Log:
JBIDE-10738
As-you-type EL validation

JUnit tests are updated

Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -1,5 +1,5 @@
 /*******************************************************************************
-  * Copyright (c) 2007-2011 Red Hat, Inc.
+  * Copyright (c) 2007-2012 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,
@@ -35,6 +35,7 @@
  * This class helps to find var/value attributes in DOM tree.   
  * @author Alexey Kazakov
  */
+ at SuppressWarnings("restriction")
 public class ElVarSearcher {
 
 	private final static String VAR_ATTRIBUTE_NAME = "var"; //$NON-NLS-1$
@@ -257,26 +258,28 @@
 	 */
 	public static Var findVar(Node node, ELParserFactory factory) {
 		if(factory!=null && node!=null && Node.ELEMENT_NODE == node.getNodeType()) {
-			Element element = (Element)node;			
-			if(element.hasAttribute(VAR_ATTRIBUTE_NAME)) {
-				String var = element.getAttribute(VAR_ATTRIBUTE_NAME);
-				int declOffset = 0;
-				int declLength = 0;
-				Node varAttr = element.getAttributeNode(VAR_ATTRIBUTE_NAME); 
-				if (varAttr instanceof IDOMAttr) {
-					int varNameStart = ((IDOMAttr)varAttr).getNameRegionStartOffset();
-					int varNameEnd = ((IDOMAttr)varAttr).getNameRegionEndOffset();
-					declOffset = varNameStart;
-					declLength = varNameEnd - varNameStart;
-				}
-				var = var.trim();
-				if(!"".equals(var)) { //$NON-NLS-1$					
-					if(element.hasAttribute(VALUE_ATTRIBUTE_NAME)) {
-						String value = element.getAttribute(VALUE_ATTRIBUTE_NAME);
-						value = value.trim();
-						Var newVar = new Var(factory, var, value, declOffset, declLength);
-						if(newVar.getElToken()!=null) {
-							return newVar;
+			Element element = (Element)node;
+			synchronized (element) {
+				if(element.hasAttribute(VAR_ATTRIBUTE_NAME)) {
+					String var = element.getAttribute(VAR_ATTRIBUTE_NAME);
+					int declOffset = 0;
+					int declLength = 0;
+					Node varAttr = element.getAttributeNode(VAR_ATTRIBUTE_NAME); 
+					if (varAttr instanceof IDOMAttr) {
+						int varNameStart = ((IDOMAttr)varAttr).getNameRegionStartOffset();
+						int varNameEnd = ((IDOMAttr)varAttr).getNameRegionEndOffset();
+						declOffset = varNameStart;
+						declLength = varNameEnd - varNameStart;
+					}
+					var = var.trim();
+					if(!"".equals(var)) { //$NON-NLS-1$					
+						if(element.hasAttribute(VALUE_ATTRIBUTE_NAME)) {
+							String value = element.getAttribute(VALUE_ATTRIBUTE_NAME);
+							value = value.trim();
+							Var newVar = new Var(factory, var, value, declOffset, declLength);
+							if(newVar.getElToken()!=null) {
+								return newVar;
+							}
 						}
 					}
 				}

Modified: trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAsYouTypeValidationTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAsYouTypeValidationTest.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAsYouTypeValidationTest.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -16,6 +16,11 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
@@ -28,6 +33,8 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.validation.internal.operations.EnabledValidatorsOperation;
+import org.jboss.tools.common.validation.ValidatorManager;
 import org.jboss.tools.test.util.JobUtils;
 import org.jboss.tools.test.util.WorkbenchUtils;
 
@@ -36,6 +43,7 @@
  * @author Victor V. Rubezhny
  *
  */
+ at SuppressWarnings("restriction")
 public abstract class AbstractAsYouTypeValidationTest extends TestCase {
 	private static final int MAX_SECONDS_TO_WAIT = 10;
 
@@ -98,55 +106,246 @@
 
 	protected abstract ISourceViewer getTextViewer();
 
-	public void doAsYouTipeInJavaValidationTest(String elToValidate,
-			String errorMessage) throws JavaModelException, BadLocationException {
+	/**
+	 * The test procedure steps:
+	 * - Find EL by a given number
+	 * - Set up a good EL => see no annotations on that EL
+	 * - Set up a broken EL => see annotation appearance on that EL
+	 * - Set up a good EL again => see annotation to disappear on that EL
+	 * 
+	 * @param goodEL
+	 * @param elToValidate
+	 * @param errorMessage
+	 * @param numberOfRegionToTest
+	 * @return boolean indicating that test was done for a region with a given number
+	 * @throws JavaModelException
+	 * @throws BadLocationException
+	 */
+	public boolean doAsYouTypeValidationTest(String goodEL, String elToValidate,
+			String errorMessage, int numberOfRegionToTest) throws JavaModelException, BadLocationException {
+
+		//============================
+		// The test procedure steps:
+		// - Find EL by a given number
+		//============================
+		
 		String documentContent = document.get();
-		int start = (documentContent == null ? -1 : documentContent
-				.indexOf(EL2FIND_START));
-		assertFalse("No EL found in Java Strings: Starting '" + EL2FIND_START
-				+ "' characters are not found in document", (start == -1));
-		int end = (documentContent == null ? -1 : documentContent.indexOf(
-				EL2FIND_END, start));
-		assertFalse("EL is not closed in Java Strings: Ending '"
-				+ EL2FIND_START + "' characters are not found in document",
-				(end == -1));
-
+		int count = -1; 
+		
+		int start = 0;
+		int end = 0;
+		while (++count <= numberOfRegionToTest) {
+			start = (documentContent == null ? -1 : documentContent
+					.indexOf(EL2FIND_START, end));
+			if (start == -1 && count == numberOfRegionToTest)
+				return false;
+			assertFalse("No EL found in Java Strings: Starting '" + EL2FIND_START
+					+ "' characters are not found in document", (start == -1));
+			end = (documentContent == null ? -1 : documentContent.indexOf(
+					EL2FIND_END, start));
+			if (end == -1 && count == numberOfRegionToTest)
+				return false;
+			assertFalse("EL is not closed in Java Strings: Ending '"
+					+ EL2FIND_START + "' characters are not found in document",
+					(end == -1));
+		}
+		if (count < numberOfRegionToTest) {
+			// No more regions to test
+			return false;
+		}
+		
 		int length = end - start + EL2FIND_END.length();
 
+		//==================================================
+		// - Set up a good EL => see no annotations on that EL
+		//==================================================
+
+//		System.out.println("Text to be replaced [0]: [" + document.get(start, length) + "]");
+		document.replace(start, length, goodEL);
+		Annotation problemAnnotation = waitForAnnotation(
+				start, end, null, MAX_SECONDS_TO_WAIT, false, false);
+		assertNull("Problem Annotation found on a good EL!", problemAnnotation);
+		length = goodEL.length();
+
+		//==============================================================
+		// - Set up a broken EL => see annotation appearance on that EL
+		//==============================================================
+
+//		System.out.println("Text to be replaced [1]: [" + document.get(start, length) + "]");
 		document.replace(start, length, elToValidate);
-
+		length = elToValidate.length();
 		end = start + elToValidate.length();
 
-		Annotation problemAnnotation = waitForProblemAnnotationAppearance(
-				start, end, MAX_SECONDS_TO_WAIT);
-		assertNotNull("No ProblemAnnotation found!", problemAnnotation);
+		problemAnnotation = waitForAnnotation(
+				start, end, errorMessage, MAX_SECONDS_TO_WAIT, false, true);
+		assertNotNull("No Problem Annotation found!", problemAnnotation);
 
 		String message = problemAnnotation.getText();
 		assertEquals(
 				"Not expected error message found in ProblemAnnotation. Expected: ["
 						+ errorMessage + "], Found: [" + message + "]",
 				errorMessage, message);
+		
+		//===================================================================
+		// - Set up a good EL again => see annotation to disappear on that EL
+		//===================================================================
+
+//		System.out.println("Text to be replaced [2]: [" + document.get(start, length) + "]");
+		document.replace(start, length, goodEL);
+		problemAnnotation = waitForAnnotation(
+				start, end, null, MAX_SECONDS_TO_WAIT, false, false);
+		assertNull("Problem Annotation has not disappeared!", problemAnnotation);
+
+		return true;
 	}
 
-	private Annotation waitForProblemAnnotationAppearance(
-			final int start, final int end, final int seconds) {
+	/**
+	 * The test procedure steps:
+	 * - Find EL by a given number
+	 * - Set up a broken EL and save the document => see problem marker appearance on that EL
+	 * - Set up a another broken EL => see annotation appearance on that EL instead of a problem marker 
+	 *   (an old problem marker has to disappear)
+	 * - Set up a good EL again => see annotation to disappear on that EL
+	 * 
+	 * @param goodEL
+	 * @param elToValidate
+	 * @param errorMessage
+	 * @param numberOfRegionToTest
+	 * @throws BadLocationException
+	 * @throws CoreException 
+	 */
+	public boolean doAsYouTypeValidationMarkerAnnotationsRemovalTest(String goodEL, String elToValidate,
+			String errorMessage, String anotherELToValidate, String anotherErrorMessage, int numberOfRegionToTest) throws BadLocationException, CoreException {
+
+//		System.out.println("doAsYouTypeValidationMarkerAnnotationsRemovalTest(goodEL=" + goodEL + ", elToValidate=" + elToValidate + ", errorMessage=[" + errorMessage + 
+//				"],\n\tanotherELToValidate=" + anotherELToValidate+ ", anotherErrorMessage=[" + anotherErrorMessage + "], numberOfRegionToTest=" + numberOfRegionToTest + ")");
+		//============================
+		// The test procedure steps:
+		// - Find EL by a given number
+		//============================
+		
+		String documentContent = document.get();
+		int count = -1; 
+		
+		int start = 0;
+		int end = 0;
+		while (++count <= numberOfRegionToTest) {
+			start = (documentContent == null ? -1 : documentContent
+					.indexOf(EL2FIND_START, end));
+			if (start == -1 && count == numberOfRegionToTest)
+				return false;
+			assertFalse("No EL found in Java Strings: Starting '" + EL2FIND_START
+					+ "' characters are not found in document", (start == -1));
+			end = (documentContent == null ? -1 : documentContent.indexOf(
+					EL2FIND_END, start));
+			if (end == -1 && count == numberOfRegionToTest)
+				return false;
+			assertFalse("EL is not closed in Java Strings: Ending '"
+					+ EL2FIND_START + "' characters are not found in document",
+					(end == -1));
+		}
+		if (count < numberOfRegionToTest) {
+			// No more regions to test
+			return false;
+		}
+			
+		int length = end - start + EL2FIND_END.length();
+
+		//========================================================================================
+		//  - Set up a broken EL and save the document => see problem marker appearance on that EL
+		//========================================================================================
+
+//		System.out.println("Text to be replaced [0]: [" + document.get(start, length) + "]");
+//		document.replace(start, length, elToValidate);
+		
+//		document = viewer.getDocument(); // Probably we should find that EL again because the document may be re-formatted at save (?)
+//		end = start + elToValidate.length();
+//		length = elToValidate.length();
+
+		// do check marker and marker annotation appeared here
+		int line = document.getLineOfOffset(start);
+		assertResourceMarkerIsCreated(file, errorMessage, line + 1);
+
+		Annotation problemAnnotation = waitForAnnotation(
+				start, end, errorMessage, MAX_SECONDS_TO_WAIT, true, true);
+		assertNotNull("Problem Marker Annotation not found!", problemAnnotation);
+		
+		String message = problemAnnotation.getText();
+		assertEquals(
+				"Not expected error message found in ProblemAnnotation. Expected: ["
+						+ errorMessage + "], Found: [" + message + "]",
+				errorMessage, message);
+		
+		//=================================================================================================
+		// - Set up a another broken EL => see annotation appearance on that EL instead of a problem marker 
+		//   (an old problem marker has to disappear)
+		//=================================================================================================
+
+//		System.out.println("Text to be replaced [1]: [" + document.get(start, length) + "] by [" + anotherELToValidate + "]");
+		document.replace(start, length, anotherELToValidate);
+		
+		end = start + anotherELToValidate.length();
+		length = anotherELToValidate.length();
+
+		problemAnnotation = waitForAnnotation(
+				start, end, anotherErrorMessage, MAX_SECONDS_TO_WAIT, false, true);
+		
+		if (problemAnnotation == null) {
+			problemAnnotation = waitForAnnotation(
+					start, end, anotherErrorMessage, MAX_SECONDS_TO_WAIT, false, true);
+		}
+		assertNotNull("No Problem Annotation found for EL " + anotherELToValidate + " on region " + numberOfRegionToTest + "!", problemAnnotation);
+
+		message = problemAnnotation.getText();
+		assertEquals(
+				"Not expected error message found in ProblemAnnotation. Expected: ["
+						+ anotherErrorMessage + "], Found: [" + message + "]",
+				anotherErrorMessage, message);
+
+		// do check marker annotation has disappeared here
+		problemAnnotation = waitForAnnotation(
+				start, end, null, MAX_SECONDS_TO_WAIT, true, false);
+		assertNull("Problem Marker Annotation has not disappeared!", problemAnnotation);
+
+		//===================================================================
+		// - Set up a good EL again => see annotation to disappear on that EL
+		//===================================================================
+
+//		System.out.println("Text to be replaced [2]: [" + document.get(start, length) + "] by [" + goodEL + "]");
+		document.replace(start, length, goodEL);
+		problemAnnotation = waitForAnnotation(
+				start, end, null, MAX_SECONDS_TO_WAIT, false, false);
+		assertNull("Problem Annotation has not disappeared!", problemAnnotation);
+
+		return true;
+	}
+	
+	private Annotation waitForAnnotation(final int start, final int end, final String errorMessage, final int seconds, final boolean markerAnnotation, final boolean waitForAppearance) {
 		final Annotation[] result = new Annotation[] { null };
 
 		Display.getDefault().syncExec(new Runnable() {
+			@SuppressWarnings("rawtypes")
 			public void run() {
 				int secondsLeft = seconds;
+				boolean isFirstPass = true;
 				while (secondsLeft-- > 0) {
-					JobUtils.delay(1000);
+					if (!isFirstPass || waitForAppearance) {
+						JobUtils.delay(1000);
 
-					// clean deffered events
-					while (Display.getCurrent().readAndDispatch())
-						;
+						// clean deffered events
+						while (Display.getCurrent().readAndDispatch())
+							;
+					} else {
+						secondsLeft++; // because the wait step was skipped
+					}
 
 					annotationModel = getAnnotationModel();
+					if (annotationModel == null) 
+						return;
+					
+					Iterator it = annotationModel.getAnnotationIterator();
 					boolean found = false;
-					@SuppressWarnings("rawtypes")
-					Iterator it = annotationModel.getAnnotationIterator();
-					while (!found && it.hasNext()) {
+					while (it.hasNext()) {
 						Object o = it.next();
 
 						if (!(o instanceof Annotation))
@@ -155,27 +354,80 @@
 						Annotation annotation = (Annotation) o;
 						Position position = annotationModel
 								.getPosition(annotation);
+						if (position == null)
+							continue;
 
 						if (position.getOffset() < start
 								|| position.getOffset() >= end)
 							continue;
 
-						if (position.getOffset() + position.getLength() >= end)
+						if (position.getOffset() + position.getLength() > end)
 							continue;
 
-						
-						if (!isAnnotationAcceptable(annotation))
+						if (!markerAnnotation && errorMessage != null && !errorMessage.equals(annotation.getText()))
 							continue;
-						
-						result[0] = (Annotation)o;
-						return;
+
+//						System.out.println("A: " + (position == null ? null : position.toString()) + ", " + annotation.getClass().getName() + ", " + annotation.getType() + ", " + annotation.getText());
+
+						found = markerAnnotation ? isMarkerAnnotationAcceptable(annotation) : isAnnotationAcceptable(annotation);
+						if (found) {
+							if (waitForAppearance) {
+								// Return the annotation we've searched for
+								result[0] = (Annotation)o;
+								return;
+							} else {
+								// Continue to wait for annotation to disappear
+								break;
+							}
+						}
 					}
+					
+					// if waiting for an annotation to disappear then don't return at first pass
+					if (!found && !waitForAppearance && !isFirstPass) {
+						return; // Annotation not found or disappeared
+					}					
+					isFirstPass = false;
 				}
 			}
 		});
 
+//		System.out.println(result[0] == null ? "Not found":"found");
 		return result[0];
 	}
 	
+	protected void waitForValidation(IProject project) throws CoreException{
+		ValidatorManager.setStatus(ValidatorManager.RUNNING);
+		IProgressMonitor monitor = new NullProgressMonitor();
+		project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+		project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+		new EnabledValidatorsOperation(project,false).run(monitor);
+		JobUtils.waitForIdle();
+	}
+	
+	protected String modifyModifyELInContent(StringBuilder content, String newEL) {
+		if (content == null)
+			return null;
+		
+		int start = 0;
+		int end = 0;
+		while (start != -1) {
+			start = content.indexOf(EL2FIND_START, end);
+			if (start == -1)
+				break;
+
+			end = content.indexOf(EL2FIND_END, start);
+			if (end == -1)
+				break;
+			
+			content.replace(start, end+1, newEL);
+		}
+		return content.toString();
+	}
+
+
 	abstract protected boolean isAnnotationAcceptable(Annotation annotation);
-}
+
+	abstract protected boolean isMarkerAnnotationAcceptable(Annotation annotation);
+	
+	abstract protected void assertResourceMarkerIsCreated(IFile file, String errorMessage, int line) throws CoreException;
+}
\ No newline at end of file

Modified: trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/java/BaseAsYouTypeInJavaValidationTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/java/BaseAsYouTypeInJavaValidationTest.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/java/BaseAsYouTypeInJavaValidationTest.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -10,7 +10,10 @@
  ******************************************************************************/
 package org.jboss.tools.common.base.test.validation.java;
 
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor;
 import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.ProblemAnnotation;
 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -18,7 +21,9 @@
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
 import org.jboss.tools.common.base.test.validation.AbstractAsYouTypeValidationTest;
+import org.jboss.tools.tests.AbstractResourceMarkerTest;
 
 /**
  * 
@@ -28,6 +33,7 @@
 @SuppressWarnings("restriction")
 public class BaseAsYouTypeInJavaValidationTest extends AbstractAsYouTypeValidationTest {
 	public static final String MARKER_TYPE = "org.jboss.tools.common.validation.el"; //$NON-NLS-1$
+	public static final String RESOURCE_MARKER_TYPE = "org.jboss.tools.jst.web.kb.elproblem"; //$NON-NLS-1$
 
 	public BaseAsYouTypeInJavaValidationTest(IProject project) {
 		this.project = project;
@@ -70,4 +76,39 @@
 
 		return true;
 	}
+	@Override
+	protected boolean isMarkerAnnotationAcceptable(Annotation annotation) {
+		if (!(annotation instanceof MarkerAnnotation))
+			return false;
+
+		MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
+
+		IMarker marker = markerAnnotation.getMarker();
+		String type;
+		try {
+			type = marker.getType();
+			return RESOURCE_MARKER_TYPE.equals(type);
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+	@Override
+	protected void assertResourceMarkerIsCreated(IFile file,
+			String errorMessage, int line) throws CoreException {
+		IMarker[] markers = AbstractResourceMarkerTest.findMarkers(
+				file, RESOURCE_MARKER_TYPE, errorMessage, true);
+
+		assertNotNull("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line, markers);
+		assertFalse("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line, markers.length == 0);
+
+		for (IMarker m : markers) {
+			Integer l = m.getAttribute(IMarker.LINE_NUMBER, -1);
+			if (l != null && line == l.intValue()) {
+				return;
+			}
+		}
+	
+		fail("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line);
+	}
 }

Modified: trunk/jsf/tests/org.jboss.tools.jsf.base.test/projects/JSF2KickStartWithoutLibs/JavaSource/demo/User.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.base.test/projects/JSF2KickStartWithoutLibs/JavaSource/demo/User.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/jsf/tests/org.jboss.tools.jsf.base.test/projects/JSF2KickStartWithoutLibs/JavaSource/demo/User.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -20,7 +20,6 @@
 @SessionScoped
 public class User {
 	private String name;
-	private String testString = "#{user.name}";
 
 	public User() {
 	}
@@ -34,6 +33,6 @@
 	}
 
 	public String sayHello() {
-		return "greeting";
+		return "greeting #{user.names}";
 	}
 }
\ No newline at end of file

Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.jsp	                        (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.jsp	2012-06-26 14:22:44 UTC (rev 42222)
@@ -0,0 +1,20 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<html>
+<head>
+	<title>Facelets Greeting Page</title>
+</head>
+<body>
+	<f:view>
+		<f:loadBundle basename="resources" var="msg" />
+		
+		<strong>
+		&nbsp;
+		#{user.name}
+		<h:outputText value="#{user.name}" />
+		<h:outputText value="!" />
+		</strong>
+	</f:view>
+</body>
+</html>
\ No newline at end of file


Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.jsp
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.xhtml	                        (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.xhtml	2012-06-26 14:22:44 UTC (rev 42222)
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+	<ui:composition template="/templates/common.xhtml">
+			<ui:define name="pageTitle">Greeting to User</ui:define>
+			<ui:define name="pageHeader">Greeting Page</ui:define>
+			<ui:define name="body">
+				#{user.name}!
+				<h:outputText value="#{user.name}" />
+			</ui:define>
+	</ui:composition>
+</html>
\ No newline at end of file


Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/AsYouTypeTestData/asYouType.xhtml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/JSFAsYouTypeValidationTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/JSFAsYouTypeValidationTest.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/JSFAsYouTypeValidationTest.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -10,8 +10,18 @@
  ******************************************************************************/
 package org.jboss.tools.jsf.ui.test.validation;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
@@ -21,6 +31,7 @@
 import org.jboss.tools.jst.web.kb.WebKbPlugin;
 import org.jboss.tools.jst.web.kb.preferences.ELSeverityPreferences;
 import org.jboss.tools.test.util.ProjectImportTestSetup;
+import org.osgi.framework.Bundle;
 
 /**
  * 
@@ -29,49 +40,219 @@
  */
 public class JSFAsYouTypeValidationTest extends BaseAsYouTypeValidationTest {
 	private static final String PROJECT_NAME = "JSF2KickStartWithoutLibs";
-	private static final String PAGE_NAME = "WebContent/pages/inputname.xhtml";
+	private static final String[][] PAGE_NAMES = {
+		{"projects/AsYouTypeTestData/asYouType.xhtml", "WebContent/pages/asYouType.xhtml"},
+		{"projects/AsYouTypeTestData/asYouType.jsp", "WebContent/pages/asYouType.jsp"}
+	};
 
 	private static final String [][] EL2VALIDATE = 
 		{ 
-			{"#{user.names}", "\"names\" cannot be resolved"}, 
-			{"#{suser.name}", "\"suser\" cannot be resolved"},
-			{"#{['}", "EL syntax error: Expecting expression."}
+			{"#{user.name}", "#{user.names}", "\"names\" cannot be resolved", "#{user.namess}", "\"namess\" cannot be resolved"}, 
+			{"#{user.name}", "#{suser.name}", "\"suser\" cannot be resolved", "#{ssuser.name}", "\"ssuser\" cannot be resolved"},
+			{"#{user.name}", "#{[}", "EL syntax error: Expecting expression.", "#{[[}", "EL syntax error: Expecting expression."}
 		};
 
-	public static final String EL2FIND_START = "#{";
-	public static final String EL2FIND_END = "}";
-	
 	private static boolean isSuspendedValidationDefaultValue;
 
 	public void setUp() throws Exception {
 		project = ProjectImportTestSetup.loadProject(PROJECT_NAME);
-		project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
 		isSuspendedValidationDefaultValue = ValidationFramework.getDefault().isSuspended();
 		ValidationFramework.getDefault().suspendAllValidation(false);
+		project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+		project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
 	}
 	
 	public void tearDown() throws Exception {
 		ValidationFramework.getDefault().suspendAllValidation(isSuspendedValidationDefaultValue);
 	}
 
-	public void testAsYouTypeInJavaValidation() throws JavaModelException, BadLocationException {
+	public void testAsYouTypeMarkerAnnotationsRemovalValidation() throws BadLocationException, CoreException {
 		assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
-		openEditor(PAGE_NAME);
-		IPreferenceStore store = WebKbPlugin.getDefault().getPreferenceStore();
-		String defaultValidateUnresolvedEL = SeverityPreferences.ENABLE;
-		String defaultUnknownELVariableName = SeverityPreferences.IGNORE;
+		
+		for (int p = 0; p < PAGE_NAMES.length; p++) {
+			String sourcePageName = PAGE_NAMES[p][0];
+			String pageName = PAGE_NAMES[p][1];
+			
+			IFile file = project.getFile(pageName);
+			IPreferenceStore store = WebKbPlugin.getDefault().getPreferenceStore();
+			String defaultValidateUnresolvedEL = SeverityPreferences.ENABLE;
+			String defaultUnknownELVariableName = SeverityPreferences.IGNORE;
+			try {
+				defaultValidateUnresolvedEL = store.getString(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL);
+				defaultUnknownELVariableName = store.getString(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME);
+				store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeverityPreferences.ENABLE);
+				store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeverityPreferences.ERROR);
+				for (int i = 0; i < EL2VALIDATE.length; i++) {
+					boolean doContinue = true;
+					int count = 0;
+					while (doContinue) {
+						prepareModifiedFile("org.jboss.tools.jsf.ui.test", sourcePageName, file, EL2VALIDATE[i][1]);
+						waitForValidation(project);
+
+						openEditor(pageName);
+						try {
+							doContinue = doAsYouTypeValidationMarkerAnnotationsRemovalTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1], EL2VALIDATE[i][2], EL2VALIDATE[i][3], EL2VALIDATE[i][4], count++);
+						} finally {
+							closeEditor();
+						}
+					}
+					assertTrue("No test regions found!", count > 1);
+				}
+			} finally {
+				store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, defaultValidateUnresolvedEL);
+				store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, defaultUnknownELVariableName);
+				try {
+					file.delete(true, null);
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+	public void testAsYouTypeValidation() throws JavaModelException, BadLocationException {
+		assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
+		
+		for (int p = 0; p < PAGE_NAMES.length; p++) {
+			String sourcePageName = PAGE_NAMES[p][0];
+			String pageName = PAGE_NAMES[p][1];
+			
+			IFile file = project.getFile(pageName);
+			prepareFile("org.jboss.tools.jsf.ui.test", sourcePageName, file);
+			IPreferenceStore store = WebKbPlugin.getDefault().getPreferenceStore();
+			String defaultValidateUnresolvedEL = SeverityPreferences.ENABLE;
+			String defaultUnknownELVariableName = SeverityPreferences.IGNORE;
+			try {
+				defaultValidateUnresolvedEL = store.getString(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL);
+				defaultUnknownELVariableName = store.getString(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME);
+				store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeverityPreferences.ENABLE);
+				store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeverityPreferences.ERROR);
+				openEditor(pageName);
+				for (int i = 0; i < EL2VALIDATE.length; i++) {
+					int count = 0;
+					while(doAsYouTypeValidationTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1], EL2VALIDATE[i][2], count++))
+						;
+					assertTrue("No test regions found!", count > 1);
+				}
+			} finally {
+				closeEditor();
+				store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, defaultValidateUnresolvedEL);
+				store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, defaultUnknownELVariableName);
+				try {
+					file.delete(true, null);
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+	private void prepareFile(String bundleName, String file, IFile destination) {
+		Bundle bundle = Platform.getBundle(bundleName);
+		if (bundle == null)
+			return;
+		
+		String filePath = null;
 		try {
-			defaultValidateUnresolvedEL = store.getString(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL);
-			defaultUnknownELVariableName = store.getString(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME);
-			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeverityPreferences.ENABLE);
-			store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeverityPreferences.ERROR);
-			for (int i = 0; i < EL2VALIDATE.length; i++) {
-				doAsYouTipeInJavaValidationTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1]);
+			filePath = FileLocator.resolve(bundle.getEntry(file)).getFile();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+			return;
+		}
+		java.io.File data = new java.io.File(filePath);
+		if (!data.exists())
+			return;
+		
+		BufferedReader r = null;
+		ByteArrayInputStream is = null;
+		try {
+			r = new BufferedReader(new FileReader(data));
+			StringBuilder content = new StringBuilder();
+			String line = null;
+			while ((line = r.readLine()) != null) {
+				content.append(line);
+				content.append('\n');
 			}
+			is = new ByteArrayInputStream(content.toString().getBytes("UTF-8"));
+			if (destination.exists()) {
+				destination.setContents(is, true, false, null);
+			} else {
+				destination.create(is, true, null);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
 		} finally {
-			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, defaultValidateUnresolvedEL);
-			store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, defaultUnknownELVariableName);
-			closeEditor();	
+			if (r != null) {
+				try {
+					r.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
 		}
 	}
+
+	private void prepareModifiedFile(String bundleName, String file, IFile destination, String el) {
+		Bundle bundle = Platform.getBundle(bundleName);
+		if (bundle == null)
+			return;
+		
+		String filePath = null;
+		try {
+			filePath = FileLocator.resolve(bundle.getEntry(file)).getFile();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+			return;
+		}
+		java.io.File data = new java.io.File(filePath);
+		if (!data.exists())
+			return;
+		
+		BufferedReader r = null;
+		ByteArrayInputStream is = null;
+		try {
+			r = new BufferedReader(new FileReader(data));
+			StringBuilder content = new StringBuilder();
+			String line = null;
+			while ((line = r.readLine()) != null) {
+				content.append(line);
+				content.append('\n');
+			}
+			
+			String modifiedContent = modifyModifyELInContent(content, el);
+			if (modifiedContent == null)
+				modifiedContent = "";
+			
+			is = new ByteArrayInputStream(modifiedContent.getBytes("UTF-8"));
+			if (destination.exists()) {
+				destination.setContents(is, true, false, null);
+			} else {
+				destination.create(is, true, null);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			if (r != null) {
+				try {
+					r.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
 }

Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/java/JSFAsYouTypeInJavaValidationTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/java/JSFAsYouTypeInJavaValidationTest.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/validation/java/JSFAsYouTypeInJavaValidationTest.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -10,15 +10,26 @@
  ******************************************************************************/
 package org.jboss.tools.jsf.ui.test.validation.java;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.wst.validation.ValidationFramework;
 import org.jboss.tools.common.base.test.validation.java.BaseAsYouTypeInJavaValidationTest;
 import org.jboss.tools.common.preferences.SeverityPreferences;
 import org.jboss.tools.jst.web.kb.WebKbPlugin;
 import org.jboss.tools.jst.web.kb.preferences.ELSeverityPreferences;
+import org.jboss.tools.test.util.JobUtils;
 import org.jboss.tools.test.util.ProjectImportTestSetup;
 
 /**
@@ -32,16 +43,59 @@
 
 	private static final String [][] EL2VALIDATE = 
 		{ 
-			{"#{user.names}", "\"names\" cannot be resolved"}, 
-			{"#{suser.name}", "\"suser\" cannot be resolved"},
-			{"#{['}", "EL syntax error: Expecting expression."}
+			{"#{user.name}", "#{user.names}", "\"names\" cannot be resolved", "#{user.namess}", "\"namess\" cannot be resolved"}, 
+			{"#{user.name}", "#{suser.name}", "\"suser\" cannot be resolved", "#{ssuser.name}", "\"ssuser\" cannot be resolved"},
+			{"#{user.name}", "#{[}", "EL syntax error: Expecting expression.", "#{[[}", "EL syntax error: Expecting expression."}
 		};
+	private boolean isSuspendedValidationDefaultValue;
 
 	public void setUp() throws Exception {
 		project = ProjectImportTestSetup.loadProject(PROJECT_NAME);
+		isSuspendedValidationDefaultValue = ValidationFramework.getDefault().isSuspended();
+		ValidationFramework.getDefault().suspendAllValidation(false);
+		project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
 		project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+		JobUtils.waitForIdle();
 	}
 
+	public void tearDown() throws Exception {
+		ValidationFramework.getDefault().suspendAllValidation(isSuspendedValidationDefaultValue);
+	}
+
+	public void testAsYouTypeMarkerAnnotationsRemovalInJavaValidation() throws BadLocationException, CoreException {
+		assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
+			
+		IFile file = project.getFile(PAGE_NAME);
+		IPreferenceStore store = WebKbPlugin.getDefault().getPreferenceStore();
+		String defaultValidateUnresolvedEL = SeverityPreferences.ENABLE;
+		String defaultUnknownELVariableName = SeverityPreferences.IGNORE;
+		try {
+			defaultValidateUnresolvedEL = store.getString(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL);
+			defaultUnknownELVariableName = store.getString(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME);
+			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeverityPreferences.ENABLE);
+			store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeverityPreferences.ERROR);
+			for (int i = 0; i < EL2VALIDATE.length; i++) {
+				boolean doContinue = true;
+				int count = 0;
+				while (doContinue) {
+					prepareModifiedFile(file, EL2VALIDATE[i][1]);
+					waitForValidation(project);
+
+					openEditor(PAGE_NAME);
+					try {
+						doContinue = doAsYouTypeValidationMarkerAnnotationsRemovalTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1], EL2VALIDATE[i][2], EL2VALIDATE[i][3], EL2VALIDATE[i][4], count++);
+					} finally {
+						closeEditor();
+					}
+				}
+				assertTrue("No test regions found!", count > 1);
+			}
+		} finally {
+			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, defaultValidateUnresolvedEL);
+			store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, defaultUnknownELVariableName);
+		}
+	}
+
 	public void testAsYouTypeInJavaValidation() throws JavaModelException, BadLocationException {
 		assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
 		openEditor(PAGE_NAME);
@@ -54,7 +108,10 @@
 			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeverityPreferences.ENABLE);
 			store.setValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeverityPreferences.ERROR);
 			for (int i = 0; i < EL2VALIDATE.length; i++) {
-				doAsYouTipeInJavaValidationTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1]);
+				int count = 0;
+				while(doAsYouTypeValidationTest(EL2VALIDATE[i][0], EL2VALIDATE[i][1], EL2VALIDATE[i][2], count++))
+					;
+				assertTrue("No test regions found!", count > 1);
 			}
 		} finally {
 			store.setValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, defaultValidateUnresolvedEL);
@@ -62,4 +119,49 @@
 			closeEditor();
 		}
 	}
+	
+	private void prepareModifiedFile(IFile destination, String el) {
+		BufferedReader r = null;
+		InputStream is = null;
+		try {
+			is = destination.getContents();
+			r = new BufferedReader(new InputStreamReader(is));
+			StringBuilder content = new StringBuilder();
+			String line = null;
+			while ((line = r.readLine()) != null) {
+				content.append(line);
+				content.append('\n');
+			}
+			is.close();
+			
+			String modifiedContent = modifyModifyELInContent(content, el);
+			if (modifiedContent == null)
+				modifiedContent = "";
+			
+			is = new ByteArrayInputStream(modifiedContent.getBytes("UTF-8"));
+			if (destination.exists()) {
+				destination.setContents(is, true, false, null);
+			} else {
+				destination.create(is, true, null);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			if (r != null) {
+				try {
+					r.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
 }

Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.base.test/src/org/jboss/tools/jst/jsp/test/validation/BaseAsYouTypeValidationTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.base.test/src/org/jboss/tools/jst/jsp/test/validation/BaseAsYouTypeValidationTest.java	2012-06-26 14:12:46 UTC (rev 42221)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.base.test/src/org/jboss/tools/jst/jsp/test/validation/BaseAsYouTypeValidationTest.java	2012-06-26 14:22:44 UTC (rev 42222)
@@ -10,16 +10,21 @@
  ******************************************************************************/
 package org.jboss.tools.jst.jsp.test.validation;
 
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
 import org.eclipse.wst.sse.ui.StructuredTextEditor;
 import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
 import org.jboss.tools.common.base.test.validation.AbstractAsYouTypeValidationTest;
 import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.tests.AbstractResourceMarkerTest;
 
 /**
  * 
@@ -29,6 +34,7 @@
 @SuppressWarnings("restriction")
 public class BaseAsYouTypeValidationTest extends AbstractAsYouTypeValidationTest {
 	public static final String MARKER_TYPE = "org.jboss.tools.common.validation.asyoutype"; //$NON-NLS-1$
+	public static final String RESOURCE_MARKER_TYPE = "org.jboss.tools.jst.web.kb.elproblem"; //$NON-NLS-1$
 
 	public BaseAsYouTypeValidationTest(IProject project) {
 		this.project = project;
@@ -70,7 +76,7 @@
 
 		TemporaryAnnotation temporaryAnnotation = (TemporaryAnnotation) annotation;
 
-		if (temporaryAnnotation.getAttributes() == null && temporaryAnnotation.getAttributes().isEmpty())
+		if (temporaryAnnotation.getAttributes() == null || temporaryAnnotation.getAttributes().isEmpty())
 			return false;
 		
 		Object value = temporaryAnnotation.getAttributes().get(MARKER_TYPE);
@@ -80,4 +86,40 @@
 
 		return true;
 	}
+	
+	@Override
+	protected boolean isMarkerAnnotationAcceptable(Annotation annotation) {
+		if (!(annotation instanceof MarkerAnnotation))
+			return false;
+
+		MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
+
+		IMarker marker = markerAnnotation.getMarker();
+		String type;
+		try {
+			type = marker.getType();
+			return RESOURCE_MARKER_TYPE.equals(type);
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+	
+	@Override
+	protected void assertResourceMarkerIsCreated(IFile file, String errorMessage, int line) throws CoreException {
+		IMarker[] markers = AbstractResourceMarkerTest.findMarkers(
+				file, RESOURCE_MARKER_TYPE, errorMessage, true);
+
+		assertNotNull("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line, markers);
+		assertFalse("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line, markers.length == 0);
+
+		for (IMarker m : markers) {
+			Integer l = m.getAttribute(IMarker.LINE_NUMBER, -1);
+			if (l != null && line == l.intValue()) {
+				return;
+			}
+		}
+	
+		fail("Resource Marker not found for type: " + RESOURCE_MARKER_TYPE + ", message: [" + errorMessage + "] at line: " + line);
+	}
 }



More information about the jbosstools-commits mailing list