View Javadoc

1   /**
2    * Copyright 2010-2013 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;
17  
18  import junit.framework.Assert;
19  
20  import org.junit.Test;
21  import org.slf4j.Logger;
22  import org.slf4j.LoggerFactory;
23  
24  public class RepositoryUtilsTest {
25  
26  	private static final Logger logger = LoggerFactory.getLogger(RepositoryUtilsTest.class);
27  
28  	@Test
29  	public void testArtifact() {
30  		Artifact a = new Artifact();
31  		a.setGroupId("org.kuali.common");
32  		a.setArtifactId("kuali-util");
33  		a.setVersion("1.0.0");
34  		a.setClassifier("webapp");
35  		a.setType("jar");
36  		String gav1 = RepositoryUtils.toString(a);
37  		Artifact parsed = RepositoryUtils.parseArtifact(gav1);
38  		String gav2 = RepositoryUtils.toString(parsed);
39  		logger.info("gav1={}", gav1);
40  		logger.info("gav2={}", gav2);
41  		Assert.assertEquals(gav1, gav2);
42  	}
43  
44  	@Test
45  	public void testEmptyArtifact() {
46  		Artifact a = new Artifact();
47  		String gav1 = RepositoryUtils.toString(a);
48  		Artifact parsed = RepositoryUtils.parseArtifact(gav1);
49  		String gav2 = RepositoryUtils.toString(parsed);
50  		logger.info("gav1={}", gav1);
51  		logger.info("gav2={}", gav2);
52  		Assert.assertEquals(gav1, gav2);
53  	}
54  
55  	@Test
56  	public void testGroupIdArtifact() {
57  		Artifact a = new Artifact();
58  		a.setGroupId("org.kuali.common");
59  		String gav1 = RepositoryUtils.toString(a);
60  		Artifact parsed = RepositoryUtils.parseArtifact(gav1);
61  		String gav2 = RepositoryUtils.toString(parsed);
62  		logger.info("gav1={}", gav1);
63  		logger.info("gav2={}", gav2);
64  		Assert.assertEquals(gav1, gav2);
65  	}
66  
67  	@Test
68  	public void testTypeArtifact() {
69  		Artifact a = new Artifact();
70  		a.setType("jar");
71  		String gav1 = RepositoryUtils.toString(a);
72  		Artifact parsed = RepositoryUtils.parseArtifact(gav1);
73  		String gav2 = RepositoryUtils.toString(parsed);
74  		logger.info("gav1={}", gav1);
75  		logger.info("gav2={}", gav2);
76  		Assert.assertEquals(gav1, gav2);
77  	}
78  }