JBoss Tools SVN: r44340 - in trunk/download.jboss.org/jbosstools/updates/requirements: android and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-10-05 12:42:16 -0400 (Fri, 05 Oct 2012)
New Revision: 44340
Added:
trunk/download.jboss.org/jbosstools/updates/requirements/android/
trunk/download.jboss.org/jbosstools/updates/requirements/android/build.xml
Log:
new android dev tools 20.0.3 mirror
Added: trunk/download.jboss.org/jbosstools/updates/requirements/android/build.xml
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/android/build.xml (rev 0)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/android/build.xml 2012-10-05 16:42:16 UTC (rev 44340)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="mirror">
+ <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
+
+ -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
+ -consoleLog -nosplash -data /tmp
+ -application org.eclipse.ant.core.antRunner
+ -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/android/build.xml"
+
+ or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
+
+ export JAVA_HOME=/opt/jdk1.6.0; \
+ ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
+ org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
+ -application org.eclipse.ant.core.antRunner \
+ -f ~/RHDS/updates/requirements/android/build.xml -Ddestination=/tmp/android-repo
+ -->
+ <target name="mirror">
+ <!-- released under ASL/BSD/EPL, so we can mirror and redistribute -->
+ <property name="URL" value="https://dl-ssl.google.com/android/eclipse/" />
+ <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/android/20.0.3.v201208082019-427395/" />
+ <property name="compress" value="true" />
+
+ <p2.mirror>
+ <repository location="file:${destination}/20.0.3.v201208082019-427395/" name="Android Development Tools for Eclipse" />
+ <source>
+ <repository location="${URL}" />
+ </source>
+
+ <slicingOptions includeFeatures="true" followStrict="true" />
+
+ <!-- DO NOT INCLUDE the Android Native Development Tools (NDK) feature (com.android.ide.eclipse.ndk.feature.group), which requires CDT -->
+ <iu id="com.android.ide.eclipse.ddms.feature.group" />
+ <iu id="com.android.ide.eclipse.adt.feature.group" />
+ <iu id="com.android.ide.eclipse.hierarchyviewer.feature.group" />
+ <iu id="com.android.ide.eclipse.traceview.feature.group" />
+ <iu id="com.android.ide.eclipse.gldebugger.feature.group" />
+
+ </p2.mirror>
+
+ <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20.0.3.v201208082019-427395/" artifactRepository="file:${destination}/20.0.3.v201208082019-427395/" publishartifacts="true" source="${destination}/20.0.3.v201208082019-427395/" compress="${compress}" />
+ </target>
+</project>
12 years, 3 months
JBoss Tools SVN: r44338 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2012-10-05 11:03:19 -0400 (Fri, 05 Oct 2012)
New Revision: 44338
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
JBIDE-12534
Some key combinations don't work in JBT XHTML Editor
Issue is fixed
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2012-10-05 13:17:03 UTC (rev 44337)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2012-10-05 15:03:19 UTC (rev 44338)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.jsp.jspeditor;
@@ -71,6 +71,7 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -168,6 +169,8 @@
public class JSPTextEditor extends StructuredTextEditor implements
ITextListener, IJSPTextEditor, ITextFormatter,
IOccurrencePreferenceProvider {
+ private static final String TEXT_EDITOR_KEYBINDING_SCOPE_ID = "org.eclipse.ui.textEditorScope"; //$NON-NLS-1$
+
private IStructuredTextOccurrenceStructureProvider fOccurrenceModelUpdater;
TextEditorDrop dnd = new TextEditorDrop();
@@ -348,6 +351,10 @@
public void createPartControl(Composite parent) {
super.createPartControl(parent);
+ IContextService contextService = (IContextService) getSite().getService(IContextService.class);
+ if (contextService != null)
+ contextService.activateContext(TEXT_EDITOR_KEYBINDING_SCOPE_ID);
+
StructuredTextOccurrenceStructureProviderRegistry registry = XmlEditorPlugin
.getDefault().getOccurrenceStructureProviderRegistry(
JspEditorPlugin.PLUGIN_ID);
12 years, 3 months
JBoss Tools SVN: r44337 - in trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test: editor/tags and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2012-10-05 09:17:03 -0400 (Fri, 05 Oct 2012)
New Revision: 44337
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AbstractTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AjaxInvisibleTagsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/ArticleTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AsideTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AudioTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CanvasTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CommandTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/DetailsTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/SummaryTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckFileChangesSaving.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/JSPPageCreationTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/XHTMLPageCreationTest.java
Log:
Fixes for JBT 4.0.0.Alpha2
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -42,7 +42,6 @@
//Test check VPE content without resource bundles
selectELExpressions();
- new SWTBotWebBrowser(TEST_PAGE, new SWTBotExt()).displayWebBrowserDOM();
assertVisualEditorNotContainNodeWithValue(webBrowser,
"#{Message.prompt_message}",
TEST_PAGE);
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AbstractTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AbstractTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AbstractTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -13,9 +13,12 @@
import java.security.InvalidParameterException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
/**
@@ -81,6 +84,7 @@
@Override
public void tearDown() throws Exception {
sourceEditor.close();
+ deleteTestPage();
super.tearDown();
}
/**
@@ -144,5 +148,31 @@
return fileName;
}
-
+ public void deleteTestPage(){
+ if (testPageType.equals(TestPageType.HTML)){
+ eclipse.deleteFile(VPEAutoTestCase.JBT_TEST_PROJECT_NAME, "WebContent","pages",getTestPageFileName());
+ }else if (testPageType.equals(TestPageType.JSP)){
+ eclipse.deleteFile(VPEAutoTestCase.JBT_TEST_PROJECT_NAME, "WebContent","pages",getTestPageFileName());
+ } else if (testPageType.equals(TestPageType.XHTML)){
+ eclipse.deleteFile(VPEAutoTestCase.JBT_TEST_PROJECT_NAME, "WebContent","pages",getTestPageFileName());
+ }
+ }
+ /**
+ * Asserts if Problems View has no errors for test page
+ * @param botExt
+ */
+ protected void assertProbelmsViewNoErrorsForPage (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems
+ (botExt,
+ null,
+ null,
+ getTestPageFileName(),
+ null);
+
+ boolean areThereNoErrors = ((errors == null) || (errors.length == 0));
+ assertTrue("There are errors in Problems view for test page: " +
+ (areThereNoErrors ? "" : errors[0].getText()),
+ areThereNoErrors);
+ }
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AjaxInvisibleTagsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AjaxInvisibleTagsTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AjaxInvisibleTagsTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -51,7 +51,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// check values which should not be displayed in Visual Editor
assertVisualEditorNotContainNodeWithValue(getVisualEditor(),
AjaxInvisibleTagsTest.JS_FUNCTION_VALUE,
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/ArticleTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/ArticleTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/ArticleTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -38,7 +38,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains ARTICLE tag
assertVisualEditorContains(getVisualEditor(), "ARTICLE", null, null, getTestPageFileName());
// visual representation contains ARTICLE_TEXT text
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AsideTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AsideTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AsideTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -38,7 +38,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains ASIDE tag
assertVisualEditorContains(getVisualEditor(), "ASIDE", null, null, getTestPageFileName());
// visual representation contains ASIDE_TEXT text
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AudioTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AudioTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/AudioTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -36,7 +36,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains AUDIO tag
assertVisualEditorContains(getVisualEditor(), "AUDIO", null, null, getTestPageFileName());
// test tag selection
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CanvasTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CanvasTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CanvasTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -36,7 +36,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains CANVAS tag
assertVisualEditorContains(getVisualEditor(), "CANVAS", null, null, getTestPageFileName());
// test tag selection
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CommandTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CommandTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/CommandTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -37,7 +37,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains COMMAND tag
assertVisualEditorContains(getVisualEditor(), "COMMAND", null, null, getTestPageFileName());
// visual representation contains COMMAND_TEXT text
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/DetailsTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/DetailsTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/DetailsTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -36,7 +36,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains DETAILS tag
assertVisualEditorContains(getVisualEditor(), "DETAILS", null, null, getTestPageFileName());
// visual representation contains DETAILS_TEXT text
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/SummaryTagTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/SummaryTagTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/tags/SummaryTagTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -36,7 +36,7 @@
@Override
protected void verifyTag() {
// check Problems View for Errors
- assertProbelmsViewNoErrors(botExt);
+ assertProbelmsViewNoErrorsForPage(botExt);
// visual representation contains SUMMARY tag
assertVisualEditorContains(getVisualEditor(), "SUMMARY", null, null, getTestPageFileName());
// visual representation contains SUMMARY_TEXT text
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckFileChangesSaving.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckFileChangesSaving.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckFileChangesSaving.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -40,7 +40,7 @@
// Test Saving
editor.insertText(changeText);
bot.sleep(sleepTime);
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.CLOSE).click();
+ bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.CLOSE_ALL).click();
bot.sleep(sleepTime);
bot.shell(IDELabel.Shell.SAVE_RESOURCE).activate();
bot.button(saveFile ? IDELabel.Button.YES : IDELabel.Button.NO).click();
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/JSPPageCreationTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/JSPPageCreationTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/JSPPageCreationTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -40,6 +40,7 @@
* Test JSP page Creation and Saving
*/
private void checkJSPPageCreation(){
+ bot.closeAllEditors();
openWebProjects();
@@ -68,7 +69,6 @@
bot.sleep(Timing.time2S());
webContentTreeItem.expand();
SWTBotTreeItem jspTestPageTreeItem = webContentTreeItem.getNode(TEST_NEW_JSP_FILE_NAME);
-
String checkResult = CheckFileChangesSaving.checkIt(bot, bot.editorByTitle(TEST_NEW_JSP_FILE_NAME).toTextEditor(),
tree, jspTestPageTreeItem,
SAVE_COMMENT, true);
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/XHTMLPageCreationTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/XHTMLPageCreationTest.java 2012-10-05 13:16:32 UTC (rev 44336)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/XHTMLPageCreationTest.java 2012-10-05 13:17:03 UTC (rev 44337)
@@ -41,7 +41,7 @@
* Test XHTML page Creation and Saving
*/
private void checkXHTMLPageCreation(){
-
+ bot.closeAllEditors();
openWebProjects();
delay();
12 years, 3 months
JBoss Tools SVN: r44336 - in trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests: editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-10-05 09:16:32 -0400 (Fri, 05 Oct 2012)
New Revision: 44336
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/NewProjectUsingBundledInSOA.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/editor/ESBActionFactory.java
Log:
Corrected reference to combo box in editor/ESBActionFactory.java
Removed unnecessary debug statements in NewProjectUsingBundledInSOA.java
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/NewProjectUsingBundledInSOA.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/NewProjectUsingBundledInSOA.java 2012-10-05 09:44:49 UTC (rev 44335)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/NewProjectUsingBundledInSOA.java 2012-10-05 13:16:32 UTC (rev 44336)
@@ -38,7 +38,7 @@
assertTrue(wiz.radio(0).isSelected());
wiz.sleep(3000l);
- org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(wiz);
+// org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(wiz);
wiz.button("Finish").click();
wiz.sleep(3000l);
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/editor/ESBActionFactory.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/editor/ESBActionFactory.java 2012-10-05 09:44:49 UTC (rev 44335)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/editor/ESBActionFactory.java 2012-10-05 13:16:32 UTC (rev 44336)
@@ -81,10 +81,10 @@
@Override
protected void doEditing(SWTBotEditor editor, String... path) {
SWTBotSection section = bot.section(editor.bot(),getSectionTitle());
- org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(bot);
+ //org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(bot);
editTextProperty(editor, section.bot(), "Process Definition Name:", "process-definition-name", "edited process definition name");
editTextProperty(editor, section.bot(), "Process ID:", "process-id", "edited processID");
- editProcess(editor,true);
+ editProcess(editor,false);
}
@Override
protected void doFillForm(SWTBotShell shell) {
@@ -431,10 +431,9 @@
Assertions.assertButtonEnabled(shell.bot().button(getFinishButton()), false);
shell.bot().text(0).setText(this.uiName);
- System.out.println ("DEBUG - this.uiName " + this.uiName);
+ //System.out.println ("DEBUG - this.uiName " + this.uiName);
+ //org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(shell.bot());
- org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(shell.bot());
-
/* ldimaggi - Nov 4 2011 - need this to avoid an error where an array
* out of bounds is hit - as the Sync Service Invoker has combo boxes, not text fields */
if (this.uiName.equals("Sync Service Invoker")) {
12 years, 3 months
JBoss Tools SVN: r44335 - in trunk/build/tycho-plugins: target-platform-utils and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: mickael_istria
Date: 2012-10-05 05:44:49 -0400 (Fri, 05 Oct 2012)
New Revision: 44335
Added:
trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/MergeTargetsMojo.java
trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java
trunk/build/tycho-plugins/target-platform-utils/src/test/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/org/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/org/jboss/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/org/jboss/tools/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/org/jboss/tools/tycho/
trunk/build/tycho-plugins/target-platform-utils/src/test/java/org/jboss/tools/tycho/targets/
Modified:
trunk/build/tycho-plugins/pom.xml
trunk/build/tycho-plugins/target-platform-utils/pom.xml
trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FlattenTargetMojo.java
Log:
New Cool mojos for target-platform manipulation:
* merge target files
* mirror target file as p2 repo (buggy)
Modified: trunk/build/tycho-plugins/pom.xml
===================================================================
--- trunk/build/tycho-plugins/pom.xml 2012-10-05 09:10:07 UTC (rev 44334)
+++ trunk/build/tycho-plugins/pom.xml 2012-10-05 09:44:49 UTC (rev 44335)
@@ -26,12 +26,26 @@
<compilerVersion>1.5</compilerVersion>
<target>1.5</target>
<source>1.5</source>
- </configuration>
+ </configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
+ <repositories>
+ <repository>
+ <id>tycho-snapshots</id>
+ <url>https://oss.sonatype.org/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
<!-- To deploy to Nexus -->
<!-- Don't change "id" since it should match credentials entry in $M2_REPO/settings.xml -->
<distributionManagement>
Modified: trunk/build/tycho-plugins/target-platform-utils/pom.xml
===================================================================
--- trunk/build/tycho-plugins/target-platform-utils/pom.xml 2012-10-05 09:10:07 UTC (rev 44334)
+++ trunk/build/tycho-plugins/target-platform-utils/pom.xml 2012-10-05 09:44:49 UTC (rev 44335)
@@ -6,6 +6,7 @@
<groupId>org.jboss.tools</groupId>
<artifactId>tycho-plugins</artifactId>
<version>0.0.1-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
<groupId>org.jboss.tools.tycho-plugins</groupId>
<artifactId>target-platform-utils</artifactId>
@@ -32,13 +33,24 @@
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-facade</artifactId>
- <version>0.15.0</version>
+ <version>0.16.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-publisher-plugin</artifactId>
+ <version>0.16.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.7</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FlattenTargetMojo.java
===================================================================
--- trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FlattenTargetMojo.java 2012-10-05 09:10:07 UTC (rev 44334)
+++ trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FlattenTargetMojo.java 2012-10-05 09:44:49 UTC (rev 44335)
@@ -95,7 +95,7 @@
if (!this.sourceTargetArtifact.isCorrectlySet()) {
throw new MojoExecutionException("'sourceTargetArtifact' must define groupId, artifactId and version");
}
- getLog().info("Downloading " + sourceTargetArtifact.toString());
+ getLog().debug("Downloading " + sourceTargetArtifact.toString());
Artifact artifact = this.repositorySystem.createArtifactWithClassifier(this.sourceTargetArtifact.getGroupId(), this.sourceTargetArtifact.getArtifactId(), this.sourceTargetArtifact.getVersion(), "target",
this.sourceTargetArtifact.getArtifactId());
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
Added: trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/MergeTargetsMojo.java
===================================================================
--- trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/MergeTargetsMojo.java (rev 0)
+++ trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/MergeTargetsMojo.java 2012-10-05 09:44:49 UTC (rev 44335)
@@ -0,0 +1,129 @@
+package org.jboss.tools.tycho.targets;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.RepositorySystem;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Creates a single platform which merges locations from all platforms
+ *
+ * @author mistria
+ * @goal merge-targets
+ */
+public class MergeTargetsMojo extends AbstractMojo {
+
+
+ /**
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ private MavenProject project;
+ /**
+ * @parameter expression="${session}"
+ * @readonly
+ */
+ private MavenSession session;
+
+ /**
+ * @component
+ */
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ /**
+ * Location of the output file.
+ * @parameter expression="${project.build.directory}/${project.artifactId}.target"
+ * @required
+ */
+ private File outputFile;
+
+ /**
+ * Target to transform (as a file)
+ * @parameter
+ */
+ private List<File> sourceTargetFiles;
+
+ /**
+ * @parameter
+ */
+ private List<TargetArtifact> sourceTargetArtifacts;
+
+ public void execute() throws MojoExecutionException {
+ if (this.sourceTargetFiles == null) {
+ this.sourceTargetFiles = new ArrayList<File>();
+ }
+ if (!this.outputFile.getParentFile().isDirectory()) {
+ this.outputFile.getParentFile().mkdirs();
+ }
+
+ if (this.sourceTargetArtifacts != null) {
+ for (TargetArtifact sourceTargetArtifact : sourceTargetArtifacts) {
+ if (!sourceTargetArtifact.isCorrectlySet()) {
+ throw new MojoExecutionException("'sourceTargetArtifact' must define groupId, artifactId and version");
+ }
+ getLog().debug("Downloading " + sourceTargetArtifact.toString());
+ Artifact artifact = this.repositorySystem.createArtifactWithClassifier(sourceTargetArtifact.getGroupId(), sourceTargetArtifact.getArtifactId(), sourceTargetArtifact.getVersion(), "target",
+ sourceTargetArtifact.getArtifactId());
+ ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+ request.setArtifact(artifact);
+ request.setLocalRepository(this.session.getLocalRepository());
+ request.setRemoteRepositories(this.project.getRemoteArtifactRepositories());
+ this.repositorySystem.resolve(request);
+
+ if (!artifact.isResolved()) {
+ throw new RuntimeException("Could not resolve target platform specification artifact " + artifact);
+ }
+
+ this.sourceTargetFiles.add(artifact.getFile());
+ }
+ }
+
+ if (this.sourceTargetFiles.size() <= 1) {
+ throw new MojoExecutionException("Please provide at least 2 files to merge");
+ }
+
+ try {
+ DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document targetDoc = docBuilder.parse(this.sourceTargetFiles.get(0));
+ Element targetElement = (Element) ((Element)targetDoc.getElementsByTagName("target").item(0)).getElementsByTagName("locations").item(0);
+
+ for (int i = 1; i < this.sourceTargetFiles.size(); i++) {
+ Document otherTargetDoc = docBuilder.parse(this.sourceTargetFiles.get(i));
+ Element otherLocations = (Element) ((Element)otherTargetDoc.getElementsByTagName("target").item(0)).getElementsByTagName("locations").item(0);
+ NodeList children = otherLocations.getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ targetElement.appendChild(targetDoc.importNode(children.item(j), true));
+ }
+ }
+
+ //write the content into xml file
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, Boolean.TRUE.toString());
+ DOMSource source = new DOMSource(targetDoc);
+ StreamResult result = new StreamResult(this.outputFile);
+ transformer.transform(source, result);
+ } catch (Exception ex) {
+ throw new MojoExecutionException("An error happened while dealing with some XML...", ex);
+ }
+ }
+}
Property changes on: trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/MergeTargetsMojo.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java
===================================================================
--- trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java (rev 0)
+++ trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java 2012-10-05 09:44:49 UTC (rev 44335)
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Mickael Istria (Red Hat, Inc.) - initial API and implementation
+ */
+package org.jboss.tools.tycho.targets;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.sisu.equinox.EquinoxServiceFactory;
+import org.eclipse.tycho.BuildOutputDirectory;
+import org.eclipse.tycho.p2.resolver.TargetDefinitionFile;
+import org.eclipse.tycho.p2.target.facade.TargetDefinition.InstallableUnitLocation;
+import org.eclipse.tycho.p2.target.facade.TargetDefinition.Location;
+import org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository;
+import org.eclipse.tycho.p2.target.facade.TargetDefinition.Unit;
+import org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor;
+import org.eclipse.tycho.p2.tools.RepositoryReferences;
+import org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription;
+import org.eclipse.tycho.p2.tools.mirroring.facade.MirrorApplicationService;
+import org.eclipse.tycho.p2.tools.mirroring.facade.MirrorOptions;
+
+/**
+ * Mirrors a target file as a p2 repo. Suitable for sharing/caching target/dependency sites.
+ *
+ * @author mistria
+ * @goal mirror-target-to-repo
+ */
+public class TargetToRepoMojo extends AbstractMojo {
+
+ /**
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ private MavenProject project;
+ /**
+ * @parameter expression="${session}"
+ * @readonly
+ */
+ private MavenSession session;
+
+ /**
+ * @parameter expression="${project.artifactId}.target"
+ */
+ private File targetFile;
+
+ /**
+ * @parameter expression="${project.build.directory}/${project.artifactId}.target.repo"
+ */
+ private File targetRepository;
+
+ /** @component */
+ private EquinoxServiceFactory p2;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ if (!this.targetFile.isFile()) {
+ throw new MojoExecutionException("Specified 'targetFile' (value: " + targetFile + ") is not a valid file");
+ }
+ this.targetRepository.mkdirs();
+
+ final MirrorApplicationService mirrorService = p2.getService(MirrorApplicationService.class);
+
+ TargetDefinitionFile target = TargetDefinitionFile.read(targetFile);
+ final RepositoryReferences sourceDescriptor = new RepositoryReferences();
+ for (final Location loc : target.getLocations()) {
+ if (loc instanceof InstallableUnitLocation) {
+ for (Repository repo : ((InstallableUnitLocation)loc).getRepositories()) {
+ sourceDescriptor.addMetadataRepository(repo.getLocation());
+ sourceDescriptor.addArtifactRepository(repo.getLocation());
+ }
+ }
+ }
+
+ final DestinationRepositoryDescriptor destinationDescriptor = new DestinationRepositoryDescriptor(this.targetRepository, this.targetFile.getName(), true, false, true);
+
+ mirrorService.mirrorStandalone(sourceDescriptor, destinationDescriptor, createIUDescriptions(target), createMirrorOptions(), new BuildOutputDirectory(this.project.getBuild().getOutputDirectory()));
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Internal error", ex);
+ }
+ }
+
+ private static Collection<IUDescription> createIUDescriptions(TargetDefinitionFile target) {
+ List<IUDescription> result = new ArrayList<IUDescription>();
+ for (final Location loc : target.getLocations()) {
+ if (loc instanceof InstallableUnitLocation) {
+ for (Unit unit : ((InstallableUnitLocation)loc).getUnits()) {
+ result.add(new IUDescription(unit.getId(), unit.getVersion()));
+ }
+ }
+ }
+ return result;
+ }
+
+ private static MirrorOptions createMirrorOptions() {
+ MirrorOptions options = new MirrorOptions();
+ options.setFollowOnlyFilteredRequirements(false);
+ options.setFollowStrictOnly(true);
+ options.setIncludeFeatures(true);
+ options.setIncludeNonGreedy(true);
+ options.setIncludeOptional(true);
+ options.setLatestVersionOnly(false);
+ return options;
+ }
+
+}
Property changes on: trunk/build/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 3 months
JBoss Tools SVN: r44333 - trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-10-05 03:29:45 -0400 (Fri, 05 Oct 2012)
New Revision: 44333
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
Log:
Removing unused import and unused @SuppressWarning annotation
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-10-05 07:03:26 UTC (rev 44332)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-10-05 07:29:45 UTC (rev 44333)
@@ -344,7 +344,6 @@
* @throws CoreException
*/
// FIXME : same code as method processAddition(annotation, etc..) ?!?
- @SuppressWarnings("incomplete-switch")
private List<JaxrsElementDelta> processChange(final IAnnotation javaAnnotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-10-05 07:03:26 UTC (rev 44332)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-10-05 07:29:45 UTC (rev 44333)
@@ -18,7 +18,6 @@
import java.util.List;
import org.eclipse.jdt.core.IJavaElementDelta;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
12 years, 3 months
JBoss Tools SVN: r44332 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-10-05 03:03:26 -0400 (Fri, 05 Oct 2012)
New Revision: 44332
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/AbstractJaxrsElementValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsJavaApplicationValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceMethodValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.properties
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsWebxmlApplicationValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/preferences/JaxrsPreferences.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java
Log:
Fixed - JBIDE-12790 - Broken tests after common validation rework
Fixed - JBIDE-12774 - Application validation error marker wont disappear
Fixed - JBIDE-12795 - JAX-RS application is not removed from metamodel as it should
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -132,14 +132,14 @@
//}
break;
case CHANGED:
- //if(element.exists()) { // needed to prevent exception for edge cases such as 'package-info.java' that holds some shadow 'A' type..
- switch (elementType) {
- case METHOD:
- return processChange((IMethod) element, ast, metamodel, progressMonitor);
- case ANNOTATION:
- return processChange((IAnnotation) element, ast, metamodel, progressMonitor);
- }
- //}
+ switch (elementType) {
+ case TYPE:
+ return processChange((IType) element, ast, metamodel, progressMonitor);
+ case METHOD:
+ return processChange((IMethod) element, ast, metamodel, progressMonitor);
+ case ANNOTATION:
+ return processChange((IAnnotation) element, ast, metamodel, progressMonitor);
+ }
break;
case REMOVED:
switch (elementType) {
@@ -338,6 +338,7 @@
}
/**
+ * Process changes on the JAX-RS element after the given annotation was changed
* @param javaAnnotation
* @param progressMonitor
* @throws CoreException
@@ -350,22 +351,8 @@
Annotation annotation = JdtUtils.resolveAnnotation(javaAnnotation, ast);
if (annotation != null) {
final JaxrsJavaElement<?> existingElement = (JaxrsJavaElement<?>) metamodel.getElement(annotation);
- if (existingElement == null) {
- final JaxrsJavaElement<?> createdElement = factory.createElement(javaAnnotation, ast, metamodel);
- if (createdElement != null) {
- metamodel.add(createdElement);
- changes.add(new JaxrsElementDelta(createdElement, ADDED));
- switch (createdElement.getElementCategory()) {
- case RESOURCE_FIELD:
- case RESOURCE_METHOD:
- JaxrsResource parentResource = ((JaxrsResourceElement<?>) createdElement).getParentResource();
- if (metamodel.containsElement(parentResource)) {
- metamodel.add(parentResource);
- changes.add(new JaxrsElementDelta(parentResource, ADDED));
- }
- }
- }
- } else {
+ // there's no reason that an annotation *change* could trigger the creation of a new JAX-RS element.
+ if (existingElement != null) {
final int flags = existingElement.addOrUpdateAnnotation(annotation);
if (flags > 0) {
changes.add(new JaxrsElementDelta(existingElement, CHANGED, flags));
@@ -375,6 +362,15 @@
return changes;
}
+ /**
+ * Process changes on the method, trying to find fine-grained changes in the signatures/parameters
+ * @param javaMethod
+ * @param ast
+ * @param metamodel
+ * @param progressMonitor
+ * @return
+ * @throws CoreException
+ */
private List<JaxrsElementDelta> processChange(IMethod javaMethod, CompilationUnit ast,
JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
@@ -390,6 +386,33 @@
}
/**
+ * Process type change (eg: supertypes changes) and remove it if kind is UNDEFINED
+ * @param javaApplication
+ * @param ast
+ * @param metamodel
+ * @param progressMonitor
+ * @return
+ * @throws CoreException
+ */
+ private List<JaxrsElementDelta> processChange(IType javaType, CompilationUnit ast,
+ JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
+ final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
+ final IJaxrsElement jaxrsElement = metamodel.getElement(javaType);
+ if (jaxrsElement != null && jaxrsElement.getElementKind() == EnumElementKind.APPLICATION_JAVA) {
+ final JaxrsJavaApplication javaApplication = (JaxrsJavaApplication) jaxrsElement;
+ final int flag = javaApplication.update(javaType);
+ if(javaApplication.getElementKind() == EnumElementKind.UNDEFINED) {
+ Logger.debug("Removing element {}", javaApplication);
+ metamodel.remove(javaApplication);
+ changes.add(new JaxrsElementDelta(jaxrsElement, REMOVED, flag));
+ }
+ else if (flag != F_NONE) {
+ changes.add(new JaxrsElementDelta(jaxrsElement, CHANGED, flag));
+ }
+ }
+ return changes;
+ }
+ /**
* @param element
* @param progressMonitor
* @return
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -18,6 +18,7 @@
import java.util.List;
import org.eclipse.jdt.core.IJavaElementDelta;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -323,7 +323,7 @@
}
}
// structural change : remove all endpoints associated with its methods
- // and creat new ones
+ // and create new ones
else {
for (JaxrsResourceMethod resourceMethod : resource.getMethods().values()) {
changes.addAll(processRemoval(resourceMethod));
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -700,20 +700,20 @@
final JaxrsResource existingResource = metamodel.getElement(eventResource.getJavaElement(),
JaxrsResource.class);
// compare at the fields level
- results.addAll(mergeResourceFields(existingResource, eventResource, metamodel));
+ results.addAll(updateResourceFields(existingResource, eventResource, metamodel));
// and compare at the methods level
- results.addAll(mergeResourceMethods(existingResource, eventResource, metamodel));
+ results.addAll(updateResourceMethods(existingResource, eventResource, metamodel));
// finally, compare at the annotations level
- results.addAll(mergeResourceAnnotations(existingResource, eventResource));
+ results.addAll(updateResourceAnnotations(existingResource, eventResource));
break;
}
return results;
}
- private final List<JaxrsElementDelta> mergeResourceAnnotations(final JaxrsResource existingResource,
+ private final List<JaxrsElementDelta> updateResourceAnnotations(final JaxrsResource existingResource,
final JaxrsResource matchingResource) {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final int flags = existingResource.mergeAnnotations(matchingResource.getAnnotations());
+ final int flags = existingResource.updateAnnotations(matchingResource.getAnnotations());
if (flags > 0) {
changes.add(new JaxrsElementDelta(existingResource, CHANGED, flags));
}
@@ -728,7 +728,7 @@
* @param otherResource
* @return the flags indicating the kind of changes that occurred during the update.
*/
- private List<JaxrsElementDelta> mergeResourceFields(final JaxrsResource existingResource,
+ private List<JaxrsElementDelta> updateResourceFields(final JaxrsResource existingResource,
final JaxrsResource matchingResource, final JaxrsMetamodel metamodel) {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
final Map<String, JaxrsResourceField> addedFields = CollectionUtils.difference(matchingResource.getFields(),
@@ -747,7 +747,7 @@
for (Entry<String, JaxrsResourceField> entry : changedFields.entrySet()) {
final JaxrsResourceField existingField = entry.getValue();
final JaxrsResourceField matchingField = matchingResource.getFields().get(entry.getKey());
- int flags = existingField.mergeAnnotations(matchingField.getAnnotations());
+ int flags = existingField.updateAnnotations(matchingField.getAnnotations());
if ((flags & F_ELEMENT_KIND) > 0 && existingField.getElementKind() == EnumElementKind.UNDEFINED) {
metamodel.remove(existingField);
changes.add(new JaxrsElementDelta(existingField, REMOVED));
@@ -765,7 +765,7 @@
return changes;
}
- private List<JaxrsElementDelta> mergeResourceMethods(final JaxrsResource existingResource,
+ private List<JaxrsElementDelta> updateResourceMethods(final JaxrsResource existingResource,
final JaxrsResource matchingResource, final JaxrsMetamodel metamodel) throws JavaModelException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
final Map<String, JaxrsResourceMethod> addedMethods = CollectionUtils.difference(matchingResource.getMethods(),
@@ -784,7 +784,7 @@
for (Entry<String, JaxrsResourceMethod> entry : changedMethods.entrySet()) {
final JaxrsResourceMethod existingMethod = entry.getValue();
final JaxrsResourceMethod matchingMethod = matchingResource.getMethods().get(entry.getKey());
- int flags = existingMethod.mergeAnnotations(matchingMethod.getAnnotations());
+ int flags = existingMethod.updateAnnotations(matchingMethod.getAnnotations());
final CompilationUnit matchingResourceAST = CompilationUnitsRepository.getInstance().getAST(matchingResource.getResource());
final JavaMethodSignature matchingResourceMethodSignature = JdtUtils.resolveMethodSignature(matchingMethod.getJavaElement(), matchingResourceAST);
if(matchingResourceMethodSignature != null) {
@@ -805,4 +805,5 @@
}
return changes;
}
+
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -98,6 +98,15 @@
return true;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "HttpMethod (built-in)[@" + getJavaClassName() + ":" + httpVerb + "]";
+ }
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -205,7 +205,7 @@
* @see java.lang.Object#toString()
*/
@Override
- public final String toString() {
+ public String toString() {
return "HttpMethod [@" + getJavaClassName() + ":" + getHttpMethodAnnotation() + "]";
}
@@ -246,7 +246,7 @@
flags += F_HTTP_METHOD_VALUE;
}
return flags;*/
- return mergeAnnotations(httpMethod.getAnnotations());
+ return updateAnnotations(httpMethod.getAnnotations());
}
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -13,9 +13,13 @@
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.*;
import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsClassname.APPLICATION_PATH;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IType;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsClassname;
+import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementCategory;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
@@ -53,7 +57,10 @@
@Override
public EnumElementKind getElementKind() {
- return EnumElementKind.APPLICATION_JAVA;
+ if(isApplicationSubclass || getApplicationPathAnnotation() != null) {
+ return EnumElementKind.APPLICATION_JAVA;
+ }
+ return EnumElementKind.UNDEFINED;
}
public boolean isJaxrsCoreApplicationSubclass() {
@@ -96,12 +103,20 @@
if(applicationPathOverride != null) {
return applicationPathOverride;
}
- final Annotation applicationPathAnnotation = getAnnotation(APPLICATION_PATH.qualifiedName);
+ final Annotation applicationPathAnnotation = getApplicationPathAnnotation();
if (applicationPathAnnotation != null) {
return applicationPathAnnotation.getValue("value");
}
return null;
}
+
+ /**
+ * @return the
+ * <code>javax.ws.rs.ApplicationPath<code> annotation set on the underlying javatype, or null if none exists.
+ */
+ public Annotation getApplicationPathAnnotation() {
+ return getAnnotation(APPLICATION_PATH.qualifiedName);
+ }
public boolean isOverriden() {
return (metamodel.getWebxmlApplication(this.getJavaClassName()) != null);
@@ -133,15 +148,37 @@
}
if(this.isJaxrsCoreApplicationSubclass() != application.isJaxrsCoreApplicationSubclass()) {
+ this.isApplicationSubclass = application.isJaxrsCoreApplicationSubclass();
flags += F_APPLICATION_HIERARCHY;
}
return flags;
}
-
+
+ /**
+ * Update this application from the given underlying java type. This update() method focused on supertype changes,
+ * as annotation updates are taken into account by the {@link JaxrsJavaElement#updateAnnotations(java.util.Map)}
+ * method.
+ *
+ * @param javaType
+ * @return flags indicating the nature of the changes
+ * @throws CoreException
+ */
+ public int update(IType javaType) throws CoreException {
+ int flags = 0;
+ final IType applicationSupertype = JdtUtils.resolveType(EnumJaxrsClassname.APPLICATION.qualifiedName, javaType.getJavaProject(), new NullProgressMonitor());
+ final boolean isApplicationSubclass = JdtUtils.isTypeOrSuperType(applicationSupertype, javaType);
+ if(this.isJaxrsCoreApplicationSubclass() != isApplicationSubclass) {
+ this.isApplicationSubclass = isApplicationSubclass;
+ flags += F_APPLICATION_HIERARCHY;
+ }
+ return flags;
+ }
+
@Override
public String toString() {
- return ("JavaApplication '" + getJavaElement().getElementName() + "': " + getApplicationPath());
+ return ("JavaApplication '" + getJavaElement().getElementName() + "': path=" + getApplicationPath());
}
+
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -138,7 +138,7 @@
return F_NONE;
}
- public int mergeAnnotations(Map<String, Annotation> otherAnnotations) {
+ public int updateAnnotations(Map<String, Annotation> otherAnnotations) {
int flags = 0;
// keep values in the 'otherAnnotations' map
final Map<String, Annotation> addedAnnotations = CollectionUtils.difference(otherAnnotations, this.annotations);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -133,7 +133,7 @@
public IResource getResource() {
return getProject();
}
-
+
@Override
public String getName() {
return "JAX-RS Metamodel for project " + getProject().getName();
@@ -732,21 +732,7 @@
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- JaxrsMetamodel other = (JaxrsMetamodel) obj;
- if (javaProject == null && other.javaProject != null) {
- return false;
- } else if (javaProject != null && other.javaProject == null) {
- return false;
- } else if (javaProject != null && other.javaProject != null && !javaProject.getHandleIdentifier().equals(other.javaProject.getHandleIdentifier())) {
- return false;
- }
- return true;
+ return false;
}
@Override
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/AbstractJaxrsElementValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/AbstractJaxrsElementValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/AbstractJaxrsElementValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -53,13 +53,5 @@
Logger.debug("Reporting problem '{}' on resource '{}'", message, target.getFullPath().toString());
return markerManager.addProblem(message, preferenceKey, messageArguments, length, offset, target, quickFixId);
}
-
- public static void deleteJaxrsMarkers(final IResource resource) throws CoreException {
- if (resource == null) {
- return;
- }
- Logger.debug("Clearing JAX-RS markers for resource " + resource.getName());
- resource.deleteMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, true, IResource.DEPTH_ONE);
- }
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsJavaApplicationValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsJavaApplicationValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsJavaApplicationValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -41,7 +41,8 @@
@Override
public void validate() throws CoreException {
final JaxrsJavaApplication application = getElement();
- deleteJaxrsMarkers(application.getResource());
+ JaxrsMetamodelValidator.deleteJaxrsMarkers(application);
+ Logger.debug("Validating element {}", getElement());
final Annotation applicationPathAnnotation = application
.getAnnotation(EnumJaxrsClassname.APPLICATION_PATH.qualifiedName);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -39,6 +39,7 @@
import org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin;
import org.jboss.tools.ws.jaxrs.core.configuration.ProjectNatureUtils;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilder;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
@@ -236,7 +237,6 @@
*/
@SuppressWarnings("incomplete-switch")
private void validate(IJaxrsElement element) throws CoreException {
- Logger.debug("Validating element {}", element);
switch (element.getElementCategory()) {
case METAMODEL:
new JaxrsMetamodelValidatorDelegate(this, (JaxrsMetamodel)element).validate();
@@ -300,6 +300,21 @@
PreferenceInfoManager.register(getProblemType(), new JaxrsPreferenceInfo());
}
+ public static void deleteJaxrsMarkers(final JaxrsBaseElement element) throws CoreException {
+ if (element == null) {
+ return;
+ }
+ deleteJaxrsMarkers(element.getResource());
+ }
+
+ public static void deleteJaxrsMarkers(final IResource resource) throws CoreException {
+ if (resource == null) {
+ return;
+ }
+ Logger.debug("Clearing JAX-RS markers for resource " + resource.getName());
+ resource.deleteMarkers(JAXRS_PROBLEM_TYPE, true, IResource.DEPTH_ONE);
+ }
+
class JaxrsPreferenceInfo implements IPreferenceInfo{
@Override
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences;
@@ -35,7 +36,8 @@
public void validate() throws CoreException {
final JaxrsMetamodel metamodel = getElement();
final IProject project = metamodel.getProject();
- deleteJaxrsMarkers(project);
+ JaxrsMetamodelValidator.deleteJaxrsMarkers(project);
+ Logger.debug("Validating element {}", getElement());
final List<IJaxrsApplication> allApplications = metamodel.getAllApplications();
if (allApplications.isEmpty()) {
addProblem(JaxrsValidationMessages.APPLICATION_NO_OCCURRENCE_FOUND,
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceMethodValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceMethodValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceMethodValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -53,6 +53,7 @@
@Override
public void validate() {
+ Logger.debug("Validating element {}", getElement());
final JaxrsResourceMethod resourceMethod = getElement();
try {
resourceMethod.hasErrors(false);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -14,6 +14,7 @@
import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
/**
@@ -31,7 +32,8 @@
@Override
public void validate() throws CoreException {
final JaxrsResource resource = getElement();
- deleteJaxrsMarkers(resource.getResource());
+ JaxrsMetamodelValidator.deleteJaxrsMarkers(resource);
+ Logger.debug("Validating element {}", getElement());
for(IJaxrsResourceMethod resourceMethod : resource.getAllMethods()) {
new JaxrsResourceMethodValidatorDelegate(getMarkerManager(), (JaxrsResourceMethod) resourceMethod).validate();
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -24,6 +24,10 @@
+
+
+
+
public static String SEARCHING_RESOURCES;
public static String VALIDATING_RESOURCE;
public static String VALIDATING_PROJECT;
@@ -33,6 +37,7 @@
public static String JAVA_APPLICATION_MISSING_APPLICATION_PATH_ANNOTATION;
public static String JAVA_APPLICATION_INVALID_TYPE_HIERARCHY;
+ public static String HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE;
public static String HTTP_METHOD_MISSING_RETENTION_ANNOTATION;
public static String HTTP_METHOD_INVALID_RETENTION_ANNOTATION_VALUE;
public static String HTTP_METHOD_MISSING_TARGET_ANNOTATION;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.properties 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsValidationMessages.properties 2012-10-05 07:03:26 UTC (rev 44332)
@@ -7,6 +7,7 @@
JAVA_APPLICATION_MISSING_APPLICATION_PATH_ANNOTATION=The Application Path should be configured with an @ApplicationPath annotation or in the web deployment descriptor.
JAVA_APPLICATION_INVALID_TYPE_HIERARCHY=Type ''{0}'' should extend javax.ws.rs.core.Application.
+HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE=The HTTP Method value cannot be empty.
HTTP_METHOD_MISSING_RETENTION_ANNOTATION=The HTTP Method should have a @Retention(RetentionPolicy.RUNTIME) annotation on its type.
HTTP_METHOD_INVALID_RETENTION_ANNOTATION_VALUE=The @Retention annotation value is not correct. It should be RetentionPolicy.RUNTIME
HTTP_METHOD_MISSING_TARGET_ANNOTATION=The HTTP Method should have a @Target(ElementType.METHOD) annotation on its type.
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsWebxmlApplicationValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsWebxmlApplicationValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsWebxmlApplicationValidatorDelegate.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -40,7 +40,8 @@
@Override
public void validate() throws CoreException {
JaxrsWebxmlApplication webxmlApplication = getElement();
- deleteJaxrsMarkers(webxmlApplication.getResource());
+ JaxrsMetamodelValidator.deleteJaxrsMarkers(webxmlApplication);
+ Logger.debug("Validating element {}", getElement());
if (webxmlApplication.getMetamodel().hasMultipleApplications()) {
final IResource webxmlResource = webxmlApplication.getResource();
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xavier Coulon - Initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.metamodel;
import org.eclipse.core.resources.IResource;
@@ -2,2 +12,7 @@
+/**
+ * Base interface for all JAX-RS elements
+ * @author Xavier Coulon
+ *
+ */
public interface IJaxrsElement {
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/preferences/JaxrsPreferences.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/preferences/JaxrsPreferences.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/preferences/JaxrsPreferences.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -29,6 +29,9 @@
public static final String WARNING_GROUP_ID = "jaxrs";
// HTTP Method group
+ public static final String HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE = INSTANCE
+ .createSeverityOption("httpMethodInvalidHttpMethodAnnotationValue"); //$NON-NLS-1$
+
public static final String HTTP_METHOD_MISSING_RETENTION_ANNOTATION = INSTANCE
.createSeverityOption("httpMethodMissingRetentionAnnotation"); //$NON-NLS-1$
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -397,6 +397,44 @@
}
@Test
+ public void shouldRemoveApplicationWhenRemovingAnnotationAndHierarchyAlreadyMissing() throws CoreException {
+ // pre-conditions
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ final Annotation appPathAnnotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, appPathAnnotation, false, metamodel);
+ metamodel.add(application);
+ // operation
+ final JavaElementDelta event = createEvent(appPathAnnotation, REMOVED);
+ final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
+ // verifications
+ assertThat(impacts.size(), equalTo(1));
+ assertThat(impacts.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
+ assertThat(impacts.get(0).getDeltaKind(), equalTo(REMOVED));
+ assertThat(impacts.get(0).getElement(), is(notNullValue()));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldRemoveApplicationWhenRemovingHierarchyAndAnnotationAlreadyMissing() throws CoreException {
+ // pre-conditions
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(type, "extends Application", "", false);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, null, true, metamodel);
+ metamodel.add(application);
+ // operation
+ final JavaElementDelta event = createEvent(type, CHANGED, IJavaElementDeltaFlag.F_SUPER_TYPES);
+ final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
+ // verifications
+ assertThat(impacts.size(), equalTo(1));
+ assertThat(impacts.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
+ assertThat(impacts.get(0).getDeltaKind(), equalTo(REMOVED));
+ assertThat(impacts.get(0).getElement(), is(notNullValue()));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
public void shouldDoNothingWhenRemovingUnrelatedAnnotationOnApplication() throws CoreException {
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -103,6 +103,7 @@
/**
* Creates a java annotated type based JAX-RS Application element
+ *
* @param type
* @return
* @throws JavaModelException
@@ -114,6 +115,7 @@
/**
* Creates a java annotated type based JAX-RS Application element
+ *
* @param type
* @param applicationPath
* @return
@@ -131,7 +133,8 @@
* @return
* @throws JavaModelException
*/
- private JaxrsWebxmlApplication createWebxmlApplication(final String applicationClassName, final String applicationPath) throws JavaModelException {
+ private JaxrsWebxmlApplication createWebxmlApplication(final String applicationClassName,
+ final String applicationPath) throws JavaModelException {
final IResource webDeploymentDescriptor = WtpUtils.getWebDeploymentDescriptor(project);
return new JaxrsWebxmlApplication(applicationClassName, applicationPath, webDeploymentDescriptor, metamodel);
}
@@ -141,11 +144,14 @@
* @throws CoreException
* @throws JavaModelException
*/
- private JaxrsHttpMethod createHttpMethod(EnumJaxrsClassname httpMethodElement) throws CoreException, JavaModelException {
- final IType httpMethodType = JdtUtils.resolveType(httpMethodElement.qualifiedName, javaProject, progressMonitor);
+ private JaxrsHttpMethod createHttpMethod(EnumJaxrsClassname httpMethodElement) throws CoreException,
+ JavaModelException {
+ final IType httpMethodType = JdtUtils
+ .resolveType(httpMethodElement.qualifiedName, javaProject, progressMonitor);
final Annotation httpMethodAnnotation = getAnnotation(httpMethodType, HTTP_METHOD.qualifiedName);
- final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod.Builder(httpMethodType, metamodel).httpMethod(httpMethodAnnotation).build();
-
+ final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod.Builder(httpMethodType, metamodel).httpMethod(
+ httpMethodAnnotation).build();
+
return httpMethod;
}
@@ -153,7 +159,8 @@
final Annotation httpMethodAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final Annotation targetAnnotation = getAnnotation(type, TARGET.qualifiedName);
final Annotation retentionAnnotation = getAnnotation(type, RETENTION.qualifiedName);
- final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod.Builder(type, metamodel).httpMethod(httpMethodAnnotation).target(targetAnnotation).retention(retentionAnnotation).build();
+ final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod.Builder(type, metamodel)
+ .httpMethod(httpMethodAnnotation).target(targetAnnotation).retention(retentionAnnotation).build();
return httpMethod;
}
@@ -197,7 +204,8 @@
// 1 application + 1 HttpMethod + 7 Resources
assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all HttpMethods, Resources, ResourceMethods and ResourceFields. only application is available: the java-based one found in src/main/java
+ // all HttpMethods, Resources, ResourceMethods and ResourceFields. only application is available: the java-based
+ // one found in src/main/java
assertThat(metamodel.getElements(javaProject).size(), equalTo(35));
}
@@ -216,10 +224,11 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 7 Resources
+ // 1 application + 1 HttpMethod + 7 Resources
assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all project-specific Applications, HttpMethods, Resources, ResourceMethods and ResourceFields (built-in HttpMethods are not bound to a project)
+ // all project-specific Applications, HttpMethods, Resources, ResourceMethods and ResourceFields (built-in
+ // HttpMethods are not bound to a project)
// 2 applications are available: the java-based and the web.xml since a full build was performed
assertThat(metamodel.getElements(javaProject).size(), equalTo(36));
}
@@ -427,7 +436,8 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(),
+ equalTo("/hello"));
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -457,14 +467,16 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION_WEBXML));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(),
+ equalTo("/hello"));
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@Test
public void shouldOverrideJavaApplicationWhenAddingCustomServletMapping() throws Exception {
- // in this test, the java-application exists first, and then a web.xml application is added -> it should immediately override the java-one
+ // in this test, the java-application exists first, and then a web.xml application is added -> it should
+ // immediately override the java-one
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -485,20 +497,26 @@
assertThat(affectedElements.get(1).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION_JAVA));
assertThat(affectedElements.get(1).getDeltaKind(), equalTo(CHANGED));
- final JaxrsJavaApplication javaApplication = (JaxrsJavaApplication)affectedElements.get(1).getElement();
- assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication)javaApplication)); // custom web.xml override DOES NOT precede the java based JAX-RS Application element
- assertThat(javaApplication.getApplicationPath(), equalTo("/hello")); // Java-based application configuration should not be changed
+ final JaxrsJavaApplication javaApplication = (JaxrsJavaApplication) affectedElements.get(1).getElement();
+ assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication) javaApplication)); // custom web.xml override
+ // DOES NOT precede the
+ // java based JAX-RS
+ // Application element
+ assertThat(javaApplication.getApplicationPath(), equalTo("/hello")); // Java-based application configuration
+ // should not be changed
assertThat(metamodel.getElements(javaProject).size(), equalTo(2)); // old application (java) + new one (web.xml)
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
}
/**
- * in this test, the webxml exists first, and then an annotated Java Application is added -> it should be immediately overriden
+ * in this test, the webxml exists first, and then an annotated Java Application is added -> it should be
+ * immediately overriden
*/
@Test
public void shouldOverrideJavaApplicationWhenAddingAnnotatedJavaApplication() throws Exception {
// precondition
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(
+ "org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
metamodel.add(webxmlApplication);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -525,7 +543,8 @@
@Test
public void shouldOverrideJavaApplicationWhenAddingUnannotatedJavaApplication() throws Exception {
// precondition
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(
+ "org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
metamodel.add(webxmlApplication);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -545,13 +564,16 @@
}
/**
- * In this test, the java application path override should be removed when the web.xml application is removed from the web.xml file
+ * In this test, the java application path override should be removed when the web.xml application is removed from
+ * the web.xml file
+ *
* @throws Exception
*/
@Test
public void shouldUnoverrideAnnotatedJavaApplicationWhenRemovingCustomWebxml() throws Exception {
// precondition
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(
+ "org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
metamodel.add(webxmlApplication);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -572,11 +594,12 @@
assertThat(application.getApplicationPath(), equalTo("/app"));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1)); // one (java)
}
-
+
@Test
public void shouldUnoverrideUnannotatedJavaApplicationWhenRemovingCustomWebxml() throws Exception {
// precondition
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(
+ "org.jboss.tools.ws.jaxrs.sample.services.RestApplication", "/hello");
metamodel.add(webxmlApplication);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -598,8 +621,7 @@
assertThat(application.getApplicationPath(), nullValue());
assertThat(metamodel.getElements(javaProject).size(), equalTo(1)); // one (java)
}
-
-
+
@Test
public void shouldNotOverrideJavaApplicationWhenAddingDefaultServletMapping() throws Exception {
// pre-conditions
@@ -620,18 +642,28 @@
assertThat(webxmlApplication.getApplicationPath(), equalTo("/hello"));
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(2)); // old application (java) + new one (web.xml)
- assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication)webxmlApplication)); // web.xml based application precedes any other java based JAX-RS Application element
- assertThat(metamodel.getJavaApplications().get(0).getApplicationPath(), equalTo("/app")); // Java-based application configuration should not be changed
+ assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication) webxmlApplication)); // web.xml based
+ // application precedes
+ // any other java based
+ // JAX-RS Application
+ // element
+ assertThat(metamodel.getJavaApplications().get(0).getApplicationPath(), equalTo("/app")); // Java-based
+ // application
+ // configuration
+ // should not be
+ // changed
}
-
+
/**
- * In this test, the existing Java Application is not modified when adding a web.xml with default application configuration,
- * but the resulting webxmlApplication becomes the primary one in the metamodel
+ * In this test, the existing Java Application is not modified when adding a web.xml with default application
+ * configuration, but the resulting webxmlApplication becomes the primary one in the metamodel
+ *
* @throws Exception
*/
@Test
public void shouldPreceedJavaApplicationWhenAddingDefaultWebxmlMapping() throws Exception {
- // in this test, the java-application exists first, and then a web.xml application is added -> it should immediately override the java-one
+ // in this test, the java-application exists first, and then a web.xml application is added -> it should
+ // immediately override the java-one
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
@@ -649,21 +681,26 @@
final JaxrsWebxmlApplication webxmlApplication = (JaxrsWebxmlApplication) affectedElements.get(0).getElement();
assertThat(webxmlApplication.getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
assertThat(webxmlApplication.getApplicationPath(), equalTo("/hello"));
- assertThat(javaApplication.getApplicationPath(), equalTo("/app")); // Java-based application configuration should not be changed
+ assertThat(javaApplication.getApplicationPath(), equalTo("/app")); // Java-based application configuration
+ // should not be changed
assertThat(metamodel.getElements(javaProject).size(), equalTo(2)); // old application (java) + new one (web.xml)
- assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication)webxmlApplication)); // old application (java) + new one (web.xml)
+ assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication) webxmlApplication)); // old application
+ // (java) + new one
+ // (web.xml)
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
}
-
+
@Test
public void shouldRestoreJavaApplicationWhenRemovingDefaultWebxmlMapping() throws Exception {
- // in this test, the java-application exists first, and then a web.xml application is added -> it should immediately override the java-one
+ // in this test, the java-application exists first, and then a web.xml application is added -> it should
+ // immediately override the java-one
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final JaxrsJavaApplication javaApplication = createJavaApplication(type);
metamodel.add(javaApplication);
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(
+ EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
metamodel.add(webxmlApplication);
// operation
final ResourceDelta event = createEvent(webxmlApplication.getResource(), REMOVED);
@@ -672,14 +709,56 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION_WEBXML));
- assertThat(javaApplication.getApplicationPath(), equalTo("/app")); // Java-based application configuration should not be changed
+ assertThat(javaApplication.getApplicationPath(), equalTo("/app")); // Java-based application configuration
+ // should not be changed
assertThat(metamodel.getElements(javaProject).size(), equalTo(1)); // java application
- assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication)javaApplication)); // old application (java) + new one (web.xml)
+ assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication) javaApplication)); // old application (java)
+ // + new one (web.xml)
verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
}
-
+
+ @Test
+ public void shouldRemoveApplicationWhenRemovingAnnotationAndHierarchyAlreadyMissing() throws CoreException {
+ // pre-conditions
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(type.getCompilationUnit(), "extends Application", "", false);
+ metamodel.add(createJavaApplication(type, "/bar"));
+ // operation
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(type.getCompilationUnit(), "@ApplicationPath(\"/app\")", "", false);
+ final ResourceDelta event = createEvent(type.getResource(), CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
+ verify(metamodel, times(1)).remove(any(JaxrsJavaApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldRemoveApplicationWhenRemovingHierarchyAndAnnotationAlreadyMissing() throws CoreException {
+ // pre-conditions
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(type.getCompilationUnit(), "@ApplicationPath(\"/app\")", "", false);
+ metamodel.add(createJavaApplication(type));
+ // operation
+ WorkbenchUtils.replaceFirstOccurrenceOfCode(type.getCompilationUnit(), "extends Application", "", false);
+ final ResourceDelta event = createEvent(type.getResource(), CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
+ verify(metamodel, times(1)).remove(any(JaxrsJavaApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+
+ }
+
/**
* In this test, the webxml application is changed when the application path is changed, too.
+ *
* @throws Exception
*/
@Test
@@ -698,14 +777,16 @@
assertThat(affectedElements.get(1).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
assertThat(affectedElements.get(1).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION_WEBXML));
assertThat(affectedElements.get(1).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(),
+ equalTo("/hello"));
verify(metamodel, times(2)).add(any(JaxrsWebxmlApplication.class)); // initial app added + new app added, too
verify(metamodel, times(1)).remove(any(JaxrsWebxmlApplication.class)); // initial app removed
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
-
+
/**
* In this test, the webxml application is changed when the application path is changed, too.
+ *
* @throws Exception
*/
@Test
@@ -722,10 +803,11 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION_WEBXML));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(),
+ equalTo("/hello"));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
-
+
@Test
public void shouldNotFailWhenWebxmlWithUnknownServletClass() throws Exception {
// pre-conditions
@@ -734,7 +816,7 @@
assertFalse(removedEntries.isEmpty());
final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
"web-3_0-with-invalid-servlet-mapping.xml", bundle);
- //metamodel.add(createApplication("/foo"));
+ // metamodel.add(createApplication("/foo"));
// operation
// operation
final ResourceDelta event = createEvent(webxmlResource, CHANGED);
@@ -756,7 +838,8 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(),
+ equalTo("/hello"));
verify(metamodel, times(1)).remove(any(JaxrsWebxmlApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
@@ -765,7 +848,8 @@
public void shouldRemoveWebxmlApplicationWhenRemovingWebxml() throws Exception {
// pre-conditions
// JaxrsMetamodel metamodel = new JaxrsMetamodel(javaProject);
- final JaxrsWebxmlApplication application = createWebxmlApplication(EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
+ final JaxrsWebxmlApplication application = createWebxmlApplication(
+ EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
metamodel.add(application);
final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
"web-3_0-with-default-servlet-mapping.xml", bundle);
@@ -787,9 +871,10 @@
// pre-conditions
final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
"web-3_0-with-servlet-mapping.xml", bundle);
- final JaxrsWebxmlApplication application = createWebxmlApplication(EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
+ final JaxrsWebxmlApplication application = createWebxmlApplication(
+ EnumJaxrsClassname.APPLICATION.qualifiedName, "/hello");
metamodel.add(application);
-
+
// operation
final IContainer webInfFolder = webxmlResource.getParent();
webInfFolder.delete(IResource.FORCE, progressMonitor);
@@ -895,7 +980,7 @@
// verifications
assertThat(affectedElements.size(), equalTo(0));
}
-
+
@Test
public void shouldRemoveHttpMethodWhenChangingResource() throws CoreException {
// pre-conditions
@@ -1053,7 +1138,8 @@
// verifications
assertThat(affectedElements.size(), equalTo(1)); // 1 resource method
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_METHOD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_METHOD));
// 4 HttpMethods + 2 resources (including their methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(8));
}
@@ -1082,9 +1168,11 @@
// verifications
assertThat(affectedElements.size(), equalTo(2)); // 2 resource methods
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_METHOD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_METHOD));
assertThat(affectedElements.get(1).getDeltaKind(), equalTo(CHANGED));
- assertThat(affectedElements.get(1).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_METHOD));
+ assertThat(affectedElements.get(1).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_METHOD));
// 4 HttpMethods + 2 resources (including their methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(8));
}
@@ -1110,7 +1198,8 @@
// verifications
assertThat(affectedElements.size(), equalTo(1)); // 1 resource method
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_METHOD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_METHOD));
// 4 HttpMethods + 1 resource (including their remaining methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(7));
}
@@ -1131,7 +1220,8 @@
// verifications
assertThat(affectedElements.size(), equalTo(1)); // 1 resource field
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_FIELD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_FIELD));
// 4 HttpMethods + 2 resources (including their methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(9));
}
@@ -1160,7 +1250,8 @@
// verifications
assertThat(affectedElements.size(), equalTo(1)); // 1 resource field
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_FIELD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_FIELD));
// 4 HttpMethods + 2 resources (including their methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(9));
}
@@ -1187,7 +1278,8 @@
// verifications
assertThat(affectedElements.size(), equalTo(1)); // 1 resource field
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(affectedElements.get(0).getElement().getElementCategory(), equalTo(EnumElementCategory.RESOURCE_FIELD));
+ assertThat(affectedElements.get(0).getElement().getElementCategory(),
+ equalTo(EnumElementCategory.RESOURCE_FIELD));
// 4 HttpMethods + 2 resources (including their methods and fields)
assertThat(metamodel.getElements(javaProject).size(), equalTo(8));
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorTestCase.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorTestCase.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -13,7 +13,6 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
import java.util.List;
@@ -41,8 +40,11 @@
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
+import static org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences.*;
import org.junit.Test;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.*;
+
/**
* @author Xi
*
@@ -62,7 +64,8 @@
* @return
* @throws JavaModelException
*/
- private JaxrsWebxmlApplication createWebxmlApplication(final String applicationClassName, final String applicationPath) throws JavaModelException {
+ private JaxrsWebxmlApplication createWebxmlApplication(final String applicationClassName,
+ final String applicationPath) throws JavaModelException {
final IResource webDeploymentDescriptor = WtpUtils.getWebDeploymentDescriptor(project);
return new JaxrsWebxmlApplication(applicationClassName, applicationPath, webDeploymentDescriptor, metamodel);
}
@@ -76,13 +79,14 @@
metamodel.remove((JaxrsBaseElement) application);
}
}
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
assertThat(metamodel.getAllApplications().size(), equalTo(1));
assertThat(metamodel.getApplication().getElementKind(), equalTo(EnumElementKind.APPLICATION_JAVA));
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- assertThat(project.findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0).length, equalTo(0));
+ final IMarker[] markers = findJaxrsMarkers(project);
+ assertThat(markers.length, equalTo(0));
}
@Test
@@ -96,11 +100,12 @@
}
assertThat(metamodel.getAllApplications().size(), equalTo(1));
assertThat(metamodel.getApplication().getElementKind(), equalTo(EnumElementKind.APPLICATION_WEBXML));
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- assertThat(project.findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0).length, equalTo(0));
+ final IMarker[] merkers = findJaxrsMarkers(project);
+ assertThat(merkers.length, equalTo(0));
}
@Test
@@ -110,12 +115,13 @@
for (IJaxrsApplication application : applications) {
metamodel.remove((JaxrsBaseElement) application);
}
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = project.findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(project);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(APPLICATION_NO_OCCURRENCE_FOUND));
}
@Test
@@ -123,15 +129,15 @@
// preconditions
final List<IJaxrsApplication> applications = metamodel.getAllApplications();
assertThat(applications, hasSize(2));
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = project.findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(0));
+ final IMarker[] markers = findJaxrsMarkers(project);
+ assertThat(markers.length, equalTo(0));
for (IJaxrsApplication application : metamodel.getAllApplications()) {
- final IMarker[] appMarkers = ((JaxrsBaseElement) application).getResource().findMarkers(
- JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, true, IResource.DEPTH_INFINITE);
+ final IMarker[] appMarkers = findJaxrsMarkers(application);
+ assertThat(appMarkers, hasPreferenceKey(APPLICATION_TOO_MANY_OCCURRENCES));
assertThat(appMarkers.length, equalTo(1));
}
}
@@ -142,7 +148,7 @@
// preconditions
final List<IJaxrsApplication> applications = metamodel.getAllApplications();
assertThat(applications, hasSize(2));
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
JaxrsJavaApplication javaApplication = null;
// remove web.xml-based application and remove @ApplicationPath annotation on java-based application
for (IJaxrsApplication application : applications) {
@@ -158,9 +164,9 @@
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = javaApplication.getJavaElement().getResource()
- .findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(JAVA_APPLICATION_MISSING_APPLICATION_PATH_ANNOTATION));
}
@Test
@@ -170,33 +176,32 @@
javaProject, new NullProgressMonitor());
WorkbenchUtils.replaceAllOccurrencesOfCode(type.getCompilationUnit(), "extends Application", "", false);
final JaxrsJavaApplication javaApplication = metamodel.getJavaApplications().get(0);
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = javaApplication.getJavaElement().getResource()
- .findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers, hasPreferenceKey(JAVA_APPLICATION_INVALID_TYPE_HIERARCHY));
}
@Test
- public void shouldNotReportProblemOnApplicationIfMissingApplicationPathAnnotationWithOverride()
- throws Exception {
+ public void shouldNotReportProblemOnApplicationIfMissingApplicationPathAnnotationWithOverride() throws Exception {
// preconditions
final JaxrsJavaApplication javaApplication = metamodel.getJavaApplications().get(0);
- final Annotation appPathAnnotation = javaApplication.getAnnotation(EnumJaxrsClassname.APPLICATION_PATH.qualifiedName);
+ final Annotation appPathAnnotation = javaApplication
+ .getAnnotation(EnumJaxrsClassname.APPLICATION_PATH.qualifiedName);
javaApplication.removeAnnotation(appPathAnnotation);
final JaxrsWebxmlApplication webxmlDefaultApplication = (JaxrsWebxmlApplication) metamodel.getApplication();
metamodel.remove(webxmlDefaultApplication);
- final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(javaApplication.getJavaClassName(), "/foo");
+ final JaxrsWebxmlApplication webxmlApplication = createWebxmlApplication(javaApplication.getJavaClassName(),
+ "/foo");
metamodel.add(webxmlApplication);
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = javaApplication.getJavaElement().getResource()
- .findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(0));
+ final IMarker[] markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers.length, equalTo(0));
}
@Test
@@ -206,12 +211,42 @@
final JaxrsJavaApplication javaApplication = metamodel.getJavaApplications().get(0);
final JaxrsWebxmlApplication webxmlDefaultApplication = (JaxrsWebxmlApplication) metamodel.getApplication();
metamodel.remove(webxmlDefaultApplication);
- MarkerUtils.deleteJaxrsMarkers(project);
+ deleteJaxrsMarkers(project);
// operation
new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
// validation
- final IMarker[] projectMarkers = javaApplication.getJavaElement().getResource()
- .findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
- assertThat(projectMarkers.length, equalTo(0));
+ final IMarker[] markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers.length, equalTo(0));
}
+
+ @Test
+ public void shouldNotReportProblemOnApplicationWhenAnnotationRemovedAndSuperclassExtensionRemoved()
+ throws CoreException, ValidationException {
+ // preconditions operation #1
+ final JaxrsJavaApplication javaApplication = metamodel.getJavaApplications().get(0);
+ final JaxrsWebxmlApplication webxmlDefaultApplication = (JaxrsWebxmlApplication) metamodel.getApplication();
+ metamodel.remove(webxmlDefaultApplication);
+ deleteJaxrsMarkers(project);
+ // operation #1: remove annotation and validate
+ LOGGER.warn("*** Operation #1 ***");
+ WorkbenchUtils.replaceAllOccurrencesOfCode(javaApplication.getJavaElement().getCompilationUnit(),
+ "@ApplicationPath(\"/app\")", "", false);
+ LOGGER.warn("*** Validating after Operation #1 ***");
+ new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
+ // validation after operation #1
+ IMarker[] markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers, hasPreferenceKey(JAVA_APPLICATION_MISSING_APPLICATION_PATH_ANNOTATION));
+ assertThat(markers.length, equalTo(1));
+ // preconditions operation #2
+ deleteJaxrsMarkers(project);
+ // operation #2: remove 'extends Application'
+ LOGGER.warn("*** Operation #2 ***");
+ WorkbenchUtils.replaceAllOccurrencesOfCode(javaApplication.getJavaElement().getCompilationUnit(),
+ "extends Application", "", false);
+ LOGGER.warn("*** Validating after Operation #2 ***");
+ new JaxrsMetamodelValidator().validateAll(project, validationHelper, context, validatorManager, reporter);
+ // validation after operation #2
+ markers = findJaxrsMarkers(javaApplication);
+ assertThat(markers.length, equalTo(0));
+ }
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorTestCase.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorTestCase.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -12,6 +12,10 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.deleteJaxrsMarkers;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.findJaxrsMarkers;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.hasPreferenceKey;
+import static org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences.RESOURCE_METHOD_UNBOUND_PATH_ANNOTATION_TEMPLATE_PARAMETER;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
@@ -31,7 +35,6 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.common.validation.ContextValidationHelper;
import org.jboss.tools.common.validation.IProjectValidationContext;
-import org.jboss.tools.common.validation.ValidationErrorManager;
import org.jboss.tools.common.validation.ValidatorManager;
import org.jboss.tools.common.validation.internal.ProjectValidationContext;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
@@ -39,7 +42,6 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
-import org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences;
import org.junit.Test;
/**
@@ -66,12 +68,13 @@
final IType customerJavaType = WorkbenchUtils.getType(
"org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsBaseElement customerResource = (JaxrsBaseElement) metamodel.getElement(customerJavaType);
- MarkerUtils.deleteJaxrsMarkers(customerResource);
+ deleteJaxrsMarkers(customerResource);
// operation
new JaxrsMetamodelValidator().validate(toSet(customerResource.getResource()), project, validationHelper,
context, validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(customerResource).length, equalTo(0));
+ final IMarker[] markers = findJaxrsMarkers(customerResource);
+ assertThat(markers.length, equalTo(0));
}
@Test
@@ -80,22 +83,20 @@
final IType barJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.BarResource",
javaProject);
final JaxrsResource barResource = metamodel.getElement(barJavaType, JaxrsResource.class);
- MarkerUtils.deleteJaxrsMarkers(barResource);
+ deleteJaxrsMarkers(barResource);
// operation
new JaxrsMetamodelValidator().validate(toSet(barResource.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- final IMarker[] markers = MarkerUtils.findJaxrsMarkers(barResource);
+ final IMarker[] markers = findJaxrsMarkers(barResource);
assertThat(markers.length, equalTo(8));
final Map<String, JaxrsResourceMethod> resourceMethods = barResource.getMethods();
for (Entry<String, JaxrsResourceMethod> entry : resourceMethods.entrySet()) {
- final IMarker[] methodMarkers = MarkerUtils.findJaxrsMarkers(entry.getValue());
+ final IMarker[] methodMarkers = findJaxrsMarkers(entry.getValue());
if (entry.getKey().contains("getContent1")) {
assertThat(entry.getValue().hasErrors(), is(true));
assertThat(methodMarkers.length, equalTo(1));
- assertThat(methodMarkers[0].getType(), equalTo(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE));
- assertThat(methodMarkers[0].getAttribute(ValidationErrorManager.PREFERENCE_KEY_ATTRIBUTE_NAME, ""),
- equalTo(JaxrsPreferences.RESOURCE_METHOD_UNBOUND_PATH_ANNOTATION_TEMPLATE_PARAMETER));
+ assertThat(methodMarkers, hasPreferenceKey(RESOURCE_METHOD_UNBOUND_PATH_ANNOTATION_TEMPLATE_PARAMETER));
} else if (entry.getKey().contains("getContent2")) {
assertThat(entry.getValue().hasErrors(), is(true));
assertThat(methodMarkers.length, equalTo(3));
@@ -120,22 +121,20 @@
final IType barJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.BazResource",
javaProject);
final JaxrsResource barResource = metamodel.getElement(barJavaType, JaxrsResource.class);
- MarkerUtils.deleteJaxrsMarkers(barResource);
+ deleteJaxrsMarkers(barResource);
// operation
new JaxrsMetamodelValidator().validate(toSet(barResource.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- final IMarker[] markers = MarkerUtils.findJaxrsMarkers(barResource);
+ final IMarker[] markers = findJaxrsMarkers(barResource);
assertThat(markers.length, equalTo(6));
final Map<String, JaxrsResourceMethod> resourceMethods = barResource.getMethods();
for (Entry<String, JaxrsResourceMethod> entry : resourceMethods.entrySet()) {
- final IMarker[] methodMarkers = MarkerUtils.findJaxrsMarkers(entry.getValue());
+ final IMarker[] methodMarkers = findJaxrsMarkers(entry.getValue());
if (entry.getKey().contains("getContent1")) {
assertThat(entry.getValue().hasErrors(), is(true));
assertThat(methodMarkers.length, equalTo(1));
- assertThat(methodMarkers[0].getType(), equalTo(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE));
- assertThat(methodMarkers[0].getAttribute(ValidationErrorManager.PREFERENCE_KEY_ATTRIBUTE_NAME, ""),
- equalTo(JaxrsPreferences.RESOURCE_METHOD_UNBOUND_PATH_ANNOTATION_TEMPLATE_PARAMETER));
+ assertThat(methodMarkers, hasPreferenceKey(RESOURCE_METHOD_UNBOUND_PATH_ANNOTATION_TEMPLATE_PARAMETER));
} else if (entry.getKey().contains("getContent2")) {
assertThat(entry.getValue().hasErrors(), is(true));
assertThat(methodMarkers.length, equalTo(2));
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java 2012-10-05 07:01:03 UTC (rev 44331)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java 2012-10-05 07:03:26 UTC (rev 44332)
@@ -8,8 +8,13 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ISourceRange;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.jboss.tools.common.validation.ValidationErrorManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsElement;
/**
* @author Xavier Coulon
@@ -22,8 +27,9 @@
* @return
* @throws CoreException
*/
- public static IMarker[] findJaxrsMarkers(final JaxrsBaseElement element) throws CoreException {
+ public static IMarker[] findJaxrsMarkers(final IJaxrsElement element) throws CoreException {
switch (element.getElementCategory()) {
+ case APPLICATION:
case HTTP_METHOD:
case RESOURCE:
return element.getResource().findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, true,
@@ -47,6 +53,10 @@
}
}
+ public static IMarker[] findJaxrsMarkers(IProject project) throws CoreException {
+ return project.findMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, 0);
+ }
+
/**
* @param element
* @throws CoreException
@@ -63,5 +73,40 @@
public static void deleteJaxrsMarkers(final IProject project) throws CoreException {
project.deleteMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, false, IResource.DEPTH_INFINITE);
}
+
+ public static Matcher<IMarker[]> hasPreferenceKey(String javaApplicationInvalidTypeHierarchy) {
+ return new MarkerPreferenceKeyMatcher(javaApplicationInvalidTypeHierarchy);
+ }
+
+ static class MarkerPreferenceKeyMatcher extends BaseMatcher<IMarker[]> {
+
+ final String expectedProblemType;
+
+ MarkerPreferenceKeyMatcher(final String expectedProblemType) {
+ this.expectedProblemType = expectedProblemType;
+ }
+ @Override
+ public boolean matches(Object item) {
+ if(item instanceof IMarker[]) {
+ for(IMarker marker : (IMarker[]) item) {
+ final String preferenceKey = marker.getAttribute(ValidationErrorManager.PREFERENCE_KEY_ATTRIBUTE_NAME, "");
+ if(preferenceKey.equals(expectedProblemType)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("marker contains preference_key (\"" + expectedProblemType + "\" problem type)");
+ }
+
+ }
+
+
+
+
}
\ No newline at end of file
12 years, 3 months
JBoss Tools SVN: r44331 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-10-05 03:01:03 -0400 (Fri, 05 Oct 2012)
New Revision: 44331
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.properties
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsValidatorConfigurationBlockDescriptionProvider.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorTestCase.java
Log:
Fixed - JBIDE-12804
Report an error when a JAX-RS @HttpMethod annotation has an invalid value
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorDelegate.java 2012-10-05 06:54:35 UTC (rev 44330)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorDelegate.java 2012-10-05 07:01:03 UTC (rev 44331)
@@ -17,6 +17,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.metamodel.quickfix.JaxrsValidationQuickFixes;
import org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences;
@@ -36,7 +37,8 @@
@Override
public void validate() throws CoreException {
final JaxrsHttpMethod httpMethod = getElement();
- deleteJaxrsMarkers(httpMethod.getResource());
+ JaxrsMetamodelValidator.deleteJaxrsMarkers(httpMethod);
+ Logger.debug("Validating element {}", getElement());
if (!httpMethod.isBuiltIn()) {
validateHttpMethodAnnotation(httpMethod);
validateRetentionAnnotation(getElement());
@@ -55,8 +57,8 @@
if (annotation != null) { // if annotation is null, the resource is not a JaxrsHttpMethod anymore.
final String httpValue = annotation.getValue("value");
if (httpValue == null || httpValue.isEmpty()) {
- addProblem(JaxrsValidationMessages.HTTP_METHOD_INVALID_RETENTION_ANNOTATION_VALUE,
- JaxrsPreferences.HTTP_METHOD_INVALID_RETENTION_ANNOTATION_VALUE, new String[0], annotation
+ addProblem(JaxrsValidationMessages.HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE,
+ JaxrsPreferences.HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE, new String[0], annotation
.getSourceRange().getLength(), annotation.getSourceRange().getOffset(),
httpMethod.getResource());
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.java 2012-10-05 06:54:35 UTC (rev 44330)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.java 2012-10-05 07:01:03 UTC (rev 44331)
@@ -20,6 +20,7 @@
public class JaxrsPreferencesMessages extends NLS {
private static final String BUNDLE_NAME = "org.jboss.tools.ws.jaxrs.ui.preferences.JaxrsPreferencesMessages"; //$NON-NLS-1$
+
public static String JAXRS_SETTINGS_PREFERENCE_PAGE_JAXRS_SUPPORT;
// Validator Preference page
@@ -38,6 +39,7 @@
// Section HTTP Method
public static String JaxrsValidatorConfigurationBlock_section_httpMethods;
+ public static String JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidHttpMethodAnnotationValue_label;
public static String JaxrsValidatorConfigurationBlock_pb_httpMethodMissingRetentionAnnotation_label;
public static String JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidRetentionAnnotationValue_label;
public static String JaxrsValidatorConfigurationBlock_pb_httpMethodMissingTargetAnnotation_label;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.properties 2012-10-05 06:54:35 UTC (rev 44330)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsPreferencesMessages.properties 2012-10-05 07:01:03 UTC (rev 44331)
@@ -26,6 +26,7 @@
#Section HTTP Methods
JaxrsValidatorConfigurationBlock_section_httpMethods=User-defined HTTP Methods
+JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidHttpMethodAnnotationValue_label=Empty @HttpMethod annotation value
JaxrsValidatorConfigurationBlock_pb_httpMethodMissingRetentionAnnotation_label=Missing @Retention annotation:
JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidRetentionAnnotationValue_label=Invalid @Retention annotation value:
JaxrsValidatorConfigurationBlock_pb_httpMethodMissingTargetAnnotation_label=Missing @Target annotation:
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsValidatorConfigurationBlockDescriptionProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsValidatorConfigurationBlockDescriptionProvider.java 2012-10-05 06:54:35 UTC (rev 44330)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/preferences/JaxrsValidatorConfigurationBlockDescriptionProvider.java 2012-10-05 07:01:03 UTC (rev 44331)
@@ -47,6 +47,7 @@
private SectionDescription SECTION_HTTP_METHODS = new SectionDescription(
JaxrsPreferencesMessages.JaxrsValidatorConfigurationBlock_section_httpMethods,
new String[][]{
+ {JaxrsPreferences.HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE, JaxrsPreferencesMessages.JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidHttpMethodAnnotationValue_label},
{JaxrsPreferences.HTTP_METHOD_MISSING_RETENTION_ANNOTATION, JaxrsPreferencesMessages.JaxrsValidatorConfigurationBlock_pb_httpMethodMissingRetentionAnnotation_label},
{JaxrsPreferences.HTTP_METHOD_INVALID_RETENTION_ANNOTATION_VALUE, JaxrsPreferencesMessages.JaxrsValidatorConfigurationBlock_pb_httpMethodInvalidRetentionAnnotationValue_label},
{JaxrsPreferences.HTTP_METHOD_MISSING_RETENTION_ANNOTATION, JaxrsPreferencesMessages.JaxrsValidatorConfigurationBlock_pb_httpMethodMissingTargetAnnotation_label},
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorTestCase.java 2012-10-05 06:54:35 UTC (rev 44330)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsHttpMethodValidatorTestCase.java 2012-10-05 07:01:03 UTC (rev 44331)
@@ -13,8 +13,14 @@
import static org.hamcrest.Matchers.equalTo;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.changeAnnotation;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.deleteJaxrsMarkers;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.findJaxrsMarkers;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.MarkerUtils.hasPreferenceKey;
import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsClassname.HTTP_METHOD;
import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsClassname.TARGET;
+import static org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences.HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences.HTTP_METHOD_INVALID_TARGET_ANNOTATION_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.preferences.JaxrsPreferences.HTTP_METHOD_MISSING_TARGET_ANNOTATION;
import static org.junit.Assert.assertThat;
import java.util.HashSet;
@@ -63,13 +69,13 @@
// preconditions
final IType fooType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject);
final JaxrsBaseElement httpMethod = (JaxrsBaseElement) metamodel.getElement(fooType);
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(0));
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ assertThat(findJaxrsMarkers(httpMethod).length, equalTo(0));
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(0));
+ assertThat(findJaxrsMarkers(httpMethod).length, equalTo(0));
}
@Test
@@ -79,13 +85,14 @@
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
final Annotation httpAnnotation = changeAnnotation(fooType, HTTP_METHOD.qualifiedName, new String[0]);
httpMethod.addOrUpdateAnnotation(httpAnnotation);
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- final IMarker[] markers = MarkerUtils.findJaxrsMarkers(httpMethod);
+ final IMarker[] markers = findJaxrsMarkers(httpMethod);
assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE));
}
@Test
@@ -95,12 +102,14 @@
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
final Annotation httpAnnotation = changeAnnotation(fooType, HTTP_METHOD.qualifiedName, (String) null);
httpMethod.addOrUpdateAnnotation(httpAnnotation);
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(httpMethod);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(HTTP_METHOD_INVALID_HTTP_METHOD_ANNOTATION_VALUE));
}
@Test
@@ -110,12 +119,14 @@
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
final Annotation targetAnnotation = getAnnotation(fooType, TARGET.qualifiedName);
httpMethod.removeAnnotation(targetAnnotation);
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(httpMethod);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(HTTP_METHOD_MISSING_TARGET_ANNOTATION));
}
@Test
@@ -126,13 +137,14 @@
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
final Annotation targetAnnotation = changeAnnotation(fooType, TARGET.qualifiedName, (String) null);
httpMethod.addOrUpdateAnnotation(targetAnnotation);
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(1));
-
+ final IMarker[] markers = findJaxrsMarkers(httpMethod);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(HTTP_METHOD_INVALID_TARGET_ANNOTATION_VALUE));
}
@Test
@@ -143,12 +155,14 @@
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
final Annotation targetAnnotation = changeAnnotation(fooType, TARGET.qualifiedName, "FOO");
httpMethod.addOrUpdateAnnotation(targetAnnotation);
- MarkerUtils.deleteJaxrsMarkers(httpMethod);
+ deleteJaxrsMarkers(httpMethod);
// operation
new JaxrsMetamodelValidator().validate(toSet(httpMethod.getResource()), project, validationHelper, context,
validatorManager, reporter);
// validation
- assertThat(MarkerUtils.findJaxrsMarkers(httpMethod).length, equalTo(1));
+ final IMarker[] markers = findJaxrsMarkers(httpMethod);
+ assertThat(markers.length, equalTo(1));
+ assertThat(markers, hasPreferenceKey(HTTP_METHOD_INVALID_TARGET_ANNOTATION_VALUE));
}
}
12 years, 3 months