KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > source > test > SourceResolverImplTestCase


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * 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
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.excalibur.source.test;
18
19 import java.io.File JavaDoc;
20
21 import junit.framework.TestCase;
22
23 import org.apache.avalon.framework.context.DefaultContext;
24 import org.apache.avalon.framework.logger.ConsoleLogger;
25 import org.apache.avalon.framework.logger.Logger;
26 import org.apache.avalon.framework.service.DefaultServiceManager;
27 import org.apache.avalon.framework.service.DefaultServiceSelector;
28 import org.apache.excalibur.source.SourceFactory;
29 import org.apache.excalibur.source.impl.ResourceSourceFactory;
30 import org.apache.excalibur.source.impl.SourceResolverImpl;
31
32 /**
33  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
34  */

35 public class SourceResolverImplTestCase extends TestCase
36 {
37
38     public SourceResolverImplTestCase( )
39     {
40         this( "source" );
41     }
42
43     public SourceResolverImplTestCase( String JavaDoc name )
44     {
45         super( name );
46     }
47
48     public void testResolver() throws Exception JavaDoc
49     {
50         Logger logger = new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG );
51
52         //
53
// create the component to handle source resolution
54
//
55

56         final SourceResolverImpl resolver = new SourceResolverImpl();
57         resolver.enableLogging( logger );
58
59         //
60
// create the context argument and set the root directory and
61
// contextualize the resolver
62
//
63
// NOTE: javadoc needed on contextualize method
64
//
65

66         final DefaultContext context = new DefaultContext();
67         context.put( "context-root", new File JavaDoc( System.getProperty( "user.dir" ) ) );
68         resolver.contextualize( context );
69
70         //
71
// create a service selector to be included in a service manager
72
// to be supplied to the resolver
73
//
74

75         final ResourceSourceFactory factory = new ResourceSourceFactory();
76         factory.enableLogging( logger.getChildLogger( "factory" ) );
77
78         // create a selector and add the factory to the selector,
79
// add the selector to the manager, and service the resolver
80
// NOTE: javadoc missing on the serviceable method
81
//
82

83         final DefaultServiceSelector selector = new DefaultServiceSelector();
84         selector.put( "resource", factory );
85
86         final DefaultServiceManager manager = new DefaultServiceManager();
87         manager.put( SourceFactory.ROLE + "Selector", selector );
88
89         resolver.service( manager );
90
91
92         logger.debug( "resolver created - but is this correct ?" );
93
94         //
95
// setup a protocol handler - TO BE DONE
96
//
97

98         logger.debug( "help me - need to setup a handler" );
99
100         //
101
// test source URL creation - TO BE DONE
102
//
103

104         logger.debug( "help me - need to test source creation" );
105
106         //
107
// test source resolution - TO BE DONE
108
//
109

110         logger.debug( "help me - need to test source resolution" );
111
112         assertTrue( true );
113     }
114
115 }
116
Popular Tags