| 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.services.Context; |
| 18 | |
import org.apache.tapestry5.test.TapestryTestConstants; |
| 19 | |
|
| 20 | |
import java.io.File; |
| 21 | |
import java.net.MalformedURLException; |
| 22 | |
import java.net.URL; |
| 23 | |
import java.util.Collections; |
| 24 | |
import java.util.List; |
| 25 | |
|
| 26 | |
public class PageTesterContext implements Context |
| 27 | |
{ |
| 28 | |
private final File contextRoot; |
| 29 | |
|
| 30 | |
public PageTesterContext(String contextRoot) |
| 31 | 52 | { |
| 32 | 52 | this.contextRoot = new File(TapestryTestConstants.MODULE_BASE_DIR, contextRoot); |
| 33 | 52 | } |
| 34 | |
|
| 35 | |
public String getInitParameter(String name) |
| 36 | |
{ |
| 37 | 0 | return null; |
| 38 | |
} |
| 39 | |
|
| 40 | |
public URL getResource(String path) |
| 41 | |
{ |
| 42 | 76 | File f = new File(contextRoot + path); |
| 43 | |
|
| 44 | 76 | if (!f.exists() || !f.isFile()) |
| 45 | |
{ |
| 46 | 42 | return null; |
| 47 | |
} |
| 48 | |
try |
| 49 | |
{ |
| 50 | 34 | return f.toURL(); |
| 51 | |
} |
| 52 | 0 | catch (MalformedURLException ex) |
| 53 | |
{ |
| 54 | 0 | throw new RuntimeException(ex); |
| 55 | |
} |
| 56 | |
} |
| 57 | |
|
| 58 | |
public List<String> getResourcePaths(String path) |
| 59 | |
{ |
| 60 | 0 | throw new UnsupportedOperationException("getResourcePaths() is not supported for ContextForPageTester."); |
| 61 | |
} |
| 62 | |
|
| 63 | |
public Object getAttribute(String name) |
| 64 | |
{ |
| 65 | 0 | throw new UnsupportedOperationException("getAttribute() is not supported for ContextForPageTester."); |
| 66 | |
} |
| 67 | |
|
| 68 | |
public List<String> getAttributeNames() |
| 69 | |
{ |
| 70 | 0 | return Collections.emptyList(); |
| 71 | |
} |
| 72 | |
|
| 73 | |
public String getMimeType(String file) |
| 74 | |
{ |
| 75 | 0 | return null; |
| 76 | |
} |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public File getRealFile(String path) |
| 82 | |
{ |
| 83 | 60 | return null; |
| 84 | |
} |
| 85 | |
} |