poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r719523 - /poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
Date Fri, 21 Nov 2008 07:30:43 GMT
Author: josh
Date: Thu Nov 20 23:30:43 2008
New Revision: 719523

URL: http://svn.apache.org/viewvc?rev=719523&view=rev
Log:
refactoring test case

Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java?rev=719523&r1=719522&r2=719523&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java Thu Nov 20
23:30:43 2008
@@ -30,7 +30,7 @@
 public final class TestHyperlinkRecord extends TestCase {
 
     //link to http://www.lakings.com/
-    byte[] data1 = { 0x02, 0x00,    //First row of the hyperlink
+    private static final byte[] data1 = { 0x02, 0x00,    //First row of the hyperlink
                      0x02, 0x00,    //Last row of the hyperlink
                      0x00, 0x00,    //First column of the hyperlink
                      0x00, 0x00,    //Last column of the hyperlink
@@ -69,7 +69,7 @@
                     0x00, (byte)0xA5, (byte)0xAB, 0x00, 0x00};
 
     //link to a file in the current directory: link1.xls
-    byte[] data2 =  {0x00, 0x00,
+    private static final byte[] data2 =  {0x00, 0x00,
                      0x00, 0x00,
                      0x00, 0x00,
                      0x00, 0x00,
@@ -94,13 +94,16 @@
                      //path to the file (plain ISO-8859 bytes, NOT UTF-16LE!)
                      0x6C, 0x69, 0x6E, 0x6B, 0x31, 0x2E, 0x78, 0x6C, 0x73, 0x00,
 
-                     //standard 28-byte tail of a file link
+                     //standard 24-byte tail of a file link
                      (byte)0xFF, (byte)0xFF, (byte)0xAD, (byte)0xDE, 0x00, 0x00, 0x00, 0x00,
                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+                     0x00, 0x00, 0x00, 0x00,
+                     
+                     0x00, 0x00, 0x00, 0x00, // length of address link field
+                     };
 
     // mailto:ebgans@mail.ru?subject=Hello,%20Ebgans!
-    byte[] data3 = {0x01, 0x00,
+    private static final byte[] data3 = {0x01, 0x00,
                     0x01, 0x00,
                     0x00, 0x00,
                     0x00, 0x00,
@@ -163,6 +166,9 @@
                     0x53, 0x00, 0x68, 0x00, 0x65, 0x00, 0x65, 0x00, 0x74, 0x00, 0x31, 0x00,
0x21,
                     0x00, 0x41, 0x00, 0x31, 0x00, 0x00, 0x00};
 
+    private void confirmGUID(byte[] expectedGuid, byte[] actualGuid) {
+		assertTrue(Arrays.equals(expectedGuid, actualGuid));
+	}
     public void testReadURLLink(){
         RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data1);
         HyperlinkRecord link = new HyperlinkRecord(is);
@@ -170,8 +176,8 @@
         assertEquals(2, link.getLastRow());
         assertEquals(0, link.getFirstColumn());
         assertEquals(0, link.getLastColumn());
-        assertTrue(Arrays.equals(HyperlinkRecord.STD_MONIKER, link.getGuid()));
-        assertTrue(Arrays.equals(HyperlinkRecord.URL_MONIKER, link.getMoniker()));
+        confirmGUID(HyperlinkRecord.STD_MONIKER, link.getGuid());
+        confirmGUID(HyperlinkRecord.URL_MONIKER, link.getMoniker());
         assertEquals(2, link.getLabelOptions());
         int opts = HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_ABS | HyperlinkRecord.HLINK_LABEL;
         assertEquals(0x17, opts);
@@ -189,8 +195,8 @@
         assertEquals(0, link.getLastRow());
         assertEquals(0, link.getFirstColumn());
         assertEquals(0, link.getLastColumn());
-        assertTrue(Arrays.equals(HyperlinkRecord.STD_MONIKER, link.getGuid()));
-        assertTrue(Arrays.equals(HyperlinkRecord.FILE_MONIKER, link.getMoniker()));
+        confirmGUID(HyperlinkRecord.STD_MONIKER, link.getGuid());
+        confirmGUID(HyperlinkRecord.FILE_MONIKER, link.getMoniker());
         assertEquals(2, link.getLabelOptions());
         int opts = HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_LABEL;
         assertEquals(0x15, opts);
@@ -207,8 +213,8 @@
         assertEquals(1, link.getLastRow());
         assertEquals(0, link.getFirstColumn());
         assertEquals(0, link.getLastColumn());
-        assertTrue(Arrays.equals(HyperlinkRecord.STD_MONIKER, link.getGuid()));
-        assertTrue(Arrays.equals(HyperlinkRecord.URL_MONIKER, link.getMoniker()));
+        confirmGUID(HyperlinkRecord.STD_MONIKER, link.getGuid());
+        confirmGUID(HyperlinkRecord.URL_MONIKER, link.getMoniker());
         assertEquals(2, link.getLabelOptions());
         int opts = HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_ABS | HyperlinkRecord.HLINK_LABEL;
         assertEquals(0x17, opts);
@@ -225,7 +231,7 @@
         assertEquals(3, link.getLastRow());
         assertEquals(0, link.getFirstColumn());
         assertEquals(0, link.getLastColumn());
-        assertTrue(Arrays.equals(HyperlinkRecord.STD_MONIKER, link.getGuid()));
+        confirmGUID(HyperlinkRecord.STD_MONIKER, link.getGuid());
         assertEquals(2, link.getLabelOptions());
         int opts = HyperlinkRecord.HLINK_LABEL | HyperlinkRecord.HLINK_PLACE;
         assertEquals(0x1C, opts);
@@ -253,7 +259,7 @@
         serialize(data4);
     }
 
-    public void testCreateURLRecord() throws Exception {
+    public void testCreateURLRecord() {
         HyperlinkRecord link = new HyperlinkRecord();
         link.newUrlLink();
         link.setFirstRow((short)2);
@@ -268,7 +274,7 @@
         assertTrue(Arrays.equals(data1, ser));
     }
 
-    public void testCreateFileRecord() throws Exception {
+    public void testCreateFileRecord() {
         HyperlinkRecord link = new HyperlinkRecord();
         link.newFileLink();
         link.setFirstRow((short)0);
@@ -283,7 +289,7 @@
         assertTrue(Arrays.equals(data2, ser));
     }
 
-    public void testCreateDocumentRecord() throws Exception {
+    public void testCreateDocumentRecord() {
         HyperlinkRecord link = new HyperlinkRecord();
         link.newDocumentLink();
         link.setFirstRow((short)3);
@@ -298,7 +304,7 @@
         assertTrue(Arrays.equals(data4, ser));
     }
 
-    public void testCreateEmailtRecord() throws Exception {
+    public void testCreateEmailtRecord() {
         HyperlinkRecord link = new HyperlinkRecord();
         link.newUrlLink();
         link.setFirstRow((short)1);
@@ -313,7 +319,7 @@
         assertTrue(Arrays.equals(data3, ser));
     }
 
-    public void testClone() throws Exception {
+    public void testClone() {
         byte[][] data = {data1, data2, data3, data4};
         for (int i = 0; i < data.length; i++) {
             RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid,
data[i]);



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


Mime
View raw message