KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hivemind > test > parse > TestModuleDescriptor


1 // Copyright 2004, 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 hivemind.test.parse;
16
17 import org.apache.hivemind.Location;
18 import org.apache.hivemind.Resource;
19 import org.apache.hivemind.impl.DefaultErrorHandler;
20 import org.apache.hivemind.impl.LocationImpl;
21 import org.apache.hivemind.parse.ModuleDescriptor;
22 import org.apache.hivemind.schema.impl.SchemaImpl;
23 import org.apache.hivemind.test.HiveMindTestCase;
24 import org.apache.hivemind.util.ClasspathResource;
25
26 /**
27  * Suite of tests for {@link ModuleDescriptor}.
28  *
29  * @author Knut Wannheden
30  */

31 public class TestModuleDescriptor extends HiveMindTestCase
32 {
33     public void testAddDupeSchema() throws Exception JavaDoc
34     {
35         ModuleDescriptor md = new ModuleDescriptor(getClassResolver(), new DefaultErrorHandler());
36         md.setModuleId("foo");
37
38         Resource r = new ClasspathResource(getClassResolver(), "/foo/bar");
39         Location l1 = new LocationImpl(r, 20);
40         Location l2 = new LocationImpl(r, 97);
41
42         SchemaImpl s1 = new SchemaImpl("test");
43         s1.setId("bar");
44         s1.setLocation(l1);
45
46         SchemaImpl s2 = new SchemaImpl("test");
47         s2.setId("bar");
48         s2.setLocation(l2);
49
50         interceptLogging(md.getClass().getName());
51
52         md.addSchema(s1);
53         md.addSchema(s2);
54
55         assertLoggedMessagePattern("Schema foo.bar conflicts with existing schema at classpath:/foo/bar, line 20\\.");
56
57         assertSame(s1, md.getSchema("bar"));
58     }
59
60 }
Popular Tags