001package org.apache.maven.doxia.macro; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.File; 023 024import java.util.HashMap; 025import java.util.Iterator; 026import java.util.Map; 027 028import org.apache.maven.doxia.parser.XhtmlBaseParser; 029import org.apache.maven.doxia.sink.impl.SinkEventElement; 030import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; 031 032import junit.framework.TestCase; 033 034public class SsiMacroTest 035 extends TestCase 036{ 037 038 /** 039 * Test of execute method, of class SwfMacro. 040 * 041 * @throws MacroExecutionException if a macro fails during testing. 042 */ 043 public void testExecute() 044 throws MacroExecutionException 045 { 046 047 Map<String, Object> macroParameters = new HashMap<String, Object>(); 048 macroParameters.put( "function", "include" ); 049 macroParameters.put( "file", "include-file.html" ); 050 051 MacroRequest request = new MacroRequest( "source", new XhtmlBaseParser(), macroParameters, new File( "." ) ); 052 SsiMacro macro = new SsiMacro(); 053 054 SinkEventTestingSink sink = new SinkEventTestingSink(); 055 macro.execute( sink, request ); 056 057 Iterator<SinkEventElement> it = sink.getEventList().iterator(); 058 SinkEventElement event = it.next(); 059 060 assertEquals( "comment", event.getName() ); 061 String comment = (String) event.getArgs()[0]; 062 assertEquals( "#include file=\"include-file.html\" ", comment ); 063 assertFalse( it.hasNext() ); 064 } 065}