This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 60e1c2c93f6e1db7b5cdb3c3ab09c32d0fc98f2e Author: Michael Osipov <[email protected]> AuthorDate: Wed Dec 29 21:58:54 2021 +0100 [DOXIA-631] Remove all deprecated macros --- .../org/apache/maven/doxia/macro/SsiMacro.java | 71 --------- .../org/apache/maven/doxia/macro/SwfMacro.java | 169 --------------------- .../org/apache/maven/doxia/macro/SsiMacroTest.java | 68 --------- .../org/apache/maven/doxia/macro/SwfMacroTest.java | 158 ------------------- 4 files changed, 466 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/SsiMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/SsiMacro.java deleted file mode 100644 index cb80f62..0000000 --- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/SsiMacro.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.doxia.macro; - -/* - * 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.util.Map; -import org.apache.maven.doxia.sink.Sink; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Server-Side Include directive, to insert a SSI into the output. - * Required parameter is <code>function</code> to define SSI function, then - * additional parameters are completely free. - * - * @since 1.7 - */ -@Deprecated -@Component( role = Macro.class, hint = "ssi" ) -public class SsiMacro - extends AbstractMacro -{ - private static final String PARAM_FUNCTION = "function"; - - private boolean isInternalParameter( String name ) - { - return PARAM_FUNCTION.equals( name ) || MacroRequest.isInternalParameter( name ); - } - /** {@inheritDoc} */ - public void execute( Sink sink, MacroRequest request ) - throws MacroExecutionException - { - String function = (String) request.getParameter( PARAM_FUNCTION ); - - required( PARAM_FUNCTION, function ); - - StringBuilder buff = new StringBuilder(); - buff.append( '#' ); - buff.append( function ); - - for ( Map.Entry<String, Object> entry : request.getParameters().entrySet() ) - { - if ( !isInternalParameter( entry.getKey() ) ) - { - buff.append( ' ' ); - buff.append( entry.getKey() ); - buff.append( "=\"" ); - buff.append( entry.getValue() ); - buff.append( '"' ); - } - } - - buff.append( ' ' ); - sink.comment( buff.toString() ); - } -} diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java deleted file mode 100644 index 1b983c0..0000000 --- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.apache.maven.doxia.macro; - -/* - * 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.apache.maven.doxia.sink.Sink; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.StringUtils; - -/** - * Macro for embedding Flash (SWF) within Maven documentation. - * - * @author <a href="mailto:[email protected]">Steve Motola</a> - * @author <a href="mailto:[email protected]">Vincent Siveton</a> - */ -@Deprecated -@Component( role = Macro.class, hint = "swf" ) -public class SwfMacro - extends AbstractMacro -{ - /** {@inheritDoc} */ - public void execute( Sink sink, MacroRequest request ) - throws MacroExecutionException - { - // parameter defaults - String src = ""; - String id = "swf"; - String width = "400"; - String height = "400"; - String quality = "high"; - String menu = "false"; - String loop = "0"; - String play = "true"; - String version = "9,0,45,0"; - String allowScript = "sameDomain"; - - // assign parameters - for ( String key : request.getParameters().keySet() ) - { - Object parameterObject = request.getParameter( key ); - if ( !( parameterObject instanceof String ) ) - { - continue; - } - String str = (String) parameterObject; - switch ( key ) - { - case "src": - if ( StringUtils.isNotEmpty( str ) ) - { - src = str; - } - break; - case "id": - if ( StringUtils.isNotEmpty( str ) ) - { - id = str; - } - break; - case "width": - if ( StringUtils.isNotEmpty( str ) ) - { - width = str; - } - break; - case "height": - if ( StringUtils.isNotEmpty( str ) ) - { - height = str; - } - break; - case "quality": - if ( StringUtils.isNotEmpty( str ) ) - { - quality = str; - } - break; - case "menu": - if ( StringUtils.isNotEmpty( str ) ) - { - menu = str; - } - break; - case "loop": - if ( StringUtils.isNotEmpty( str ) ) - { - loop = str; - } - break; - case "play": - if ( StringUtils.isNotEmpty( str ) ) - { - play = str; - } - break; - case "version": - // enable version shorthand - // TODO: put in other shorthand versions - if ( str.equals( "6" ) ) - { - version = "6,0,29,0"; - } - else - { - if ( str.equals( "9" ) ) - { - version = "9,0,45,0"; - } - else - { - if ( StringUtils.isNotEmpty( str ) ) - { - version = str; - } - } - } - break; - case "allowScript": - if ( StringUtils.isNotEmpty( str ) ) - { - allowScript = str; - } - break; - default: - // ignore all other - } - } - - StringBuilder content = new StringBuilder(); - content.append( "<center>" ).append( EOL ); - content.append( "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " ) - .append( "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" ) - .append( version ).append( "\" width=\"" ).append( width ).append( "\" height=\"" ).append( height ) - .append( "\" id=\"" ).append( id ).append( "\">" ).append( EOL ); - content.append( "<param name=\"movie\" value=\"" ).append( src ).append( "\" />" ).append( EOL ); - content.append( "<param name=\"quality\" value=\"" ).append( quality ).append( "\" />" ).append( EOL ); - content.append( "<param name=\"menu\" value=\"" ).append( menu ).append( "\" />" ).append( EOL ); - content.append( "<param name=\"loop\" value=\"" ).append( loop ).append( "\" />" ).append( EOL ); - content.append( "<param name=\"play\" value=\"" ).append( play ).append( "\" />" ).append( EOL ); - content.append( "<param name=\"allowScriptAccess\" value=\"" ) - .append( allowScript ).append( "\" />" ).append( EOL ); - content.append( "<embed src=\"" ).append( src ).append( "\" width=\"" ).append( width ).append( "\" height=\"" ) - .append( height ).append( "\" loop=\"" ).append( loop ).append( "\" play=\"" ).append( play ) - .append( "\" quality=\"" ).append( quality ).append( "\" allowScriptAccess=\"" ).append( allowScript ) - .append( "\" " ).append( "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" " ) - .append( "type=\"application/x-shockwave-flash\" menu=\"" ).append( menu ).append( "\">" ).append( EOL ); - content.append( "</embed>" ).append( EOL ); - content.append( "</object>" ).append( EOL ); - content.append( "</center>" ).append( EOL ); - - sink.rawText( content.toString() ); - } -} diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java deleted file mode 100644 index 7ef3f97..0000000 --- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.apache.maven.doxia.macro; - -/* - * 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.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.maven.doxia.parser.XhtmlBaseParser; -import org.apache.maven.doxia.sink.impl.SinkEventElement; -import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -public class SsiMacroTest -{ - - /** - * Test of execute method, of class SwfMacro. - * - * @throws MacroExecutionException if a macro fails during testing. - */ - @Test - public void testExecute() - throws MacroExecutionException - { - - Map<String, Object> macroParameters = new HashMap<>(); - macroParameters.put( "function", "include" ); - macroParameters.put( "file", "include-file.html" ); - - MacroRequest request = new MacroRequest( "source", new XhtmlBaseParser(), macroParameters, new File( "." ) ); - SsiMacro macro = new SsiMacro(); - - SinkEventTestingSink sink = new SinkEventTestingSink(); - macro.execute( sink, request ); - - Iterator<SinkEventElement> it = sink.getEventList().iterator(); - SinkEventElement event = it.next(); - - assertEquals( "comment", event.getName() ); - String comment = (String) event.getArgs()[0]; - assertEquals( "#include file=\"include-file.html\" ", comment ); - assertFalse( it.hasNext() ); - } -} diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java deleted file mode 100644 index e827f84..0000000 --- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.apache.maven.doxia.macro; - -/* - * 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.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.maven.doxia.sink.impl.SinkEventElement; -import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Test swf macro. - * - * @author ltheussl - */ -public class SwfMacroTest -{ - /** - * Test of execute method, of class SwfMacro. - * - * @throws MacroExecutionException if a macro fails during testing. - */ - @Test - public void testExecute() - throws MacroExecutionException - { - - Map<String, Object> macroParameters = new HashMap<>(); - macroParameters.put( "src", "src.swf" ); - macroParameters.put( "id", "Movie" ); - macroParameters.put( "width", "50" ); - macroParameters.put( "height", "60" ); - macroParameters.put( "quality", "best" ); - macroParameters.put( "menu", "true" ); - macroParameters.put( "loop", "3" ); - macroParameters.put( "play", "false" ); - macroParameters.put( "version", "6" ); - macroParameters.put( "allowScript", "always" ); - - - SinkEventTestingSink sink = new SinkEventTestingSink(); - MacroRequest request = new MacroRequest( macroParameters, new File( "." ) ); - SwfMacro macro = new SwfMacro(); - macro.required( "src", "value" ); - - try - { - macro.required( "src", "" ); - fail(); - } - catch ( IllegalArgumentException e ) - { - assertNotNull( e ); - } - - try - { - macro.required( "src", null ); - fail(); - } - catch ( IllegalArgumentException e ) - { - assertNotNull( e ); - } - - macro.execute( sink, request ); - - Iterator<SinkEventElement> it = sink.getEventList().iterator(); - SinkEventElement event = it.next(); - - assertEquals( "rawText", event.getName() ); - assertFalse( it.hasNext() ); - - request = new MacroRequest( new HashMap<String, Object>(), new File( "." ) ); - sink.reset(); - - macro.execute( sink, request ); - - it = sink.getEventList().iterator(); - event = it.next(); - - assertEquals( "rawText", event.getName() ); - assertFalse( it.hasNext() ); - } - - /** - * Test that SwfMacro does not crash if other things then Strings are provided. - * - * @throws MacroExecutionException if a macro fails during testing. - */ - @Test - public void testOthersThenStringParameters() - throws MacroExecutionException - { - - Map<String, Object> macroParameters = new HashMap<>(); - macroParameters.put( "src", "src.swf" ); - macroParameters.put( "id", "Movie" ); - macroParameters.put( "width", "50" ); - macroParameters.put( "height", "60" ); - macroParameters.put( "quality", "best" ); - macroParameters.put( "menu", "true" ); - macroParameters.put( "loop", "3" ); - macroParameters.put( "play", "false" ); - macroParameters.put( "version", "6" ); - macroParameters.put( "allowScript", "always" ); - macroParameters.put( "notAString", 0 ); - - - SinkEventTestingSink sink = new SinkEventTestingSink(); - MacroRequest request = new MacroRequest( macroParameters, new File( "." ) ); - SwfMacro macro = new SwfMacro(); - macro.required( "src", "value" ); - - macro.execute( sink, request ); - - Iterator<SinkEventElement> it = sink.getEventList().iterator(); - SinkEventElement event = it.next(); - - assertEquals( "rawText", event.getName() ); - assertFalse( it.hasNext() ); - - request = new MacroRequest( new HashMap<String, Object>(), new File( "." ) ); - sink.reset(); - - macro.execute( sink, request ); - - it = sink.getEventList().iterator(); - event = it.next(); - - assertEquals( "rawText", event.getName() ); - assertFalse( it.hasNext() ); - } -}
