Author: akazakov
Date: 2008-01-25 13:03:55 -0500 (Fri, 25 Jan 2008)
New Revision: 5974
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.1
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/UsualComponent.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.2
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1690 Fixed. Check duplicate @Remove methods only
in stateful sessian bean components.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-01-25
17:10:32 UTC (rev 5973)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-01-25
18:03:55 UTC (rev 5974)
@@ -501,6 +501,7 @@
ISeamTextSourceReference location = getScopeLocation(component);
addError(STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID,
SeamPreferences.STATEFUL_COMPONENT_WRONG_SCOPE, new String[]{component.getName()},
location, javaDeclaration.getResource());
}
+ validateDuplicateComponentMethod(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_REMOVE);
}
}
@@ -515,7 +516,6 @@
private void validateDuplicateComponentMethods(ISeamComponent component) {
validateDuplicateComponentMethod(SeamComponentMethodType.DESTROY, component,
DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_DESTROY);
- validateDuplicateComponentMethod(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_REMOVE);
validateDuplicateComponentMethod(SeamComponentMethodType.CREATE, component,
CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_CREATE);
validateDuplicateComponentMethod(SeamComponentMethodType.UNWRAP, component,
UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_UNWRAP);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-01-25
17:10:32 UTC (rev 5973)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-01-25
18:03:55 UTC (rev 5974)
@@ -28,10 +28,10 @@
##Section Entities
SeamValidatorConfigurationBlock_section_entities=Entities
SeamValidatorConfigurationBlock_pb_entityComponentHasWrongScope_label=Entity component
has wrong scope:
-SeamValidatorConfigurationBlock_pb_duplicateRemove_label=Duplicate @Remove method:
##Section Component life-cycle methods
SeamValidatorConfigurationBlock_section_lifecycle=Component life-cycle methods:
+SeamValidatorConfigurationBlock_pb_duplicateRemove_label=Duplicate @Remove method for
stateful session bean:
SeamValidatorConfigurationBlock_pb_duplicateDestroy_label=Duplicate @Destroy method:
SeamValidatorConfigurationBlock_pb_duplicateCreate_label=Duplicate @Create method:
SeamValidatorConfigurationBlock_pb_duplicateUnwrap_label=Duplicate @Unwrap method:
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2008-01-25
17:10:32 UTC (rev 5973)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2008-01-25
18:03:55 UTC (rev 5974)
@@ -69,14 +69,14 @@
private static SectionDescription SECTION_ENTITY = new SectionDescription(
SeamPreferencesMessages.SeamValidatorConfigurationBlock_section_entities,
new String[][]{
- {SeamPreferences.ENTITY_COMPONENT_WRONG_SCOPE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_entityComponentHasWrongScope_label},
- {SeamPreferences.DUPLICATE_REMOVE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateRemove_label},
+ {SeamPreferences.ENTITY_COMPONENT_WRONG_SCOPE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_entityComponentHasWrongScope_label}
}
);
private static SectionDescription SECTION_LIFECYCLE = new SectionDescription(
SeamPreferencesMessages.SeamValidatorConfigurationBlock_section_lifecycle,
new String[][]{
+ {SeamPreferences.DUPLICATE_REMOVE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateRemove_label},
{SeamPreferences.DUPLICATE_DESTROY,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateDestroy_label},
{SeamPreferences.DUPLICATE_CREATE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateCreate_label},
{SeamPreferences.DUPLICATE_UNWRAP,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateUnwrap_label},
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.2
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.2 2008-01-25
17:10:32 UTC (rev 5973)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.2 2008-01-25
18:03:55 UTC (rev 5974)
@@ -12,7 +12,7 @@
http://jboss.com/products/seam/mail
http://jboss.com/products/seam/mail-1.2.xsd
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-1.1.xsd">
- <component class="org.domain.SeamWebTestProject.session.StateComponent"
name="statefulComponent" scope="application">
+ <component class="org.domain.SeamWebTestProject.session.StateComponent"
name="stateComponent" scope="application">
<property name="abc">value1</property>
</component>
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.1
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.1
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.1 2008-01-25
18:03:55 UTC (rev 5974)
@@ -0,0 +1,24 @@
+package org.domain.SeamWebWarTestProject.session;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+
+@Stateful
+@Name("statefulComponent")
+public class StatefulComponent {
+
+ @Destroy
+ public void destroyMethod(){
+ }
+
+ @Remove
+ public void removeMethod1(){
+ }
+
+ @Remove
+ public void removeMethod2(){
+ }
+}
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/UsualComponent.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/UsualComponent.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/UsualComponent.java 2008-01-25
18:03:55 UTC (rev 5974)
@@ -0,0 +1,14 @@
+package org.domain.SeamWebWarTestProject.session;
+
+import org.jboss.seam.annotations.Name;
+import javax.ejb.Remove;
+
+@Name("usualComponent")
+public class UsualComponent {
+
+ @Remove
+ public void removeMethod1() {}
+
+ @Remove
+ public void removeMethod2() {}
+}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-01-25
17:10:32 UTC (rev 5973)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-01-25
18:03:55 UTC (rev 5974)
@@ -22,20 +22,13 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.internal.decorators.DecoratorManager;
-import org.eclipse.ui.progress.UIJob;
-import org.jboss.tools.common.model.XJob;
-import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamPreferences;
-import org.jboss.tools.seam.core.test.project.facet.TestUtils;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.test.util.JUnitUtils;
-import org.jboss.tools.test.util.ResourcesUtils;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
public class SeamValidatorsTest extends TestCase {
@@ -61,8 +54,7 @@
assertNotNull("Seam project is null", seamProject);
return seamProject;
}
-
-
+
public void testComponentsValidator() {
ISeamProject seamProject = getSeamProject(project);
@@ -187,10 +179,10 @@
refreshProject(project);
number = getMarkersNumber(componentsFile);
- assertFalse("Problem marker 'Component class name cannot be resolved to a
type' not found' not found' not found", number == 0);
+ assertFalse("Problem marker 'Component class name cannot be resolved to a
type' was not found", number == 0);
messages = getMarkersMessage(componentsFile);
- assertTrue("Problem marker 'Component class name cannot be resolved to a
type' not found",
"\"org.domain.SeamWebTestProject.session.StateComponent\" cannot be
resolved to a type".equals(messages[0]));
+ assertTrue("Problem marker 'Component class name cannot be resolved to a
type' was not found",
"\"org.domain.SeamWebTestProject.session.StateComponent\" cannot be
resolved to a type".equals(messages[0]));
lineNumbers = getMarkersNumbersOfLine(componentsFile);
@@ -257,64 +249,29 @@
JUnitUtils.fail("Error in changing 'abcEntity.java' content to " +
"'abcEntity.2'", ex);
}
-
+
refreshProject(project);
-
+
number = getMarkersNumber(abcEntityFile);
assertFalse("Problem marker 'Entity component has wrong scope' not
found' not found' not found", number == 0);
-
+
String[] messages = getMarkersMessage(abcEntityFile);
assertTrue("Problem marker 'Entity component has wrong scope' not
found", "Entity component \"abcEntity\" should not have
org.jboss.seam.ScopeType.STATELESS".equals(messages[0]));
int[] lineNumbers = getMarkersNumbersOfLine(abcEntityFile);
-
- assertTrue("Problem marker has wrong line number", lineNumbers[0] == 15);
-
- // Duplicate @Remove method
- System.out.println("Test - Duplicate @Remove method");
-
- IFile abcEntityFile3 =
project.getFile("src/action/org/domain/SeamWebWarTestProject/entity/abcEntity.3");
- try{
- abcEntityFile.setContents(abcEntityFile3.getContents(), true, false, new
NullProgressMonitor());
- }catch(Exception ex){
- JUnitUtils.fail("Error in changing 'abcEntity.java' content to " +
- "'abcEntity.3'", ex);
- }
-
- refreshProject(project);
-
- number = getMarkersNumber(abcEntityFile);
- assertFalse("Problem marker 'Duplicate @Remove method' not found' not
found' not found", number == 0);
-
- messages = getMarkersMessage(abcEntityFile);
- assertTrue("Problem marker 'Duplicate @Remove method' not found",
messages[0].startsWith("Duplicate @Remove method \"removeMethod"));
- lineNumbers = getMarkersNumbersOfLine(abcEntityFile);
-
- assertTrue("Wrong number of problem markers", lineNumbers.length ==
messages.length && messages.length == 2);
-
- if(messages[1].indexOf("removeMethod2") >= 0){
- assertTrue("Problem marker has wrong line number", lineNumbers[0] == 42);
- assertTrue("Problem marker has wrong line number", lineNumbers[1] == 47);
- }else{
- assertTrue("Problem marker has wrong line number", lineNumbers[0] == 47);
- assertTrue("Problem marker has wrong line number", lineNumbers[1] == 42);
-
- }
+ assertTrue("Problem marker has wrong line number", lineNumbers[0] == 15);
}
public void testComponentLifeCycleMethodsValidator() {
ISeamProject seamProject = getSeamProject(project);
IFile componentsFile = project.getFile("WebContent/WEB-INF/components.xml");
-
+
IFile statefulComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.java");
-
- int number = getMarkersNumber(statefulComponentFile);
- assertTrue("Problem marker was found in StatefulComponent.java file", number
== 0);
// Duplicate @Destroy method
System.out.println("Test - Duplicate @Destroy method");
-
+
IFile statefulComponentFile6 =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.6");
try{
statefulComponentFile.setContents(statefulComponentFile6.getContents(), true, false,
new NullProgressMonitor());
@@ -324,12 +281,12 @@
}
refreshProject(project);
+
+ int number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Duplicate @Destroy method' was not
found", number == 0);
- number = getMarkersNumber(statefulComponentFile);
- assertFalse("Problem marker 'Duplicate @Destroy method' not found' not
found' not found", number == 0);
-
String[] messages = getMarkersMessage(statefulComponentFile);
- assertTrue("Problem marker 'Duplicate @Destroy method' not found",
messages[0].startsWith("Duplicate @Destroy method \"destroyMethod"));
+ assertTrue("Problem marker 'Duplicate @Destroy method' was not
found", messages[0].startsWith("Duplicate @Destroy method
\"destroyMethod"));
int[] lineNumbers = getMarkersNumbersOfLine(statefulComponentFile);
@@ -358,10 +315,10 @@
refreshProject(project);
number = getMarkersNumber(statefulComponentFile);
- assertFalse("Problem marker 'Duplicate @Create method' not found' not
found' not found", number == 0);
+ assertFalse("Problem marker 'Duplicate @Create method' was not found'
not found' not found", number == 0);
messages = getMarkersMessage(statefulComponentFile);
- assertTrue("Problem marker 'Duplicate @Create method' not found",
messages[0].startsWith("Duplicate @Create method \"createMethod"));
+ assertTrue("Problem marker 'Duplicate @Create method' was not found",
messages[0].startsWith("Duplicate @Create method \"createMethod"));
lineNumbers = getMarkersNumbersOfLine(statefulComponentFile);
@@ -390,10 +347,10 @@
refreshProject(project);
number = getMarkersNumber(statefulComponentFile);
- assertFalse("Problem marker 'Duplicate @Unwrap method' not found' not
found' not found", number == 0);
+ assertFalse("Problem marker 'Duplicate @Unwrap method' was not found'
not found' not found", number == 0);
messages = getMarkersMessage(statefulComponentFile);
- assertTrue("Problem marker 'Duplicate @Unwrap method' not found",
messages[0].startsWith("Duplicate @Unwrap method \"unwrapMethod"));
+ assertTrue("Problem marker 'Duplicate @Unwrap method' was not found",
messages[0].startsWith("Duplicate @Unwrap method \"unwrapMethod"));
lineNumbers = getMarkersNumbersOfLine(statefulComponentFile);
@@ -507,8 +464,49 @@
lineNumbers = getMarkersNumbersOfLine(statefulComponentFile);
assertTrue("Problem marker has wrong line number", lineNumbers[0] == 23);
+
+ // Duplicate @Remove method
+
+ IFile statefulComponentFile1 =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.1");
+ try{
+ statefulComponentFile.setContents(statefulComponentFile1.getContents(), true, false,
new NullProgressMonitor());
+ }catch(Exception ex){
+ JUnitUtils.fail("Error in changing 'StatefulComponent.java' content to
" +
+ "'StatefulComponent.1'", ex);
+ }
+
+ refreshProject(project);
+
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Duplicate @Remove method' not found",
number == 0);
+
+ messages = getMarkersMessage(statefulComponentFile);
+ assertTrue("Problem marker 'Duplicate @Remove method' not found",
messages[0].startsWith("Duplicate @Remove method \"removeMethod"));
+
+ lineNumbers = getMarkersNumbersOfLine(statefulComponentFile);
+
+ assertTrue("Wrong number of problem markers", lineNumbers.length ==
messages.length && messages.length == 2);
+
+ if(messages[1].indexOf("removeMethod2") >= 0){
+ assertTrue("Problem marker has wrong line number", lineNumbers[0] == 17);
+ assertTrue("Problem marker has wrong line number", lineNumbers[1] == 21);
+ }else{
+ assertTrue("Problem marker has wrong line number", lineNumbers[0] == 21);
+ assertTrue("Problem marker has wrong line number", lineNumbers[1] == 17);
+ }
}
-
+
+ /**
+ * The validator should check duplicate @Remove methods only in stateful session bean
component
+ * This method tests usual component (not stateful sessian bean) with two @Remove
methods. It must not have error markers.
+ */
+ public void testDuplicateRemoveMethodInComponent() {
+ getSeamProject(project);
+ IFile componentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/UsualComponent.java");
+ int number = getMarkersNumber(componentFile);
+ assertTrue("Problem marker was found in UsualComponent.java file", number ==
0);
+ }
+
public void testFactoriesValidator() {
ISeamProject seamProject = getSeamProject(project);