QueryWritable implements Writable { @Override public boolean equals(Object obj) { if (getClass() != obj.getClass()) { return false; } Query other = ((QueryWritable) obj).getQuery(); return _query.equals(other); } QueryWritable();  QueryWritable(Query query); @Override void readFields(DataInput input); @Override void write(DataOutput output); Query getQuery(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testSerializeQuery() throws Exception { TermQuery termQuery = new TermQuery(new Term("katta")); QueryWritable writable = new QueryWritable(termQuery); DataOutputBuffer buffer = writeWritable(writable); QueryWritable writable2 = new QueryWritable(); readWritable(buffer, writable2); assertTrue(writable.equals(writable2)); }