@@ -0,0 +1,2631 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0A/* $Id$ */%0Apackage org.apache.fop.pdf;%0A%0Aimport java.awt.Dimension;%0Aimport java.awt.Rectangle;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0A%0Aimport javax.xml.transform.stream.StreamResult;%0A%0Aimport org.junit.Test;%0A%0Aimport org.apache.fop.apps.FOUserAgent;%0Aimport org.apache.fop.apps.FopFactory;%0Aimport org.apache.fop.fonts.FontInfo;%0Aimport org.apache.fop.render.intermediate.IFContext;%0Aimport org.apache.fop.render.intermediate.IFException;%0Aimport org.apache.fop.render.intermediate.extensions.Link;%0Aimport org.apache.fop.render.intermediate.extensions.URIAction;%0Aimport org.apache.fop.render.pdf.PDFDocumentHandler;%0Aimport org.apache.fop.render.pdf.extensions.PDFEmbeddedFileAttachment;%0A%0Aimport junit.framework.Assert;%0A%0Apublic class PDFAttachmentTestCase %7B%0A    private FOUserAgent ua = FopFactory.newInstance(new File(%22.%22).toURI()).newFOUserAgent();%0A%0A    @Test%0A    public void testAddEmbeddedFile() throws IFException %7B%0A        PDFDocumentHandler docHandler = new PDFDocumentHandler(new IFContext(ua));%0A        docHandler.setFontInfo(new FontInfo());%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        docHandler.setResult(new StreamResult(out));%0A        docHandler.startDocument();%0A        docHandler.startPage(0, %22%22, %22%22, new Dimension());%0A        docHandler.handleExtensionObject(new PDFEmbeddedFileAttachment(%22filename%22, %22src%22, %22desc%22));%0A        docHandler.getDocumentNavigationHandler().renderLink(new Link(%0A                new URIAction(%22embedded-file:filename%22, false), new Rectangle()));%0A        docHandler.endDocument();%0A        Assert.assertTrue(out.toString().contains(%22%3C%3C%5Cn  /Type /Filespec%5Cn  /F (filename)%22));%0A        Assert.assertTrue(out.toString().contains(%22%3C%3C%5Cn/S /JavaScript%5Cn%22%0A                + %22/JS (this.exportDataObject(%7BcName:%5C%22filename%5C%22, nLaunch:2%7D);)%5Cn%3E%3E%22));%0A    %7D%0A%7D%0A

Add test for PDF Attachment