AbstractPeerTXRegionStub implements TXRegionStub { @Override public int entryCount() { try { RemoteSizeMessage.SizeResponse response = RemoteSizeMessage.send(this.state.getTarget(), getRegion()); return response.waitForSize(); } catch (RegionDestroyedException regionDestroyedException) { throw new TransactionDataNotColocatedException( String.format("Region %s not colocated with other regions in transaction", regionDestroyedException.getRegionFullPath()), regionDestroyedException); } catch (CacheClosedException cacheClosedException) { throw new TransactionDataNodeHasDepartedException( "Cache was closed while performing size operation"); } catch (TransactionException transactionException) { throw transactionException; } catch (Exception exception) { throw new TransactionException(exception); } } AbstractPeerTXRegionStub(TXStateStub txstate); @Override Set getRegionKeysForIteration(); @Override int entryCount();  }
@Test public void entryCountTranslatesCacheClosedException() { expectedException.expect(TransactionDataNodeHasDepartedException.class); when((region).getSystem()).thenThrow(CacheClosedException.class); txrStub.entryCount(); fail( "AbstractPeerTXRegionStub expected to translate CacheClosedException to TransactionDataNodeHasDepartedException "); }
@Test public void entryCountTranslatesRegionDestroyedException() { expectedException.expect(TransactionDataNotColocatedException.class); when((region).getSystem()).thenThrow(RegionDestroyedException.class); txrStub.entryCount(); fail( "AbstractPeerTXRegionStub expected to translate CacheClosedException to TransactionDataNodeHasDepartedException "); }
@Test public void entryCountRethrowTransactionException() { expectedException.expect(TransactionDataNodeHasDepartedException.class); when((region).getSystem()).thenThrow(TransactionDataNodeHasDepartedException.class); txrStub.entryCount(); fail( "AbstractPeerTXRegionStub expected to rethrow TransactionDataNodeHasDepartedException "); }
@Test public void entryCountTranslatesRuntimeException() { expectedException.expect(TransactionException.class); when((region).getSystem()).thenThrow(new RuntimeException()); txrStub.entryCount(); fail( "AbstractPeerTXRegionStub expected to translate RuntimeException to TransactionException "); }