| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 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 | |
} |