本文整理汇总了Java中libcore.util.SerializationTester类的典型用法代码示例。如果您正苦于以下问题:Java SerializationTester类的具体用法?Java SerializationTester怎么用?Java SerializationTester使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SerializationTester类属于libcore.util包,在下文中一共展示了SerializationTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerializationWithComparator
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSerializationWithComparator() {
String s = "aced0005737200116a6176612e7574696c2e547265654d61700cc1f63e2d256a"
+ "e60300014c000a636f6d70617261746f727400164c6a6176612f7574696c2f436"
+ "f6d70617261746f723b78707372002a6a6176612e6c616e672e537472696e6724"
+ "43617365496e73656e736974697665436f6d70617261746f7277035c7d5c50e5c"
+ "e02000078707704000000027400016171007e00057400016271007e000678";
TreeMap<String, String> map = new TreeMap<String, String>(
String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
new SerializationTester<NavigableMap<String, String>>(map, s) {
@Override protected void verify(NavigableMap<String, String> deserialized) {
assertEquals(0, deserialized.comparator().compare("X", "x"));
}
}.test();
}
示例2: testJava5SerializationWithComparator
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testJava5SerializationWithComparator() {
String s = "aced0005737200116a6176612e7574696c2e547265654d61700cc1f63e2d256a"
+ "e60300014c000a636f6d70617261746f727400164c6a6176612f7574696c2f436"
+ "f6d70617261746f723b78707372002a6a6176612e6c616e672e537472696e6724"
+ "43617365496e73656e736974697665436f6d70617261746f7277035c7d5c50e5c"
+ "e02000078707704000000027400016171007e00057400016271007e000678";
TreeMap<String, String> map = new TreeMap<String, String>(
String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
new SerializationTester<TreeMap<String, String>>(map, s) {
@Override protected void verify(TreeMap<String, String> deserialized) {
assertEquals(0, deserialized.comparator().compare("X", "x"));
}
}.test();
}
示例3: testSubSetSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSubSetSerialization() {
String s = "aced0005737200116a6176612e7574696c2e54726565536574dd98509395ed87"
+ "5b03000078707372002a6a6176612e6c616e672e537472696e672443617365496"
+ "e73656e736974697665436f6d70617261746f7277035c7d5c50e5ce0200007870"
+ "770400000002740001617400016278";
TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
set.add("a");
set.add("b");
set.add("c");
set.add("d");
final SortedSet<String> subSet = set.subSet("a", "c");
new SerializationTester<SortedSet<String>>(subSet, s) {
@Override protected void verify(SortedSet<String> deserialized) {
assertBounded(deserialized, deserialized == subSet);
}
}.test();
}
示例4: testNavigableSubSetSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testNavigableSubSetSerialization() {
String s = "aced0005737200116a6176612e7574696c2e54726565536574dd98509395ed87"
+ "5b03000078707372002a6a6176612e6c616e672e537472696e672443617365496"
+ "e73656e736974697665436f6d70617261746f7277035c7d5c50e5ce0200007870"
+ "770400000002740001627400016378";
TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
set.add("a");
set.add("b");
set.add("c");
set.add("d");
final SortedSet<String> subSet = set.subSet("a", false, "c", true);
new SerializationTester<SortedSet<String>>(subSet, s) {
@Override protected void verify(SortedSet<String> deserialized) {
assertBounded(deserialized, deserialized == subSet);
}
}.test();
}
示例5: test_isReachable
import libcore.util.SerializationTester; //导入依赖的package包/类
public void test_isReachable() throws Exception {
// http://code.google.com/p/android/issues/detail?id=20203
String s = "aced0005737200146a6176612e6e65742e496e6574416464726573732d9b57af"
+ "9fe3ebdb0200034900076164647265737349000666616d696c794c0008686f737"
+ "44e616d657400124c6a6176612f6c616e672f537472696e673b78704a7d9d6300"
+ "00000274000e7777772e676f6f676c652e636f6d";
InetAddress inetAddress = InetAddress.getByName("www.google.com");
new SerializationTester<InetAddress>(inetAddress, s) {
@Override protected void verify(InetAddress deserialized) throws Exception {
deserialized.isReachable(500);
for (NetworkInterface nif
: Collections.list(NetworkInterface.getNetworkInterfaces())) {
deserialized.isReachable(nif, 20, 500);
}
}
@Override protected boolean equals(InetAddress a, InetAddress b) {
return a.getHostName().equals(b.getHostName());
}
}.test();
}
示例6: testSerializingSubclass
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSerializingSubclass() throws IOException, ClassNotFoundException {
AttributedCharacterIterator.Attribute a = new CustomAttribute();
try {
SerializationTester.reserialize(a);
fail();
} catch (InvalidObjectException expected) {
}
}
示例7: testEnumSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testEnumSerialization() {
String s = "aced00057e7200236c6962636f72652e6a6176612e6c616e672e456e756d5465"
+ "737424526f7368616d626f00000000000000001200007872000e6a6176612e6c6"
+ "16e672e456e756d000000000000000012000078707400055041504552";
Roshambo value = Roshambo.PAPER;
assertTrue(value.getClass() == Roshambo.class);
new SerializationTester<Roshambo>(value, s).test();
}
示例8: testEnumSubclassSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testEnumSubclassSerialization() {
String s = "aced00057e7200236c6962636f72652e6a6176612e6c616e672e456e756d5465"
+ "737424526f7368616d626f00000000000000001200007872000e6a6176612e6c6"
+ "16e672e456e756d00000000000000001200007870740004524f434b";
Roshambo value = Roshambo.ROCK;
assertTrue(value.getClass() != Roshambo.class);
new SerializationTester<Roshambo>(value, s).test();
}
示例9: testEmptyMapSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testEmptyMapSerialization() {
String s = "aced0005737200116a6176612e7574696c2e547265654d61700cc1f63e2d256a"
+ "e60300014c000a636f6d70617261746f727400164c6a6176612f7574696c2f436"
+ "f6d70617261746f723b78707077040000000078";
TreeMap<String, String> map = new TreeMap<String, String>();
new SerializationTester<TreeMap<String, String>>(map, s).test();
}
示例10: testSubMapSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSubMapSerialization() {
String s = "aced0005737200216a6176612e7574696c2e547265654d617024417363656e646"
+ "96e675375624d61700cab946d1f0fab1c020000787200216a6176612e7574696c2"
+ "e547265654d6170244e6176696761626c655375624d6170e2d0a70e64210e08020"
+ "0075a000966726f6d53746172745a000b6869496e636c75736976655a000b6c6f4"
+ "96e636c75736976655a0005746f456e644c000268697400124c6a6176612f6c616"
+ "e672f4f626a6563743b4c00026c6f71007e00024c00016d7400134c6a6176612f7"
+ "574696c2f547265654d61703b7870000001007400016374000161737200116a617"
+ "6612e7574696c2e547265654d61700cc1f63e2d256ae60300014c000a636f6d706"
+ "17261746f727400164c6a6176612f7574696c2f436f6d70617261746f723b78707"
+ "372002a6a6176612e6c616e672e537472696e672443617365496e73656e7369746"
+ "97665436f6d70617261746f7277035c7d5c50e5ce0200007870770400000004710"
+ "07e000671007e00067400016271007e000c71007e000571007e000574000164710"
+ "07e000d78";
TreeMap<String, String> map = new TreeMap<String, String>(
String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
SortedMap<String, String> subMap = map.subMap("a", "c");
new SerializationTester<SortedMap<String, String>>(subMap, s) {
@Override protected void verify(SortedMap<String, String> deserialized) {
try {
deserialized.put("e", "e");
fail();
} catch (IllegalArgumentException expected) {
}
}
}.test();
}
示例11: testNavigableSubMapSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testNavigableSubMapSerialization() {
String s = "aced0005737200216a6176612e7574696c2e547265654d617024417363656e646"
+ "96e675375624d61700cab946d1f0fab1c020000787200216a6176612e7574696c2"
+ "e547265654d6170244e6176696761626c655375624d6170e2d0a70e64210e08020"
+ "0075a000966726f6d53746172745a000b6869496e636c75736976655a000b6c6f4"
+ "96e636c75736976655a0005746f456e644c000268697400124c6a6176612f6c616"
+ "e672f4f626a6563743b4c00026c6f71007e00024c00016d7400134c6a6176612f7"
+ "574696c2f547265654d61703b7870000100007400016374000161737200116a617"
+ "6612e7574696c2e547265654d61700cc1f63e2d256ae60300014c000a636f6d706"
+ "17261746f727400164c6a6176612f7574696c2f436f6d70617261746f723b78707"
+ "372002a6a6176612e6c616e672e537472696e672443617365496e73656e7369746"
+ "97665436f6d70617261746f7277035c7d5c50e5ce0200007870770400000004710"
+ "07e000671007e00067400016271007e000c71007e000571007e000574000164710"
+ "07e000d78";
TreeMap<String, String> map = new TreeMap<String, String>(
String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
SortedMap<String, String> subMap = map.subMap("a", false, "c", true);
new SerializationTester<SortedMap<String, String>>(subMap, s) {
@Override protected void verify(SortedMap<String, String> deserialized) {
try {
deserialized.put("e", "e");
fail();
} catch (IllegalArgumentException expected) {
}
}
}.test();
}
示例12: testDescendingMapSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testDescendingMapSerialization() {
String s = "aced0005737200226a6176612e7574696c2e547265654d61702444657363656e6"
+ "4696e675375624d61700cab946d1f0f9d0c0200014c001172657665727365436f6"
+ "d70617261746f727400164c6a6176612f7574696c2f436f6d70617261746f723b7"
+ "87200216a6176612e7574696c2e547265654d6170244e6176696761626c6553756"
+ "24d6170e2d0a70e64210e080200075a000966726f6d53746172745a000b6869496"
+ "e636c75736976655a000b6c6f496e636c75736976655a0005746f456e644c00026"
+ "8697400124c6a6176612f6c616e672f4f626a6563743b4c00026c6f71007e00034"
+ "c00016d7400134c6a6176612f7574696c2f547265654d61703b787001010101707"
+ "0737200116a6176612e7574696c2e547265654d61700cc1f63e2d256ae60300014"
+ "c000a636f6d70617261746f7271007e000178707372002a6a6176612e6c616e672"
+ "e537472696e672443617365496e73656e736974697665436f6d70617261746f727"
+ "7035c7d5c50e5ce02000078707704000000027400016171007e000a74000162710"
+ "07e000b78737200286a6176612e7574696c2e436f6c6c656374696f6e732452657"
+ "665727365436f6d70617261746f7232000003fa6c354d510200014c0003636d707"
+ "1007e0001787071007e0009";
TreeMap<String, String> map = new TreeMap<String, String>(
String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
NavigableMap<String, String> descendingMap = map.descendingMap();
new SerializationTester<NavigableMap<String, String>>(descendingMap, s) {
@Override protected void verify(NavigableMap<String, String> deserialized) {
assertEquals("b", deserialized.navigableKeySet().first());
}
}.test();
}
示例13: testJava5SubMapSerialization
import libcore.util.SerializationTester; //导入依赖的package包/类
/**
* On JDK5, this fails with a NullPointerException after deserialization!
*/
public void testJava5SubMapSerialization() {
String s = "aced0005737200186a6176612e7574696c2e547265654d6170245375624d6170"
+ "a5818343a213c27f0200055a000966726f6d53746172745a0005746f456e644c0"
+ "00766726f6d4b65797400124c6a6176612f6c616e672f4f626a6563743b4c0006"
+ "7468697324307400134c6a6176612f7574696c2f547265654d61703b4c0005746"
+ "f4b657971007e00017870000074000161737200116a6176612e7574696c2e5472"
+ "65654d61700cc1f63e2d256ae60300014c000a636f6d70617261746f727400164"
+ "c6a6176612f7574696c2f436f6d70617261746f723b78707372002a6a6176612e"
+ "6c616e672e537472696e672443617365496e73656e736974697665436f6d70617"
+ "261746f7277035c7d5c50e5ce020000787077040000000471007e000471007e00"
+ "047400016271007e000a7400016371007e000b7400016471007e000c7871007e0"
+ "00b";
TreeMap<String, String> map = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
SortedMap<String, String> subMap = map.subMap("a", "c");
new SerializationTester<SortedMap<String, String>>(subMap, s) {
@Override protected void verify(SortedMap<String, String> deserialized) {
try {
deserialized.put("e", "e");
fail();
} catch (IllegalArgumentException expected) {
}
}
}.test();
}
示例14: testSerialize
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSerialize() {
String s = "aced0005737200206a6176612e6265616e732e50726f70657274794368616e67"
+ "65537570706f727458d5d264574860bb03000349002a70726f706572747943686"
+ "16e6765537570706f727453657269616c697a65644461746156657273696f6e4c"
+ "00086368696c6472656e7400154c6a6176612f7574696c2f486173687461626c6"
+ "53b4c0006736f757263657400124c6a6176612f6c616e672f4f626a6563743b78"
+ "7000000002737200136a6176612e7574696c2e486173687461626c6513bb0f252"
+ "14ae4b803000246000a6c6f6164466163746f724900097468726573686f6c6478"
+ "703f4000000000000877080000000b00000001740001617371007e00000000000"
+ "2707400046265616e7372003a6c6962636f72652e6a6176612e7574696c2e6265"
+ "616e732e50726f70657274794368616e6765537570706f7274546573742445766"
+ "56e744c6f67b92667637d0b6f450200024c00036c6f677400104c6a6176612f75"
+ "74696c2f4c6973743b4c00046e616d657400124c6a6176612f6c616e672f53747"
+ "2696e673b7870737200136a6176612e7574696c2e41727261794c6973747881d2"
+ "1d99c7619d03000149000473697a6578700000000077040000000a7874000b6c6"
+ "97374656e6572546f4171007e000c70787871007e00087371007e00097371007e"
+ "000d0000000077040000000a7874000d6c697374656e6572546f416c6c7078";
Object bean = "bean";
PropertyChangeSupport support = new PropertyChangeSupport(bean);
EventLog listenerToAll = new EventLog();
listenerToAll.name = "listenerToAll";
EventLog listenerToA = new EventLog();
listenerToA.name = "listenerToA";
support.addPropertyChangeListener(listenerToAll);
support.addPropertyChangeListener("a", listenerToA);
support.addPropertyChangeListener("a", listenerToA);
new SerializationTester<PropertyChangeSupport>(support, s) {
@Override protected boolean equals(PropertyChangeSupport a, PropertyChangeSupport b) {
return describe(a.getPropertyChangeListeners())
.equals(describe(b.getPropertyChangeListeners()));
}
@Override protected void verify(PropertyChangeSupport deserialized) {
assertEquals("[a to listenerToA, a to listenerToA, listenerToAll]",
describe(deserialized.getPropertyChangeListeners()));
}
}.test();
}
示例15: testSerializationWithComparator
import libcore.util.SerializationTester; //导入依赖的package包/类
public void testSerializationWithComparator() {
String s = "aced0005737200116a6176612e7574696c2e54726565536574dd98509395ed87"
+ "5b03000078707372002a6a6176612e6c616e672e537472696e672443617365496"
+ "e73656e736974697665436f6d70617261746f7277035c7d5c50e5ce0200007870"
+ "770400000002740001617400016278";
TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
set.add("a");
set.add("b");
new SerializationTester<NavigableSet<String>>(set, s) {
@Override protected void verify(NavigableSet<String> deserialized) {
assertEquals(0, deserialized.comparator().compare("X", "x"));
}
}.test();
}