From dd7f71e66df8f54e312e5a0823d4abee2757c88f Mon Sep 17 00:00:00 2001 From: Morgan James Delagrange Date: Fri, 22 Feb 2002 22:01:48 +0000 Subject: [PATCH] canonical forms for serialized maps in Collections 2.0 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130567 13f79535-47bb-0310-9956-ffa450edef68 --- data/test/LRUMap.emptyMap.version2.obj | Bin 0 -> 131 bytes data/test/LRUMap.fullMap.version2.obj | Bin 0 -> 382 bytes data/test/MultiHashMap.emptyMap.version2.obj | Bin 0 -> 183 bytes data/test/MultiHashMap.fullMap.version2.obj | Bin 0 -> 777 bytes .../SequencedHashMap.emptyMap.version2.obj | Bin 0 -> 75 bytes .../SequencedHashMap.fullMap.version2.obj | Bin 0 -> 326 bytes data/test/TreeMap.emptyMap.version2.obj | Bin 0 -> 84 bytes data/test/TreeMap.fullMap.version2.obj | Bin 0 -> 347 bytes .../commons/collections/TestHashMap.java | 25 +++++- .../apache/commons/collections/TestMap.java | 75 ++++++++++++++++-- 10 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 data/test/LRUMap.emptyMap.version2.obj create mode 100644 data/test/LRUMap.fullMap.version2.obj create mode 100644 data/test/MultiHashMap.emptyMap.version2.obj create mode 100644 data/test/MultiHashMap.fullMap.version2.obj create mode 100644 data/test/SequencedHashMap.emptyMap.version2.obj create mode 100644 data/test/SequencedHashMap.fullMap.version2.obj create mode 100644 data/test/TreeMap.emptyMap.version2.obj create mode 100644 data/test/TreeMap.fullMap.version2.obj diff --git a/data/test/LRUMap.emptyMap.version2.obj b/data/test/LRUMap.emptyMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..0c6ae326bdbd69df48bec401048789e3e3452cfc GIT binary patch literal 131 zcmZ4UmVvdnh(R^KC|xhHATc>3RWCU|H#a}87)a;jq$ZbSg4jMmp}vU)a&ULVQFe!a%zf4VsQpgx85tI$t#uAgh09r$~hPq7*c?kp#lJyuq~$m literal 0 HcmV?d00001 diff --git a/data/test/LRUMap.fullMap.version2.obj b/data/test/LRUMap.fullMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..b86ac5fd9ef5b08f416ea85746c9480e07671d21 GIT binary patch literal 382 zcmaiuF;2rk5JgAA2`N(L02Dz$XQW(#h5{N82N>JKI%4hJc-KjsA~&Go3N%REfGcnT zu7JcH__Lv>@c;XE{-5>x4~;@cXRb3jdoF9qOV>264RC9vj7vS=+&$c~KiPkMK3~0l zOo_G~UH;R#msKxqDb+QH8twdh{_-|IpK04~CPY->n?=eB%XOrY+B(wFqjR`~Diqvl zg1ZCk66_RW;{i}WW?aw}YCyQPL!@zX4I2?niRiQzYw^T5IWCTkb5$`QG5I@bY9klc uB9&ZsgtP;yFt{EIp$e?Q45~dgyll}+uG1$O^iN?6jMr>?@hjTX>Gl_ZLVKS8 literal 0 HcmV?d00001 diff --git a/data/test/MultiHashMap.emptyMap.version2.obj b/data/test/MultiHashMap.emptyMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..f335491bdfde863f7698a29e49c5ab82b9790481 GIT binary patch literal 183 zcmZ4UmVvdnh(SBQC|xhHATc>3RWCU|H#a}87)a;jq$ZbSg4n*LIVG7MiNzVdi3L(W z-ZCn5v0PN&Gk#nO)X&%^2tgpOVrOv%uCk~E-A{)OSi5lVh{ug>Xnvc=IB8+ zv$EehcvvjqA~OS%8v|EPeqxGSVsc4-ktYLZNk&m>aYlYlN=1Ra0|N+flyd+{ZVr7rmK1;*S!y?cWbYziC&%}b-AQE;3pShuh-Hj!v7!hYrZ z^=9`aUDuAOp}vSu-ERiN^6tux&c3+c`}-HC^VL#*g4(`GKUsGKeTjik;`3gqV zTGkgB=CyCJO9#B5KO^dFCdc_OBWkUW0Y;;|FFWokLN0_XsBqj>O!;2X{AI`841JvC zJ20ZwvOwyh@3VN3R)uNh?6oYIjuCZM7ycWf&YCzW=uFgFcFVI?Ui%XiW7_a#V|VzF UVjjhoU6PVmbH|#F^g-+B7leGl^#A|> literal 0 HcmV?d00001 diff --git a/data/test/SequencedHashMap.emptyMap.version2.obj b/data/test/SequencedHashMap.emptyMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..8f750ab5baaeaec56126b676b25eb066c3536a0d GIT binary patch literal 75 zcmZ4UmVvdnh(SNUC|xhHATc>3RWCU|H#a}87)a;jq$ZbSg4n^Sg{7%^$*CzGiNzVd Zi3NJElqRoKQWN4~V5lf4XJG(>3IHL<8KwXL literal 0 HcmV?d00001 diff --git a/data/test/SequencedHashMap.fullMap.version2.obj b/data/test/SequencedHashMap.fullMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..4dfc23179fecb3230957ed0bdd6b2624e18d5eae GIT binary patch literal 326 zcmXYrK~BR!3`H%G78a~}ge+heBu>GG6(?{~GpTUmX=c(kUGx$?1rjGi;tqTdZ2p@! z{^R89hgNB#C!0dUk-J`+&W6Fp1gc7xcYc18{VZcA+ZRs#E63)$zJAsZn|q>DJXS=s z$yBwq0LF5pRk3v=>!; zVqJ)f+hDeB7c}nvPu@Dpqbgd3z9W?#NSDQCEJV7n7b~Q{0aqEhLf^rrHAgBNU;oBT$ literal 0 HcmV?d00001 diff --git a/data/test/TreeMap.fullMap.version2.obj b/data/test/TreeMap.fullMap.version2.obj new file mode 100644 index 0000000000000000000000000000000000000000..03a7ef519dc2d89042dd4f8e9ef32ab0c27a4c13 GIT binary patch literal 347 zcmX|6yH3ME5M1Q5K@klUG}MTSL`sW9LmN7NU=7FRvGE@E*@;u|Mf?OmLq|)^?15-z zZf0j^b?;wPb}gN)dEjZERx*8Ty?@|%`tf~tbG7~~=x9NcC*4MFIcb~dVqxK#g=hEw z{_Q@-ogrWn$hBbzv7U^0m9Y7ORO8&>_rtO&_wVa0titC z6&Z0LGmPV)`dp7locz6Dx}cra8QId(i=eQ|45QfiF(L+Jason van Zyl - * @version $Id: TestHashMap.java,v 1.3 2002/02/22 02:18:50 mas Exp $ + * @version $Id: TestHashMap.java,v 1.4 2002/02/22 22:01:48 morgand Exp $ */ public class TestHashMap extends TestMap { @@ -114,4 +114,21 @@ public class TestHashMap extends TestMap assertEquals("Top item is 'Second Item'", map.get("first"), "First Item"); assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item"); } + + + /** + * We don't need to test compatibility for JVM collections. Override in + * subclasses. + */ + public void testEmptyMapCompatibility() { + + } + + /** + * We don't need to test compatibility for JVM collections. Override in + * subclasses. + */ + public void testFullMapCompatibility() { + + } } diff --git a/src/test/org/apache/commons/collections/TestMap.java b/src/test/org/apache/commons/collections/TestMap.java index e09f96159..18856aeb9 100644 --- a/src/test/org/apache/commons/collections/TestMap.java +++ b/src/test/org/apache/commons/collections/TestMap.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.9 2002/02/22 06:16:35 morgand Exp $ - * $Revision: 1.9 $ - * $Date: 2002/02/22 06:16:35 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.10 2002/02/22 22:01:48 morgand Exp $ + * $Revision: 1.10 $ + * $Date: 2002/02/22 22:01:48 $ * * ==================================================================== * @@ -87,13 +87,13 @@ import java.util.NoSuchElementException; * * @author Michael Smith * @author Rodney Waldhoff - * @version $Id: TestMap.java,v 1.9 2002/02/22 06:16:35 morgand Exp $ + * @version $Id: TestMap.java,v 1.10 2002/02/22 22:01:48 morgand Exp $ */ public abstract class TestMap extends TestObject { + public TestMap(String testName) { super(testName); } - /** * Override if your map does not allow a null key. The * default implementation returns true @@ -927,7 +927,70 @@ public abstract class TestMap extends TestObject { assertEquals("Both maps are same size",map.size(), getSampleKeys().length); assertEquals("Both maps are same size",map2.size(),getSampleKeys().length); - } + } + + + public String getCanonicalEmptyMapName(Map map) { + StringBuffer retval = new StringBuffer(); + retval.append("data/test/"); + String mapName = map.getClass().getName(); + mapName = mapName.substring(mapName.lastIndexOf(".")+1,mapName.length()); + retval.append(mapName); + retval.append(".emptyMap."); + retval.append(COLLECTIONS_VERSION); + retval.append(".obj"); + return retval.toString(); + } + + public String getCanonicalFullMapName(Map map) { + StringBuffer retval = new StringBuffer(); + retval.append("data/test/"); + String mapName = map.getClass().getName(); + mapName = mapName.substring(mapName.lastIndexOf(".")+1,mapName.length()); + retval.append(mapName); + retval.append(".fullMap."); + retval.append(COLLECTIONS_VERSION); + retval.append(".obj"); + return retval.toString(); + } + + /** + * Compare the current serialized form of the Map + * against the canonical version in CVS. + */ + public void testEmptyMapCompatibility() throws IOException, ClassNotFoundException { + /** + * Create canonical objects with this code + Map map = makeEmptyMap(); + if (!(map instanceof Serializable)) return; + + writeExternalFormToDisk((Serializable) map, getCanonicalEmptyMapName(map)); + */ + + // test to make sure the canonical form has been preserved + if (!(makeEmptyMap() instanceof Serializable)) return; + Map map = (Map) readExternalFormFromDisk(getCanonicalEmptyMapName(makeEmptyMap())); + assertTrue("Maps is empty",map.isEmpty() == true); + } + + /** + * Compare the current serialized form of the Map + * against the canonical version in CVS. + */ + public void testFullMapCompatibility() throws IOException, ClassNotFoundException { + /** + * Create canonical objects with this code + Map map = makeFullMap(); + if (!(map instanceof Serializable)) return; + + writeExternalFormToDisk((Serializable) map, getCanonicalFullMapName(map)); + */ + + // test to make sure the canonical form has been preserved + if (!(makeFullMap() instanceof Serializable)) return; + Map map = (Map) readExternalFormFromDisk(getCanonicalFullMapName(makeFullMap())); + assertEquals("Both maps are same size",map.size(), getSampleKeys().length); + } /* // optional operation