Author: akazakov
Date: 2008-04-07 17:17:35 -0400 (Mon, 07 Apr 2008)
New Revision: 7395
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
Log:
Fixed tests
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2008-04-07
20:47:06 UTC (rev 7394)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2008-04-07
21:17:35 UTC (rev 7395)
@@ -14,6 +14,10 @@
import junit.framework.Test;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
/**
@@ -57,6 +61,15 @@
return projects;
}
+ public static IProject loadProject(String projectName) throws CoreException {
+ IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(projectName);
+ assertNotNull("Can't load " + projectName, project);
+ IProject result = project.getProject();
+ result.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ EditorTestHelper.joinBackgroundActivities();
+ return result;
+ }
+
@Override
protected void setUp() throws Exception {
importProjects();
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2008-04-07
20:47:06 UTC (rev 7394)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2008-04-07
21:17:35 UTC (rev 7395)
@@ -12,10 +12,10 @@
import junit.framework.TestCase;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.test.util.JUnitUtils;
/**
* @author eskimo
@@ -36,12 +36,12 @@
super(name);
}
- protected int findMarkerfLine(IFile file, String type, String pattern)
+ protected int findMarkerfLine(IResource resource, String type, String pattern)
throws CoreException {
int number = -1;
IMarker[] markers = new IMarker[0];
- markers = file.findMarkers(type, false, IResource.DEPTH_INFINITE);
+ markers = resource.findMarkers(type, false, IResource.DEPTH_INFINITE);
for (int i = 0; i < markers.length; i++) {
String message = markers[i].getAttribute(IMarker.MESSAGE, "");
@@ -53,29 +53,74 @@
return number;
}
- protected void assertMarkerIsCreated(IFile file, MarkerData markerData) throws
CoreException {
- assertMarkerIsCreated(file, markerData.type, markerData.pattern, markerData.line);
+ protected void assertMarkerIsCreated(IResource resource, MarkerData markerData) throws
CoreException {
+ assertMarkerIsCreated(resource, markerData.type, markerData.pattern, markerData.line);
}
- protected void assertMarkerIsCreated(IFile file, String type, String pattern, int
expectedLine)
+ protected void assertMarkerIsCreated(IResource resource, String type, String pattern,
int expectedLine)
throws CoreException {
-
+
int line = findMarkerfLine(
- file, type, pattern);
-
+ resource, type, pattern);
+
assertTrue("Marker matches the '" + pattern + "' pattern
wasn't found",
line != -1);
-
+
assertEquals("Marker matches the '" + pattern + "' pattern was
found at wrong line",
expectedLine,line);
}
- protected void assertMarkersIsCreated(IFile file, MarkerData[] markersData) throws
CoreException {
+ protected void assertMarkersIsCreated(IResource resource, MarkerData[] markersData)
throws CoreException {
for (MarkerData markerData : markersData) {
- assertMarkerIsCreated(file, markerData);
+ assertMarkerIsCreated(resource, markerData);
}
}
+ public static int getMarkersNumber(IResource resource){
+ try{
+ IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ for(int i=0;i<markers.length;i++){
+ System.out.println("Marker - "+markers[i].getAttribute(IMarker.MESSAGE,
""));
+ }
+ return markers.length;
+ }catch(CoreException ex){
+ JUnitUtils.fail("Can'r get problem markers", ex);
+ }
+ return -1;
+ }
+
+ public static String[] getMarkersMessage(IResource resource){
+ String[] messages = null;
+ try{
+ IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ messages = new String[markers.length];
+
+ for(int i=0;i<markers.length;i++){
+ System.out.println("Marker - "+markers[i].getAttribute(IMarker.MESSAGE,
""));
+ messages[i] = markers[i].getAttribute(IMarker.MESSAGE, "");
+ }
+ }catch(CoreException ex){
+ JUnitUtils.fail("Can't get problem markers", ex);
+ }
+ return messages;
+ }
+
+ public static int[] getMarkersNumbersOfLine(IResource resource){
+ int[] numbers = null;
+ try{
+ IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ numbers = new int[markers.length];
+
+ for(int i=0;i<markers.length;i++){
+ System.out.println("Marker line number -
"+markers[i].getAttribute(IMarker.LINE_NUMBER, 0));
+ numbers[i] = markers[i].getAttribute(IMarker.LINE_NUMBER, 0);
+ }
+ }catch(CoreException ex){
+ JUnitUtils.fail("Can't get problem markers.", ex);
+ }
+ return numbers;
+ }
+
/**
*
* @author eskimo