geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [59/94] [abbrv] incubator-geode git commit: GEODE-917: Merge branch 'feature/GEODE-917' into develop
Date Tue, 23 Feb 2016 20:23:55 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
index 0000000,d4f9e97..feb5de8
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
@@@ -1,0 -1,33 +1,32 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package com.gemstone.gemfire.internal.offheap;
+ 
+ import org.junit.runner.RunWith;
+ import org.junit.runners.Suite;
+ 
+ @Suite.SuiteClasses({
+ 	DataAsAddressJUnitTest.class,
 -	GemFireChunkJUnitTest.class,
 -	ChunkWithHeapFormJUnitTest.class,
 -	GemFireChunkSliceJUnitTest.class,
 -	GemFireChunkFactoryJUnitTest.class
++	ObjectChunkJUnitTest.class,
++	ObjectChunkWithHeapFormJUnitTest.class,
++	ObjectChunkSliceJUnitTest.class,
+ })
+ @RunWith(Suite.class)
+ public class StoredObjectTestSuite {
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
index 0000000,aaa2ec8..3ae6159
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
@@@ -1,0 -1,289 +1,289 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.internal.offheap;
+ 
+ import static org.junit.Assert.*;
+ import static org.mockito.Mockito.*;
+ 
+ import org.junit.After;
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ import org.mockito.listeners.InvocationListener;
+ import org.mockito.listeners.MethodInvocationReport;
+ 
+ import com.gemstone.gemfire.LogWriter;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ @Category(UnitTest.class)
+ public class SyncChunkStackJUnitTest {
+   static {
+     ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
+   }
+ 
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+   }
+ 
+   @AfterClass
+   public static void tearDownAfterClass() throws Exception {
+   }
+ 
+   @Before
+   public void setUp() throws Exception {
+   }
+ 
+   @After
+   public void tearDown() throws Exception {
+   }
+ 
+   @Test
+   public void addressZeroCausesStackToBeEmpty() {
+     SyncChunkStack stack = new SyncChunkStack(0L);
+     assertEquals(true, stack.isEmpty());
+   }
+ 
+   @Test
+   public void defaultStackIsEmpty() {
+     SyncChunkStack stack = new SyncChunkStack();
+     assertEquals(true, stack.isEmpty());
+   }
+ 
+   @Test
+   public void defaultStackReturnsZeroFromTop() {
+     SyncChunkStack stack = new SyncChunkStack();
+     assertEquals(0L, stack.getTopAddress());
+   }
+   
+   @Test
+   public void defaultStackReturnsZeroFromPoll() {
+     SyncChunkStack stack = new SyncChunkStack();
+     assertEquals(0L, stack.poll());
+   }
+   
+   @Test
+   public void defaultStackReturnsZeroFromClear() {
+     SyncChunkStack stack = new SyncChunkStack();
+     assertEquals(0L, stack.clear());
+     assertEquals(true, stack.isEmpty());
+   }
+   
+   @Test
+   public void defaultStackLogsNothing() {
+     SyncChunkStack stack = new SyncChunkStack();
+     LogWriter lw = mock(LogWriter.class, withSettings().invocationListeners(new InvocationListener() {
+       @Override
+       public void reportInvocation(MethodInvocationReport methodInvocationReport) {
+         fail("Unexpected invocation");
+       }
+     }));
+     stack.logSizes(lw, "should not be used");
+   }
+   
+   @Test
+   public void defaultStackComputeSizeIsZero() {
+     SyncChunkStack stack = new SyncChunkStack();
+     assertEquals(0L, stack.computeTotalSize());
+   }
+   
+   @Test
+   public void stackCreatedWithAddressIsNotEmpty() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+ 
+       SyncChunkStack stack = new SyncChunkStack(chunk.getMemoryAddress());
+       assertEquals(false, stack.isEmpty());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+   @Test
+   public void stackWithChunkIsNotEmpty() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+ 
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(chunk.getMemoryAddress());
+       assertEquals(false, stack.isEmpty());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+   @Test
+   public void stackWithChunkTopEqualsAddress() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+ 
+       long addr = chunk.getMemoryAddress();
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(addr);
+       assertEquals(addr, stack.getTopAddress());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+   @Test
+   public void addressZeroOfferCausesFailedAssertion() {
+     SyncChunkStack stack = new SyncChunkStack(0L);
+     try {
+       stack.offer(0);
+       fail("expected AssertionError");
+     } catch (AssertionError expected) {
+     }
+   }
+ 
+ 
+   @Test
+   public void stackWithChunkClearReturnsAddressAndEmptiesStack() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+ 
+       long addr = chunk.getMemoryAddress();
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(addr);
+       long clearAddr = stack.clear();
+       assertEquals(addr, clearAddr);
+       assertEquals(true, stack.isEmpty());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+   @Test
+   public void stackWithChunkPollReturnsAddressAndEmptiesStack() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+ 
+       long addr = chunk.getMemoryAddress();
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(addr);
+       long pollAddr = stack.poll();
+       assertEquals(addr, pollAddr);
+       assertEquals(true, stack.isEmpty());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+   @Test
+   public void stackWithChunkTotalSizeIsChunkSize() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+       int chunkSize = chunk.getSize();
+ 
+       long addr = chunk.getMemoryAddress();
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(addr);
+       assertEquals(chunkSize, stack.computeTotalSize());
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+ 
+   @Test
+   public void stackWithChunkLogShowsMsgAndSize() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+       int chunkSize = chunk.getSize();
+ 
+       long addr = chunk.getMemoryAddress();
+       SyncChunkStack stack = new SyncChunkStack();
+       stack.offer(addr);
+       LogWriter lw = mock(LogWriter.class);
+       stack.logSizes(lw, "foo");
+       verify(lw).info("foo"+chunkSize);
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+   
+   private class TestableSyncChunkStack extends SyncChunkStack {
+     public boolean doConcurrentMod = true;
+     public int chunk2Size;
+     private SimpleMemoryAllocatorImpl ma;
+     TestableSyncChunkStack(SimpleMemoryAllocatorImpl ma) {
+       this.ma = ma;
+     }
+     @Override
+     protected void testHookDoConcurrentModification() {
+       if (doConcurrentMod) {
+         doConcurrentMod = false;
 -        Chunk chunk2 = (Chunk) ma.allocate(50, null);
++        ObjectChunk chunk2 = (ObjectChunk) ma.allocate(50);
+         this.chunk2Size = chunk2.getSize();
+         this.offer(chunk2.getMemoryAddress());
+       }
+     }
+   }
+   @Test
+   public void stackWithChunkTotalSizeIsChunkSizeWithConcurrentMod() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+       int chunkSize = chunk.getSize();
+ 
+       long addr = chunk.getMemoryAddress();
+       TestableSyncChunkStack stack = new TestableSyncChunkStack(ma);
+       stack.offer(addr);
+       long totalSize = stack.computeTotalSize();
+       assertEquals("chunkSize=" + chunkSize + " chunk2Size=" + stack.chunk2Size, chunkSize + stack.chunk2Size, totalSize);
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ 
+ 
+   @Test
+   public void stackWithChunkLogShowsMsgAndSizeWithConcurrentMod() {
+     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+     try {
 -      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
 -      Chunk chunk = (Chunk) ma.allocate(100, null);
++      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
++      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
+       int chunkSize = chunk.getSize();
+ 
+       long addr = chunk.getMemoryAddress();
+       TestableSyncChunkStack stack = new TestableSyncChunkStack(ma);
+       stack.offer(addr);
+       LogWriter lw = mock(LogWriter.class);
+       stack.logSizes(lw, "foo");
+       verify(lw).info("foo"+chunkSize);
+       verify(lw).info("foo"+stack.chunk2Size);
+     } finally {
+       SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+     }
+   }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunkJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunkJUnitTest.java
index 0000000,a98fa28..d7168a7
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunkJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunkJUnitTest.java
@@@ -1,0 -1,87 +1,87 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.internal.offheap;
+ 
+ import static org.junit.Assert.*;
+ 
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ 
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ @Category(UnitTest.class)
+ public class UnsafeMemoryChunkJUnitTest extends MemoryChunkJUnitTestBase {
+ 
+   @Override
+   protected MemoryChunk createChunk(int size) {
+     return new UnsafeMemoryChunk(size);
+   }
+ 
+   @Test
+   public void testGetAddress() {
+     MemoryChunk mc = createChunk(1024);
+     try {
 -      UnsafeMemoryChunk umc = (UnsafeMemoryChunk) mc;
++      AddressableMemoryChunk umc = (AddressableMemoryChunk) mc;
+       assertNotEquals(0, umc.getMemoryAddress());
+     } finally {
+       mc.release();
+     }
+   }
+   
+   @Test(expected=AssertionError.class)
+   public void readAbsoluteBytesFailsIfSizeLessThanZero() {
+     UnsafeMemoryChunk.readAbsoluteBytes(0L, null, 0, -1);
+   }
+   @Test
+   public void readAbsoluteBytesDoesNothingIfSizeIsZero() {
+     UnsafeMemoryChunk.readAbsoluteBytes(0L, new byte[0], 0, 0);
+   }
+   @Test(expected=AssertionError.class)
+   public void readAbsoluteBytesFailsIfSizeGreaterThanArrayLength() {
+     UnsafeMemoryChunk.readAbsoluteBytes(0L, new byte[0], 0, 1);
+   }
+   @Test(expected=AssertionError.class)
+   public void readAbsoluteBytesFailsIfByteOffsetNegative() {
+     UnsafeMemoryChunk.readAbsoluteBytes(0L, new byte[0], -1, 0);
+   }
+   @Test(expected=AssertionError.class)
+   public void readAbsoluteBytesFailsIfByteOffsetGreaterThanArrayLength() {
+     UnsafeMemoryChunk.readAbsoluteBytes(0L, new byte[0], 1, 0);
+   }
+   
+   @Test(expected=AssertionError.class)
+   public void writeAbsoluteBytesFailsIfSizeLessThanZero() {
+     UnsafeMemoryChunk.writeAbsoluteBytes(0L, null, 0, -1);
+   }
+   @Test
+   public void writeAbsoluteBytesDoesNothingIfSizeIsZero() {
+     UnsafeMemoryChunk.writeAbsoluteBytes(0L, new byte[0], 0, 0);
+   }
+   @Test(expected=AssertionError.class)
+   public void writeAbsoluteBytesFailsIfSizeGreaterThanArrayLength() {
+     UnsafeMemoryChunk.writeAbsoluteBytes(0L, new byte[0], 0, 1);
+   }
+   @Test(expected=AssertionError.class)
+   public void writeAbsoluteBytesFailsIfByteOffsetNegative() {
+     UnsafeMemoryChunk.writeAbsoluteBytes(0L, new byte[0], -1, 0);
+   }
+   @Test(expected=AssertionError.class)
+   public void writeAbsoluteBytesFailsIfByteOffsetGreaterThanArrayLength() {
+     UnsafeMemoryChunk.writeAbsoluteBytes(0L, new byte[0], 1, 0);
+   }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
index 0000000,c7c7b7b..0f918cb
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
@@@ -1,0 -1,52 +1,52 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.pdx;
+ 
+ import static org.junit.Assert.fail;
+ 
+ import java.nio.ByteBuffer;
+ 
+ import org.junit.experimental.categories.Category;
+ 
 -import com.gemstone.gemfire.internal.offheap.Chunk;
++import com.gemstone.gemfire.internal.offheap.ObjectChunk;
+ import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+ import com.gemstone.gemfire.internal.offheap.StoredObject;
+ import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
+ import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSourceFactory;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ @Category(UnitTest.class)
+ public class OffHeapByteBufferByteSourceJUnitTest extends OffHeapByteSourceJUnitTest {
+   
+   @Override
+   protected ByteSource createByteSource(byte[] bytes) {
 -    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false, null);
 -    if (so instanceof Chunk) {
 -      Chunk c = (Chunk) so;
++    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
++    if (so instanceof ObjectChunk) {
++      ObjectChunk c = (ObjectChunk) so;
+       ByteBuffer bb = c.createDirectByteBuffer();
+       if (bb == null) {
+         fail("could not create a direct ByteBuffer for an off-heap Chunk");
+       }
+       return ByteSourceFactory.create(bb);
+     } else {
+       // bytes are so small they can be encoded in a long (see DataAsAddress).
+       // So for this test just wrap the original bytes.
+       return ByteSourceFactory.wrap(bytes);
+     }
+   }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
index 0000000,543ef94..6457425
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
@@@ -1,0 -1,65 +1,65 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.pdx;
+ 
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.experimental.categories.Category;
+ 
 -import com.gemstone.gemfire.internal.offheap.Chunk;
++import com.gemstone.gemfire.internal.offheap.ObjectChunk;
+ import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
+ import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
+ import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+ import com.gemstone.gemfire.internal.offheap.StoredObject;
+ import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk;
+ import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
+ import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSourceFactory;
+ import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.OffHeapByteSource;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ @Category(UnitTest.class)
+ public class OffHeapByteSourceJUnitTest extends ByteSourceJUnitTest {
+ 
+   @Before
+   public void setUp() throws Exception {
 -    SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{new UnsafeMemoryChunk(1024*1024)});
++    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{new UnsafeMemoryChunk(1024*1024)});
+   }
+ 
+   @After
+   public void tearDown() throws Exception {
+     SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+   }
+ 
+   @Override
+   protected boolean isTestOffHeap() {
+     return true;
+   }
+   
+   @Override
+   protected ByteSource createByteSource(byte[] bytes) {
 -    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false, null);
 -    if (so instanceof Chunk) {
++    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
++    if (so instanceof ObjectChunk) {
+       // bypass the factory to make sure that OffHeapByteSource is tested
 -      return new OffHeapByteSource((Chunk)so);
++      return new OffHeapByteSource((ObjectChunk)so);
+     } else {
+       // bytes are so small they can be encoded in a long (see DataAsAddress).
+       // So for this test just wrap the original bytes.
+       return ByteSourceFactory.wrap(bytes);
+     }
+   }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c741a68f/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index 0000000,74260ed..dc03990
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@@ -1,0 -1,525 +1,523 @@@
+ 
+ package com.gemstone.gemfire.security;
+ 
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  * 
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  * 
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ 
+ import java.util.Iterator;
+ import java.util.Properties;
+ 
++import com.gemstone.gemfire.test.dunit.VM;
+ import security.AuthzCredentialGenerator;
+ import security.CredentialGenerator;
+ 
+ import com.gemstone.gemfire.cache.Region;
+ import com.gemstone.gemfire.cache.execute.Function;
+ import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+ import com.gemstone.gemfire.internal.AvailablePort;
+ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+ import com.gemstone.gemfire.internal.cache.execute.PRClientServerTestBase;
+ import com.gemstone.gemfire.internal.cache.functions.TestFunction;
+ import com.gemstone.gemfire.test.dunit.Host;
+ import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+ 
+ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
+ 
+   /** constructor */
+   public ClientMultiUserAuthzDUnitTest(String name) {
+     super(name);
+   }
+ 
+   public void setUp() throws Exception {
+ 
+     super.setUp();
+     final Host host = Host.getHost(0);
+     server1 = host.getVM(0);
+     server2 = host.getVM(1);
+     client1 = host.getVM(2);
+     client2 = host.getVM(3);
+ 
+     server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
+     server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
+     client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
+     SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
+   }
+ 
+   // Tests with one user authorized to do puts/gets/containsKey/destroys and
+   // another not authorized for the same.
+   public void testOps1() throws Exception {
+     Iterator iter = getDummyGeneratorCombos().iterator();
+     while (iter.hasNext()) {
+       AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+       CredentialGenerator cGen = gen.getCredentialGenerator();
+       Properties extraAuthProps = cGen.getSystemProperties();
+       Properties javaProps = cGen.getJavaProperties();
+       Properties extraAuthzProps = gen.getSystemProperties();
+       String authenticator = cGen.getAuthenticator();
+       String authInit = cGen.getAuthInit();
+       String accessor = gen.getAuthorizationCallback();
+ 
+       LogWriterUtils.getLogWriter().info("testOps1: Using authinit: " + authInit);
+       LogWriterUtils.getLogWriter().info(
+           "testOps1: Using authenticator: " + authenticator);
+       LogWriterUtils.getLogWriter().info("testOps1: Using accessor: " + accessor);
+ 
+       // Start servers with all required properties
+       Properties serverProps = buildProperties(authenticator, accessor, false,
+           extraAuthProps, extraAuthzProps);
 -      Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      createCacheServers(javaProps, serverProps, port1, port2);
++
++      Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
++      Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
 -          OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
++              OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
++              OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
+           port2)) {
+         continue;
+       }
+       verifyPutsGets();
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
 -          OperationCode.DESTROY, OperationCode.DESTROY},
++              OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
++              OperationCode.DESTROY, OperationCode.DESTROY},
+           javaProps, authInit, port1, port2)) {
+         continue;
+       }
+       verifyContainsKeyDestroys();
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
 -          OperationCode.INVALIDATE, OperationCode.INVALIDATE},
