You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/01/22 20:20:40 UTC
[maven-doxia-sitetools] 01/01: [DOXIASITETOOLS-242] Remove all deprecated code
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch DOXIASITETOOLS-242
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
commit bc6dc81c4bf1953bab5afa2f6f65c7380f4a0c24
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Jan 22 20:59:45 2022 +0100
[DOXIASITETOOLS-242] Remove all deprecated code
This closes #25
---
.../decoration/inheritance/PathDescriptor.java | 255 --------
.../site/decoration/inheritance/PathUtils.java | 145 -----
.../site/decoration/inheritance/Doxia91Test.java | 72 ---
.../decoration/inheritance/PathDescriptorTest.java | 655 ---------------------
.../site/decoration/inheritance/PathUtilsTest.java | 80 ---
.../doxia/siterenderer/DefaultSiteRenderer.java | 16 -
.../apache/maven/doxia/siterenderer/Renderer.java | 59 --
.../maven/doxia/siterenderer/RenderingContext.java | 12 -
.../doxia/siterenderer/SkinResourceLoader.java | 125 ----
.../siterenderer/DefaultSiteRendererTest.java | 28 -
.../doxia/siterenderer/SkinResourceLoaderTest.java | 63 --
11 files changed, 1510 deletions(-)
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptor.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptor.java
deleted file mode 100644
index 6c5f550..0000000
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptor.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * This class holds an instance of a maven path. This consists of a relative path (e.g. images/maven-logo.png) and a
- * base reference which can also be a relative path (e.g. '.' or '../doxia') or an URL that is used for an absolute
- * anchor.
- *
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- * @deprecated use {@link URIPathDescriptor} instead.
- */
-
-public class PathDescriptor
-{
- private final URL baseUrl;
-
- private final URL pathUrl;
-
- private final String relativePath;
-
- /**
- * Construct a PathDescriptor from a path.
- *
- * @param path the path.
- * @throws java.net.MalformedURLException if a URL cannot be formed from the path.
- */
- public PathDescriptor( final String path )
- throws MalformedURLException
- {
- this( (URL) null, path );
- }
-
- /**
- * Construct a PathDescriptor from a path and a base.
- *
- * @param base a base reference.
- * @param path the path.
- * @throws java.net.MalformedURLException if a URL cannot be formed from the path.
- */
- public PathDescriptor( final String base, final String path )
- throws MalformedURLException
- {
- this( PathDescriptor.buildBaseUrl( base ), path );
- }
-
- /**
- * Construct a PathDescriptor from a path and a base.
- *
- * @param baseUrl a base reference.
- * @param path the path.
- * @throws java.net.MalformedURLException if a URL cannot be formed from the path.
- */
- public PathDescriptor( final URL baseUrl, final String path )
- throws MalformedURLException
- {
- this.baseUrl = baseUrl;
-
- URL pathURL = null;
- String relPath = null;
-
- try
- {
- pathURL = new URL( path );
- }
- catch ( MalformedURLException e )
- {
- try
- {
- pathURL = buildUrl( baseUrl, path );
- }
- catch ( MalformedURLException e2 )
- {
- // If we got an absolute path passed in and end here, then the path
- // is converted to relative because we have no reference URL anyway
- // to which it has been anchored.
- if ( path != null && path.startsWith( "/" ) )
- {
- relPath = path.substring( 1 );
- }
- else
- {
- relPath = path;
- }
- }
- }
-
- this.pathUrl = pathURL;
- this.relativePath = relPath;
- }
-
- private static URL buildBaseUrl( final String base )
- throws MalformedURLException
- {
- if ( base == null )
- {
- return null;
- }
-
- try
- {
- return new URL( base );
- }
- catch ( MalformedURLException e )
- {
- return new File( base ).toURI().toURL();
- }
- }
-
- private static URL buildUrl( final URL baseUrl, final String path )
- throws MalformedURLException
- {
- if ( baseUrl == null )
- {
- throw new MalformedURLException( "Base is null!" );
- }
-
- if ( path == null )
- {
- return baseUrl;
- }
-
- if ( baseUrl.getProtocol().equals( "file" ) )
- {
- return new File( baseUrl.getFile(), path ).toURI().toURL();
- }
-
- if ( path.startsWith( "/" ) && baseUrl.getPath().endsWith( "/" ) )
- {
- return new URL( baseUrl, path.substring( 1 ) );
- }
-
- return new URL( baseUrl, path );
- }
-
- /**
- * Check if this PathDescriptor describes a file.
- *
- * @return true for file, false otherwise.
- */
- public boolean isFile()
- {
- return isRelative() || pathUrl.getProtocol().equals( "file" );
- }
-
- /**
- * Check if this PathDescriptor describes a relative path.
- *
- * @return true if {@link #getPathUrl()} returns null.
- */
- public boolean isRelative()
- {
- return pathUrl == null;
- }
-
- /**
- * Get the base URL.
- *
- * @return the base URL.
- */
- public URL getBaseUrl()
- {
- return baseUrl;
- }
-
- /**
- * Get the path as a URL.
- *
- * @return the path as a URL.
- */
- public URL getPathUrl()
- {
- return pathUrl;
- }
-
- /**
- * Get the path.
- *
- * @return the path.
- */
- public String getPath()
- {
- if ( getPathUrl() != null )
- {
- if ( isFile() )
- {
- return StringUtils.stripEnd( getPathUrl().getPath(), "/" );
- }
- else
- {
- return getPathUrl().getPath();
- }
- }
- else
- {
- return relativePath;
- }
- }
-
- /**
- * Get the location for files.
- *
- * @return the location.
- */
- public String getLocation()
- {
- if ( isFile() )
- {
- if ( getPathUrl() != null )
- {
- return StringUtils.stripEnd( getPathUrl().getFile(), "/" );
- }
- else
- {
- return relativePath;
- }
- }
- else
- {
- return getPathUrl().toExternalForm();
- }
- }
-
- /** {@inheritDoc} */
- public String toString()
- {
- StringBuilder res =
- new StringBuilder( ( StringUtils.isNotEmpty( relativePath ) ) ? relativePath : String.valueOf( pathUrl ) );
- res.append( " (Base: " ).append( baseUrl ).append( ") Location: " ).append( getLocation() );
- return res.toString();
- }
-}
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
deleted file mode 100644
index fad4afb..0000000
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.codehaus.plexus.util.PathTool;
-
-/**
- * Utilities that allow conversion of old and new pathes and URLs relative to each other.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- * @deprecated this only operates on deprecated classes, it is not used anymore.
- */
-public abstract class PathUtils
-{
- /**
- * Private constructor.
- */
- private PathUtils()
- {
- // do not instantiate
- }
-
- /**
- * <p>convertPath.</p>
- *
- * @param oldPath not null
- * @param newPath not null
- * @return a PathDescriptor converted by the new path
- * @throws java.net.MalformedURLException if any
- */
- public static final PathDescriptor convertPath( final PathDescriptor oldPath, final PathDescriptor newPath )
- throws MalformedURLException
- {
- String relative = getRelativePath( oldPath, newPath );
-
- if ( relative == null )
- {
- return oldPath;
- }
-
- return new PathDescriptor( relative );
- }
-
- /**
- * <p>getRelativePath.</p>
- *
- * @param oldPathDescriptor not null
- * @param newPathDescriptor not null
- * @return a relative path depending if PathDescriptor is a file or a web url.
- * @see PathTool#getRelativeFilePath(String, String)
- * @see PathTool#getRelativeWebPath(String, String)
- */
- public static final String getRelativePath( final PathDescriptor oldPathDescriptor,
- final PathDescriptor newPathDescriptor )
- {
- // Cannot convert from URL to file.
- if ( oldPathDescriptor.isFile() )
- {
- if ( !newPathDescriptor.isFile() )
- {
- // We want to convert from a file to an URL. This is normally not possible...
- if ( oldPathDescriptor.isRelative() )
- {
- // unless the old path is a relative path. Then we might convert an existing
- // site into a new URL using resolvePaths()...
- return oldPathDescriptor.getPath();
- }
-
- // The old path is not relative. Bail out.
- return null;
- }
- else
- {
- // both are files, if either of them is relative, bail out
- // see DOXIASITETOOLS-29, MSITE-404, PLXUTILS-116
- if ( oldPathDescriptor.isRelative() || newPathDescriptor.isRelative() )
- {
- return null;
- }
- }
- }
-
- // Don't optimize to else. This might also be old.isFile && new.isFile ...
- if ( !oldPathDescriptor.isFile() )
- {
- // URLs, determine if they share protocol and domain info
- URL oldUrl = oldPathDescriptor.getPathUrl();
- URL newUrl = newPathDescriptor.getPathUrl();
-
- if ( oldUrl == null || newUrl == null )
- {
- // One of the sites has a strange URL. no relative path possible, bail out.
- return null;
- }
-
- if ( ( newUrl.getProtocol().equalsIgnoreCase( oldUrl.getProtocol() ) )
- && ( newUrl.getHost().equalsIgnoreCase( oldUrl.getHost() ) )
- && ( newUrl.getPort() == oldUrl.getPort() ) )
- {
- // Both paths point to the same site. So we can use relative paths.
-
- String oldPath = oldPathDescriptor.getPath();
- String newPath = newPathDescriptor.getPath();
-
- return PathTool.getRelativeWebPath( newPath, oldPath );
- }
-
- // Different sites. No relative Path possible.
- return null;
- }
-
- // Both Descriptors point to an absolute path. We can build a relative path.
- String oldPath = oldPathDescriptor.getPath();
- String newPath = newPathDescriptor.getPath();
-
- if ( oldPath == null || newPath == null )
- {
- // One of the sites has a strange URL. no relative path possible, bail out.
- return null;
- }
-
- return PathTool.getRelativeFilePath( oldPath, newPath );
- }
-}
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/Doxia91Test.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/Doxia91Test.java
deleted file mode 100644
index bcb8585..0000000
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/Doxia91Test.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for DOXIA-91 problems. All tests make sure that a passed in null will not generate any path conversion but
- * just returns the old path.
- *
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- */
-public class Doxia91Test
-{
- /** @throws Exception */
- @Test
- public void testOldPathNull()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( null );
- PathDescriptor newPath = new PathDescriptor( "http://www.apache.org/" );
-
- PathDescriptor diff = PathUtils.convertPath( oldPath, newPath );
-
- assertEquals( diff, oldPath );
- }
-
- /** @throws Exception */
- @Test
- public void testNewPathNull()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( "http://www.apache.org/", "file:///home/henning/foo" );
- PathDescriptor newPath = new PathDescriptor( null );
-
- PathDescriptor diff = PathUtils.convertPath( oldPath, newPath );
-
- assertEquals( diff, oldPath );
- }
-
- /** @throws Exception */
- @Test
- public void testBothPathNull()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( null );
- PathDescriptor newPath = new PathDescriptor( null );
-
- PathDescriptor diff = PathUtils.convertPath( oldPath, newPath );
-
- assertEquals( diff, oldPath );
- }
-}
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptorTest.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptorTest.java
deleted file mode 100644
index 3662b72..0000000
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathDescriptorTest.java
+++ /dev/null
@@ -1,655 +0,0 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.codehaus.plexus.util.Os;
-import org.codehaus.plexus.util.StringUtils;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test the PathDescriptor creation under various circumstances.
- *
- * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
- */
-public class PathDescriptorTest
-{
- /** @throws Exception */
- @Test
- public void testAbsPath()
- throws Exception
- {
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( "/" + path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testRelPath()
- throws Exception
- {
- String path = "relativePath";
-
- PathDescriptor desc = new PathDescriptor( path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testEmptyAbsPath()
- throws Exception
- {
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( "/" + path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testEmptyRelPath()
- throws Exception
- {
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullPath()
- throws Exception
- {
- String path = null;
-
- PathDescriptor desc = new PathDescriptor( path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNull( desc.getPath() );
- assertNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullBaseAbsPath()
- throws Exception
- {
- String base = null;
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullBaseRelPath()
- throws Exception
- {
- String base = null;
- String path = "relativePath";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullBaseEmptyAbsPath()
- throws Exception
- {
- String base = null;
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullBaseEmptyRelPath()
- throws Exception
- {
- String base = null;
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testNullBaseNullPath()
- throws Exception
- {
- String base = null;
- String path = null;
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertTrue( desc.isRelative() );
- assertNull( desc.getBaseUrl() );
- assertNull( desc.getPathUrl() );
- assertNull( desc.getPath() );
- assertNull( desc.getLocation() );
- assertEquals( "wrong path", path, desc.getPath() );
- assertEquals( "wrong location", path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testUrlBaseAbsPath()
- throws Exception
- {
- String base = "http://maven.apache.org/";
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testUrlBaseRelPath()
- throws Exception
- {
- String base = "http://maven.apache.org/";
- String path = "relativePath";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testUrlBaseEmptyAbsPath()
- throws Exception
- {
- String base = "http://maven.apache.org/";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testUrlBaseEmptyRelPath()
- throws Exception
- {
- String base = "http://maven.apache.org/";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + path, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testUrlBaseNullPath()
- throws Exception
- {
- String base = "http://maven.apache.org/";
- String path = null;
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/", desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
-
- /** @throws Exception */
- @Test
- public void testFileBaseAbsPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( "file://" + base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base + "/" + path ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base + "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + "/" + path, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testFileBaseRelPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "relativePath";
-
- PathDescriptor desc = new PathDescriptor( "file://" + base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base + "/" + path ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base + "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + "/" + path, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testFileBaseEmptyAbsPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( "file://" + base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testFileBaseEmptyRelPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( "file://" + base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testFileBaseNullPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = null;
-
- PathDescriptor desc = new PathDescriptor( "file://" + base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
-
-/*
- // same as testUrlBaseAbsPath with scp, this fails!? DOXIASITETOOLS-47
- public void testUriBaseAbsPath()
- throws Exception
- {
- String base = "scp://people.apache.org/";
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertFalse( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( "wrong path", "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + path, desc.getLocation() );
- }
-*/
-
- /** @throws Exception */
- @Test
- public void testPathBaseAbsPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "absolutePath";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base + "/" + path ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base + "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + "/" + path, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testPathBaseRelPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "relativePath";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base + "/" + path ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base + "/" + path, desc.getPath() );
- assertEquals( "wrong location", base + "/" + path, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testPathBaseEmptyAbsPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, "/" + path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testPathBaseEmptyRelPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = "";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testPathBaseNullPath()
- throws Exception
- {
- String base = "/tmp/foo";
- String path = null;
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- String s = StringUtils.replace( new File( base ).toURI().toURL().toString(), "file:", "" );
- assertEquals( "wrong path", s, desc.getPath() );
- assertEquals( "wrong location", s, desc.getLocation() );
- }
- else
- {
- assertEquals( "wrong path", base, desc.getPath() );
- assertEquals( "wrong location", base, desc.getLocation() );
- }
- }
-
- /** @throws Exception */
- @Test
- public void testPathRelBase()
- throws Exception
- {
- String base = "../msite-404";
- String path = "index.html";
-
- PathDescriptor desc = new PathDescriptor( base, path );
-
- assertTrue( desc.isFile() );
- assertFalse( desc.isRelative() );
- assertNotNull( desc.getBaseUrl() );
- assertNotNull( desc.getPathUrl() );
- assertNotNull( desc.getPath() );
- assertNotNull( desc.getLocation() );
- assertEquals( desc.getPath(), desc.getLocation() );
- // Hudson doesn't like this?
- //assertEquals( desc.getPathUrl().toString(), desc.getBaseUrl().toString() + "/" + path );
- }
-}
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtilsTest.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtilsTest.java
deleted file mode 100644
index 06130c5..0000000
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtilsTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- * @author ltheussl
- */
-public class PathUtilsTest
-{
- private static final String SLASH = File.separator;
-
- /** @throws Exception */
- @Test
- public void testConvertPath()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( (String) null, "base" );
- PathDescriptor newPath = new PathDescriptor( "/tmp", "target" );
- assertEquals( oldPath, PathUtils.convertPath( oldPath, newPath ) );
- assertEquals( newPath, PathUtils.convertPath( newPath, oldPath ) );
- }
-
- /** @throws Exception */
- @Test
- public void testGetRelativePath()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( "/tmp/foo", "base" );
- PathDescriptor newPath = new PathDescriptor( "/tmp", "target" );
- assertEquals( ".." + SLASH + ".." + SLASH + "target", PathUtils.getRelativePath( oldPath, newPath ) );
-
- oldPath = new PathDescriptor( (String) null, "base" );
- assertNull( PathUtils.getRelativePath( oldPath, newPath ) );
- assertNull( PathUtils.getRelativePath( newPath, oldPath ) );
-
- oldPath = new PathDescriptor( "/tmp/foo", null );
- assertEquals( ".." + SLASH + "target", PathUtils.getRelativePath( oldPath, newPath ) );
- assertEquals( ".." + SLASH + "foo", PathUtils.getRelativePath( newPath, oldPath ) );
- }
-
- /** @throws Exception */
- @Test
- public void testRelativePathScpBase()
- throws Exception
- {
- PathDescriptor oldPath = new PathDescriptor( "http://maven.apache.org/", "source" );
- PathDescriptor newPath = new PathDescriptor( "http://maven.apache.org/", "target" );
- assertEquals( "../source", PathUtils.getRelativePath( oldPath, newPath ) );
-
- oldPath = new PathDescriptor( "scp://people.apache.org/", "source" );
- newPath = new PathDescriptor( "scp://people.apache.org/", "target" );
- // same with scp URLs fails?! DOXIASITETOOLS-47
- //assertEquals( "../source", PathUtils.getRelativePath( oldPath, newPath ) );
- }
-}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
index 644eb0c..e214cc1 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
@@ -32,7 +32,6 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.text.DateFormat;
@@ -901,21 +900,6 @@ public class DefaultSiteRenderer
}
/** {@inheritDoc} */
- @Deprecated
- public SiteRenderingContext createContextForTemplate( File templateFile, Map<String, ?> attributes,
- DecorationModel decoration, String defaultWindowTitle,
- Locale locale )
- throws MalformedURLException
- {
- SiteRenderingContext context = createSiteRenderingContext( attributes, decoration, defaultWindowTitle, locale );
-
- context.setTemplateName( templateFile.getName() );
- context.setTemplateClassLoader( new URLClassLoader( new URL[]{templateFile.getParentFile().toURI().toURL()} ) );
-
- return context;
- }
-
- /** {@inheritDoc} */
public void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory,
File outputDirectory )
throws IOException
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
index 3e7bc89..d3460b0 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
@@ -24,14 +24,12 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
/**
* <p>Site Renderer interface: render a collection of documents into a site, ie decored with a site template
@@ -60,19 +58,6 @@ public interface Renderer // TODO rename to SiteRenderer
throws RendererException, IOException;
/**
- * Generate a document output from a Doxia SiteRenderer Sink, i.e. merge the document content into
- * the site template.
- *
- * @param writer the Writer to use.
- * @param sink the Site Renderer Sink that received the Doxia events during document content rendering.
- * @param siteRenderingContext the SiteRenderingContext to use.
- * @throws RendererException if it bombs.
- * @deprecated since 1.8, use mergeDocumentIntoSite
- */
- void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext )
- throws RendererException;
-
- /**
* Generate a document output integrated in a site from a document content,
* i.e. merge the document content into the site template.
*
@@ -103,38 +88,6 @@ public interface Renderer // TODO rename to SiteRenderer
throws RendererException, IOException;
/**
- * Create a Site Rendering Context for a site using a local template.
- *
- * @param templateFile template file
- * @param attributes attributes to use
- * @param decoration a decoration model
- * @param defaultWindowTitle default window title
- * @param locale locale to use
- * @return a SiteRenderingContext.
- * @throws MalformedURLException if it bombs.
- * @since 1.7, had an additional skinFile parameter before
- * @deprecated Deprecated without replacement, use skins only.
- * @see #createContextForSkin(Artifact, Map, DecorationModel, String, Locale)
- */
- @Deprecated
- SiteRenderingContext createContextForTemplate( File templateFile, Map<String, ?> attributes,
- DecorationModel decoration, String defaultWindowTitle,
- Locale locale )
- throws MalformedURLException;
-
- /**
- * Copy resource files.
- *
- * @param siteRenderingContext the SiteRenderingContext to use
- * @param resourcesDirectory resources directory as file
- * @param outputDirectory output directory as file
- * @throws IOException if it bombs.
- * @deprecated since 1.7, use copyResources without resourcesDirectory parameter
- */
- void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory )
- throws IOException;
-
- /**
* Copy resource files from skin, template, and site resources.
*
* @param siteRenderingContext the SiteRenderingContext to use.
@@ -149,18 +102,6 @@ public interface Renderer // TODO rename to SiteRenderer
* Locate Doxia document source files in the site source context.
*
* @param siteRenderingContext the SiteRenderingContext to use
- * @return the Doxia document renderers in a Map keyed by output file name.
- * @throws IOException if it bombs.
- * @throws RendererException if it bombs.
- * @deprecated since 1.8, use locateDocumentFiles with editable parameter
- */
- Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext )
- throws IOException, RendererException;
-
- /**
- * Locate Doxia document source files in the site source context.
- *
- * @param siteRenderingContext the SiteRenderingContext to use
* @param editable Doxia document renderer as editable? (should not set editable if generated Doxia source)
* @return the Doxia document renderers in a Map keyed by output file name.
* @throws IOException if it bombs.
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
index 239e6ec..aa7cdaa 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
@@ -55,12 +55,6 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
private final String generator;
- @Deprecated
- public RenderingContext( File basedir, String document )
- {
- this( basedir, null, document, null, null, false, null );
- }
-
/**
* <p>
* Constructor for RenderingContext when document is not rendered from a Doxia markup source.
@@ -77,12 +71,6 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
this( basedir, null, document, null, null, false, generator );
}
- @Deprecated
- public RenderingContext( File basedir, String document, String parserId, String extension )
- {
- this( basedir, null, document, parserId, extension, false, null );
- }
-
public RenderingContext( File basedir, String basedirRelativePath, String document, String parserId,
String extension, boolean editable )
{
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java
deleted file mode 100644
index e8870de..0000000
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.maven.doxia.siterenderer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.runtime.resource.loader.ResourceLoader;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.commons.collections.ExtendedProperties;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- * Skin resource loader: gets content from context classloader, which should contain skin artifact,
- * and normalizes newlines
- * (see <a href="https://issues.apache.org/jira/browse/DOXIASITETOOLS-87">DOXIASITETOOLS-87</a>).
- *
- * @author Hervé Boutemy
- */
-@Deprecated
-public class SkinResourceLoader
- extends ResourceLoader
-{
- public void init( ExtendedProperties configuration )
- {
- }
-
- public synchronized InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- if ( name.startsWith( "/" ) )
- {
- name = name.substring( 1 );
- }
-
- return normalizeNewline( classLoader.getResourceAsStream( name ) );
- }
-
- InputStream normalizeNewline( InputStream in )
- throws ResourceNotFoundException
- {
- if ( in == null )
- {
- return null;
- }
-
- try
- {
- byte[] content = IOUtil.toByteArray( in );
-
- // following code based on org.apache.maven.doxia.sink.AbstractSink.unifyEOLs(String)
-
- byte[] eol = System.getProperty( "line.separator" ).getBytes();
-
- final int size = content.length;
-
- ByteArrayOutputStream out = new ByteArrayOutputStream( size );
-
- for ( int i = 0; i < size; i++ )
- {
- byte b = content[i];
-
- if ( b == '\r' )
- {
- if ( ( i + 1 ) < size && content[i + 1] == '\n' )
- {
- i++;
- }
-
- out.write( eol );
- }
- else if ( b == '\n' )
- {
- out.write( eol );
- }
- else
- {
- out.write( b );
- }
- }
-
- return new ByteArrayInputStream( out.toByteArray() );
- }
- catch ( IOException ioe )
- {
- throw new ResourceNotFoundException( "cannot read resource", ioe );
- }
- finally
- {
- IOUtil.close( in );
- }
- }
-
- public boolean isSourceModified( Resource resource )
- {
- return false;
- }
-
- public long getLastModified( Resource resource )
- {
- return 0;
- }
-}
diff --git a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
index 755e27e..4a414d8 100644
--- a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
+++ b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
@@ -316,34 +316,6 @@ public class DefaultSiteRendererTest
assertEquals( expectedResult, renderResult );
}
- public void testVelocityToolManagerForTemplate()
- throws Exception
- {
- StringWriter writer = new StringWriter();
-
- File templateFile =
- new File( getBasedir(), "target/test-classes/org/apache/maven/doxia/siterenderer/velocity-toolmanager.vm" );
- Map<String, Object> attributes = new HashMap<String, Object>();
-
- /*
- * We need to add doxiaSiteRendererVersion manually because version property from pom.properties
- * is not available at test time in some cases.
- */
- attributes.put( "doxiaSiteRendererVersion", "1.7-bogus" );
-
- SiteRenderingContext siteRenderingContext =
- renderer.createContextForTemplate( templateFile, attributes, new DecorationModel(),
- "defaultWindowTitle", Locale.ENGLISH );
- RenderingContext context = new RenderingContext( new File( "" ), "document.html", "generator" );
- SiteRendererSink sink = new SiteRendererSink( context );
- renderer.mergeDocumentIntoSite( writer, sink, siteRenderingContext );
-
- String renderResult = writer.toString();
- InputStream in = getClass().getResourceAsStream( "velocity-toolmanager.expected.txt" );
- String expectedResult = StringUtils.unifyLineSeparators( IOUtils.toString( in, StandardCharsets.UTF_8 ) );
- assertEquals( expectedResult, renderResult );
- }
-
public void testVelocityToolManagerForSkin()
throws Exception
{
diff --git a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java
deleted file mode 100644
index 6f7a5e9..0000000
--- a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.apache.maven.doxia.siterenderer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.maven.doxia.sink.impl.AbstractSink;
-import org.codehaus.plexus.util.IOUtil;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class SkinResourceLoaderTest
-{
- private SkinResourceLoader skinResourceLoader = new SkinResourceLoader();
-
- @Test
- public void testNormalizeNewline() throws Exception
- {
- String EOL = AbstractSink.EOL;
- String EOL_MACOS9 = "\r";
- String EOL_UNIX = "\n";
- String EOL_WIN = "\r\n";
-
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_MACOS9 + " world" ) );
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_UNIX + " world" ) );
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_WIN + " world" ) );
-
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_MACOS9 ) );
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_UNIX ) );
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_WIN ) );
-
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_MACOS9 + "Hello world" ) );
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_UNIX + "Hello world" ) );
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_WIN + "Hello world" ) );
- }
-
- private String normalizeNewline( String text ) throws IOException
- {
- InputStream in = new ByteArrayInputStream( text.getBytes() );
- InputStream out = skinResourceLoader.normalizeNewline( in );
- return IOUtil.toString( out );
- }
-}