Key implements Serializable { public static Key create(URI uri, Vary vary) { return new Key( URIBuilder.fromURI(Objects.requireNonNull(uri, "URI may not be null")).toNormalizedURI(), Objects.requireNonNull(vary, "vary may not be null") ); } Key(URI uri, Vary vary); static Key create(URI uri, Vary vary); static Key create(HTTPRequest request, HTTPResponse response); URI getURI(); Vary getVary(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static Key parse(Properties properties); Properties toProperties();  }
@Test public void testSerializationWithEmptyVary() { Key key1 = Key.create(URI.create("foo"), new Vary()); byte[] bytes = SerializationUtils.serialize(key1); Key key2 = (Key) SerializationUtils.deserialize(bytes); Assert.assertEquals(key1, key2); }
@Test public void testSerializationOneItemInVary() { Key key1 = Key.create(URI.create("foo"), new Vary(Collections.singletonMap("Accept-Language", "en"))); byte[] bytes = SerializationUtils.serialize(key1); Key key2 = (Key) SerializationUtils.deserialize(bytes); Assert.assertEquals(key1, key2); }