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;
17  
18  import java.util.Map;
19  import java.util.PropertyResourceBundle;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  import org.seasar.extension.unit.S2TestCase;
24  
25  public class ThreadContextTest extends S2TestCase {
26  
27  	public HttpServletRequest request;
28  
29      public void testGetMessagesMap() throws Throwable {
30          Map<?, ?> result = ThreadContext.getMessagesMap();
31          assertEquals("result.size()", 13, result.size());
32          assertEquals("(HashMap) result.get(\"valid.arrayMaxSize\")", "{0}は{1}以下選択してください。", result.get("valid.arrayMaxSize"));
33      }
34      
35      public void testGetMessagesResourceBundle() throws Throwable {
36          PropertyResourceBundle result = (PropertyResourceBundle) ThreadContext.getMessagesResourceBundle();
37          assertTrue("result.getKeys().hasMoreElements()", result.getKeys().hasMoreElements());
38      }
39      
40      public void testGetRequest() throws Throwable {
41          ThreadContext.setRequest(request);
42          HttpServletRequest result = ThreadContext.getRequest();
43          assertSame("ThreadContext.getRequest()", request, result);
44      }
45      
46      public void testRemove() throws Throwable {
47          ThreadContext.setRequest(request);
48          ThreadContext.remove();
49          assertNull("ThreadContext.remove()", ThreadContext.getRequest());
50      }
51      
52  }
53