Changed CRLF to LF in .java test files. Minor reformatting and compiler warning fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@776056 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-05-18 19:11:45 +00:00
parent b924e3f4c8
commit e6a53dc85b
26 changed files with 3290 additions and 3291 deletions

View File

@ -1,4 +1,3 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -18,27 +17,23 @@
package org.apache.poi.ddf;
import junit.framework.TestCase;
import org.apache.poi.util.HexRead;
import org.apache.poi.util.HexDump;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.io.IOException;
import java.util.Arrays;
import junit.framework.TestCase;
/**
* Test read/serialize of escher blip records
*
* @author Yegor Kozlov
*/
public class TestEscherBlipRecord extends TestCase
{
public final class TestEscherBlipRecord extends TestCase {
protected String cwd = System.getProperty("DDF.testdata.path");
//test reading/serializing of a PNG blip
public void testReadPNG() throws IOException {
public void testReadPNG() {
//provided in bug-44886
byte[] data = read(new File(cwd, "Container.dat"));
@ -83,7 +78,7 @@ public class TestEscherBlipRecord extends TestCase
}
//test reading/serializing of a PICT metafile
public void testReadPICT() throws IOException {
public void testReadPICT() {
//provided in bug-44886
byte[] data = read(new File(cwd, "Container.dat"));
@ -135,7 +130,7 @@ public class TestEscherBlipRecord extends TestCase
}
//integral test: check that the read-write-read round trip is consistent
public void testContainer() throws IOException {
public void testContainer() {
byte[] data = read(new File(cwd, "Container.dat"));
EscherContainerRecord record = new EscherContainerRecord();
@ -145,11 +140,15 @@ public class TestEscherBlipRecord extends TestCase
assertTrue(Arrays.equals(data, ser));
}
private byte[] read(File file) throws IOException {
private byte[] read(File file) {
byte[] data = new byte[(int)file.length()];
try {
FileInputStream is = new FileInputStream(file);
is.read(data);
is.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return data;
}

View File

@ -90,7 +90,7 @@ public final class HSSFTestDataSamples {
if (dataDirName == null) {
// check to see if we can just get the resources from the classpath
InputStream is = openClasspathResource("SampleSS.xls");
if(is != null) {
if (is != null) {
try {
is.close(); // be nice
} catch (IOException e) {
@ -100,18 +100,17 @@ public final class HSSFTestDataSamples {
return;
}
throw new RuntimeException("Must set system property '"
+ TEST_DATA_DIR_SYS_PROPERTY_NAME
+ "' before running tests");
+ TEST_DATA_DIR_SYS_PROPERTY_NAME + "' before running tests");
}
File dataDir = new File(dataDirName);
if (!dataDir.exists()) {
throw new RuntimeException("Data dir '" + dataDirName
+ "' specified by system property '"
+ TEST_DATA_DIR_SYS_PROPERTY_NAME + "' does not exist");
+ "' specified by system property '" + TEST_DATA_DIR_SYS_PROPERTY_NAME
+ "' does not exist");
}
// convert to canonical file, to make any subsequent error messages clearer.
// convert to canonical file, to make any subsequent error messages
// clearer.
try {
_resolvedDataDir = dataDir.getCanonicalFile();
} catch (IOException e) {

View File

@ -27,6 +27,7 @@ import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.UnknownRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord;
/**
* Tests for {@link RowBlocksReader}
@ -35,7 +36,7 @@ import org.apache.poi.hssf.record.WindowTwoRecord;
*/
public final class TestRowBlocksReader extends TestCase {
public void testAbnormalPivotTableRecords_bug46280() {
int SXVIEW_SID = 0x00B0;
int SXVIEW_SID = ViewDefinitionRecord.sid;
Record[] inRecs = {
new RowRecord(0),
new NumberRecord(),

View File

@ -126,7 +126,6 @@ public final class TestTextObjectRecord extends TestCase {
assertEquals(buff.length(), str.length());
assertEquals(buff.toString(), str.getString());
}
}
/**
@ -192,5 +191,4 @@ public final class TestTextObjectRecord extends TestCase {
assertEquals(linkData.length, data2.length);
assertTrue(Arrays.equals(linkData, data2));
}
}

View File

@ -33,7 +33,6 @@ public final class TestHSSFPatriarch extends TestCase {
HSSFSheet sheet = wb.createSheet();
HSSFPatriarch patr = sheet.createDrawingPatriarch();
assertNotNull(patr);
// assert something more interesting
@ -67,5 +66,4 @@ public final class TestHSSFPatriarch extends TestCase {
existingPatr = sheet.getDrawingPatriarch();
assertNotNull(existingPatr);
}
}

View File

@ -42,7 +42,8 @@ public final class TestHSSFPictureData extends TestCase{
public void testPictures() throws IOException {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
List lst = wb.getAllPictures();
@SuppressWarnings("unchecked") // TODO - add getFormat() to interface PictureData and genericise wb.getAllPictures()
List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
//assertEquals(2, lst.size());
for (Iterator it = lst.iterator(); it.hasNext(); ) {

View File

@ -1,26 +1,21 @@
/*
* 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.poi.hssf.usermodel;
/* ====================================================================
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
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
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.poi.hssf.usermodel;
import junit.framework.TestCase;
@ -67,5 +62,4 @@ public final class TestHSSFTextbox extends TestCase{
assertEquals(1, rt2.numFormattingRuns());
assertEquals(HSSFRichTextString.NO_FONT, rt2.getFontOfFormattingRun(0));
}
}
}

View File

@ -14,12 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss;
import org.apache.poi.ss.usermodel.Workbook;
/**
* Incapsulates a provider of test data for common HSSF / XSSF tests.
* Encapsulates a provider of test data for common HSSF / XSSF tests.
*/
public interface ITestDataProvider {
/**

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss;
import junit.framework.TestCase;
@ -23,7 +24,7 @@ import junit.framework.TestCase;
*
* @author Yegor Kozlov
*/
public class TestSpreadsheetVersion extends TestCase {
public final class TestSpreadsheetVersion extends TestCase {
public void testExcel97(){
SpreadsheetVersion v = SpreadsheetVersion.EXCEL97;

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.usermodel;
import junit.framework.TestCase;

View File

@ -14,12 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.usermodel;
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* @author Yegor Kozlov
@ -75,7 +75,6 @@ public abstract class BaseTestFont extends TestCase {
/**
* Tests that we can define fonts to a new
* file, save, load, and still see them
* @throws Exception
*/
public void testCreateSave() {
Workbook wb = getTestDataProvider().createWorkbook();
@ -130,8 +129,6 @@ public abstract class BaseTestFont extends TestCase {
assertEquals(true, wb.getFontAt(font2Idx).getItalic());
}
/**
* Test that fonts get added properly
*
@ -200,5 +197,4 @@ public abstract class BaseTestFont extends TestCase {
)
);
}
}

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.usermodel;
import junit.framework.TestCase;
@ -48,6 +49,4 @@ public abstract class BaseTestPicture extends TestCase {
assertEquals(referenceAnchor.getDx2(), anchor1.getDx2());
assertEquals(referenceAnchor.getDy2(), anchor1.getDy2());
}
}

View File

@ -195,7 +195,7 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
public final void baseTestShiftWithNames() {
Workbook wb = getTestDataProvider().createWorkbook();
Sheet sheet1 = wb.createSheet("Sheet1");
Sheet sheet2 = wb.createSheet("Sheet2");
wb.createSheet("Sheet2");
Row row = sheet1.createRow(0);
row.createCell(0).setCellValue(1.1);
row.createCell(1).setCellValue(2.2);

View File

@ -1,3 +1,20 @@
/* ====================================================================
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.poi.ss.usermodel;
import junit.framework.TestCase;
@ -23,7 +40,6 @@ public abstract class BaseTestWorkbook extends TestCase {
fail("should have thrown exceptiuon due to invalid sheet index");
} catch (IllegalArgumentException e) {
// expected during successful test
;
}
Sheet sheet0 = wb.createSheet();
@ -55,10 +71,9 @@ public abstract class BaseTestWorkbook extends TestCase {
for (String sheetName : invalidNames) {
try {
wb.createSheet(sheetName);
fail("should have thrown exceptiuon due to invalid sheet name: " + sheetName);
fail("should have thrown exception due to invalid sheet name: " + sheetName);
} catch (IllegalArgumentException e) {
// expected during successful test
;
}
}
//still have 3 sheets
@ -91,7 +106,6 @@ public abstract class BaseTestWorkbook extends TestCase {
assertEquals(0, wb.getSheetIndex("sheet0"));
assertEquals(1, wb.getSheetIndex("sheet1"));
assertEquals(2, wb.getSheetIndex("I changed!"));
}
public void testRemoveSheetAt() {
@ -124,7 +138,6 @@ public abstract class BaseTestWorkbook extends TestCase {
assertEquals(0, b.getNumberOfSheets());
}
public void testSheetSelection() {
Workbook b = getTestDataProvider().createWorkbook();
b.createSheet("Sheet One");
@ -176,7 +189,7 @@ public abstract class BaseTestWorkbook extends TestCase {
Workbook wb = getTestDataProvider().createWorkbook();
for (int i=0; i < 10; i++) {
Sheet sh = wb.createSheet("Sheet " + i);
wb.createSheet("Sheet " + i);
}
// Check the initial order
@ -280,11 +293,10 @@ public abstract class BaseTestWorkbook extends TestCase {
assertSame(row, cell.getRow());
}
/** Tests that all of the unicode capable string fields can be set, written and then read back
*
*
/**
* Tests that all of the unicode capable string fields can be set, written and then read back
*/
public void testUnicodeInAll() throws Exception {
public void testUnicodeInAll() {
Workbook wb = getTestDataProvider().createWorkbook();
CreationHelper factory = wb.getCreationHelper();
//Create a unicode dataformat (contains euro symbol)
@ -312,7 +324,7 @@ public abstract class BaseTestWorkbook extends TestCase {
c.setCellValue(12.34);
c.getCellStyle().setDataFormat(fmt);
Cell c2 = r.createCell(2);
Cell c2 = r.createCell(2); // TODO - c2 unused but changing next line ('c'->'c2') causes test to fail
c.setCellValue(factory.createRichTextString("\u20ac"));
Cell c3 = r.createCell(3);
@ -351,5 +363,4 @@ public abstract class BaseTestWorkbook extends TestCase {
c3 = r.getCell(3);
assertEquals(c3.getCellFormula(), formulaString);
}
}

View File

@ -23,7 +23,8 @@ import junit.framework.TestCase;
/**
* Tests that the common CellReference works as we need it to
*/
public class TestRegion extends TestCase {
@SuppressWarnings("deprecation") // the Region class is deprecated in the public API, but still needs to be tested
public final class TestRegion extends TestCase {
public void testGetRegionRef() {
int rowFrom = 3;
@ -51,5 +52,4 @@ public class TestRegion extends TestCase {
assertEquals(0, region_1.getColumnFrom());
assertEquals((short)4, region_1.getColumnTo());
}
}