01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.core.settings;
19:
20: import java.io.File;
21: import java.io.IOException;
22: import java.text.ParseException;
23:
24: import junit.framework.TestCase;
25:
26: import org.apache.ivy.Ivy;
27: import org.apache.ivy.plugins.resolver.DependencyResolver;
28: import org.apache.ivy.plugins.resolver.IBiblioResolver;
29: import org.apache.ivy.plugins.resolver.IvyRepResolver;
30:
31: public class ConfigureTest extends TestCase {
32: public void testDefault() throws ParseException, IOException {
33: Ivy ivy = new Ivy();
34: ivy.configureDefault();
35:
36: IvySettings settings = ivy.getSettings();
37: assertNotNull(settings.getDefaultResolver());
38:
39: DependencyResolver publicResolver = settings
40: .getResolver("public");
41: assertNotNull(publicResolver);
42: assertTrue(publicResolver instanceof IBiblioResolver);
43: IBiblioResolver ibiblio = (IBiblioResolver) publicResolver;
44: assertTrue(ibiblio.isM2compatible());
45: }
46:
47: public void testDefault14() throws ParseException, IOException {
48: Ivy ivy = new Ivy();
49: ivy.configureDefault14();
50:
51: IvySettings settings = ivy.getSettings();
52: assertNotNull(settings.getDefaultResolver());
53:
54: DependencyResolver publicResolver = settings
55: .getResolver("public");
56: assertTrue(publicResolver instanceof IvyRepResolver);
57: }
58:
59: public void testTypedefWithCustomClasspath() throws Exception {
60: Ivy ivy = new Ivy();
61: ivy.setVariable("ivy.custom.test.dir", new File(
62: "test/java/org/apache/ivy/core/settings").toURL()
63: .toString());
64: ivy.configure(ConfigureTest.class
65: .getResource("ivysettings-custom-typedef.xml"));
66:
67: DependencyResolver custom = ivy.getSettings().getResolver(
68: "custom");
69: assertNotNull(custom);
70: assertEquals("org.apache.ivy.plugins.resolver.CustomResolver",
71: custom.getClass().getName());
72: }
73:
74: public void testTypedefWithCustomClasspathWithFile()
75: throws Exception {
76: Ivy ivy = new Ivy();
77: ivy.setVariable("ivy.custom.test.dir", new File(
78: "test/java/org/apache/ivy/core/settings").toString());
79: ivy.configure(ConfigureTest.class
80: .getResource("ivysettings-custom-typedef2.xml"));
81:
82: DependencyResolver custom = ivy.getSettings().getResolver(
83: "custom");
84: assertNotNull(custom);
85: assertEquals("org.apache.ivy.plugins.resolver.CustomResolver",
86: custom.getClass().getName());
87: }
88:
89: }
|