KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > parser > ModuleDescriptorParserRegistryTest


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

7 package fr.jayasoft.ivy.parser;
8
9 import java.io.File JavaDoc;
10 import java.io.IOException JavaDoc;
11 import java.io.InputStream JavaDoc;
12 import java.net.URL JavaDoc;
13 import java.text.ParseException JavaDoc;
14
15 import junit.framework.TestCase;
16 import fr.jayasoft.ivy.DefaultModuleDescriptor;
17 import fr.jayasoft.ivy.Ivy;
18 import fr.jayasoft.ivy.ModuleDescriptor;
19 import fr.jayasoft.ivy.ModuleRevisionId;
20 import fr.jayasoft.ivy.repository.Resource;
21
22 public class ModuleDescriptorParserRegistryTest extends TestCase {
23     public static class MyParser extends AbstractModuleDescriptorParser {
24         public ModuleDescriptor parseDescriptor(Ivy ivy, URL JavaDoc descriptorURL, Resource res, boolean validate) throws ParseException JavaDoc, IOException JavaDoc {
25             return DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance("test", "parser", "1.0"));
26         }
27
28         public void toIvyFile(InputStream JavaDoc is, Resource res, File JavaDoc destFile, ModuleDescriptor md) throws ParseException JavaDoc, IOException JavaDoc {
29         }
30
31         public boolean accept(Resource res) {
32             return true;
33         }
34
35     }
36     public void testAddConfigured() throws Exception JavaDoc {
37         Ivy ivy = new Ivy();
38         ivy.addConfigured(new MyParser());
39         ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy, ModuleDescriptorParserRegistryTest.class.getResource("nores"), false);
40         assertNotNull(md);
41         assertEquals(ModuleRevisionId.newInstance("test", "parser", "1.0"), md.getModuleRevisionId());
42     }
43 }
44
Popular Tags