01: package org.apache.maven.settings.validation;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import junit.framework.TestCase;
23: import org.apache.maven.settings.Profile;
24: import org.apache.maven.settings.Repository;
25: import org.apache.maven.settings.Settings;
26:
27: /**
28: *
29: * @author mkleint
30: */
31: public class DefaultSettingsValidatorTest extends TestCase {
32:
33: public DefaultSettingsValidatorTest(String testName) {
34: super (testName);
35: }
36:
37: protected void setUp() throws Exception {
38: super .setUp();
39: }
40:
41: protected void tearDown() throws Exception {
42: super .tearDown();
43: }
44:
45: public void testValidate() {
46: Settings model = new Settings();
47: Profile prof = new Profile();
48: prof.setId("xxx");
49: model.addProfile(prof);
50: DefaultSettingsValidator instance = new DefaultSettingsValidator();
51: SettingsValidationResult result = instance.validate(model);
52: assertEquals(0, result.getMessageCount());
53:
54: Repository repo = new Repository();
55: prof.addRepository(repo);
56: result = instance.validate(model);
57: assertEquals(2, result.getMessageCount());
58:
59: repo.setUrl("http://xxx.xxx.com");
60: result = instance.validate(model);
61: assertEquals(1, result.getMessageCount());
62:
63: repo.setId("xxx");
64: result = instance.validate(model);
65: assertEquals(0, result.getMessageCount());
66:
67: }
68:
69: }
|