poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1779866 [3/3] - in /poi/trunk/src: examples/src/org/apache/poi/hssf/usermodel/examples/ examples/src/org/apache/poi/hssf/view/ examples/src/org/apache/poi/ss/examples/html/ java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/usermodel...
Date Sun, 22 Jan 2017 22:01:23 GMT
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java?rev=1779866&r1=1779865&r2=1779866&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java Sun Jan 22
22:01:22 2017
@@ -18,6 +18,10 @@
 package org.apache.poi.hssf.usermodel;
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import java.awt.Color;
 import java.io.IOException;
@@ -27,21 +31,19 @@ import java.util.Map;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.PaletteRecord;
 import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.Font;
+import org.junit.Before;
 import org.junit.Test;
 
-import junit.framework.TestCase;
-
-/**
- * @author Brian Sanders (bsanders at risklabs dot com)
- */
-public final class TestHSSFPalette extends TestCase {
+public final class TestHSSFPalette {
     private PaletteRecord _palette;
     private HSSFPalette _hssfPalette;
 
 
-    @Override
-    public void setUp()
-    {
+    @Before
+    public void setUp() {
         _palette = new PaletteRecord();
         _hssfPalette = new HSSFPalette(_palette);
     }
@@ -49,6 +51,7 @@ public final class TestHSSFPalette exten
     /**
      * Verifies that a custom palette can be created, saved, and reloaded
      */
+    @Test
     public void testCustomPalette() {
         //reading sample xls
         HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("Simple.xls");
@@ -62,9 +65,9 @@ public final class TestHSSFPalette exten
         book = HSSFTestDataSamples.writeOutAndReadBack(book);
 
         palette = book.getCustomPalette();
-        HSSFColor color = palette.getColor(HSSFColor.CORAL.index);  //unmodified
+        HSSFColor color = palette.getColor(HSSFColorPredefined.CORAL.getIndex());  //unmodified
         assertNotNull("Unexpected null in custom palette (unmodified index)", color);
-        short[] expectedRGB = HSSFColor.CORAL.triplet;
+        short[] expectedRGB = HSSFColorPredefined.CORAL.getTriplet();
         short[] actualRGB = color.getTriplet();
         String msg = "Expected palette position to remain unmodified";
         assertEquals(msg, expectedRGB[0], actualRGB[0]);
@@ -83,6 +86,7 @@ public final class TestHSSFPalette exten
     /**
      * Uses the palette from cell stylings
      */
+    @Test
     public void testPaletteFromCellColours() {
         HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("SimpleWithColours.xls");
 
@@ -98,8 +102,8 @@ public final class TestHSSFPalette exten
         assertEquals("I'm plain", cellA.getStringCellValue());
         assertEquals(64, cellA.getCellStyle().getFillForegroundColor());
         assertEquals(64, cellA.getCellStyle().getFillBackgroundColor());
-        assertEquals(HSSFFont.COLOR_NORMAL, cellA.getCellStyle().getFont(book).getColor());
-        assertEquals(0, cellA.getCellStyle().getFillPattern());
+        assertEquals(Font.COLOR_NORMAL, cellA.getCellStyle().getFont(book).getColor());
+        assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPatternEnum());
         assertEquals("0:0:0", p.getColor((short)64).getHexString());
         assertEquals(null, p.getColor((short)32767));
 
@@ -108,7 +112,7 @@ public final class TestHSSFPalette exten
         assertEquals(64, cellB.getCellStyle().getFillForegroundColor());
         assertEquals(64, cellB.getCellStyle().getFillBackgroundColor());
         assertEquals(10, cellB.getCellStyle().getFont(book).getColor());
-        assertEquals(0, cellB.getCellStyle().getFillPattern());
+        assertEquals(FillPatternType.NO_FILL, cellB.getCellStyle().getFillPatternEnum());
         assertEquals("0:0:0", p.getColor((short)64).getHexString());
         assertEquals("FFFF:0:0", p.getColor((short)10).getHexString());
 
@@ -117,7 +121,7 @@ public final class TestHSSFPalette exten
         assertEquals(11, cellC.getCellStyle().getFillForegroundColor());
         assertEquals(64, cellC.getCellStyle().getFillBackgroundColor());
         assertEquals(10, cellC.getCellStyle().getFont(book).getColor());
-        assertEquals(1, cellC.getCellStyle().getFillPattern());
+        assertEquals(FillPatternType.SOLID_FOREGROUND, cellC.getCellStyle().getFillPatternEnum());
         assertEquals("0:FFFF:0", p.getColor((short)11).getHexString());
         assertEquals("FFFF:0:0", p.getColor((short)10).getHexString());
 
@@ -126,7 +130,7 @@ public final class TestHSSFPalette exten
         assertEquals(13, cellD.getCellStyle().getFillForegroundColor());
         assertEquals(64, cellD.getCellStyle().getFillBackgroundColor());
         assertEquals(14, cellD.getCellStyle().getFont(book).getColor());
-        assertEquals(0, cellD.getCellStyle().getFillPattern());
+        assertEquals(FillPatternType.NO_FILL, cellD.getCellStyle().getFillPatternEnum());
         assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString());
         assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
 
@@ -135,11 +139,12 @@ public final class TestHSSFPalette exten
         assertEquals(13, cellE.getCellStyle().getFillForegroundColor());
         assertEquals(64, cellE.getCellStyle().getFillBackgroundColor());
         assertEquals(14, cellE.getCellStyle().getFont(book).getColor());
-        assertEquals(0, cellE.getCellStyle().getFillPattern());
+        assertEquals(FillPatternType.NO_FILL, cellE.getCellStyle().getFillPatternEnum());
         assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString());
         assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
     }
 
+    @Test
     public void testFindSimilar() throws IOException {
         HSSFWorkbook book = new HSSFWorkbook();
         HSSFPalette p = book.getCustomPalette();
@@ -230,6 +235,7 @@ public final class TestHSSFPalette exten
      * Verifies that the generated gnumeric-format string values match the
      * hardcoded values in the HSSFColor default color palette
      */
+    @Test
     public void testGnumericStrings() {
         compareToDefaults(new ColorComparator() {
             @Override
@@ -243,6 +249,7 @@ public final class TestHSSFPalette exten
     /**
      * Verifies that the palette handles invalid palette indexes
      */
+    @Test
     public void testBadIndexes() {
         //too small
         _hssfPalette.setColorAtIndex((short) 2, (byte) 255, (byte) 255, (byte) 255);
@@ -275,6 +282,7 @@ public final class TestHSSFPalette exten
         }
     }
 
+    @Test
     public void testAddColor() {
         try
         {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/util/AllHSSFUtilTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/util/AllHSSFUtilTests.java?rev=1779866&r1=1779865&r2=1779866&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/util/AllHSSFUtilTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/util/AllHSSFUtilTests.java Sun Jan 22 22:01:22
2017
@@ -17,22 +17,18 @@
 
 package org.apache.poi.hssf.util;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  * Collects all tests for org.apache.poi.hssf.util.
- * 
- * @author Josh Micich
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    TestAreaReference.class,
+    TestCellReference.class,
+    TestHSSFColor.class,
+    TestRKUtil.class
+})
 public class AllHSSFUtilTests {
-	
-	public static Test suite() {
-		TestSuite result = new TestSuite(AllHSSFUtilTests.class.getName());
-		result.addTestSuite(TestAreaReference.class);
-		// result.addTestSuite(TestCellReference.class); //converted to junit4
-		result.addTestSuite(TestHSSFColor.class);
-		result.addTestSuite(TestRKUtil.class);
-		return result;
-	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java?rev=1779866&r1=1779865&r2=1779866&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java Sun Jan 22 22:01:22
2017
@@ -17,38 +17,45 @@
 
 package org.apache.poi.hssf.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Map;
 
-import junit.framework.TestCase;
-/**
- * @author Nick Burch
- */
-public final class TestHSSFColor extends TestCase {
-	public void testBasics() {
+import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
+import org.junit.Test;
+
+public final class TestHSSFColor {
+    @Test
+    public void testBasics() {
 		assertNotNull(HSSFColor.YELLOW.class);
-		assertTrue(HSSFColor.YELLOW.index > 0);
-		assertTrue(HSSFColor.YELLOW.index2 > 0);
+		assertTrue(HSSFColorPredefined.YELLOW.getIndex() > 0);
+		assertTrue(HSSFColorPredefined.YELLOW.getIndex2() > 0);
 	}
 	
+    @Test
 	public void testContents() {
-		assertEquals(3, HSSFColor.YELLOW.triplet.length);
-		assertEquals(255, HSSFColor.YELLOW.triplet[0]);
-		assertEquals(255, HSSFColor.YELLOW.triplet[1]);
-		assertEquals(0, HSSFColor.YELLOW.triplet[2]);
+	    short[] triplet = HSSFColorPredefined.YELLOW.getTriplet();
+		assertEquals(3, triplet.length);
+		assertEquals(255, triplet[0]);
+		assertEquals(255, triplet[1]);
+		assertEquals(0, triplet[2]);
 		
-		assertEquals("FFFF:FFFF:0", HSSFColor.YELLOW.hexString);
+		assertEquals("FFFF:FFFF:0", HSSFColorPredefined.YELLOW.getHexString());
 	}
 	
+    @Test
 	public void testTrippletHash() {
 		Map<String, HSSFColor> tripplets = HSSFColor.getTripletHash();
 		
 		assertEquals(
 				HSSFColor.MAROON.class,
-				tripplets.get(HSSFColor.MAROON.hexString).getClass()
+				tripplets.get(HSSFColorPredefined.MAROON.getHexString()).getClass()
 		);
 		assertEquals(
 				HSSFColor.YELLOW.class,
-				tripplets.get(HSSFColor.YELLOW.hexString).getClass()
+				tripplets.get(HSSFColorPredefined.YELLOW.getHexString()).getClass()
 		);
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message