Source Code Cross Referenced for XmlSettingsParserTest.java in  » Code-Analyzer » apache-ivy » org » apache » ivy » core » settings » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » apache ivy » org.apache.ivy.core.settings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.ivy.core.settings;
019:
020:        import java.io.File;
021:        import java.util.List;
022:
023:        import junit.framework.TestCase;
024:
025:        import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
026:        import org.apache.ivy.core.cache.ResolutionCacheManager;
027:        import org.apache.ivy.core.module.descriptor.Artifact;
028:        import org.apache.ivy.core.module.id.ModuleId;
029:        import org.apache.ivy.core.module.id.ModuleRevisionId;
030:        import org.apache.ivy.core.report.ResolveReport;
031:        import org.apache.ivy.core.resolve.ResolveOptions;
032:        import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
033:        import org.apache.ivy.plugins.latest.LatestStrategy;
034:        import org.apache.ivy.plugins.latest.LatestTimeStrategy;
035:        import org.apache.ivy.plugins.lock.AbstractLockStrategy;
036:        import org.apache.ivy.plugins.lock.LockStrategy;
037:        import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
038:        import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest;
039:        import org.apache.ivy.plugins.report.ReportOutputter;
040:        import org.apache.ivy.plugins.resolver.ChainResolver;
041:        import org.apache.ivy.plugins.resolver.DependencyResolver;
042:        import org.apache.ivy.plugins.resolver.FileSystemResolver;
043:        import org.apache.ivy.plugins.resolver.MockResolver;
044:        import org.apache.ivy.plugins.version.ChainVersionMatcher;
045:        import org.apache.ivy.plugins.version.MockVersionMatcher;
046:        import org.apache.ivy.plugins.version.VersionMatcher;
047:
048:        /**
049:         * TODO write javadoc
050:         */
051:        public class XmlSettingsParserTest extends TestCase {
052:            public void test() throws Exception {
053:                IvySettings settings = new IvySettings();
054:                XmlSettingsParser parser = new XmlSettingsParser(settings);
055:                parser.parse(XmlSettingsParserTest.class
056:                        .getResource("ivysettings-test.xml"));
057:
058:                File defaultCache = settings.getDefaultCache();
059:                assertNotNull(defaultCache);
060:                assertEquals("mycache", defaultCache.getName());
061:
062:                assertFalse(settings.isCheckUpToDate());
063:                assertFalse(settings.doValidate());
064:
065:                assertEquals("[module]/ivys/ivy-[revision].xml", settings
066:                        .getDefaultCacheIvyPattern());
067:                assertEquals("[module]/[type]s/[artifact]-[revision].[ext]",
068:                        settings.getDefaultCacheArtifactPattern());
069:
070:                LatestStrategy latest = settings
071:                        .getLatestStrategy("mylatest-revision");
072:                assertNotNull(latest);
073:                assertTrue(latest instanceof  LatestRevisionStrategy);
074:                LatestRevisionStrategy l = (LatestRevisionStrategy) latest;
075:                assertEquals(new Integer(-2), l.getSpecialMeanings().get("pre"));
076:                assertEquals(new Integer(4), l.getSpecialMeanings().get("qa"));
077:
078:                DependencyResolver defaultResolver = settings
079:                        .getDefaultResolver();
080:                assertNotNull(defaultResolver);
081:                assertEquals("libraries", defaultResolver.getName());
082:                assertTrue(defaultResolver instanceof  FileSystemResolver);
083:                FileSystemResolver fsres = (FileSystemResolver) defaultResolver;
084:                List ivyPatterns = fsres.getIvyPatterns();
085:                assertNotNull(ivyPatterns);
086:                assertEquals(1, ivyPatterns.size());
087:                assertEquals(
088:                        "lib/[organisation]/[module]/ivys/ivy-[revision].xml",
089:                        ivyPatterns.get(0));
090:
091:                LatestStrategy strategy = fsres.getLatestStrategy();
092:                assertNotNull(strategy);
093:                assertTrue(strategy instanceof  LatestRevisionStrategy);
094:
095:                DependencyResolver internal = settings.getResolver("internal");
096:                assertNotNull(internal);
097:                assertTrue(internal instanceof  ChainResolver);
098:                ChainResolver chain = (ChainResolver) internal;
099:                List subresolvers = chain.getResolvers();
100:                assertNotNull(subresolvers);
101:                assertEquals(2, subresolvers.size());
102:                FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers
103:                        .get(0);
104:                assertEquals("int1", fsInt1.getName());
105:                assertEquals(1, fsInt1.getIvyPatterns().size());
106:                assertEquals(
107:                        "sharedrep/[organisation]/[module]/ivys/ivy-[revision].xml",
108:                        fsInt1.getIvyPatterns().get(0));
109:                assertEquals("int2", ((DependencyResolver) subresolvers.get(1))
110:                        .getName());
111:
112:                strategy = fsInt1.getLatestStrategy();
113:                assertNotNull(strategy);
114:                assertTrue(strategy instanceof  LatestTimeStrategy);
115:
116:                assertEquals("libraries", settings.getResolver(
117:                        ModuleRevisionId.newInstance("unknown", "lib", "1.0"))
118:                        .getName());
119:                assertEquals("internal", settings.getResolver(
120:                        ModuleRevisionId.newInstance("apache", "ant", "1.0"))
121:                        .getName());
122:                assertEquals("int2", settings.getResolver(
123:                        ModuleRevisionId.newInstance("apache", "ivy", "2.0"))
124:                        .getName());
125:                assertEquals("int1", settings.getResolver(
126:                        ModuleRevisionId.newInstance("apache", "ivy", "1.0"))
127:                        .getName());
128:                assertEquals("int1", settings.getResolver(
129:                        ModuleRevisionId.newInstance("apache", "ivyde", "1.0"))
130:                        .getName());
131:            }
132:
133:            public void testTypedef() throws Exception {
134:                IvySettings settings = new IvySettings();
135:                XmlSettingsParser parser = new XmlSettingsParser(settings);
136:                parser.parse(XmlSettingsParserTest.class
137:                        .getResource("ivysettings-typedef.xml"));
138:
139:                DependencyResolver mock = settings.getResolver("mock3");
140:                assertNotNull(mock);
141:                assertTrue(mock instanceof  MockResolver);
142:
143:                DependencyResolver internal = settings.getResolver("internal");
144:                assertNotNull(internal);
145:                assertTrue(internal instanceof  ChainResolver);
146:                ChainResolver chain = (ChainResolver) internal;
147:                List subresolvers = chain.getResolvers();
148:                assertNotNull(subresolvers);
149:                assertEquals(2, subresolvers.size());
150:
151:                assertEquals("mock1",
152:                        ((DependencyResolver) subresolvers.get(0)).getName());
153:                assertEquals("mock2",
154:                        ((DependencyResolver) subresolvers.get(1)).getName());
155:                assertTrue(subresolvers.get(0) instanceof  MockResolver);
156:                assertTrue(subresolvers.get(1) instanceof  MockResolver);
157:            }
158:
159:            public void testStatuses() throws Exception {
160:                IvySettings settings = new IvySettings();
161:                XmlSettingsParser parser = new XmlSettingsParser(settings);
162:                parser.parse(XmlSettingsParserTest.class
163:                        .getResource("ivysettings-status.xml"));
164:
165:                assertEquals("bronze", settings.getStatusManager()
166:                        .getDefaultStatus());
167:                assertEquals(0, settings.getStatusManager().getPriority("gold"));
168:                assertEquals(1, settings.getStatusManager().getPriority(
169:                        "silver"));
170:                assertEquals(2, settings.getStatusManager().getPriority(
171:                        "bronze"));
172:                assertEquals(false, settings.getStatusManager().isIntegration(
173:                        "gold"));
174:                assertEquals(false, settings.getStatusManager().isIntegration(
175:                        "silver"));
176:                assertEquals(true, settings.getStatusManager().isIntegration(
177:                        "bronze"));
178:            }
179:
180:            public void testConflictManager() throws Exception {
181:                IvySettings settings = new IvySettings();
182:                XmlSettingsParser parser = new XmlSettingsParser(settings);
183:                parser.parse(XmlSettingsParserTest.class
184:                        .getResource("ivysettings-conflict-manager.xml"));
185:
186:                assertEquals("latest-time", settings.getConflictManager(
187:                        new ModuleId("apache", "ivyde")).getName());
188:                assertEquals("all", settings.getConflictManager(
189:                        new ModuleId("apache", "ant")).getName());
190:            }
191:
192:            public void testCache() throws Exception {
193:                IvySettings settings = new IvySettings();
194:                XmlSettingsParser parser = new XmlSettingsParser(settings);
195:                parser.parse(XmlSettingsParserTest.class
196:                        .getResource("ivysettings-cache.xml"));
197:
198:                assertEquals(new File("repository"), settings
199:                        .getDefaultRepositoryCacheBasedir());
200:                assertEquals(new File("resolution"), settings
201:                        .getDefaultResolutionCacheBasedir());
202:                assertEquals("artifact-lock", settings.getDefaultLockStrategy()
203:                        .getName());
204:
205:                assertEquals("[module]/ivys/ivy-[revision].xml", settings
206:                        .getDefaultCacheIvyPattern());
207:                assertEquals("[module]/[type]s/[artifact]-[revision].[ext]",
208:                        settings.getDefaultCacheArtifactPattern());
209:                assertEquals(true, settings.isDefaultUseOrigin());
210:
211:                DefaultRepositoryCacheManager c = (DefaultRepositoryCacheManager) settings
212:                        .getRepositoryCacheManager("mycache");
213:                assertNotNull(c);
214:                assertEquals("mycache", c.getName());
215:                assertEquals(1000, c.getDefaultTTL());
216:                assertEquals(200, c.getTTL(ModuleRevisionId.newInstance(
217:                        "apache", "ivy", "latest.integration")));
218:                assertEquals(10 * 60 * 1000 + 20 * 1000, // 10m 20s 
219:                        c
220:                                .getTTL(ModuleRevisionId.newInstance("org1",
221:                                        "A", "A")));
222:                assertEquals(5 * 3600 * 1000, // 5h 
223:                        c
224:                                .getTTL(ModuleRevisionId.newInstance("org2",
225:                                        "A", "A")));
226:                assertEquals(60 * 3600 * 1000, // 2d 12h = 60h 
227:                        c
228:                                .getTTL(ModuleRevisionId.newInstance("org3",
229:                                        "A", "A")));
230:                assertEquals(new File("mycache"), c.getBasedir());
231:                assertEquals(false, c.isUseOrigin());
232:                assertEquals("no-lock", c.getLockStrategy().getName());
233:
234:                assertEquals("[module]/ivy-[revision].xml", c.getIvyPattern());
235:                assertEquals("[module]/[artifact]-[revision].[ext]", c
236:                        .getArtifactPattern());
237:
238:                DefaultRepositoryCacheManager c2 = (DefaultRepositoryCacheManager) settings
239:                        .getRepositoryCacheManager("mycache2");
240:                assertNotNull(c2);
241:                assertEquals("mycache2", c2.getName());
242:                assertEquals(new File("repository"), c2.getBasedir());
243:                assertEquals("artifact-lock", c2.getLockStrategy().getName());
244:
245:                assertEquals("[module]/ivys/ivy-[revision].xml", c2
246:                        .getIvyPattern());
247:                assertEquals("[module]/[type]s/[artifact]-[revision].[ext]", c2
248:                        .getArtifactPattern());
249:
250:                assertEquals(true, c2.isUseOrigin());
251:
252:                assertEquals(c2, settings.getResolver("A")
253:                        .getRepositoryCacheManager());
254:                assertEquals(c, settings.getResolver("B")
255:                        .getRepositoryCacheManager());
256:            }
257:
258:            public void testVersionMatchers1() throws Exception {
259:                IvySettings settings = new IvySettings();
260:                XmlSettingsParser parser = new XmlSettingsParser(settings);
261:                parser.parse(XmlSettingsParserTest.class
262:                        .getResource("ivysettings-vmatcher1.xml"));
263:
264:                VersionMatcher mock = settings.getVersionMatcher("vmock");
265:                assertNotNull(mock);
266:                assertTrue(mock instanceof  MockVersionMatcher);
267:
268:                VersionMatcher v = settings.getVersionMatcher();
269:                assertTrue(v instanceof  ChainVersionMatcher);
270:                ChainVersionMatcher chain = (ChainVersionMatcher) v;
271:                assertEquals(3, chain.getMatchers().size());
272:                assertTrue(chain.getMatchers().contains(mock));
273:                assertTrue(chain.getMatchers().contains(
274:                        settings.getVersionMatcher("exact")));
275:                assertTrue(chain.getMatchers().contains(
276:                        settings.getVersionMatcher("latest")));
277:            }
278:
279:            public void testVersionMatchers2() throws Exception {
280:                IvySettings settings = new IvySettings();
281:                XmlSettingsParser parser = new XmlSettingsParser(settings);
282:                parser.parse(XmlSettingsParserTest.class
283:                        .getResource("ivysettings-vmatcher2.xml"));
284:
285:                VersionMatcher mock = settings.getVersionMatcher("vmock");
286:                assertNotNull(mock);
287:                assertTrue(mock instanceof  MockVersionMatcher);
288:
289:                VersionMatcher v = settings.getVersionMatcher();
290:                assertTrue(v instanceof  ChainVersionMatcher);
291:                ChainVersionMatcher chain = (ChainVersionMatcher) v;
292:                assertEquals(5, chain.getMatchers().size());
293:                assertTrue(chain.getMatchers().contains(mock));
294:            }
295:
296:            public void testRef() throws Exception {
297:                IvySettings settings = new IvySettings();
298:                XmlSettingsParser parser = new XmlSettingsParser(settings);
299:                parser.parse(XmlSettingsParserTest.class
300:                        .getResource("ivysettings-ref.xml"));
301:
302:                DependencyResolver internal = settings.getResolver("internal");
303:                assertNotNull(internal);
304:                assertTrue(internal instanceof  ChainResolver);
305:                ChainResolver chain = (ChainResolver) internal;
306:                List subresolvers = chain.getResolvers();
307:                assertNotNull(subresolvers);
308:                assertEquals(2, subresolvers.size());
309:                FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers
310:                        .get(0);
311:                assertEquals("fs", fsInt1.getName());
312:
313:                List ivyPatterns = fsInt1.getIvyPatterns();
314:                assertNotNull(ivyPatterns);
315:                assertEquals(1, ivyPatterns.size());
316:                assertEquals(
317:                        "sharedrep/[organisation]/[module]/ivys/ivy-[revision].xml",
318:                        ivyPatterns.get(0));
319:
320:                DependencyResolver external = settings.getResolver("external");
321:                assertNotNull(external);
322:                assertTrue(external instanceof  ChainResolver);
323:                chain = (ChainResolver) external;
324:                subresolvers = chain.getResolvers();
325:                assertNotNull(subresolvers);
326:                assertEquals(1, subresolvers.size());
327:                FileSystemResolver fsInt2 = (FileSystemResolver) subresolvers
328:                        .get(0);
329:                assertEquals("fs", fsInt2.getName());
330:
331:                ivyPatterns = fsInt2.getIvyPatterns();
332:                assertNotNull(ivyPatterns);
333:                assertEquals(1, ivyPatterns.size());
334:                assertEquals(
335:                        "sharedrep/[organisation]/[module]/ivys/ivy-[revision].xml",
336:                        ivyPatterns.get(0));
337:            }
338:
339:            public void testMacro() throws Exception {
340:                IvySettings settings = new IvySettings();
341:                XmlSettingsParser parser = new XmlSettingsParser(settings);
342:                parser.parse(XmlSettingsParserTest.class
343:                        .getResource("ivysettings-macro.xml"));
344:
345:                DependencyResolver def = settings.getResolver("default");
346:                assertNotNull(def);
347:                assertTrue(def instanceof  ChainResolver);
348:                ChainResolver chain = (ChainResolver) def;
349:                List subresolvers = chain.getResolvers();
350:                assertNotNull(subresolvers);
351:                assertEquals(2, subresolvers.size());
352:                FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers
353:                        .get(0);
354:                assertEquals("default-fs1", fsInt1.getName());
355:
356:                List ivyPatterns = fsInt1.getIvyPatterns();
357:                assertNotNull(ivyPatterns);
358:                assertEquals(1, ivyPatterns.size());
359:                assertEquals(
360:                        "path/to/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]",
361:                        ivyPatterns.get(0));
362:
363:                FileSystemResolver fsInt2 = (FileSystemResolver) subresolvers
364:                        .get(1);
365:                assertEquals("default-fs2", fsInt2.getName());
366:
367:                ivyPatterns = fsInt2.getIvyPatterns();
368:                assertNotNull(ivyPatterns);
369:                assertEquals(1, ivyPatterns.size());
370:                assertEquals(
371:                        "path/to/secondrep/[organisation]/[module]/[type]s/ivy-[revision].xml",
372:                        ivyPatterns.get(0));
373:
374:                DependencyResolver other = settings.getResolver("other");
375:                assertNotNull(other);
376:                assertTrue(other instanceof  ChainResolver);
377:                chain = (ChainResolver) other;
378:                subresolvers = chain.getResolvers();
379:                assertNotNull(subresolvers);
380:                assertEquals(2, subresolvers.size());
381:
382:                fsInt2 = (FileSystemResolver) subresolvers.get(1);
383:                assertEquals("other-fs2", fsInt2.getName());
384:
385:                ivyPatterns = fsInt2.getIvyPatterns();
386:                assertNotNull(ivyPatterns);
387:                assertEquals(1, ivyPatterns.size());
388:                assertEquals(
389:                        "path/to/secondrep/[module]/[type]s/ivy-[revision].xml",
390:                        ivyPatterns.get(0));
391:            }
392:
393:            public void testMacroAndRef() throws Exception {
394:                // test case for IVY-319
395:                IvySettings settings = new IvySettings();
396:                XmlSettingsParser parser = new XmlSettingsParser(settings);
397:                parser.parse(XmlSettingsParserTest.class
398:                        .getResource("ivysettings-macro+ref.xml"));
399:
400:                DependencyResolver shared = settings.getResolver("shared");
401:                assertNotNull(shared);
402:                assertTrue(shared instanceof  FileSystemResolver);
403:
404:                DependencyResolver mychain = settings.getResolver("mychain");
405:                assertNotNull(mychain);
406:                assertTrue(mychain instanceof  ChainResolver);
407:                ChainResolver chain = (ChainResolver) mychain;
408:                List subresolvers = chain.getResolvers();
409:                assertNotNull(subresolvers);
410:                assertEquals(1, subresolvers.size());
411:                shared = (DependencyResolver) subresolvers.get(0);
412:                assertEquals("shared", shared.getName());
413:                assertTrue(shared instanceof  FileSystemResolver);
414:            }
415:
416:            public void testInclude() throws Exception {
417:                IvySettings settings = new IvySettings();
418:                XmlSettingsParser parser = new XmlSettingsParser(settings);
419:                parser.parse(XmlSettingsParserTest.class
420:                        .getResource("ivysettings-include.xml"));
421:
422:                DependencyResolver def = settings.getResolver("default");
423:                assertNotNull(def);
424:                assertTrue(def instanceof  ChainResolver);
425:                ChainResolver chain = (ChainResolver) def;
426:                List subresolvers = chain.getResolvers();
427:                assertNotNull(subresolvers);
428:                assertEquals(2, subresolvers.size());
429:                FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers
430:                        .get(0);
431:                assertEquals("default-fs1", fsInt1.getName());
432:
433:                List ivyPatterns = fsInt1.getIvyPatterns();
434:                assertNotNull(ivyPatterns);
435:                assertEquals(1, ivyPatterns.size());
436:                assertEquals(
437:                        "path/to/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]",
438:                        ivyPatterns.get(0));
439:
440:                DependencyResolver inc = settings.getResolver("includeworks");
441:                assertNotNull(inc);
442:                assertTrue(inc instanceof  ChainResolver);
443:                chain = (ChainResolver) inc;
444:                subresolvers = chain.getResolvers();
445:                assertNotNull(subresolvers);
446:                assertEquals(2, subresolvers.size());
447:
448:                fsInt1 = (FileSystemResolver) subresolvers.get(0);
449:                assertEquals("includeworks-fs1", fsInt1.getName());
450:
451:                ivyPatterns = fsInt1.getIvyPatterns();
452:                assertNotNull(ivyPatterns);
453:                assertEquals(1, ivyPatterns.size());
454:                assertEquals(
455:                        "included/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]",
456:                        ivyPatterns.get(0));
457:            }
458:
459:            public void testParser() throws Exception {
460:                IvySettings settings = new IvySettings();
461:                XmlSettingsParser parser = new XmlSettingsParser(settings);
462:                parser.parse(XmlSettingsParserTest.class
463:                        .getResource("ivysettings-parser.xml"));
464:                assertEquals(ModuleDescriptorParserRegistryTest.MyParser.class
465:                        .getName(), ModuleDescriptorParserRegistry
466:                        .getInstance().getParsers()[0].getClass().getName());
467:            }
468:
469:            public void testOutputter() throws Exception {
470:                IvySettings settings = new IvySettings();
471:                XmlSettingsParser parser = new XmlSettingsParser(settings);
472:                parser.parse(XmlSettingsParserTest.class
473:                        .getResource("ivysettings-outputter.xml"));
474:
475:                // System.out.println(Arrays.asList(ivy.getReportOutputters()));
476:
477:                ReportOutputter testOutputter = settings
478:                        .getReportOutputter("test");
479:                assertNotNull(testOutputter);
480:                assertTrue(testOutputter instanceof  MyOutputter);
481:            }
482:
483:            public void testLockingStrategies() throws Exception {
484:                IvySettings settings = new IvySettings();
485:                XmlSettingsParser parser = new XmlSettingsParser(settings);
486:                parser.parse(XmlSettingsParserTest.class
487:                        .getResource("ivysettings-lock-strategies.xml"));
488:
489:                LockStrategy lockStrategy = settings.getLockStrategy("test");
490:                assertNotNull(lockStrategy);
491:                assertTrue(lockStrategy instanceof  MyLockStrategy);
492:            }
493:
494:            public static class MyOutputter implements  ReportOutputter {
495:                public void output(ResolveReport report,
496:                        ResolutionCacheManager cacheMgr, ResolveOptions options) {
497:                }
498:
499:                public String getName() {
500:                    return "test";
501:                }
502:
503:            }
504:
505:            public static class MyLockStrategy extends AbstractLockStrategy {
506:                public boolean lockArtifact(Artifact artifact,
507:                        File artifactFileToDownload)
508:                        throws InterruptedException {
509:                    return false;
510:                }
511:
512:                public void unlockArtifact(Artifact artifact,
513:                        File artifactFileToDownload) {
514:                }
515:            }
516:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.