From: Javen O'Neal Date: Sun, 17 Apr 2016 11:40:18 +0000 (+0000) Subject: upgrade TestPaletteRecord to junit4 X-Git-Tag: REL_3_15_BETA2~293 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=830b6a0c7d7b396bf1366800bd159dd8a2bd2c1b;p=poi.git upgrade TestPaletteRecord to junit4 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1739587 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java index cbf9018647..b7598fd124 100644 --- a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java +++ b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java @@ -68,7 +68,7 @@ import org.junit.runners.Suite; TestNoteRecord.class, TestNoteStructureSubRecord.class, TestObjRecord.class, - TestPaletteRecord.class, + //TestPaletteRecord.class, //converted to junit4 TestPaneRecord.class, TestPLVRecord.class, TestRecalcIdRecord.class, diff --git a/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java b/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java index be40e8fedb..9fd3c2ad47 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java @@ -17,33 +17,35 @@ package org.apache.poi.hssf.record; -import java.util.Iterator; +import static org.junit.Assert.assertEquals; + import java.util.Map; -import junit.framework.TestCase; +import java.util.Map.Entry; + import org.apache.poi.hssf.util.HSSFColor; +import org.junit.Test; /** * Verifies that custom palette editing works correctly * * @author Brian Sanders (bsanders at risklabs dot com) */ -public final class TestPaletteRecord extends TestCase { +public final class TestPaletteRecord { /** * Tests that the default palette matches the constants of HSSFColor */ + @Test public void testDefaultPalette() { PaletteRecord palette = new PaletteRecord(); //make sure all the HSSFColor constants match - Map colors = HSSFColor.getIndexHash(); - Iterator indexes = colors.keySet().iterator(); - while (indexes.hasNext()) - { - Integer index = (Integer) indexes.next(); - HSSFColor c = (HSSFColor) colors.get(index); + Map colors = HSSFColor.getIndexHash(); + for (Entry entry : colors.entrySet()) { + int index = entry.getKey(); + HSSFColor c = entry.getValue(); short[] rgbTriplet = c.getTriplet(); - byte[] paletteTriplet = palette.getColor(index.shortValue()); + byte[] paletteTriplet = palette.getColor((short) index); String msg = "Expected HSSFColor constant to match PaletteRecord at index 0x" + Integer.toHexString(c.getIndex()); assertEquals(msg, rgbTriplet[0], paletteTriplet[0] & 0xff);