/core/img/apps/

ssteiner-pdfbox3' type='application/atom+xml'/>
aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src/test/java/org/apache/fop/pdf/PDFNumsArrayPDFV17TestCase.java
blob: ac09d221ce9c67fdba5fdcc26acfbeaf561fa407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * 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.
 */

/* $Id$ */

package org.apache.fop.pdf;

import java.io.IOException;

import org.junit.Before;
import org.junit.Test;

/**
 * Test case for {@link PDFNumsArray}. PDF1.7 requires text values to be included as refs and
 * number values to be included as direct objects.
 */
public class PDFNumsArrayPDFV17TestCase extends PDFObjectTestCase {
    private static final int TEST_NUMBER = 44;
    private static final String TEST_TEXT = "Test text";
    private PDFNumsArray numsArray;
    private String expectedStringNumsArray = "[0 1 0 R 1 " + TEST_NUMBER + "]";
    private String expectedStringText = "((" + TEST_TEXT + "))";

    @Before
    public void setUp() {
        doc.setPDFVersion(Version.V1_7);
        numsArray = new PDFNumsArray(parent);
        numsArray.setDocument(doc);
        PDFText pdfText = new PDFText();
        pdfText.setText(TEST_TEXT);
        numsArray.put(0, pdfText);
        PDFNumber num = new PDFNumber();
        num.setNumber(TEST_NUMBER);
        numsArray.put(1, num);

        pdfObjectUnderTest = numsArray;
    }

    /**
     * Test output() - ensure that this object is properly outputted to the PDF document.
     * @throws IOException if an I/O error occurs
     */
    @Test
    public void testOutput() throws IOException {
        testOutputStreams(expectedStringNumsArray, numsArray);
        testOutputStreams(expectedStringText, doc.objects.get(1));
    }
}