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.plugins.conflict;
19:
20: import java.io.File;
21:
22: import junit.framework.TestCase;
23:
24: import org.apache.ivy.Ivy;
25: import org.apache.ivy.core.cache.DefaultResolutionCacheManager;
26: import org.apache.ivy.core.resolve.ResolveOptions;
27: import org.apache.ivy.util.FileUtil;
28:
29: public class StrictConflictManagerTest extends TestCase {
30: private Ivy ivy;
31:
32: private File cache;
33:
34: protected void setUp() throws Exception {
35: ivy = new Ivy();
36: ivy.configure(StrictConflictManagerTest.class
37: .getResource("ivysettings-strict-test.xml"));
38: cache = new File("build/cache");
39: cache.mkdirs();
40: }
41:
42: protected void tearDown() throws Exception {
43: FileUtil.forceDelete(cache);
44: }
45:
46: public void testInitFromConf() throws Exception {
47: ConflictManager cm = ivy.getSettings()
48: .getDefaultConflictManager();
49: assertTrue(cm instanceof StrictConflictManager);
50: }
51:
52: public void testNoConflictResolve() throws Exception {
53: ivy
54: .resolve(StrictConflictManagerTest.class
55: .getResource("ivy-noconflict.xml"),
56: getResolveOptions());
57: }
58:
59: public void testNoConflictWithDynamicRevisionResolve()
60: throws Exception {
61: ivy.resolve(StrictConflictManagerTest.class
62: .getResource("ivy-noconflict-dynamic.xml"),
63: getResolveOptions());
64: }
65:
66: public void testConflictResolve() throws Exception {
67: try {
68: ivy.resolve(StrictConflictManagerTest.class
69: .getResource("ivy-conflict.xml"),
70: getResolveOptions());
71:
72: fail("Resolve should have failed with a conflict");
73: } catch (StrictConflictException e) {
74: // this is expected
75: }
76: }
77:
78: public void testConflictWithDynamicRevisionResolve()
79: throws Exception {
80: try {
81: ivy.resolve(StrictConflictManagerTest.class
82: .getResource("ivy-conflict-dynamic.xml"),
83: getResolveOptions());
84:
85: fail("Resolve should have failed with a conflict");
86: } catch (StrictConflictException e) {
87: // this is expected
88: }
89: }
90:
91: private ResolveOptions getResolveOptions() {
92: return new ResolveOptions().setValidate(false);
93: }
94: }
|