++              OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
++              OperationCode.INVALIDATE, OperationCode.INVALIDATE},
+           javaProps, authInit, port1, port2)) {
+         continue;
+       }
+       verifyContainsKeyInvalidates();
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.GET, OperationCode.GET}, new OperationCode[] {
 -          OperationCode.REGION_DESTROY, OperationCode.REGION_DESTROY},
++              OperationCode.GET, OperationCode.GET}, new OperationCode[] {
++              OperationCode.REGION_DESTROY, OperationCode.REGION_DESTROY},
+           javaProps, authInit, port1, port2)) {
+         continue;
+       }
+       verifyGetAllInTX();
+       verifyGetAllRegionDestroys();
+     }
+   }
+ 
+   private boolean prepareClientsForOps(AuthzCredentialGenerator gen,
+       CredentialGenerator cGen, OperationCode[] client1OpCodes,
+       OperationCode[] client2OpCodes, Properties javaProps, String authInit,
+       Integer port1, Integer port2) {
+     return prepareClientsForOps(gen, cGen, client1OpCodes, client2OpCodes,
+         javaProps, authInit, port1, port2, Boolean.TRUE /*
+                                                          * both clients in
+                                                          * multiuser mode
+                                                          */, Boolean.FALSE /* unused */);
+   }
+ 
+   private boolean prepareClientsForOps(AuthzCredentialGenerator gen,
+       CredentialGenerator cGen, OperationCode[] client1OpCodes,
+       OperationCode[] client2OpCodes, Properties javaProps, String authInit,
+       Integer port1, Integer port2, Boolean bothClientsInMultiuserMode,
+       Boolean allowOp) {
+     // Start client1 with valid/invalid client1OpCodes credentials
+     Properties[] client1Credentials = new Properties[] {
+         gen.getAllowedCredentials(client1OpCodes, new String[] {regionName}, 1),
+         gen.getDisallowedCredentials(new OperationCode[] {client1OpCodes[1]},
+             new String[] {regionName}, 1)};
+     if (client1Credentials[0] == null || client1Credentials[0].size() == 0) {
+       LogWriterUtils.getLogWriter().info(
+           "testOps1: Unable to obtain valid credentials with "
+               + client1OpCodes[0].toString()
+               + " permission; skipping this combination.");
+       return false;
+     }
+     if (client1Credentials[1] == null || client1Credentials[1].size() == 0) {
+       LogWriterUtils.getLogWriter().info(
+           "testOps1: Unable to obtain valid credentials with no "
+               + client1OpCodes[0].toString()
+               + " permission; skipping this combination.");
+       return false;
+     }
+     javaProps = cGen.getJavaProperties();
+     LogWriterUtils.getLogWriter().info(
+         "testOps1: For first client credentials: " + client1Credentials[0]
+             + "\n" + client1Credentials[1]);
+     client1.invoke(SecurityTestUtil.class, "createCacheClientForMultiUserMode",
+         new Object[] {Integer.valueOf(2), authInit, client1Credentials,
+             javaProps, new Integer[] {port1, port2}, null, Boolean.FALSE,
+             SecurityTestUtil.NO_EXCEPTION});
+ 
+     // Start client2 with valid/invalid client2OpCodes credentials
+     Properties[] client2Credentials = new Properties[] {
+         gen.getAllowedCredentials(client2OpCodes,
+             new String[] {regionName}, 2),
+         gen.getDisallowedCredentials(client2OpCodes,
+             new String[] {regionName}, 9)};
+     if (client2Credentials[0] == null || client2Credentials[0].size() == 0) {
+       LogWriterUtils.getLogWriter().info(
+           "testOps1: Unable to obtain valid credentials with "
+               + client2OpCodes[0].toString()
+               + " permission; skipping this combination.");
+       return false;
+     }
+     if (client2Credentials[1] == null || client2Credentials[1].size() == 0) {
+       LogWriterUtils.getLogWriter().info(
+           "testOps1: Unable to obtain valid credentials with no "
+               + client2OpCodes[0].toString()
+               + " permission; skipping this combination.");
+       return false;
+     }
+     javaProps = cGen.getJavaProperties();
+     LogWriterUtils.getLogWriter().info(
+         "testOps1: For second client credentials: " + client2Credentials[0]
+             + "\n" + client2Credentials[1]);
+     if (bothClientsInMultiuserMode) {
+       client2.invoke(SecurityTestUtil.class,
+           "createCacheClientForMultiUserMode", new Object[] {
+               Integer.valueOf(2), authInit, client2Credentials, javaProps,
+               new Integer[] {port1, port2}, null, Boolean.FALSE,
+               SecurityTestUtil.NO_EXCEPTION});
+     } else {
+       int credentialsIndex = allowOp ? 0 : 1;
+       client2.invoke(SecurityTestUtil.class, "createCacheClient", new Object[] {
+           authInit, client2Credentials[credentialsIndex], javaProps,
+           new Integer[] {port1, port2}, null, Boolean.FALSE, "false",
+           SecurityTestUtil.NO_EXCEPTION});
+     }
+     return true;
+   }
+ 
+   private void verifyPutsGets() throws Exception {
+     verifyPutsGets(true, false /*unused */);
+   }
+ 
+   private void verifyPutsGets(Boolean isMultiuser, Boolean opAllowed)
+       throws Exception {
+     // Perform some put operations from client1
+     client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
+         Integer.valueOf(2),
+         Integer.valueOf(2),
+         new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+             SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+ 
+     // Verify that the gets succeed/fail
+     if (isMultiuser) {
 -    client2.invoke(SecurityTestUtil.class, "doMultiUserGets", new Object[] {
 -        Integer.valueOf(2),
 -        Integer.valueOf(2),
 -        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
++      client2.invoke(SecurityTestUtil.class, "doMultiUserGets", new Object[] {
++          Integer.valueOf(2),
++          Integer.valueOf(2),
++          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++              SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+     } else {
+       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
+           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
+       client2.invoke(SecurityTestUtil.class, "doMultiUserGets", new Object[] {
+           Integer.valueOf(1), Integer.valueOf(1),
+           new Integer[] {expectedResult}});
+     }
+   }
+ 
+   private void verifyContainsKeyDestroys() throws Exception {
+     verifyContainsKeyDestroys(true, false /* unused */);
+   }
+ 
+   private void verifyContainsKeyDestroys(Boolean isMultiuser, Boolean opAllowed)
+       throws Exception {
+     // Do puts before verifying containsKey
+     client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
+         Integer.valueOf(2),
+         Integer.valueOf(2),
+         new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+             SecurityTestUtil.NO_EXCEPTION}});
+     client1.invoke(SecurityTestUtil.class, "doMultiUserContainsKeys",
+         new Object[] {
+             Integer.valueOf(1),
+             Integer.valueOf(2),
+             new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+                 SecurityTestUtil.NOTAUTHZ_EXCEPTION},
+             new Boolean[] {Boolean.TRUE, Boolean.FALSE}});
+ 
+     // Verify that the destroys succeed/fail
+     if (isMultiuser) {
+       client2.invoke(SecurityTestUtil.class, "doMultiUserDestroys",
+           new Object[] {
+               Integer.valueOf(2),
+               Integer.valueOf(2),
+               new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+                   SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+     } else {
+       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
+           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
+       client2.invoke(SecurityTestUtil.class, "doMultiUserDestroys",
+           new Object[] {Integer.valueOf(1), Integer.valueOf(1),
+               new Integer[] {expectedResult}});
+     }
+   }
+ 
+   private void verifyContainsKeyInvalidates() throws Exception {
+     verifyContainsKeyInvalidates(true, false /* unused */);
+   }
+ 
+   private void verifyContainsKeyInvalidates(Boolean isMultiuser, Boolean opAllowed)
+       throws Exception {
+     // Do puts before verifying containsKey
+     client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
+         Integer.valueOf(2),
+         Integer.valueOf(2),
+         new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+             SecurityTestUtil.NO_EXCEPTION}});
+     client1.invoke(SecurityTestUtil.class, "doMultiUserContainsKeys",
+         new Object[] {
+             Integer.valueOf(1),
+             Integer.valueOf(2),
+             new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+                 SecurityTestUtil.NOTAUTHZ_EXCEPTION},
+             new Boolean[] {Boolean.TRUE, Boolean.FALSE}});
+ 
+     // Verify that the invalidates succeed/fail
+     if (isMultiuser) {
+       client2.invoke(SecurityTestUtil.class, "doMultiUserInvalidates",
+           new Object[] {
+               Integer.valueOf(2),
+               Integer.valueOf(2),
+               new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+                   SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+     } else {
+       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
+           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
+       client2.invoke(SecurityTestUtil.class, "doMultiUserInvalidates",
+           new Object[] {Integer.valueOf(1), Integer.valueOf(1),
+               new Integer[] {expectedResult}});
+     }
+   }
+ 
+   private void verifyGetAllInTX() {
+     server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
+     client1.invoke(SecurityTestUtil.class, "doMultiUserGetAll", new Object[] {
 -      Integer.valueOf(2),
 -      new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -          SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Boolean.TRUE/*use TX*/});
++        Integer.valueOf(2),
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Boolean.TRUE/*use TX*/});
+   }
+ 
+   private void verifyGetAllRegionDestroys() {
+     server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
+     client1.invoke(SecurityTestUtil.class, "doMultiUserGetAll", new Object[] {
 -      Integer.valueOf(2),
 -      new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -          SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
++        Integer.valueOf(2),
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+ 
+     // Verify that the region destroys succeed/fail
+     client2.invoke(SecurityTestUtil.class, "doMultiUserRegionDestroys",
+         new Object[] {
+             Integer.valueOf(2),
+             new Integer[] {SecurityTestUtil.NO_EXCEPTION,
+                 SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+   }
 -  
++
+   public static void doPuts() {
+     Region region = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.regionName);
+     region.put("key1", "value1");
+     region.put("key2", "value2");
+   }
+ 
+   // Test query/function execute
+   public void testOps2() throws Exception {
 -      AuthzCredentialGenerator gen = getXmlAuthzGenerator();
 -      CredentialGenerator cGen = gen.getCredentialGenerator();
 -      Properties extraAuthProps = cGen.getSystemProperties();
 -      Properties javaProps = cGen.getJavaProperties();
 -      Properties extraAuthzProps = gen.getSystemProperties();
 -      String authenticator = cGen.getAuthenticator();
 -      String authInit = cGen.getAuthInit();
 -      String accessor = gen.getAuthorizationCallback();
++    AuthzCredentialGenerator gen = getXmlAuthzGenerator();
++    CredentialGenerator cGen = gen.getCredentialGenerator();
++    Properties extraAuthProps = cGen.getSystemProperties();
++    Properties javaProps = cGen.getJavaProperties();
++    Properties extraAuthzProps = gen.getSystemProperties();
++    String authenticator = cGen.getAuthenticator();
++    String authInit = cGen.getAuthInit();
++    String accessor = gen.getAuthorizationCallback();
++
++    LogWriterUtils.getLogWriter().info("testOps2: Using authinit: " + authInit);
++    LogWriterUtils.getLogWriter().info("testOps2: Using authenticator: " + authenticator);
++    LogWriterUtils.getLogWriter().info("testOps2: Using accessor: " + accessor);
++
++    // Start servers with all required properties
++    Properties serverProps = buildProperties(authenticator, accessor, false,
++        extraAuthProps, extraAuthzProps);
++    Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
++    Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
++
++    // Start client1 with valid/invalid QUERY credentials
++    Properties[] client1Credentials = new Properties[] {
++        gen.getAllowedCredentials(
++            new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
++            new String[] {regionName},
++            1),
++        gen.getDisallowedCredentials(
++            new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
++            new String[] {regionName},
++            1)
++    };
+ 
 -      LogWriterUtils.getLogWriter().info("testOps2: Using authinit: " + authInit);
 -      LogWriterUtils.getLogWriter().info("testOps2: Using authenticator: " + authenticator);
 -      LogWriterUtils.getLogWriter().info("testOps2: Using accessor: " + accessor);
++    javaProps = cGen.getJavaProperties();
++    LogWriterUtils.getLogWriter().info(
++        "testOps2: For first client credentials: " + client1Credentials[0]
++            + "\n" + client1Credentials[1]);
++    client1.invoke(SecurityTestUtil.class,
++        "createCacheClientForMultiUserMode", new Object[] {
++            Integer.valueOf(2), authInit, client1Credentials, javaProps,
++            new Integer[] {port1, port2}, null, Boolean.FALSE,
++            SecurityTestUtil.NO_EXCEPTION});
+ 
 -      // Start servers with all required properties
 -      Properties serverProps = buildProperties(authenticator, accessor, false,
 -          extraAuthProps, extraAuthzProps);
 -      Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      createCacheServers(javaProps, serverProps, port1, port2);
 -
 -      // Start client1 with valid/invalid QUERY credentials
 -      Properties[] client1Credentials = new Properties[] {
 -          gen.getAllowedCredentials(
 -                  new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
 -                  new String[] {regionName},
 -                  1),
 -          gen.getDisallowedCredentials(
 -                  new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
 -                  new String[] {regionName},
 -                  1)
 -      };
 -
 -      javaProps = cGen.getJavaProperties();
 -      LogWriterUtils.getLogWriter().info(
 -          "testOps2: For first client credentials: " + client1Credentials[0]
 -              + "\n" + client1Credentials[1]);
 -      client1.invoke(SecurityTestUtil.class,
 -          "createCacheClientForMultiUserMode", new Object[] {
 -              Integer.valueOf(2), authInit, client1Credentials, javaProps,
 -              new Integer[] {port1, port2}, null, Boolean.FALSE,
 -              SecurityTestUtil.NO_EXCEPTION});
++    // Start client2 with valid/invalid EXECUTE_FUNCTION credentials
++    Properties[] client2Credentials = new Properties[] {
++        gen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
++            new String[] {regionName}, 2),
++        gen.getDisallowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
++            new String[] {regionName}, 9)};
+ 
 -      // Start client2 with valid/invalid EXECUTE_FUNCTION credentials
 -      Properties[] client2Credentials = new Properties[] {
 -          gen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
 -              new String[] {regionName}, 2),
 -          gen.getDisallowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
 -              new String[] {regionName}, 9)};
++    javaProps = cGen.getJavaProperties();
++    LogWriterUtils.getLogWriter().info(
++        "testOps2: For second client credentials: " + client2Credentials[0]
++            + "\n" + client2Credentials[1]);
++    client2.invoke(SecurityTestUtil.class,
++        "createCacheClientForMultiUserMode", new Object[] {
++            Integer.valueOf(2), authInit, client2Credentials, javaProps,
++            new Integer[] {port1, port2}, null, Boolean.FALSE,
++            SecurityTestUtil.NO_EXCEPTION});
++    Function function = new TestFunction(true,TestFunction.TEST_FUNCTION1);
++    server1.invoke(PRClientServerTestBase.class,
++        "registerFunction", new Object []{function});
+ 
 -      javaProps = cGen.getJavaProperties();
 -      LogWriterUtils.getLogWriter().info(
 -          "testOps2: For second client credentials: " + client2Credentials[0]
 -              + "\n" + client2Credentials[1]);
 -      client2.invoke(SecurityTestUtil.class,
 -          "createCacheClientForMultiUserMode", new Object[] {
 -              Integer.valueOf(2), authInit, client2Credentials, javaProps,
 -              new Integer[] {port1, port2}, null, Boolean.FALSE,
 -              SecurityTestUtil.NO_EXCEPTION});
 -      Function function = new TestFunction(true,TestFunction.TEST_FUNCTION1);
 -      server1.invoke(PRClientServerTestBase.class,
 -          "registerFunction", new Object []{function});
 -      
 -      server2.invoke(PRClientServerTestBase.class,
 -          "registerFunction", new Object []{function});
 -      
 -      // Perform some put operations before verifying queries
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
 -          Integer.valueOf(4),
 -          Integer.valueOf(2),
 -          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -              SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
 -          new Object[] {
 -              Integer.valueOf(2),
 -              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
 -          new Object[] {
 -              Integer.valueOf(2),
 -              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
++    server2.invoke(PRClientServerTestBase.class,
++        "registerFunction", new Object []{function});
+ 
 -      // Verify that the FE succeeds/fails
 -      client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
 -          Integer.valueOf(2),
 -          function,
 -          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -              SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
 -          Boolean.FALSE});
++    // Perform some put operations before verifying queries
++    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
++        Integer.valueOf(4),
++        Integer.valueOf(2),
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
++    client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
++        new Object[] {
++            Integer.valueOf(2),
++            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
++    client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
++        new Object[] {
++            Integer.valueOf(2),
++            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
+ 
 -      // Failover
 -      server1.invoke(() -> SecurityTestUtil.closeCache());
 -      Thread.sleep(2000);
++    // Verify that the FE succeeds/fails
++    client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
++        Integer.valueOf(2),
++        function,
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
++        Boolean.FALSE});
+ 
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
 -          Integer.valueOf(4),
 -          Integer.valueOf(2),
 -          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -              SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
++    // Failover
++    server1.invoke(() -> SecurityTestUtil.closeCache());
++    Thread.sleep(2000);
+ 
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
 -          new Object[] {
 -              Integer.valueOf(2),
 -              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
 -      client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
 -          new Object[] {
 -              Integer.valueOf(2),
 -              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
++    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
++        Integer.valueOf(4),
++        Integer.valueOf(2),
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+ 
 -      // Verify that the FE succeeds/fails
 -      client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
 -          Integer.valueOf(2),
 -          function,
 -          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
 -              SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
 -          Boolean.TRUE});
++    client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
++        new Object[] {
++            Integer.valueOf(2),
++            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
++    client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
++        new Object[] {
++            Integer.valueOf(2),
++            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
++
++    // Verify that the FE succeeds/fails
++    client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
++        Integer.valueOf(2),
++        function,
++        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
++            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
++        Boolean.TRUE});
+ 
+ 
+   }
+ 
 -  protected void createCacheServers(Properties javaProps,
 -      Properties serverProps, Integer port1, Integer port2) {
 -    server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps,
 -            javaProps));
 -    server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps,
 -            javaProps));
