[ 
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.

Reply via email to