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.controller.ActionDefBuilder; 23 24 public class ActionProcessorImplTest extends TestCase { 25 26 public void testConstructor() throws Throwable { 27 new ActionProcessorImpl(); 28 assertTrue("Test call resulted in expected outcome", true); 29 } 30 31 public void testSetActionContext() throws Throwable { 32 ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl(); 33 ActionContext context = new ActionContextImpl(); 34 actionProcessorImpl.setActionContext(context); 35 assertSame("actionProcessorImpl.context", context, getPrivateField(actionProcessorImpl, "context")); 36 } 37 38 public void testSetActionDefBuilder() throws Throwable { 39 ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl(); 40 ActionDefBuilder actionDefBuilder = new ActionDefBuilderImpl(); 41 actionProcessorImpl.setActionDefBuilder(actionDefBuilder); 42 assertSame("actionProcessorImpl.actionDefBuilder", actionDefBuilder, getPrivateField(actionProcessorImpl, "actionDefBuilder")); 43 } 44 45 // public void testProcessThrowsStringIndexOutOfBoundsException() throws Throwable { 46 // ActionProcessorImpl actionProcessorImpl = new ActionProcessorImpl(); 47 // MockServletContext mockServletContext = new MockServletContext(); 48 // mockServletContext.setContextBasePath("testActionProcessorImplParam1"); 49 // HttpServletResponse response = mockServletContext.createHttpServletResponse(); 50 // try { 51 // actionProcessorImpl.process(mockServletContext.createHttpServletRequest("testActionProcessorImplParam1"), response, null); 52 // fail("Expected StringIndexOutOfBoundsException to be thrown"); 53 // } catch (StringIndexOutOfBoundsException ex) { 54 // assertEquals("(MockHttpServletResponse) response", "text/html; charset=UTF-8", ((MockHttpServletResponse) response).getContentType()); 55 // assertEquals("(MockHttpServletResponse) response", "UTF-8", ((MockHttpServletResponse) response).getCharacterEncoding()); 56 // assertEquals("ex.getMessage()", "String index out of range: -1", ex.getMessage()); 57 // assertThrownBy(String.class, ex); 58 // assertNull("actionProcessorImpl.cubbyConvention", getPrivateField(actionProcessorImpl, "cubbyConvention")); 59 // assertNull("actionProcessorImpl.context", getPrivateField(actionProcessorImpl, "context")); 60 // boolean actual = ((Logger) getPrivateField(ActionProcessorImpl.class, "logger")).isDebugEnabled(); 61 // assertFalse("actionProcessorImplActionProcessorImpl.logger.isDebugEnabled()", actual); 62 // } 63 // } 64 } 65