@@ -0,0 +1,3456 @@
+/*%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%0Apackage org.apache.pdfbox.text;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.File;%0Aimport java.io.FileReader;%0Aimport java.io.IOException;%0A%0Aimport org.apache.pdfbox.pdmodel.PDDocument;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A * Test for the PDButton class.%0A *%0A */%0Apublic class BidiTest%0A%7B%0A    private static final File IN_DIR = new File(%22src/test/resources/org/apache/pdfbox/text/%22);%0A    private static final String NAME_OF_PDF = %22BidiSample.pdf%22;%0A    private static final String NAME_OF_TXT = %22BidiSample.pdf.txt%22;%0A    private static final String NAME_OF_TXT_SORTED = %22BidiSample.pdf-sorted.txt%22;%0A%0A    private PDDocument document;%0A    private PDFTextStripper stripper;%0A%0A    @Before%0A    public void setUp() throws IOException%0A    %7B%0A        document = PDDocument.load(new File(IN_DIR, NAME_OF_PDF));%0A        stripper = new PDFTextStripper();%0A        stripper.setLineSeparator(%22%5Cn%22);%0A    %7D%0A%0A    @Test%0A    public void testSorted() throws IOException%0A    %7B%0A        stripper.setSortByPosition(true);%0A        String extractedText = stripper.getText(document);%0A%0A        FileReader compareTextReader = new FileReader(new File(IN_DIR, NAME_OF_TXT_SORTED));%0A        BufferedReader bufferedCompareTextReader = new BufferedReader(compareTextReader);%0A%0A        StringBuilder compareTextBuilder = new StringBuilder();%0A%0A        String line = bufferedCompareTextReader.readLine();%0A%0A        while (line != null)%0A        %7B%0A            compareTextBuilder.append(line);%0A            compareTextBuilder.append('%5Cn');%0A            line = bufferedCompareTextReader.readLine();%0A        %7D%0A%0A        bufferedCompareTextReader.close();%0A%0A        assertEquals(extractedText, compareTextBuilder.toString());%0A%0A    %7D%0A%0A    @Test%0A    public void testNotSorted() throws IOException%0A    %7B%0A        stripper.setSortByPosition(false);%0A        String extractedText = stripper.getText(document);%0A%0A        FileReader compareTextReader = new FileReader(new File(IN_DIR, NAME_OF_TXT));%0A        BufferedReader bufferedCompareTextReader = new BufferedReader(compareTextReader);%0A%0A        StringBuilder compareTextBuilder = new StringBuilder();%0A        String line = bufferedCompareTextReader.readLine();%0A%0A        while (line != null)%0A        %7B%0A            compareTextBuilder.append(line);%0A            compareTextBuilder.append('%5Cn');%0A            line = bufferedCompareTextReader.readLine();%0A        %7D%0A%0A        bufferedCompareTextReader.close();%0A%0A        assertEquals(extractedText, compareTextBuilder.toString());%0A%0A    %7D%0A%0A    @After%0A    public void tearDown() throws IOException%0A    %7B%0A        document.close();%0A    %7D%0A%0A%7D%0A

add unit test