Coverage Report - org.seasar.cubby.unit.MockServletContext
 
Classes in this File Line Coverage Branch Coverage Complexity
MockServletContext
11%
4/34
N/A
1.56
 
 1  
 /*
 2  
  * Copyright 2004-2010 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  
 
 17  
 package org.seasar.cubby.unit;
 18  
 
 19  
 import java.io.InputStream;
 20  
 import java.net.MalformedURLException;
 21  
 import java.net.URL;
 22  
 import java.util.Enumeration;
 23  
 import java.util.Hashtable;
 24  
 import java.util.Set;
 25  
 
 26  
 import javax.servlet.RequestDispatcher;
 27  
 import javax.servlet.Servlet;
 28  
 import javax.servlet.ServletContext;
 29  
 import javax.servlet.ServletException;
 30  
 
 31  
 import org.slf4j.Logger;
 32  
 import org.slf4j.LoggerFactory;
 33  
 
 34  
 /**
 35  
  * プラグインを初期化するためのサーブレットコンテキストのモックです。
 36  
  * 
 37  
  * @author baba
 38  
  */
 39  3
 class MockServletContext implements ServletContext {
 40  
 
 41  1
         private static final Logger logger = LoggerFactory
 42  
                         .getLogger(MockServletContext.class);
 43  
 
 44  3
         private Hashtable<String, String> initParameters = new Hashtable<String, String>();
 45  
 
 46  3
         private Hashtable<String, Object> attributes = new Hashtable<String, Object>();
 47  
 
 48  
         /**
 49  
          * {@inheritDoc}
 50  
          */
 51  
         public String getContextPath() {
 52  0
                 throw new UnsupportedOperationException();
 53  
         }
 54  
 
 55  
         /**
 56  
          * {@inheritDoc}
 57  
          */
 58  
         public ServletContext getContext(String uripath) {
 59  0
                 throw new UnsupportedOperationException();
 60  
         }
 61  
 
 62  
         /**
 63  
          * {@inheritDoc}
 64  
          */
 65  
         public int getMajorVersion() {
 66  0
                 return 2;
 67  
         }
 68  
 
 69  
         /**
 70  
          * {@inheritDoc}
 71  
          */
 72  
         public int getMinorVersion() {
 73  0
                 return 5;
 74  
         }
 75  
 
 76  
         /**
 77  
          * {@inheritDoc}
 78  
          */
 79  
         public String getMimeType(String file) {
 80  0
                 throw new UnsupportedOperationException();
 81  
         }
 82  
 
 83  
         /**
 84  
          * {@inheritDoc}
 85  
          */
 86  
         @SuppressWarnings("unchecked")
 87  
         public Set getResourcePaths(String path) {
 88  0
                 throw new UnsupportedOperationException();
 89  
         }
 90  
 
 91  
         /**
 92  
          * {@inheritDoc}
 93  
          */
 94  
         public URL getResource(String path) throws MalformedURLException {
 95  0
                 throw new UnsupportedOperationException();
 96  
         }
 97  
 
 98  
         /**
 99  
          * {@inheritDoc}
 100  
          */
 101  
         public InputStream getResourceAsStream(String path) {
 102  0
                 throw new UnsupportedOperationException();
 103  
         }
 104  
 
 105  
         /**
 106  
          * {@inheritDoc}
 107  
          */
 108  
         public RequestDispatcher getRequestDispatcher(String path) {
 109  0
                 throw new UnsupportedOperationException();
 110  
         }
 111  
 
 112  
         /**
 113  
          * {@inheritDoc}
 114  
          */
 115  
         public RequestDispatcher getNamedDispatcher(String name) {
 116  0
                 throw new UnsupportedOperationException();
 117  
         }
 118  
 
 119  
         /**
 120  
          * {@inheritDoc}
 121  
          */
 122  
         public Servlet getServlet(String name) throws ServletException {
 123  0
                 throw new UnsupportedOperationException();
 124  
         }
 125  
 
 126  
         /**
 127  
          * {@inheritDoc}
 128  
          */
 129  
         @SuppressWarnings("unchecked")
 130  
         public Enumeration getServlets() {
 131  0
                 throw new UnsupportedOperationException();
 132  
         }
 133  
 
 134  
         /**
 135  
          * {@inheritDoc}
 136  
          */
 137  
         @SuppressWarnings("unchecked")
 138  
         public Enumeration getServletNames() {
 139  0
                 throw new UnsupportedOperationException();
 140  
         }
 141  
 
 142  
         /**
 143  
          * {@inheritDoc}
 144  
          */
 145  
         public void log(String msg) {
 146  0
                 logger.info(msg);
 147  0
         }
 148  
 
 149  
         /**
 150  
          * {@inheritDoc}
 151  
          */
 152  
         public void log(Exception exception, String msg) {
 153  0
                 this.log(msg, exception);
 154  0
         }
 155  
 
 156  
         /**
 157  
          * {@inheritDoc}
 158  
          */
 159  
         public void log(String message, Throwable throwable) {
 160  0
                 logger.info(message, throwable);
 161  0
         }
 162  
 
 163  
         /**
 164  
          * {@inheritDoc}
 165  
          */
 166  
         public String getRealPath(String path) {
 167  0
                 throw new UnsupportedOperationException();
 168  
         }
 169  
 
 170  
         /**
 171  
          * {@inheritDoc}
 172  
          */
 173  
         public String getServerInfo() {
 174  0
                 throw new UnsupportedOperationException();
 175  
         }
 176  
 
 177  
         /**
 178  
          * {@inheritDoc}
 179  
          */
 180  
         public String getInitParameter(String name) {
 181  0
                 return initParameters.get(name);
 182  
         }
 183  
 
 184  
         /**
 185  
          * {@inheritDoc}
 186  
          */
 187  
         @SuppressWarnings("unchecked")
 188  
         public Enumeration getInitParameterNames() {
 189  0
                 return initParameters.keys();
 190  
         }
 191  
 
 192  
         /**
 193  
          * {@inheritDoc}
 194  
          */
 195  
         public Object getAttribute(String name) {
 196  0
                 return attributes.get(name);
 197  
         }
 198  
 
 199  
         /**
 200  
          * {@inheritDoc}
 201  
          */
 202  
         @SuppressWarnings("unchecked")
 203  
         public Enumeration getAttributeNames() {
 204  0
                 return attributes.keys();
 205  
         }
 206  
 
 207  
         /**
 208  
          * {@inheritDoc}
 209  
          */
 210  
         public void setAttribute(String name, Object object) {
 211  0
                 attributes.put(name, object);
 212  0
         }
 213  
 
 214  
         /**
 215  
          * {@inheritDoc}
 216  
          */
 217  
         public void removeAttribute(String name) {
 218  0
                 attributes.remove(name);
 219  0
         }
 220  
 
 221  
         /**
 222  
          * {@inheritDoc}
 223  
          */
 224  
         public String getServletContextName() {
 225  0
                 throw new UnsupportedOperationException();
 226  
         }
 227  
 
 228  
 }