1   /*
2    * Copyright 2004-2008 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.cubby.controller.impl;
17  
18  import static org.seasar.cubby.TestUtils.getPrivateField;
19  import junit.framework.TestCase;
20  
21  import org.seasar.cubby.controller.ActionContext;
22  import org.seasar.cubby.convention.CubbyConvention;
23  import org.seasar.cubby.convention.impl.CubbyConventionImpl;
24  
25  public class ActionProcessorImplTest extends TestCase {
26  
27  	public void testConstructor() throws Throwable {
28          new ActionProcessorImpl();
29          assertTrue("Test call resulted in expected outcome", true);
30      }
31      
32      public void testSetActionContext() throws Throwable {
33          ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl();
34          ActionContext context = new ActionContextImpl();
35          actionProcessorImpl.setActionContext(context);
36          assertSame("actionProcessorImpl.context", context, getPrivateField(actionProcessorImpl, "context"));
37      }
38      
39      public void testSetCubbyConvention() throws Throwable {
40          ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl();
41          CubbyConvention cubbyConvention = new CubbyConventionImpl();
42          actionProcessorImpl.setCubbyConvention(cubbyConvention);
43          assertSame("actionProcessorImpl.cubbyConvention", cubbyConvention, getPrivateField(actionProcessorImpl, "cubbyConvention"));
44      }
45      
46  //    public void testProcessThrowsStringIndexOutOfBoundsException() throws Throwable {
47  //        ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl();
48  //        MockServletContext mockServletContext = new MockServletContext();
49  //        mockServletContext.setContextBasePath("testActionProcessorImplParam1");
50  //        HttpServletResponse response = mockServletContext.createHttpServletResponse();
51  //        try {
52  //            actionProcessorImpl.process(mockServletContext.createHttpServletRequest("testActionProcessorImplParam1"), response, null);
53  //            fail("Expected StringIndexOutOfBoundsException to be thrown");
54  //        } catch (StringIndexOutOfBoundsException ex) {
55  //            assertEquals("(MockHttpServletResponse) response", "text/html; charset=UTF-8", ((MockHttpServletResponse) response).getContentType());
56  //            assertEquals("(MockHttpServletResponse) response", "UTF-8", ((MockHttpServletResponse) response).getCharacterEncoding());
57  //            assertEquals("ex.getMessage()", "String index out of range: -1", ex.getMessage());
58  //            assertThrownBy(String.class, ex);
59  //            assertNull("actionProcessorImpl.cubbyConvention", getPrivateField(actionProcessorImpl, "cubbyConvention"));
60  //            assertNull("actionProcessorImpl.context", getPrivateField(actionProcessorImpl, "context"));
61  //            boolean actual = ((Logger) getPrivateField(ActionProcessorImpl.class, "logger")).isDebugEnabled();
62  //            assertFalse("actionProcessorImplActionProcessorImpl.logger.isDebugEnabled()", actual);
63  //        }
64  //    }
65  }
66