01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.tapestry.internal.test;
16:
17: import java.io.IOException;
18: import java.io.InputStream;
19: import java.net.URL;
20:
21: import org.apache.tapestry.internal.test.PageTesterContext;
22: import org.testng.Assert;
23: import org.testng.annotations.Test;
24:
25: public class PageTesterContextTest extends Assert {
26: @Test
27: public void to_URL() throws IOException {
28: PageTesterContext context = new PageTesterContext(
29: "src/test/app2");
30: URL resource = context.getResource("/OpaqueResource.txt");
31: InputStream stream = resource.openStream();
32: stream.close();
33: }
34:
35: @Test
36: public void to_URL_no_file() throws IOException {
37: PageTesterContext context = new PageTesterContext(
38: "src/test/app2");
39: URL resource = context.getResource("/NonExisting.txt");
40: assertNull(resource);
41: }
42:
43: @Test
44: public void to_URL_is_dir() throws IOException {
45: PageTesterContext context = new PageTesterContext("src/test");
46: URL resource = context.getResource("/app2");
47: assertNull(resource);
48: }
49: }
|