001 package org.apache.maven.artifact.resolver; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.util.Arrays; 023 import java.util.List; 024 025 import junit.framework.TestCase; 026 027 /** 028 * Test the artifact resolution exception message 029 * 030 * @author Mauro Talevi 031 */ 032 public class ArtifactResolutionExceptionTest 033 extends TestCase 034 { 035 private static final String LS = System.getProperty( "line.separator" ); 036 037 public void testMissingArtifactMessageFormat() 038 { 039 String message = "Missing artifact"; 040 String indentation = " "; 041 String groupId = "aGroupId"; 042 String artifactId = "anArtifactId"; 043 String version = "aVersion"; 044 String type = "jar"; 045 String classifier = "aClassifier"; 046 String downloadUrl = "http://somewhere.com/download"; 047 List path = Arrays.asList( "dependency1", "dependency2" ); 048 String expected = 049 "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS 050 + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS 051 + " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion " 052 + "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS + LS 053 + " Alternatively, if you host your own repository you can deploy the file there: " + LS 054 + " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId" 055 + " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" 056 + " -Durl=[url] -DrepositoryId=[id]" + LS + LS + " Path to dependency: " + LS + " \t1) dependency1" 057 + LS + " \t2) dependency2" + LS + LS; 058 String actual = 059 AbstractArtifactResolutionException.constructMissingArtifactMessage( message, indentation, groupId, 060 artifactId, version, type, classifier, 061 downloadUrl, path ); 062 assertEquals( expected, actual ); 063 } 064 }