View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.metainf.model;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.kuali.common.util.log.LoggerUtils;
21  import org.slf4j.Logger;
22  
23  public class PathComparatorTest {
24  
25  	private static final Logger logger = LoggerUtils.make();
26  
27  	@Test
28  	public void testCompare() {
29  		PathComparator instance = new PathComparator();
30  		try {
31  			instance.compare(-1, new String[] { "" }, new String[] { "" });
32  			Assert.fail();
33  		} catch (IllegalArgumentException e) {
34  			logger.info(e.getMessage());
35  		}
36  		try {
37  			instance.compare(1, new String[] { "" }, new String[] { "" });
38  			Assert.fail();
39  		} catch (IllegalArgumentException e) {
40  			logger.info(e.getMessage());
41  		}
42  		try {
43  			instance.compare(1, new String[] { "", "" }, new String[] { "" });
44  			Assert.fail();
45  		} catch (IllegalArgumentException e) {
46  			logger.info(e.getMessage());
47  		}
48  	}
49  
50  	@Test
51  	public void testCompareTokens() {
52  		PathComparator instance = new PathComparator();
53  		String[] two = { "a", "b" };
54  		String[] three = { "a", "b", "c" };
55  		Assert.assertEquals(-1, instance.compare(two, three));
56  		Assert.assertEquals(1, instance.compare(three, two));
57  	}
58  }