Coverage Report - org.apache.tapestry5.internal.test.PageTesterSession
 
Classes in this File Line Coverage Branch Coverage Complexity
PageTesterSession
57%
12/21
100%
6/6
0
 
 1  
 // Copyright 2006, 2007, 2008 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.internal.test;
 16  
 
 17  
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 18  
 import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
 19  
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 20  
 import org.apache.tapestry5.services.Session;
 21  
 
 22  
 import java.util.List;
 23  
 import java.util.Map;
 24  
 
 25  24
 public class PageTesterSession implements Session
 26  
 {
 27  24
     private final Map<String, Object> attributes = CollectionFactory.newMap();
 28  
 
 29  
     public List<String> getAttributeNames()
 30  
     {
 31  36
         return InternalUtils.sortedKeys(attributes);
 32  
     }
 33  
 
 34  
     public List<String> getAttributeNames(String prefix)
 35  
     {
 36  28
         List<String> result = newList();
 37  
 
 38  28
         for (String name : getAttributeNames())
 39  34
             if (name.startsWith(prefix)) result.add(name);
 40  
 
 41  28
         return result;
 42  
     }
 43  
 
 44  
     public Object getAttribute(String name)
 45  
     {
 46  36
         return attributes.get(name);
 47  
     }
 48  
 
 49  
     public void setAttribute(String name, Object value)
 50  
     {
 51  100
         if (value == null)
 52  
         {
 53  24
             attributes.remove(name);
 54  
         }
 55  
         else
 56  
         {
 57  76
             attributes.put(name, value);
 58  
         }
 59  100
     }
 60  
 
 61  
     private void nyi(String name)
 62  
     {
 63  0
         throw new IllegalStateException(String.format("%s.%s() is not yet implemented.", getClass()
 64  
                 .getName(), name));
 65  
     }
 66  
 
 67  
     public int getMaxInactiveInterval()
 68  
     {
 69  0
         nyi("getMaxInativeInterval");
 70  
 
 71  0
         return 0;
 72  
     }
 73  
 
 74  
     public void invalidate()
 75  
     {
 76  0
         nyi("invalidate");
 77  0
     }
 78  
 
 79  
     public boolean isInvalidated()
 80  
     {
 81  0
         return false;
 82  
     }
 83  
 
 84  
     public void restoreDirtyObjects()
 85  
     {
 86  0
     }
 87  
 
 88  
     public void setMaxInactiveInterval(int seconds)
 89  
     {
 90  0
         nyi("setMaxInactiveInterval");
 91  0
     }
 92  
 }