List of usage examples for org.springframework.util StringUtils pathEquals
public static boolean pathEquals(String path1, String path2)
From source file:org.jruby.rack.mock.WebUtils.java
/** * Set a system property to the web application root directory. * The key of the system property can be defined with the "webAppRootKey" * context-param in {@code web.xml}. Default is "webapp.root". * <p>Can be used for tools that support substition with {@code System.getProperty} * values, like log4j's "${key}" syntax within log file locations. * @param servletContext the servlet context of the web application * @throws IllegalStateException if the system property is already set, * or if the WAR file is not expanded//from w w w .j a v a 2s . c o m * @see #WEB_APP_ROOT_KEY_PARAM * @see #DEFAULT_WEB_APP_ROOT_KEY * @see WebAppRootListener * @see Log4jWebConfigurer */ public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException { Assert.notNull(servletContext, "ServletContext must not be null"); String root = servletContext.getRealPath("/"); if (root == null) { throw new IllegalStateException( "Cannot set web app root system property when WAR file is not expanded"); } String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM); String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY); String oldValue = System.getProperty(key); if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) { throw new IllegalStateException("Web app root system property already set to different value: '" + key + "' = [" + oldValue + "] instead of [" + root + "] - " + "Choose unique values for the 'webAppRootKey' context-param in your web.xml files!"); } System.setProperty(key, root); servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]"); }
From source file:spring.osgi.io.OsgiBundleResourceTest.java
private void testFileVsOsgiFileResolution(Resource fileRes, Resource otherRes) throws Exception { assertNotNull(fileRes.getURL());//from ww w. j a v a 2s. c o m assertNotNull(fileRes.getFile()); assertTrue(fileRes.getFile().exists()); assertNotNull(otherRes.getURL()); assertNotNull(otherRes.getFile()); assertTrue( StringUtils.pathEquals(fileRes.getFile().getAbsolutePath(), otherRes.getFile().getAbsolutePath())); }