KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > storeconfig > StoreRegistryTest


1 /*
2  * Copyright 1999-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.catalina.storeconfig;
17
18 import java.io.PrintWriter JavaDoc;
19 import java.io.StringWriter JavaDoc;
20
21 import junit.framework.TestCase;
22
23 import org.apache.catalina.core.StandardServer;
24
25 /**
26  * @author Peter Rossbach
27  *
28  */

29 public class StoreRegistryTest extends TestCase {
30
31     StoreRegistry registry;
32
33     StringWriter JavaDoc writer = new StringWriter JavaDoc();
34
35     PrintWriter JavaDoc pWriter = new PrintWriter JavaDoc(writer);
36
37     StandardServer standardServer = new StandardServer();
38
39     IStoreFactory factory;
40
41     StoreDescription desc;
42
43     /*
44      * create registry and register Server
45      *
46      * @see junit.framework.TestCase#setUp()
47      */

48     protected void setUp() throws Exception JavaDoc {
49
50         super.setUp();
51         registry = new StoreRegistry();
52         desc = new StoreDescription();
53         desc.setTag("Server");
54         desc.setTagClass("org.apache.catalina.core.StandardServer");
55         desc.setStandard(true);
56         desc
57                 .setStoreFactoryClass("org.apache.catalina.storeconfig.StoreFactoryBase");
58         registry.registerDescription(desc);
59         factory = new StoreFactoryBase();
60         factory.setRegistry(registry);
61     }
62
63     public void testSaveServer() throws Exception JavaDoc {
64         assertNotNull(registry.findDescription(StandardServer.class));
65         factory.store(pWriter, -2, standardServer);
66         assertEquals("XML Diff", "<Server/>" + LF.LINE_SEPARATOR, writer
67                 .toString());
68     }
69
70     public void testAttributes() throws Exception JavaDoc {
71         standardServer.setPort(7305);
72         factory.store(pWriter, -2, standardServer);
73         assertEquals("XML Diff", "<Server" + LF.LINE_SEPARATOR
74                 + " port=\"7305\"/>" + LF.LINE_SEPARATOR, writer.toString());
75
76     }
77
78 }
Popular Tags