### Question:
CacheItem implements Serializable { public boolean isTargetClassAndCurrentJvmTargetClassMatch() { Class<?> targetClassOnThisJVM; try { targetClassOnThisJVM = Class.forName(targetClassName); } catch (ClassNotFoundException e) { log.error("target class " + targetClassName + " does not exist on this JVM."); return false; } ObjectStreamClass osc = ObjectStreamClass.lookup(targetClassOnThisJVM); if (osc == null) { return false; } return targetClassSerialVersionUID == osc.getSerialVersionUID(); } CacheItem();  CacheItem(Object cacheEntry, boolean useStructuredCache); Object getCacheEntry(); String getTargetClassName(); long getTargetClassSerialVersionUID(); boolean isUseStructuredCache(); boolean isTargetClassAndCurrentJvmTargetClassMatch(); static boolean checkIfClassVersionApplicable(Object cacheEntry, boolean useStructuredCache); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final String STRUCTURED_CACHE_ENTRY_SUBCLASS_KEY; }### Answer:
@Test public void isTargetClassAndCurrentJvmTargetClassMatch_jvm_has_no_targetClass() throws Exception { CacheItem cacheItem = createCacheItem("kr.pe.kwonnam.hibernate4memcached.NotExistingClass", 1L); assertThat(cacheItem.isTargetClassAndCurrentJvmTargetClassMatch()).isFalse(); }
@Test public void isTargetClassAndCurrentJvmTargetClassMatch_class_exist_but_Not_Serializable() throws Exception { CacheItem cacheItem = createCacheItem(NotSerializableFakeEntity.class.getName(), 1L); assertThat(cacheItem.isTargetClassAndCurrentJvmTargetClassMatch()).isFalse(); }
@Test public void isTargetClassAndCurrentJvmTargetClassMatch_class_exist_but_different_serialversionUID() throws Exception { CacheItem cacheItem = createCacheItem(FakeEntity.class.getName(), FakeEntity.serialVersionUID + 1L); assertThat(cacheItem.isTargetClassAndCurrentJvmTargetClassMatch()).isFalse(); }
@Test public void isTargetClassAndCurrentJvmTargetClassMatch_match_true() throws Exception { CacheItem cacheItem = createCacheItem(FakeEntity.class.getName(), FakeEntity.serialVersionUID); assertThat(cacheItem.isTargetClassAndCurrentJvmTargetClassMatch()).isTrue(); }