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 RegexpConflictManagerTest 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(RegexpConflictManagerTest.class
37: .getResource("ivysettings-regexp-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 testNoApiConflictResolve() throws Exception {
47: try {
48: ivy.resolve(RegexpConflictManagerTest.class
49: .getResource("ivy-no-regexp-conflict.xml"),
50: getResolveOptions());
51: } catch (StrictConflictException e) {
52: fail("Unexpected conflict: " + e);
53: }
54: }
55:
56: public void testConflictResolve() throws Exception {
57: try {
58: ivy.resolve(RegexpConflictManagerTest.class
59: .getResource("ivy-conflict.xml"),
60: getResolveOptions());
61:
62: fail("Resolve should have failed with a conflict");
63: } catch (StrictConflictException e) {
64: // this is expected
65: assertTrue(
66: "bad exception message: " + e.getMessage(),
67: e
68: .getMessage()
69: .indexOf(
70: "org1#mod1.2;2.0.0:2.0 (needed by [apache#resolve-noconflict;1.0])") != -1);
71: assertTrue("bad exception message: " + e.getMessage(), e
72: .getMessage().indexOf("conflicts with") != -1);
73: assertTrue(
74: "bad exception message: " + e.getMessage(),
75: e
76: .getMessage()
77: .indexOf(
78: "org1#mod1.2;2.1.0:2.1 (needed by [apache#resolve-noconflict;1.0])") != -1);
79: }
80: }
81:
82: private ResolveOptions getResolveOptions() {
83: return new ResolveOptions().setValidate(false);
84: }
85: }
|