/*
 * 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.
 */
package org.apache.pdfbox.pdmodel.fdf;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

/**
 * Tests for the FDFAnnotation class.
 * 
 * @author Johanneke Lamberink
 *
 */
public class FDFAnnotationTest
{

    @Test
    public void loadXFDFAnnotations() throws IOException
    {
        FDFDocument fdfDoc = null;
        InputStream stream = null;
        List<FDFAnnotation> fdfAnnots = new ArrayList<>();
        try
        {
            stream = FDFAnnotationTest.class
                    .getResourceAsStream("xfdf-test-document-annotations.xml");
            fdfDoc = FDFDocument.loadXFDF(stream);
            fdfAnnots = fdfDoc.getCatalog().getFDF().getAnnotations();
            assertEquals(17, fdfAnnots.size());
        }
        finally
        {
            if (stream != null)
            {
                stream.close();
            }
            if (fdfDoc != null)
            {
                fdfDoc.close();
            }
        }
    }
}

@@ -836,16 +836,37 @@
 l.fdf;%0A%0A
+import java.io.File;%0A
 import s
@@ -947,50 +947,30 @@
 ava.
-io.InputStream;%0Aimport java.util.ArrayList
+net.URISyntaxException
 ;%0Aim
@@ -1132,17 +1132,16 @@
 nTest%0A%7B%0A
-%0A
     @Tes
@@ -1202,187 +1202,61 @@
 tion
-%0A    %7B%0A        FDFDocument fdfDoc = null;%0A        InputStream stream = null;%0A        List%3CFDFAnnotation%3E fdfAnnots = new ArrayList%3C%3E();%0A        try%0A        %7B%0A            stream = 
+, URISyntaxException%0A    %7B%0A        File f = new File(
 FDFA
@@ -1278,29 +1278,8 @@
 lass
-%0A                    
 .get
@@ -1290,16 +1290,8 @@
 urce
-AsStream
 (%22xf
@@ -1324,16 +1324,25 @@
 ns.xml%22)
+.toURI())
 ;%0A      
@@ -1339,27 +1339,40 @@
 ));%0A        
-   
+try (FDFDocument
  fdfDoc = FD
@@ -1394,28 +1394,53 @@
 FDF(
-stream);%0A           
+f))%0A        %7B%0A            List%3CFDFAnnotation%3E
  fdf
@@ -1557,232 +1557,11 @@
   %7D%0A
-        finally%0A        %7B%0A            if (stream != null)%0A            %7B%0A                stream.close();%0A            %7D%0A            if (fdfDoc != null)%0A            %7B%0A                fdfDoc.close();%0A            %7D%0A        %7D%0A
     %7D%0A%7D
-%0A

simplify code