示例#1
0
 @Test
 public void
     given_copy_on_write_when_copyElementForRemovalIfNeeded_with_Element_then_returns_same() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(false, true, copyStrategy);
   Element element = new Element("key", "value");
   assertThat(copyStrategyHandler.copyElementForRemovalIfNeeded(element), sameInstance(element));
 }
示例#2
0
 @Test
 public void
     given_copy_on_read_and_write_when_copyElementForRemovalIfNeeded_with_Element_then_returns_different() {
   Element element = new Element("key", "value");
   Element serial = new Element("key", new byte[] {});
   when(copyStrategy.copyForWrite(element)).thenReturn(new Element("key", new byte[] {}));
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(true, true, copyStrategy);
   assertThat(copyStrategyHandler.copyElementForRemovalIfNeeded(element), is(serial));
   verify(copyStrategy).copyForWrite(element);
 }
示例#3
0
 @Test
 public void
     given_copy_on_write_when_copyElementForWriteIfNeeded_with_Element_then_returns_different() {
   Element element = new Element("key", "value");
   Element serial = new Element("key", new byte[] {});
   when(copyStrategy.copyForWrite(element)).thenReturn(serial);
   when(copyStrategy.copyForRead(serial)).thenReturn(new Element("key", "value"));
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(false, true, copyStrategy);
   assertThat(
       copyStrategyHandler.copyElementForWriteIfNeeded(element),
       allOf(not(sameInstance(element)), equalTo(element)));
   verify(copyStrategy).copyForWrite(element);
   verify(copyStrategy).copyForRead(serial);
 }
示例#4
0
 @Test
 public void given_no_copy_when_copyElementForWriteIfNeeded_with_Element_then_returns_same() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(false, false, null);
   Element element = new Element("key", "value");
   assertThat(copyStrategyHandler.copyElementForWriteIfNeeded(element), sameInstance(element));
 }
示例#5
0
 @Test
 public void given_no_copy_when_copyElementForReadIfNeeded_with_null_then_returns_null() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(false, false, null);
   assertThat(copyStrategyHandler.copyElementForReadIfNeeded(null), nullValue());
 }
示例#6
0
 @Test
 public void given_copy_on_read_and_write_when_isCopyActive_then_false() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(true, false, copyStrategy);
   assertThat(copyStrategyHandler.isCopyActive(), is(true));
 }
示例#7
0
 @Test
 public void given_no_copy_when_isCopyActive_then_false() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(false, false, null);
   assertThat(copyStrategyHandler.isCopyActive(), is(false));
 }
示例#8
0
 @Test
 public void
     given_copy_on_read_and_write_when_copyElementForRemovalIfNeeded_with_null_then_returns_null() {
   CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(true, true, copyStrategy);
   assertThat(copyStrategyHandler.copyElementForRemovalIfNeeded(null), nullValue());
 }