You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Eung-ju PARK (JIRA)" <ji...@apache.org> on 2009/02/04 18:01:46 UTC

[jira] Created: (WW-2983) Anonymous Action classes cause IndexOutOfBoundException

Anonymous Action classes cause IndexOutOfBoundException
-------------------------------------------------------

                 Key: WW-2983
                 URL: https://issues.apache.org/struts/browse/WW-2983
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Convention
    Affects Versions: 2.1.6
            Reporter: Eung-ju PARK
            Priority: Minor


I have some anonymous Action classes in unit test code. Anonymous classes have no name. Class#getSimpleName returns "". It causes IndexOutOfBoundException when initialing convention-plugin.

PackageBasedActionConfigBuilder#buildConfiguration skips all interfaces, enums, annotations, and abstract classes. It should skip anonymous classes too. Add actionClass.isAnonymous() to the skip condition.

I have some anonymous Action classs in my unit test code. It's not good design.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2983) Anonymous Action classes cause IndexOutOfBoundException

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45596#action_45596 ] 

Musachy Barroso commented on WW-2983:
-------------------------------------

I see, I was very skeptical on how the plugin could found these classes. Checking for anonymous won't break anything so it can be added for convenience.

> Anonymous Action classes cause IndexOutOfBoundException
> -------------------------------------------------------
>
>                 Key: WW-2983
>                 URL: https://issues.apache.org/struts/browse/WW-2983
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Eung-ju PARK
>            Priority: Minor
>
> I have some anonymous Action classes in unit test code. Anonymous classes have no name. Class#getSimpleName returns "". It causes IndexOutOfBoundException when initialing convention-plugin.
> PackageBasedActionConfigBuilder#buildConfiguration skips all interfaces, enums, annotations, and abstract classes. It should skip anonymous classes too. Add actionClass.isAnonymous() to the skip condition.
> I have some anonymous Action classs in my unit test code. It's not good design.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2983) Anonymous Action classes cause IndexOutOfBoundException

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45585#action_45585 ] 

Musachy Barroso commented on WW-2983:
-------------------------------------

how does the plugin finds anonymous classes? do you mean inner classes? Can you post an example?

> Anonymous Action classes cause IndexOutOfBoundException
> -------------------------------------------------------
>
>                 Key: WW-2983
>                 URL: https://issues.apache.org/struts/browse/WW-2983
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Eung-ju PARK
>            Priority: Minor
>
> I have some anonymous Action classes in unit test code. Anonymous classes have no name. Class#getSimpleName returns "". It causes IndexOutOfBoundException when initialing convention-plugin.
> PackageBasedActionConfigBuilder#buildConfiguration skips all interfaces, enums, annotations, and abstract classes. It should skip anonymous classes too. Add actionClass.isAnonymous() to the skip condition.
> I have some anonymous Action classs in my unit test code. It's not good design.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-2983) Anonymous Action classes cause IndexOutOfBoundException

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-2983.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.7

> Anonymous Action classes cause IndexOutOfBoundException
> -------------------------------------------------------
>
>                 Key: WW-2983
>                 URL: https://issues.apache.org/struts/browse/WW-2983
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Eung-ju PARK
>            Priority: Minor
>             Fix For: 2.1.7
>
>
> I have some anonymous Action classes in unit test code. Anonymous classes have no name. Class#getSimpleName returns "". It causes IndexOutOfBoundException when initialing convention-plugin.
> PackageBasedActionConfigBuilder#buildConfiguration skips all interfaces, enums, annotations, and abstract classes. It should skip anonymous classes too. Add actionClass.isAnonymous() to the skip condition.
> I have some anonymous Action classs in my unit test code. It's not good design.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2983) Anonymous Action classes cause IndexOutOfBoundException

Posted by "Eung-ju PARK (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45595#action_45595 ] 

Eung-ju PARK commented on WW-2983:
----------------------------------

I mean ANONYMOUS classes, not INNER classes. I have anonymous Action classes in test cases to test abstract Actions or to bypass complex logics. Here is the examples.

-- To test abstract PageAction --
	private PageAction action;

	@Before public void beforeEach() {
		action = new PageAction() {};
	}
	
	@Test public void shouldAcceptAndPublicPageId() {
		action.setPageId(1);
		assertEquals(1, action.getRequestedPageId());
	}
	...

-- To bypass complex logic in ViewPageAction --
	@Before public void beforeEach() {
		action = new ViewPageAction() {
			boolean isPageBookmarkedByUser(Page page, User user) {
				return true;
			}
			VisitPage visitPage() {
				return null;
			}
		};

		coreService = mockery.mock(CoreService.class);
		action.setCoreService(coreService);
		uiService = mockery.mock(UiService.class);
		action.setUiService(uiService);
		pageRepository = mockery.mock(PageRepository.class);
		action.setPageRepository(pageRepository);
		pageAttachmentRepository = mockery.mock(PageAttachmentRepository.class);
		action.setPageAttachmentRepository(pageAttachmentRepository);
		wiki = WikiTest.publicWiki();
		action.setWiki(wiki);
		User user = UserTest.FOO;
		action.setUser(user);
	}
	
	@Test public void success() {
		final Page page = PageTest.FOO_PAGE;
		final String text = "Content of the page";
		final PageRevision latestRevision = MockPageRevision.FOO_REV2;
		...

My IDE(Eclipse) load all classes in the classpath. Unfortunately My IDE can't exclude tests when run the web application. In production, there is no test classes in classpath so not a problem.

> Anonymous Action classes cause IndexOutOfBoundException
> -------------------------------------------------------
>
>                 Key: WW-2983
>                 URL: https://issues.apache.org/struts/browse/WW-2983
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Eung-ju PARK
>            Priority: Minor
>
> I have some anonymous Action classes in unit test code. Anonymous classes have no name. Class#getSimpleName returns "". It causes IndexOutOfBoundException when initialing convention-plugin.
> PackageBasedActionConfigBuilder#buildConfiguration skips all interfaces, enums, annotations, and abstract classes. It should skip anonymous classes too. Add actionClass.isAnonymous() to the skip condition.
> I have some anonymous Action classs in my unit test code. It's not good design.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.