@Test public void transactionCacheClearedOnTransactionClose() { ContentDataStore dataStore = new ContentDataStore() { @Override protected List<Name> createTypeNames() throws IOException { return null; } @Override protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { return null; } }; Transaction transaction = new DefaultTransaction(); ContentEntry entry = new ContentEntry(dataStore, new NameImpl("test")); ContentState state = entry.getState(transaction); new DiffTransactionState(state); assertSame(state, entry.getState(transaction)); assertSame(state.getTransaction(), transaction); try { transaction.close(); ContentState stateForClosedTransaction = entry.getState(transaction); assertNotSame(stateForClosedTransaction, state); } catch (IOException e) { fail("Cannot close transaction: " + e.getLocalizedMessage()); } }
public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } }
ContentEntry { public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } } }
ContentEntry { public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } } ContentEntry(ContentDataStore dataStore, Name typeName); }
ContentEntry { public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } } ContentEntry(ContentDataStore dataStore, Name typeName); Name getName(); String getTypeName(); ContentDataStore getDataStore(); ContentState getState(Transaction transaction); void dispose(); void clearTransaction(Transaction transaction); String toString(); }
ContentEntry { public ContentState getState(Transaction transaction) { if (transaction != null && state.containsKey(transaction)) { return state.get(transaction); } else { ContentState auto = state.get(Transaction.AUTO_COMMIT); ContentState copy = (ContentState) auto.copy(); Transaction t = (transaction != null ? transaction : Transaction.AUTO_COMMIT); copy.setTransaction(t); state.put(t, copy); return copy; } } ContentEntry(ContentDataStore dataStore, Name typeName); Name getName(); String getTypeName(); ContentDataStore getDataStore(); ContentState getState(Transaction transaction); void dispose(); void clearTransaction(Transaction transaction); String toString();  }