++
++  protected Integer createCacheServerOnVM(VM server, Properties javaProps, Properties serverProps) {
++    return (Integer)server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), serverProps,
++        javaProps));
++
+   }
+ 
+   public void testOpsWithClientsInDifferentModes() throws Exception {
+     Iterator iter = getDummyGeneratorCombos().iterator();
+     while (iter.hasNext()) {
+       AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+       CredentialGenerator cGen = gen.getCredentialGenerator();
+       Properties extraAuthProps = cGen.getSystemProperties();
+       Properties javaProps = cGen.getJavaProperties();
+       Properties extraAuthzProps = gen.getSystemProperties();
+       String authenticator = cGen.getAuthenticator();
+       String authInit = cGen.getAuthInit();
+       String accessor = gen.getAuthorizationCallback();
+ 
+       LogWriterUtils.getLogWriter().info("testOpsWithClientsInDifferentModes: Using authinit: " + authInit);
+       LogWriterUtils.getLogWriter().info(
+           "testOpsWithClientsInDifferentModes: Using authenticator: " + authenticator);
+       LogWriterUtils.getLogWriter().info("testOpsWithClientsInDifferentModes: Using accessor: " + accessor);
+ 
+       // Start servers with all required properties
+       Properties serverProps = buildProperties(authenticator, accessor, false,
+           extraAuthProps, extraAuthzProps);
 -      Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 -      createCacheServers(javaProps, serverProps, port1, port2);
++      Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
++      Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
 -          OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
++              OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
++              OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
+           port2, Boolean.FALSE, Boolean.TRUE)) {
+         continue;
+       }
+       verifyPutsGets(false, true);
+ 
+       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
 -          OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
 -          OperationCode.DESTROY, OperationCode.DESTROY},
++              OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
++              OperationCode.DESTROY, OperationCode.DESTROY},
+           javaProps, authInit, port1, port2, Boolean.FALSE, Boolean.FALSE)) {
+         continue;
+       }
+       verifyContainsKeyDestroys(false, false);
+     }
+   }
+ 
+   // End Region: Tests
+ 
+   @Override
+   protected final void preTearDown() throws Exception {
+     // close the clients first
+     client1.invoke(() -> SecurityTestUtil.closeCache());
+     client2.invoke(() -> SecurityTestUtil.closeCache());
+     SecurityTestUtil.closeCache();
+     // then close the servers
+     server1.invoke(() -> SecurityTestUtil.closeCache());
+     server2.invoke(() -> SecurityTestUtil.closeCache());
+   }
+ }


Mime
View raw message