@Test public void testSomeMethod() throws IOException { TestKryoStreamCodec coder = new TestKryoStreamCodec(); TestKryoStreamCodec decoder = new TestKryoStreamCodec(); KryoSerializableStreamCodec<Object> objCoder = new KryoSerializableStreamCodec<Object>(); Slice sliceOfObj = objCoder.toByteArray(10); Integer decodedObj = (Integer) objCoder.fromByteArray(sliceOfObj); Assert.assertEquals("codec", decodedObj.intValue(), 10); TestTuple tp = new TestTuple(5); Slice dsp1 = coder.toByteArray(tp); Slice dsp2 = coder.toByteArray(tp); Assert.assertEquals(dsp1, dsp2); Object tcObject1 = decoder.fromByteArray(dsp1); assert (tp.equals(tcObject1)); Object tcObject2 = decoder.fromByteArray(dsp2); assert (tp.equals(tcObject2)); dsp1 = coder.toByteArray(tp); dsp2 = coder.toByteArray(tp); Assert.assertEquals(dsp1, dsp2); }
public static Set<TestTuple> getTuplesByKey(String key, Set<TestTuple> props) { Set<TestTuple> result = new HashSet<TestTuple>(); for (TestTuple p : props) { if (p.getKey().equals(key)) { result.add(p); } } return result; }