View | Details | Raw Unified | Return to bug 58261
Collapse All | Expand All

(-)src/java/org/apache/poi/hssf/dev/ReSave.java (-5 / +5 lines)
Lines 33-43 Link Here
33
public class ReSave {
33
public class ReSave {
34
    public static void main(String[] args) throws Exception {
34
    public static void main(String[] args) throws Exception {
35
        boolean initDrawing = false;
35
        boolean initDrawing = false;
36
        for(String arg : args) {
36
        for(String filename : args) {
37
            if(arg.equals("-dg")) initDrawing = true;
37
            if(filename.equals("-dg")) initDrawing = true;
38
            else {
38
            else {
39
                System.out.print("reading " + arg + "...");
39
                System.out.print("reading " + filename + "...");
40
                FileInputStream is = new FileInputStream(arg);
40
                FileInputStream is = new FileInputStream(filename);
41
                HSSFWorkbook wb = new HSSFWorkbook(is);
41
                HSSFWorkbook wb = new HSSFWorkbook(is);
42
                try {
42
                try {
43
                    System.out.println("done");
43
                    System.out.println("done");
Lines 49-55 Link Here
49
                        }
49
                        }
50
                    }
50
                    }
51
    
51
    
52
                    String outputFile = arg.replace(".xls", "-saved.xls");
52
                    String outputFile = filename.replace(".xls", "-saved.xls");
53
                    System.out.print("saving to " + outputFile + "...");
53
                    System.out.print("saving to " + outputFile + "...");
54
                    FileOutputStream out = new FileOutputStream(outputFile);
54
                    FileOutputStream out = new FileOutputStream(outputFile);
55
                    try {
55
                    try {
(-)src/java/org/apache/poi/hssf/dev/BiffViewer.java (-2 / +2 lines)
Lines 114-121 Link Here
114
            try {
114
            try {
115
                hasNext = recStream.hasNextRecord();
115
                hasNext = recStream.hasNextRecord();
116
            } catch (LeftoverDataException e) {
116
            } catch (LeftoverDataException e) {
117
                e.printStackTrace();
117
                e.printStackTrace(System.out);
118
                System.err.println("Discarding " + recStream.remaining() + " bytes and continuing");
118
                System.out.println("Discarding " + recStream.remaining() + " bytes and continuing");
119
                recStream.readRemainder();
119
                recStream.readRemainder();
120
                hasNext = recStream.hasNextRecord();
120
                hasNext = recStream.hasNextRecord();
121
            }
121
            }
(-)src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java (+3 lines)
Lines 20-25 Link Here
20
import java.io.File;
20
import java.io.File;
21
import java.io.FileOutputStream;
21
import java.io.FileOutputStream;
22
import java.io.IOException;
22
import java.io.IOException;
23
import java.io.PrintStream;
23
import java.util.Date;
24
import java.util.Date;
24
25
25
import junit.framework.TestCase;
26
import junit.framework.TestCase;
Lines 34-39 Link Here
34
import org.apache.poi.ss.usermodel.Name;
35
import org.apache.poi.ss.usermodel.Name;
35
import org.apache.poi.ss.usermodel.Sheet;
36
import org.apache.poi.ss.usermodel.Sheet;
36
import org.apache.poi.ss.usermodel.Cell;
37
import org.apache.poi.ss.usermodel.Cell;
38
import org.junit.AfterClass;
39
import org.junit.BeforeClass;
37
40
38
/**
41
/**
39
 * @author Andrew C. Oliver (acoliver at apache dot org)
42
 * @author Andrew C. Oliver (acoliver at apache dot org)
(-)src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java (-9 / +19 lines)
Lines 21-26 Link Here
21
import java.io.PrintStream;
21
import java.io.PrintStream;
22
import java.util.List;
22
import java.util.List;
23
23
24
import org.junit.After;
25
import org.junit.Before;
26
24
public class TestEFBiffViewer extends BaseXLSIteratingTest {
27
public class TestEFBiffViewer extends BaseXLSIteratingTest {
25
	static {
28
	static {
26
		// Look at the output of the test for the detailed stacktrace of the failures...
29
		// Look at the output of the test for the detailed stacktrace of the failures...
Lines 41-56 Link Here
41
		SILENT_EXCLUDED.add("35897-type4.xls");   // unsupported encryption
44
		SILENT_EXCLUDED.add("35897-type4.xls");   // unsupported encryption
42
	}
45
	}
43
	
46
	
47
	private PrintStream sysout, ps;
48
49
	@Before
50
	public void setUp() throws Exception {
51
		// redirect standard out during the test to avoid spamming the console with output
52
		sysout = System.out;
53
		ps = new PrintStream(NULL_OUTPUT_STREAM);
54
		System.setOut(ps);
55
	}
56
	
57
	@After
58
	public void tearDown() throws Exception {
59
		System.setOut(sysout);
60
	}
61
	
44
	@Override
62
	@Override
45
	void runOneFile(String dir, String file, List<String> failed) throws IOException {
63
	void runOneFile(String dir, String file, List<String> failed) throws IOException {
46
		PrintStream save = System.out;
64
		EFBiffViewer.main(new String[] { new File(dir, file).getAbsolutePath() });
47
		try {
48
			// redirect standard out during the test to avoid spamming the console with output
49
			System.setOut(new PrintStream(NULL_OUTPUT_STREAM));
50
51
			EFBiffViewer.main(new String[] { new File(dir, file).getAbsolutePath() });
52
		} finally {
53
			System.setOut(save);
54
		}
55
	}
65
	}
56
}
66
}
(-)src/testcases/org/apache/poi/hssf/dev/TestReSave.java (-24 / +33 lines)
Lines 24-29 Link Here
24
import java.util.List;
24
import java.util.List;
25
25
26
import org.apache.poi.POIDataSamples;
26
import org.apache.poi.POIDataSamples;
27
import org.junit.After;
28
import org.junit.Before;
27
import org.junit.Test;
29
import org.junit.Test;
28
30
29
public class TestReSave extends BaseXLSIteratingTest {
31
public class TestReSave extends BaseXLSIteratingTest {
Lines 37-86 Link Here
37
		SILENT_EXCLUDED.add("43493.xls");	// HSSFWorkbook cannot open it as well
39
		SILENT_EXCLUDED.add("43493.xls");	// HSSFWorkbook cannot open it as well
38
		SILENT_EXCLUDED.add("46904.xls"); 
40
		SILENT_EXCLUDED.add("46904.xls"); 
39
		SILENT_EXCLUDED.add("51832.xls");	// password 
41
		SILENT_EXCLUDED.add("51832.xls");	// password 
40
        SILENT_EXCLUDED.add("44958_1.xls");   // known bad file
42
		SILENT_EXCLUDED.add("44958_1.xls");   // known bad file
41
	}
43
	}
42
	
44
	
45
	//private PrintStream sysout, ps;
46
	
47
	@Before
43
	@Override
48
	@Override
49
	public void setUp() throws Exception {
50
		sysout = System.out;
51
		ps = new PrintStream(BaseXLSIteratingTest.NULL_OUTPUT_STREAM);
52
		System.setOut(ps);
53
	}
54
	
55
	@After
56
	@Override
57
	public void tearDown() throws Exception {
58
		System.setOut(sysout);
59
	}
60
	
61
	@Override
44
	void runOneFile(String dir, String file, List<String> failed) throws Exception {
62
	void runOneFile(String dir, String file, List<String> failed) throws Exception {
45
		// avoid running on files leftover from previous failed runs
63
		// avoid running on files leftover from previous failed runs
46
		if(file.endsWith("-saved.xls")) {
64
		if(file.endsWith("-saved.xls")) {
47
			return;
65
			return;
48
		}
66
		}
49
67
50
		PrintStream save = System.out;
51
		try {
68
		try {
52
			// redirect standard out during the test to avoid spamming the console with output
69
			ReSave.main(new String[] { new File(dir, file).getAbsolutePath() });
53
			System.setOut(new PrintStream(NULL_OUTPUT_STREAM));
70
			
71
			// also try BiffViewer on the saved file
72
			new TestBiffViewer().runOneFile(dir, file.replace(".xls", "-saved.xls"), failed);
54
73
55
			try {
74
			try {
56
				ReSave.main(new String[] { new File(dir, file).getAbsolutePath() });
75
				// had one case where the re-saved could not be re-saved!
57
				
76
				ReSave.main(new String[] { new File(dir, file.replace(".xls", "-saved.xls")).getAbsolutePath() });
58
				// also try BiffViewer on the saved file
59
				new TestBiffViewer().runOneFile(dir, file.replace(".xls", "-saved.xls"), failed);
60
61
    			try {
62
        			// had one case where the re-saved could not be re-saved!
63
        			ReSave.main(new String[] { new File(dir, file.replace(".xls", "-saved.xls")).getAbsolutePath() });
64
    			} finally {
65
    				// clean up the re-re-saved file
66
    				new File(dir, file.replace(".xls", "-saved.xls").replace(".xls", "-saved.xls")).delete();
67
    			}
68
			} finally {
77
			} finally {
69
				// clean up the re-saved file
78
				// clean up the re-re-saved file
70
				new File(dir, file.replace(".xls", "-saved.xls")).delete();
79
				new File(dir, file.replace(".xls", "-saved.xls").replace(".xls", "-saved.xls")).delete();
71
			}
80
			}
72
73
		} finally {
81
		} finally {
74
			System.setOut(save);
82
			// clean up the re-saved file
83
			new File(dir, file.replace(".xls", "-saved.xls")).delete();
75
		}
84
		}
76
	}
85
	}
77
86
78
	@Test
87
	@Test
79
	public void testOneFile() throws Exception {
88
	public void testOneFile() throws Exception {
80
        String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY);
89
		String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY);
81
        if(dataDirName == null) {
90
		if(dataDirName == null) {
82
            dataDirName = "test-data";
91
			dataDirName = "test-data";
83
        }
92
		}
84
93
85
		List<String> failed = new ArrayList<String>();
94
		List<String> failed = new ArrayList<String>();
86
		runOneFile(dataDirName + "/spreadsheet", "49219.xls", failed);
95
		runOneFile(dataDirName + "/spreadsheet", "49219.xls", failed);
(-)src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java (+17 lines)
Lines 24-35 Link Here
24
import java.io.FilenameFilter;
24
import java.io.FilenameFilter;
25
import java.io.IOException;
25
import java.io.IOException;
26
import java.io.OutputStream;
26
import java.io.OutputStream;
27
import java.io.PrintStream;
27
import java.util.ArrayList;
28
import java.util.ArrayList;
28
import java.util.List;
29
import java.util.List;
29
30
30
import org.apache.poi.POIDataSamples;
31
import org.apache.poi.POIDataSamples;
31
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
32
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
32
import org.junit.Test;
33
import org.junit.Test;
34
import org.junit.After;
35
import org.junit.Before;
33
36
34
/**
37
/**
35
 * Base class for integration-style tests which iterate over all test-files
38
 * Base class for integration-style tests which iterate over all test-files
Lines 40-45 Link Here
40
43
41
	protected static final List<String> EXCLUDED = new ArrayList<String>();
44
	protected static final List<String> EXCLUDED = new ArrayList<String>();
42
	protected static final List<String> SILENT_EXCLUDED = new ArrayList<String>();
45
	protected static final List<String> SILENT_EXCLUDED = new ArrayList<String>();
46
	
47
	protected PrintStream sysout, ps;
48
	
49
    @Before
50
    public void setUp() throws Exception {
51
        sysout = System.out;
52
        ps = new PrintStream(BaseXLSIteratingTest.NULL_OUTPUT_STREAM);
53
        System.setOut(ps);
54
    }
55
    
56
    @After
57
    public void tearDown() throws Exception {
58
        System.setOut(sysout);
59
    }
43
60
44
	@Test
61
	@Test
45
	public void testMain() throws Exception {
62
	public void testMain() throws Exception {
(-)src/testcases/org/apache/poi/POITestCase.java (+21 lines)
Lines 18-23 Link Here
18
package org.apache.poi;
18
package org.apache.poi;
19
19
20
20
21
import java.io.IOException;
22
import java.io.OutputStream;
21
import java.util.Collection;
23
import java.util.Collection;
22
24
23
import junit.framework.TestCase;
25
import junit.framework.TestCase;
Lines 27-32 Link Here
27
 *  features 
29
 *  features 
28
 */
30
 */
29
public class POITestCase extends TestCase {
31
public class POITestCase extends TestCase {
32
    protected static final OutputStream NULL_OUTPUT_STREAM = new NullOutputStream();
33
    /**
34
     * Implementation of an OutputStream which does nothing, used
35
     * to redirect stdout to avoid spamming the console with output
36
     */
37
    public static class NullOutputStream extends OutputStream {
38
        @Override
39
        public void write(byte[] b, int off, int len) {
40
        }
41
42
        @Override
43
        public void write(int b) {
44
        }
45
46
        @Override
47
        public void write(byte[] b) throws IOException {
48
        }
49
    }
50
    
30
    public static void assertContains(String haystack, String needle) {
51
    public static void assertContains(String haystack, String needle) {
31
        assertTrue(
52
        assertTrue(
32
              "Unable to find expected text '" + needle + "' in text:\n" + haystack,
53
              "Unable to find expected text '" + needle + "' in text:\n" + haystack,
(-)src/testcases/org/apache/poi/ss/format/TestCellFormat.java (-2 / +2 lines)
Lines 835-842 Link Here
835
            Row row = sheet.createRow(0);
835
            Row row = sheet.createRow(0);
836
            Cell cell = row.createCell(0);
836
            Cell cell = row.createCell(0);
837
            cell.setCellValue(123456.6);
837
            cell.setCellValue(123456.6);
838
            System.out.println(cf1.apply(cell).text);
838
            final CellFormatResult displayedValue = cf1.apply(cell);
839
            assertEquals("123456 3/5", cf1.apply(cell).text);
839
            assertEquals("123456 3/5", displayedValue.text);
840
        } finally {
840
        } finally {
841
            wb.close();
841
            wb.close();
842
        }
842
        }
(-)src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java (-62 / +69 lines)
Lines 42-119 Link Here
42
    private void outputLocaleDataFormats( Date date, boolean dates, boolean times, int style, String styleName ) throws Exception {
42
    private void outputLocaleDataFormats( Date date, boolean dates, boolean times, int style, String styleName ) throws Exception {
43
43
44
        Workbook workbook = new HSSFWorkbook();
44
        Workbook workbook = new HSSFWorkbook();
45
        String sheetName;
45
        try {
46
        if( dates ) {
46
            String sheetName;
47
            if( times ) {
47
            if( dates ) {
48
                sheetName = "DateTimes";
48
                if( times ) {
49
                    sheetName = "DateTimes";
50
                } else {
51
                    sheetName = "Dates";
52
                }
49
            } else {
53
            } else {
50
                sheetName = "Dates";
54
                sheetName = "Times";
51
            }
55
            }
52
        } else {
56
            Sheet sheet = workbook.createSheet(sheetName);
53
            sheetName = "Times";
57
            Row header = sheet.createRow(0);
54
        }
58
            header.createCell(0).setCellValue("locale");
55
        Sheet sheet = workbook.createSheet(sheetName);
59
            header.createCell(1).setCellValue("DisplayName");
56
        Row header = sheet.createRow(0);
60
            header.createCell(2).setCellValue("Excel " + styleName);
57
        header.createCell(0).setCellValue("locale");
61
            header.createCell(3).setCellValue("java.text.DateFormat");
58
        header.createCell(1).setCellValue("DisplayName");
62
            header.createCell(4).setCellValue("Equals");
59
        header.createCell(2).setCellValue("Excel " + styleName);
63
            header.createCell(5).setCellValue("Java pattern");
60
        header.createCell(3).setCellValue("java.text.DateFormat");
64
            header.createCell(6).setCellValue("Excel pattern");
61
        header.createCell(4).setCellValue("Equals");
62
        header.createCell(5).setCellValue("Java pattern");
63
        header.createCell(6).setCellValue("Excel pattern");
64
65
        int rowNum = 1;
66
        for( Locale locale : DateFormat.getAvailableLocales() ) {
67
            try {
68
                Row row = sheet.createRow(rowNum++);
69
    
65
    
70
                row.createCell(0).setCellValue(locale.toString());
66
            int rowNum = 1;
71
                row.createCell(1).setCellValue(locale.getDisplayName());
67
            for( Locale locale : DateFormat.getAvailableLocales() ) {
72
    
68
                try {
73
                DateFormat dateFormat;
69
                    Row row = sheet.createRow(rowNum++);
74
                if( dates ) {
70
        
75
                    if( times ) {
71
                    row.createCell(0).setCellValue(locale.toString());
76
                        dateFormat = DateFormat.getDateTimeInstance(style, style, locale);
72
                    row.createCell(1).setCellValue(locale.getDisplayName());
73
        
74
                    DateFormat dateFormat;
75
                    if( dates ) {
76
                        if( times ) {
77
                            dateFormat = DateFormat.getDateTimeInstance(style, style, locale);
78
                        } else {
79
                            dateFormat = DateFormat.getDateInstance(style, locale);
80
                        }
77
                    } else {
81
                    } else {
78
                        dateFormat = DateFormat.getDateInstance(style, locale);
82
                        dateFormat = DateFormat.getTimeInstance(style, locale);
79
                    }
83
                    }
80
                } else {
84
        
81
                    dateFormat = DateFormat.getTimeInstance(style, locale);
85
                    Cell cell = row.createCell(2);
86
        
87
                    cell.setCellValue(date);
88
                    CellStyle cellStyle = row.getSheet().getWorkbook().createCellStyle();
89
        
90
                    String javaDateFormatPattern = ((SimpleDateFormat)dateFormat).toPattern();
91
                    String excelFormatPattern = DateFormatConverter.convert(locale, javaDateFormatPattern);
92
        
93
                    DataFormat poiFormat = row.getSheet().getWorkbook().createDataFormat();
94
                    cellStyle.setDataFormat(poiFormat.getFormat(excelFormatPattern));
95
                    row.createCell(3).setCellValue(dateFormat.format(date));
96
        
97
                    cell.setCellStyle(cellStyle);
98
        
99
                    // the formula returns TRUE is the formatted date in column C equals to the string in column D
100
                    row.createCell(4).setCellFormula("TEXT(C"+rowNum+",G"+rowNum+")=D" + rowNum);
101
                    row.createCell(5).setCellValue(javaDateFormatPattern);
102
                    row.createCell(6).setCellValue(excelFormatPattern);
103
                } catch (Exception e) {
104
                    throw new RuntimeException("Failed for locale: " + locale + ", having locales: " + 
105
                            Arrays.toString(DateFormat.getAvailableLocales()), e);
82
                }
106
                }
107
            }
83
    
108
    
84
                Cell cell = row.createCell(2);
109
            File outputFile = TempFile.createTempFile("Locale" + sheetName + styleName, ".xlsx");
85
    
110
            FileOutputStream outputStream = new FileOutputStream(outputFile);
86
                cell.setCellValue(date);
111
            try {
87
                CellStyle cellStyle = row.getSheet().getWorkbook().createCellStyle();
112
                workbook.write(outputStream);
88
    
113
            } finally {
89
                String javaDateFormatPattern = ((SimpleDateFormat)dateFormat).toPattern();
114
                outputStream.close();
90
                String excelFormatPattern = DateFormatConverter.convert(locale, javaDateFormatPattern);
91
    
92
                DataFormat poiFormat = row.getSheet().getWorkbook().createDataFormat();
93
                cellStyle.setDataFormat(poiFormat.getFormat(excelFormatPattern));
94
                row.createCell(3).setCellValue(dateFormat.format(date));
95
    
96
                cell.setCellStyle(cellStyle);
97
    
98
                // the formula returns TRUE is the formatted date in column C equals to the string in column D
99
                row.createCell(4).setCellFormula("TEXT(C"+rowNum+",G"+rowNum+")=D" + rowNum);
100
                row.createCell(5).setCellValue(javaDateFormatPattern);
101
                row.createCell(6).setCellValue(excelFormatPattern);
102
            } catch (Exception e) {
103
                throw new RuntimeException("Failed for locale: " + locale + ", having locales: " + 
104
                        Arrays.toString(DateFormat.getAvailableLocales()), e);
105
            }
115
            }
116
            
117
            // FIXME: can testing the output file be automated by POI?
118
            // if not, should this message be sent to POILogger so as not to clutter ant test output?
119
            System.out.println("Open " + outputFile.getAbsolutePath()+" in Excel");
106
        }
120
        }
107
121
        finally {
108
        File outputFile = TempFile.createTempFile("Locale" + sheetName + styleName, ".xlsx");
122
            workbook.close();
109
        FileOutputStream outputStream = new FileOutputStream(outputFile);
110
        try {
111
            workbook.write(outputStream);
112
        } finally {
113
            outputStream.close();
114
        }
123
        }
115
116
        System.out.println("Open " + outputFile.getAbsolutePath()+" in Excel");
117
    }
124
    }
118
125
119
    public void testJavaDateFormatsInExcel() throws Exception {
126
    public void testJavaDateFormatsInExcel() throws Exception {
(-)src/testcases/org/apache/poi/ddf/TestEscherDump.java (-8 / +26 lines)
Lines 20-58 Link Here
20
import static org.junit.Assert.*;
20
import static org.junit.Assert.*;
21
21
22
import java.io.ByteArrayInputStream;
22
import java.io.ByteArrayInputStream;
23
import java.io.PrintStream;
23
24
24
import org.apache.poi.POIDataSamples;
25
import org.apache.poi.POIDataSamples;
26
import org.apache.poi.POITestCase;
25
import org.apache.poi.hssf.HSSFTestDataSamples;
27
import org.apache.poi.hssf.HSSFTestDataSamples;
26
import org.apache.poi.util.IOUtils;
28
import org.apache.poi.util.IOUtils;
29
import org.junit.After;
30
import org.junit.Before;
27
import org.junit.Test;
31
import org.junit.Test;
28
32
29
public class TestEscherDump {
33
public class TestEscherDump {
34
    private PrintStream sysout, ps;
35
    
36
    @Before
37
    public void setUp() throws Exception {
38
        sysout = System.out;
39
        ps = new PrintStream(new POITestCase.NullOutputStream());
40
        System.setOut(ps);
41
    }
42
    
43
    @After
44
    public void tearDown() throws Exception {
45
        System.setOut(sysout);
46
    }
47
    
30
    @Test
48
    @Test
31
    public void testSimple() throws Exception {
49
    public void testSimple() throws Exception {
32
        // simple test to at least cover some parts of the class
50
        // simple test to at least cover some parts of the class
33
        EscherDump.main(new String[] {});
51
        EscherDump.main(new String[] {});
34
        
52
        
35
        new EscherDump().dump(0, new byte[] {}, System.out);
53
        new EscherDump().dump(0, new byte[] {}, ps);
36
        new EscherDump().dump(new byte[] {}, 0, 0, System.out);
54
        new EscherDump().dump(new byte[] {}, 0, 0, ps);
37
        new EscherDump().dumpOld(0, new ByteArrayInputStream(new byte[] {}), System.out);
55
        new EscherDump().dumpOld(0, new ByteArrayInputStream(new byte[] {}), ps);
38
    }
56
    }
39
57
40
    @Test
58
    @Test
41
    public void testWithData() throws Exception {
59
    public void testWithData() throws Exception {
42
        new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] { 00, 00, 00, 00, 00, 00, 00, 00 }), System.out);
60
        new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] { 00, 00, 00, 00, 00, 00, 00, 00 }), ps);
43
    }
61
    }
44
62
45
    @Test
63
    @Test
46
    public  void testWithSamplefile() throws Exception {
64
    public  void testWithSamplefile() throws Exception {
47
        //InputStream stream = HSSFTestDataSamples.openSampleFileStream(")
65
        //InputStream stream = HSSFTestDataSamples.openSampleFileStream(")
48
        byte[] data = POIDataSamples.getDDFInstance().readFile("Container.dat");
66
        byte[] data = POIDataSamples.getDDFInstance().readFile("Container.dat");
49
        new EscherDump().dump(data.length, data, System.out);
67
        new EscherDump().dump(data.length, data, ps);
50
        //new EscherDump().dumpOld(data.length, new ByteArrayInputStream(data), System.out);
68
        //new EscherDump().dumpOld(data.length, new ByteArrayInputStream(data), ps);
51
        
69
        
52
        data = new byte[2586114];
70
        data = new byte[2586114];
53
        int bytes = IOUtils.readFully(HSSFTestDataSamples.openSampleFileStream("44593.xls"), data);
71
        int bytes = IOUtils.readFully(HSSFTestDataSamples.openSampleFileStream("44593.xls"), data);
54
        assertTrue(bytes != -1);
72
        assertTrue(bytes != -1);
55
        //new EscherDump().dump(bytes, data, System.out);
73
        //new EscherDump().dump(bytes, data, ps);
56
        //new EscherDump().dumpOld(bytes, new ByteArrayInputStream(data), System.out);
74
        //new EscherDump().dumpOld(bytes, new ByteArrayInputStream(data), ps);
57
    }
75
    }
58
}
76
}
(-)src/testcases/org/apache/poi/util/TestHexDump.java (+17 lines)
Lines 26-31 Link Here
26
import java.io.PrintStream;
26
import java.io.PrintStream;
27
import java.lang.reflect.Constructor;
27
import java.lang.reflect.Constructor;
28
28
29
import org.apache.poi.POITestCase;
30
import org.junit.After;
31
import org.junit.Before;
32
29
import junit.framework.TestCase;
33
import junit.framework.TestCase;
30
34
31
/**
35
/**
Lines 34-39 Link Here
34
 */
38
 */
35
public final class TestHexDump extends TestCase {
39
public final class TestHexDump extends TestCase {
36
40
41
    private PrintStream sysout, ps;
42
    
43
    @Before
44
    public void setUp() throws Exception {
45
        sysout = System.out;
46
        ps = new PrintStream(new POITestCase.NullOutputStream());
47
        System.setOut(ps);
48
    }
49
    
50
    @After
51
    public void tearDown() throws Exception {
52
        System.setOut(sysout);
53
    }
37
54
38
    private static char toHex(int n) {
55
    private static char toHex(int n) {
39
        return Character.toUpperCase(Character.forDigit(n & 0x0F, 16));
56
        return Character.toUpperCase(Character.forDigit(n & 0x0F, 16));

Return to bug 58261