01: // Copyright 2006, 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.services;
16:
17: import org.apache.tapestry.Asset;
18: import org.apache.tapestry.internal.test.InternalBaseTestCase;
19: import org.apache.tapestry.ioc.Resource;
20: import org.apache.tapestry.services.AssetFactory;
21: import org.apache.tapestry.services.Context;
22: import org.apache.tapestry.services.Request;
23: import org.testng.annotations.Test;
24:
25: public class ContextAssetFactoryTest extends InternalBaseTestCase {
26: @Test
27: public void root_resource() {
28: Context context = mockContext();
29: Request request = mockRequest();
30:
31: replay();
32:
33: AssetFactory factory = new ContextAssetFactory(request, context);
34:
35: assertEquals(factory.getRootResource().toString(), "context:/");
36:
37: verify();
38: }
39:
40: @Test
41: public void asset_client_URL() {
42: Context context = mockContext();
43: Request request = mockRequest();
44:
45: Resource r = new ContextResource(context, "foo/Bar.txt");
46:
47: train_getContextPath(request, "/context");
48:
49: replay();
50:
51: AssetFactory factory = new ContextAssetFactory(request, context);
52:
53: Asset asset = factory.createAsset(r);
54:
55: assertSame(asset.getResource(), r);
56: assertEquals(asset.toClientURL(), "/context/foo/Bar.txt");
57: assertEquals(asset.toString(), asset.toClientURL());
58:
59: verify();
60: }
61:
62: }
|