Author: xcoulon
Date: 2011-06-09 17:00:58 -0400 (Thu, 09 Jun 2011)
New Revision: 31986
Added:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services.gif
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services_error.gif
Removed:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/customization.png
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/wsdl_file_obj.gif
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/Resource.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethodMapping.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/RouteEndpoint.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/utils/ResourceMethodAnnotatedParameter.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsLabelProvider.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateCategory.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateElement.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/SyncFileSystemStructureProvider.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceChangesTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceMethodChangesTestCase.java
Log:
Fixing minor bugs related to UI error reporting and Metamodel updates, increasing test
setup speed by skipping .svn folders.
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/Resource.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/Resource.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/Resource.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -186,7 +186,6 @@
String key = keys.get(javaMethod);
if (resourceMethods.containsKey(key)) {
ResourceMethod resourceMethod = resourceMethods.get(key);
-
Set<EnumElementChange> resourceMethodChanges =
resourceMethod.merge(javaMethod, progressMonitor);
Set<EnumElementChange> changes = new HashSet<EnumElementChange>();
changes.addAll(resourceChanges);
@@ -215,8 +214,12 @@
Logger.debug("Added " + resourceMethod.toString());
}
} catch (InvalidModelElementException e) {
- Logger.warn("ResourceMethod '" + javaMethod.getElementName()
+ Logger.warn("ResourceMethod bound to '" + javaMethod.getElementName()
+ "' is not a valid JAX-RS ResourceMethod: " + e.getMessage());
+ if (resourceMethods.containsKey(javaMethod)) {
+ resourceMethods.remove(javaMethod);
+ }
+
}
}
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethod.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethod.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethod.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -120,7 +120,22 @@
getMapping().validate();
}
+ /**
+ * Sets a flag of whether the underlying java method has compilation errors
+ * or not. If true, also marke the parent resource with errors flag.
+ *
+ * @param h
+ * : true if the java element has errors, false otherwise
+ */
@Override
+ public void hasErrors(final boolean h) {
+ super.hasErrors(h);
+ if (hasErrors()) {
+ parentResource.hasErrors(true);
+ }
+ }
+
+ @Override
public final BaseElement.EnumKind getKind() {
return kind;
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethodMapping.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethodMapping.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/ResourceMethodMapping.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -186,6 +186,7 @@
marker.setAttribute(IMarker.LINE_NUMBER, pathParam.getLineNumber());
marker.setAttribute(IMarker.CHAR_START, pathParam.getCharStart());
marker.setAttribute(IMarker.CHAR_END, pathParam.getCharEnd());
+ this.resourceMethod.hasErrors(true);
}
}
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/RouteEndpoint.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/RouteEndpoint.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/RouteEndpoint.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -5,6 +5,7 @@
import java.util.LinkedList;
import java.util.List;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.utils.ResourceMethodAnnotatedParameter;
public class RouteEndpoint implements Comparable<RouteEndpoint> {
@@ -88,7 +89,9 @@
return h;
}
}
- throw new InvalidModelElementException("No HttpMethod annotation found for this
endpoint: " + resourceMethods);
+ Logger.debug("No HttpMethod annotation found for this endpoint: " +
resourceMethods);
+ return null;
+
}
private static String computeUriPathTemplate(LinkedList<ResourceMethod>
resourceMethods) {
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/utils/ResourceMethodAnnotatedParameter.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/utils/ResourceMethodAnnotatedParameter.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/utils/ResourceMethodAnnotatedParameter.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -18,20 +18,20 @@
public class ResourceMethodAnnotatedParameter implements Validable,
Comparable<ResourceMethodAnnotatedParameter> {
private final String parameterType;
-
+
private final String annotationType;
private final String annotationValue;
-
+
private final int charStart;
-
+
private final int charEnd;
-
+
private final int lineNumber;
-
/**
* Full constructor
+ *
* @param parent
* @param parameterName
* @param parameterType
@@ -41,8 +41,8 @@
* @param charEnd
* @param lineNumber
*/
- public ResourceMethodAnnotatedParameter(String parameterType,
- String annotationType, String annotationValue, int charStart, int charEnd, int
lineNumber) {
+ public ResourceMethodAnnotatedParameter(String parameterType, String annotationType,
String annotationValue,
+ int charStart, int charEnd, int lineNumber) {
super();
this.parameterType = parameterType;
this.annotationType = annotationType;
@@ -100,14 +100,25 @@
}
/**
- * Compares method parameters by their textual location
- * {@inheritDoc}
+ * Compares method parameters by their textual location {@inheritDoc}
+ *
* @param otherParam
* @return
*/
@Override
public int compareTo(ResourceMethodAnnotatedParameter otherParam) {
- return getCharStart() - otherParam.getCharStart();
+ return getCharStart() - otherParam.getCharStart();
}
-
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "ResourceMethodAnnotatedParameter [parameterType=" + parameterType +
", annotationType="
+ + annotationType + ", annotationValue=" + annotationValue + "]";
+ }
+
}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/customization.png
===================================================================
(Binary files differ)
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services_error.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/restful_web_services_error.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/icons/wsdl_file_obj.gif
===================================================================
(Binary files differ)
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsLabelProvider.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsLabelProvider.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsLabelProvider.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -37,7 +37,10 @@
@Override
public Image getImage(Object element) {
if (element instanceof UriPathTemplateCategory) {
- return JBossJaxrsUIPlugin.getDefault().createImage("wsdl_file_obj.gif");
+ if (((UriPathTemplateCategory) element).hasErrors()) {
+ return
JBossJaxrsUIPlugin.getDefault().createImage("restful_web_services_error.gif");
+ }
+ return
JBossJaxrsUIPlugin.getDefault().createImage("restful_web_services.gif");
} else if (element instanceof UriPathTemplateElement) {
if (((UriPathTemplateElement) element).hasErrors()) {
return
JBossJaxrsUIPlugin.getDefault().createImage("url_mapping_error.gif");
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateCategory.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateCategory.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateCategory.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -91,6 +91,17 @@
Logger.debug("Input changed in UriPathTemplateCategory");
}
+ public boolean hasErrors() {
+ for (Route route : metamodel.getRoutes().getAll()) {
+ for (ResourceMethod resourceMethod : route.getResourceMethods()) {
+ if (resourceMethod.hasErrors()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
@Override
public void dispose() {
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateElement.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateElement.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriPathTemplateElement.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -69,7 +69,12 @@
}
public boolean hasErrors() {
- return getLastMethod().hasErrors();
+ for (ResourceMethod resourceMethod : route.getResourceMethods()) {
+ if (resourceMethod.hasErrors()) {
+ return true;
+ }
+ }
+ return false;
}
/**
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -27,6 +27,10 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.MethodRule;
+import org.junit.rules.TestWatchman;
+import org.junit.runners.model.FrameworkMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,6 +65,24 @@
private ProjectSynchronizator synchronizor;
+ @Rule
+ public MethodRule watchman = new TestWatchman() {
+ @Override
+ public void starting(FrameworkMethod method) {
+ LOGGER.info("**********************************************************************************");
+ LOGGER.info("Starting test '{}'...", method.getName());
+ LOGGER.info("**********************************************************************************");
+ }
+
+ @Override
+ public void finished(FrameworkMethod method) {
+ LOGGER.info("**********************************************************************************");
+ LOGGER.info("Test '{}' finished.", method.getName());
+ LOGGER.info("**********************************************************************************");
+ }
+
+ };
+
@BeforeClass
public static void setupWorkspace() throws Exception {
long startTime = new Date().getTime();
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/SyncFileSystemStructureProvider.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/SyncFileSystemStructureProvider.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/SyncFileSystemStructureProvider.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -35,17 +35,15 @@
*
*/
@SuppressWarnings("restriction")
-public class SyncFileSystemStructureProvider implements
- IImportStructureProvider {
+public class SyncFileSystemStructureProvider implements IImportStructureProvider {
- private static final Logger LOGGER = LoggerFactory
- .getLogger(SyncFileSystemStructureProvider.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(SyncFileSystemStructureProvider.class);
private final IPath source;
private final IPath destination;
- private final List<IPath> ignoredRelativePaths = new ArrayList<IPath>();
+ private final List<String> ignoredRelativePaths = new ArrayList<String>();
/**
* Creates an instance of <code>SyncFileSystemStructureProvider</code>.
@@ -61,6 +59,7 @@
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
+ @Override
public List<File> getChildren(Object element) {
File folder = (File) element;
String[] children = folder.list();
@@ -69,28 +68,22 @@
for (int i = 0; i < childrenLength; i++) {
File sourceFile = new File(folder, children[i]);
- IPath relativeSourcePath = new Path(sourceFile.getAbsolutePath())
- .makeRelativeTo(source);
+ IPath relativeSourcePath = new
Path(sourceFile.getAbsolutePath()).makeRelativeTo(source);
// always add the sub directories
- if (ignoredRelativePaths.contains(relativeSourcePath)) {
+ if (ignoredRelativePaths.contains(relativeSourcePath.lastSegment())) {
continue;
}
- if (sourceFile.isDirectory()) {
+ if (sourceFile.isDirectory() &&
!ignoredRelativePaths.contains(relativeSourcePath.lastSegment())) {
result.addAll(getChildren(sourceFile));
}
// only add the other files if they are missing or were modified in
// the destination destination
else {
- IPath relativeDestinationPath = destination
- .append(relativeSourcePath);
- File destinationFile = new File(
- relativeDestinationPath.toOSString());
- if (!destinationFile.exists()
- || destinationFile.lastModified() > sourceFile
- .lastModified()) {
- LOGGER.debug("Adding '" + relativeSourcePath
- + "' to sync operation.");
+ IPath relativeDestinationPath = destination.append(relativeSourcePath);
+ File destinationFile = new File(relativeDestinationPath.toOSString());
+ if (!destinationFile.exists() || destinationFile.lastModified() >
sourceFile.lastModified()) {
+ LOGGER.debug("Adding '" + relativeSourcePath + "' to sync
operation.");
result.add(sourceFile);
}
}
@@ -102,6 +95,7 @@
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
+ @Override
public InputStream getContents(Object element) {
try {
return new FileInputStream((File) element);
@@ -114,6 +108,7 @@
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
+ @Override
public String getFullPath(Object element) {
return ((File) element).getPath();
}
@@ -121,6 +116,7 @@
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
+ @Override
public String getLabel(Object element) {
// Get the name - if it is empty then return the path as it is a file
@@ -136,11 +132,12 @@
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
+ @Override
public boolean isFolder(Object element) {
return ((File) element).isDirectory();
}
- public void ignoreRelativeSourcePath(IPath relativePath) {
+ public void ignoreRelativeSourcePath(String relativePath) {
this.ignoredRelativePaths.add(relativePath);
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -88,9 +88,9 @@
LOGGER.info("Target workspace location: " +
targetWorkspace.getRoot().getRawLocation());
SyncFileSystemStructureProvider syncFileSystemStructureProvider = new
SyncFileSystemStructureProvider(
projectSourcePath, project.getLocation());
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new Path(".svn"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new
Path("target"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new Path("bin"));
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath(".svn");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath("target");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath("bin");
List<File> filesToImport =
syncFileSystemStructureProvider.getChildren(projectSourcePath.toFile());
if (filesToImport != null && filesToImport.size() > 0) {
ImportOperation operation = new ImportOperation(project.getFullPath(),
projectSourcePath.toFile(),
@@ -109,11 +109,12 @@
LOGGER.info("Removing added files from the target workspace");
// reverse detection operation
syncFileSystemStructureProvider = new
SyncFileSystemStructureProvider(project.getLocation(), projectSourcePath);
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new
Path("target"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new Path("bin"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new
Path(".project"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new
Path(".classpath"));
- syncFileSystemStructureProvider.ignoreRelativeSourcePath(new
Path(".settings"));
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath("target");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath("bin");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath(".svn");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath(".project");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath(".classpath");
+ syncFileSystemStructureProvider.ignoreRelativeSourcePath(".settings");
List<File> filesToRemove =
syncFileSystemStructureProvider.getChildren(project.getLocation().toFile());
for (File fileToRemove : filesToRemove) {
Assert.assertTrue("File not deleted : " + fileToRemove,
fileToRemove.delete());
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceChangesTestCase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceChangesTestCase.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceChangesTestCase.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -21,8 +21,10 @@
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
import org.jboss.tools.ws.jaxrs.core.builder.AbstractMetamodelBuilderTestCase;
import org.jboss.tools.ws.jaxrs.core.metamodel.BaseElement.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.HTTPMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.MediaTypeCapabilities;
import org.jboss.tools.ws.jaxrs.core.metamodel.Resource;
+import org.jboss.tools.ws.jaxrs.core.metamodel.ResourceMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.Resources;
import org.junit.Assert;
import org.junit.Test;
@@ -291,9 +293,31 @@
Assert.assertTrue("Resource not marked with errors",
fooResource.hasErrors());
// operation 2
WorkbenchUtils.addImport(fooResource.getJavaElement().getCompilationUnit(),
Path.class.getName());
- // post-conditions 2: errors reported (import is missing)
+ // post-conditions 2: no error reported (import was restored)
Assert.assertEquals(6, metamodel.getHttpMethods().size());
Assert.assertFalse("Resource still marked with errors",
fooResource.hasErrors());
Assert.assertEquals("Wrong number of routes", 12,
metamodel.getRoutes().getAll().size());
}
+
+ @Test
+ public void shouldReportErrorsWhenChangingPathParam() throws JavaModelException {
+ // pre-condition
+ Resource customersResource =
metamodel.getResources().getByPath("/customers");
+ Assert.assertNotNull("CustomersResource not found", customersResource);
+ Assert.assertFalse("No error expected", customersResource.hasErrors());
+ HTTPMethod httpMethod = metamodel.getHttpMethods().getByVerb("GET");
+ ResourceMethod resourceMethod = customersResource.getByMapping(httpMethod,
"{id}", null, null);
+ Assert.assertNotNull("ResourceMethod not found", resourceMethod);
+ // operation 1
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(resourceMethod.getJavaElement(),
"{id}", "{i}");
+ // post-conditions 1: error(s) reported
+ Assert.assertTrue("Resource not marked with errors",
resourceMethod.hasErrors());
+ Assert.assertTrue("Resource not marked with errors",
customersResource.hasErrors());
+ // operation 2
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(resourceMethod.getJavaElement(),
"{i}", "{id}");
+ // post-conditions 2: no error reported (PathParam value was fixed)
+ Assert.assertFalse("Resource still marked with errors",
resourceMethod.hasErrors());
+ Assert.assertFalse("Resource still marked with errors",
customersResource.hasErrors());
+
+ }
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceMethodChangesTestCase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceMethodChangesTestCase.java 2011-06-09
20:54:19 UTC (rev 31985)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/builder/ResourceMethodChangesTestCase.java 2011-06-09
21:00:58 UTC (rev 31986)
@@ -29,7 +29,6 @@
import org.jboss.tools.ws.jaxrs.core.metamodel.Resources;
import org.jboss.tools.ws.jaxrs.core.metamodel.Route;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -247,7 +246,6 @@
}
@Test
- @Ignore
public void shouldBecomeSubresourceLocatorWhenRemovingHTTPMethodAnnotation() throws
CoreException {
// pre-conditions
Resource resource = metamodel.getResources().getByTypeName(