### Question:
XATransactionalStore extends AbstractStore { public Element removeElement(Element element) throws NullPointerException { TransactionContext context = getOrCreateTransactionContext(); Element previous = getCurrentElement(element.getKey(), context); if (previous != null && previous.getValue().equals(element.getValue())) { context.addCommand(new StoreRemoveElementCommand(element), element); return previous; } return null; } XATransactionalStore(Ehcache cache, EhcacheXAStore ehcacheXAStore,
                                TransactionManagerLookup transactionManagerLookup, TransactionManager txnManager); boolean put(final Element element); boolean putWithWriter(final Element element, final CacheWriterManager writerManager); Element get(final Object key); Element getQuiet(final Object key); final List getKeys(); Element remove(final Object key); Element removeWithWriter(final Object key, final CacheWriterManager writerManager); void removeAll(); void dispose(); int getSize(); int getOnDiskSize(); int getOffHeapSize(); int getInMemorySize(); int getTerracottaClusteredSize(); long getInMemorySizeInBytes(); long getOffHeapSizeInBytes(); long getOnDiskSizeInBytes(); Status getStatus(); boolean containsKey(final Object key); boolean containsKeyInMemory(final Object key); boolean containsKeyOffHeap(final Object key); boolean containsKeyOnDisk(final Object key); void expireElements(); void flush(); boolean bufferFull(); Policy getInMemoryEvictionPolicy(); void setInMemoryEvictionPolicy(final Policy policy); Object getInternalContext(); @Override boolean isCacheCoherent(); @Override boolean isClusterCoherent(); @Override boolean isNodeCoherent(); @Override void setNodeCoherent(boolean coherent); @Override void waitUntilClusterCoherent(); Element putIfAbsent(Element element); Element removeElement(Element element); boolean replace(Element old, Element element); boolean replace(Element old, Element element, ElementComparer comparer); Element replace(Element element); EhcacheXAResource getOrCreateXAResource(); Object getMBean();  }### Answer:
@Test public void testRemoveElement() throws Exception { transactionManager.begin(); assertEquals("Cache should be empty to start", 0, cache.getSize()); assertEquals("Cach1 should be empty to start", 0, cach1.getSize()); assertFalse(cache.removeElement(new Element("blah", "someValue"))); cache.put(new Element("blah", "value")); assertFalse(cache.removeElement(new Element("blah", "someValue"))); transactionManager.commit(); transactionManager.begin(); assertNotNull(cache.get("blah")); assertTrue(cache.removeElement(new Element("blah", "value"))); transactionManager.commit(); transactionManager.begin(); assertNull(cache.get("blah")); transactionManager.commit(); transactionManager.begin(); cache.put(new Element("key", "value")); transactionManager.commit(); transactionManager.begin(); cach1.put(new Element("random", "things")); cache.removeElement(new Element("key", "value")); Transaction tx1 = transactionManager.suspend(); transactionManager.begin(); assertTrue(cache.removeElement(new Element("key", "value"))); transactionManager.commit(); transactionManager.resume(tx1); try { transactionManager.commit(); fail("Transaction should have failed, element is deleted already"); } catch (RollbackException e) { } transactionManager.begin(); assertNull(cache.get("key")); transactionManager.commit(); transactionManager.begin(); cache.put(new Element("key", "value")); transactionManager.commit(); transactionManager.begin(); cach1.put(new Element("random", "things")); cache.removeElement(new Element("key", "value")); tx1 = transactionManager.suspend(); transactionManager.begin(); cache.put(new Element("key", "newValue")); transactionManager.commit(); transactionManager.resume(tx1); try { transactionManager.commit(); fail("Transaction should have failed, element has changed in the meantime!"); } catch (RollbackException e) { } transactionManager.begin(); assertNotNull(cache.get("key")); assertEquals("newValue", cache.get("key").getValue()); transactionManager.commit(); }