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.dom.Document;
19: import org.apache.tapestry.internal.test.InternalBaseTestCase;
20: import org.apache.tapestry.services.Environment;
21: import org.testng.annotations.Test;
22:
23: public class InjectStandardStylesheetCommandTest extends
24: InternalBaseTestCase {
25: @Test
26: public void no_head_element() {
27: Document d = new Document();
28: Environment env = mockEnvironment();
29: Asset asset = mockAsset();
30:
31: d.newRootElement("foo");
32: String initial = d.toString();
33:
34: train_peek(env, Document.class, d);
35:
36: replay();
37:
38: new InjectStandardStylesheetCommand(asset).cleanup(env);
39:
40: assertEquals(d.toString(), initial,
41: "Document structure should not change.");
42:
43: verify();
44: }
45:
46: @Test
47: public void head_element_found() {
48: Document d = new Document();
49: Environment env = mockEnvironment();
50: Asset asset = mockAsset();
51:
52: d.newRootElement("html").element("head");
53:
54: train_peek(env, Document.class, d);
55:
56: train_toClientURL(asset, "{clientURL}");
57:
58: replay();
59:
60: new InjectStandardStylesheetCommand(asset).cleanup(env);
61:
62: verify();
63:
64: assertEquals(
65: d.toString(),
66: "<html><head><link href=\"{clientURL}\" rel=\"stylesheet\" type=\"text/css\"></head></html>");
67: }
68: }
|