Buggy code:
public class BinarySerializationQuerySelfTest extends GridCommonAbstractTest { private Ignite ignite ; private IgniteCache < Integer , Object > cache ; @ Override protected void beforeTest ( ) throws Exception { } private static CacheTypeMetadata metaForClass ( Class cls ) { } @ Override protected void afterTest ( ) throws Exception { } public void testPlain ( ) throws Exception { } public void testSerializable ( ) throws Exception { } public void testExternalizable ( ) throws Exception { } public void testBinarylizable ( ) throws Exception { } public void testWriteReadObject ( ) throws Exception { } @ SuppressWarnings ( "unchecked" ) private void check ( Class cls ) throws Exception { cache . put ( 1 , BinarySerializationQuerySelfTest . createInstance ( cls , 10 ) ) ; cache . put ( 2 , BinarySerializationQuerySelfTest . createInstance ( cls , 20 ) ) ; cache . put ( 3 , BinarySerializationQuerySelfTest . createInstance ( cls , 30 ) ) ; Iterator iter = cache . query ( new SqlQuery ( cls , "val=20" ) ) . iterator ( ) ; assert iter . hasNext ( ) ; Cache . Entry res = ( ( Cache . Entry ) ( iter . next ( ) ) ) ; assertEquals ( 2 , res . getKey ( ) ) ; <START_BUG> assertEquals ( 20 , U . field ( res . getValue ( ) , "val" ) ) ; <END_BUG> assert ! ( iter . hasNext ( ) ) ; iter = cache . query ( new SqlFieldsQuery ( ( ( "SELECT<seq2seq4repair_space>p.val<seq2seq4repair_space>FROM<seq2seq4repair_space>" + ( cls . getSimpleName ( ) ) ) + "<seq2seq4repair_space>p<seq2seq4repair_space>WHERE<seq2seq4repair_space>p.val=20" ) ) ) . iterator ( ) ; assert iter . hasNext ( ) ; List < Object > fieldsRes = ( ( List < Object > ) ( iter . next ( ) ) ) ; assertEquals ( 20 , fieldsRes . get ( 0 ) ) ; assert ! ( iter . hasNext ( ) ) ; } private static Object createInstance ( Class cls , int val ) { } protected boolean useReflectiveSerializer ( ) { } private static class EntityPlain { public int val ; public EntityPlain ( ) { } public EntityPlain ( int val ) { } } private static class EntitySerializable implements Serializable { public int val ; public EntitySerializable ( ) { } public EntitySerializable ( int val ) { } } private static class EntityExternalizable implements Externalizable { public int val ; public EntityExternalizable ( ) { } public EntityExternalizable ( int val ) { } @ Override public void writeExternal ( ObjectOutput out ) throws IOException { } @ Override public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { } } private static class EntityBinarylizable implements Binarylizable { public int val ; public EntityBinarylizable ( ) { } public EntityBinarylizable ( int val ) { } @ Override public void writeBinary ( BinaryWriter writer ) throws BinaryObjectException { } @ Override public void readBinary ( BinaryReader reader ) throws BinaryObjectException { } } private static class EntityWriteReadObject implements Serializable { public int val ; public EntityWriteReadObject ( ) { } public EntityWriteReadObject ( int val ) { } private void writeObject ( ObjectOutputStream s ) throws IOException { } private void readObject ( ObjectInputStream s ) throws IOException , ClassNotFoundException { } } }

Fix:
assertEquals ( Integer . valueOf ( 20 ) , U . field ( res . getValue ( ) , "val" ) ) ;