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