aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-09-29 10:14:40 +0000
committerDominik Stadler <centic@apache.org>2015-09-29 10:14:40 +0000
commitdce1c426df2ee527716fb87d4f3c70e12dcfcf3d (patch)
tree71d46a5088e1374fb96bcff314091261dc4d7e69
parentaacf48d5aaaee4bf2b154b63a8a6f36ebbf2aa19 (diff)
downloadpoi-dce1c426df2ee527716fb87d4f3c70e12dcfcf3d.tar.gz
poi-dce1c426df2ee527716fb87d4f3c70e12dcfcf3d.zip
Tried to reproduce bug 48403 but couldn't, still adding the related unit test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1705830 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
index 056d17efcc..fb2ae45431 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
@@ -19,14 +19,17 @@ package org.apache.poi.hssf.usermodel;
import static org.junit.Assert.assertArrayEquals;
+import java.awt.Color;
+import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.PaletteRecord;
import org.apache.poi.hssf.util.HSSFColor;
+import org.junit.Test;
+
+import junit.framework.TestCase;
/**
* @author Brian Sanders (bsanders at risklabs dot com)
@@ -137,7 +140,7 @@ public final class TestHSSFPalette extends TestCase {
assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
}
- public void testFindSimilar() {
+ public void testFindSimilar() throws IOException {
HSSFWorkbook book = new HSSFWorkbook();
HSSFPalette p = book.getCustomPalette();
@@ -219,6 +222,8 @@ public final class TestHSSFPalette extends TestCase {
p.getColor((short)12).getHexString(),
p.findSimilarColor(255, 2, 10).getHexString()
);
+
+ book.close();
}
/**
@@ -283,4 +288,27 @@ public final class TestHSSFPalette extends TestCase {
private static interface ColorComparator {
void compare(HSSFColor expected, HSSFColor palette);
}
+
+ @Test
+ public void test48403() throws Exception {
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ Color color = Color.decode("#006B6B");
+ HSSFPalette palette = wb.getCustomPalette();
+
+ HSSFColor hssfColor = palette.findColor((byte) color.getRed(),
+ (byte) color.getGreen(), (byte) color.getBlue());
+ assertNull(hssfColor);
+
+ palette.setColorAtIndex(
+ (short) (PaletteRecord.STANDARD_PALETTE_SIZE - 1),
+ (byte) color.getRed(), (byte) color.getGreen(),
+ (byte) color.getBlue());
+ hssfColor = palette.getColor((short) (PaletteRecord.STANDARD_PALETTE_SIZE - 1));
+ assertNotNull(hssfColor);
+ assertEquals(55, hssfColor.getIndex());
+ assertArrayEquals(new short[] {0, 107, 107}, hssfColor.getTriplet());
+
+ wb.close();
+ }
}