@Test void normalizeWhenRootWebapp() { when(this.configurationSource.getProperty("xwiki.webapppath")).thenReturn(""); ExtendedURL extendedURL = new ExtendedURL(Arrays.asList("one", "two")); assertEquals("/one/two", this.normalizer.normalize(extendedURL).serialize()); }
@Override public ExtendedURL normalize(ExtendedURL partialURL) { String contextPath = StringUtils.strip(getContextPath(), URL_SEGMENT_DELIMITER); if (contextPath == null) { throw new RuntimeException(String.format("Failed to normalize the URL [%s] since the " + "application's Servlet context couldn't be computed.", partialURL)); } List<String> segments = new ArrayList<>(); if (StringUtils.isNotEmpty(contextPath)) { segments.add(contextPath); } segments.addAll(partialURL.getSegments()); return new ExtendedURL(segments, partialURL.getParameters()); }
ContextExtendedURLURLNormalizer implements URLNormalizer<ExtendedURL> { @Override public ExtendedURL normalize(ExtendedURL partialURL) { String contextPath = StringUtils.strip(getContextPath(), URL_SEGMENT_DELIMITER); if (contextPath == null) { throw new RuntimeException(String.format("Failed to normalize the URL [%s] since the " + "application's Servlet context couldn't be computed.", partialURL)); } List<String> segments = new ArrayList<>(); if (StringUtils.isNotEmpty(contextPath)) { segments.add(contextPath); } segments.addAll(partialURL.getSegments()); return new ExtendedURL(segments, partialURL.getParameters()); } }
ContextExtendedURLURLNormalizer implements URLNormalizer<ExtendedURL> { @Override public ExtendedURL normalize(ExtendedURL partialURL) { String contextPath = StringUtils.strip(getContextPath(), URL_SEGMENT_DELIMITER); if (contextPath == null) { throw new RuntimeException(String.format("Failed to normalize the URL [%s] since the " + "application's Servlet context couldn't be computed.", partialURL)); } List<String> segments = new ArrayList<>(); if (StringUtils.isNotEmpty(contextPath)) { segments.add(contextPath); } segments.addAll(partialURL.getSegments()); return new ExtendedURL(segments, partialURL.getParameters()); }  }
ContextExtendedURLURLNormalizer implements URLNormalizer<ExtendedURL> { @Override public ExtendedURL normalize(ExtendedURL partialURL) { String contextPath = StringUtils.strip(getContextPath(), URL_SEGMENT_DELIMITER); if (contextPath == null) { throw new RuntimeException(String.format("Failed to normalize the URL [%s] since the " + "application's Servlet context couldn't be computed.", partialURL)); } List<String> segments = new ArrayList<>(); if (StringUtils.isNotEmpty(contextPath)) { segments.add(contextPath); } segments.addAll(partialURL.getSegments()); return new ExtendedURL(segments, partialURL.getParameters()); }  @Override ExtendedURL normalize(ExtendedURL partialURL); }
ContextExtendedURLURLNormalizer implements URLNormalizer<ExtendedURL> { @Override public ExtendedURL normalize(ExtendedURL partialURL) { String contextPath = StringUtils.strip(getContextPath(), URL_SEGMENT_DELIMITER); if (contextPath == null) { throw new RuntimeException(String.format("Failed to normalize the URL [%s] since the " + "application's Servlet context couldn't be computed.", partialURL)); } List<String> segments = new ArrayList<>(); if (StringUtils.isNotEmpty(contextPath)) { segments.add(contextPath); } segments.addAll(partialURL.getSegments()); return new ExtendedURL(segments, partialURL.getParameters()); }  @Override ExtendedURL normalize(ExtendedURL partialURL);  }