KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > parse > TestXmlResourceProcessor


1 // Copyright 2005 The Apache Software Foundation
2
//
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 implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.parse;
16
17 import hivemind.test.FrameworkTestCase;
18
19 import java.net.URL JavaDoc;
20
21 import org.apache.hivemind.ApplicationRuntimeException;
22 import org.apache.hivemind.Resource;
23 import org.apache.hivemind.impl.DefaultErrorHandler;
24 import org.apache.hivemind.util.FileResource;
25 import org.apache.hivemind.util.URLResource;
26
27 public class TestXmlResourceProcessor extends FrameworkTestCase
28 {
29     public void testMissingURLResource() throws Exception JavaDoc
30     {
31         XmlResourceProcessor processor = new XmlResourceProcessor(getClassResolver(),
32                 new DefaultErrorHandler());
33
34         Resource[] missingResources = new Resource[]
35         { new FileResource("foo"), new URLResource(new URL JavaDoc("file://MissingFile")) };
36
37         for (int i = 0; i < missingResources.length; i++)
38         {
39             try
40             {
41                 processor.processResource(missingResources[i]);
42
43                 fail();
44             }
45             catch (ApplicationRuntimeException e)
46             {
47                 assertEquals(ParseMessages.missingResource(missingResources[i]), e.getMessage());
48
49             }
50         }
51     }
52 }
Popular Tags