View Javadoc
1   /**
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the Educational
3    * Community License, Version 2.0 (the "License"); you may not use this file
4    * except in compliance with the License. You may obtain a copy of the License
5    * at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12   * License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package org.kuali.mobility.bus.dao.helper;
16  
17  import java.io.IOException;
18  
19  import org.springframework.core.io.Resource;
20  
21  /**
22   * Helper class to get a unit test compatible URL string from the classpath
23   * @author Kuali Mobility Team (mobility.collab@kuali.org)
24   * @since 2.3.0
25   */
26  public class URLHelper {
27  
28  	/**
29  	 * A reference to a springyfied resource
30  	 */
31  	private Resource resource;
32  	
33  	/**
34  	 * Sets the resource
35  	 * @param resource
36  	 */
37  	public void setResource(Resource resource){
38  		this.resource = resource;
39  	}
40  	
41  	/**
42  	 * Get a string representing the url to the resource
43  	 * @return
44  	 */
45  	public String getUrlPath(){
46  		try {
47  			return resource.getURL().toString();
48  		} catch (IOException e) {
49  			e.printStackTrace();
50  			return "ERROR";
51  		}
52  	}
53  }