http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/NonLocalRegionEntryTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/NonLocalRegionEntryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/NonLocalRegionEntryTest.java new file mode 100644 index 0000000..1f99dac --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/NonLocalRegionEntryTest.java @@ -0,0 +1,45 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class NonLocalRegionEntryTest { + + @Test + public void shouldBeMockable() throws Exception { + NonLocalRegionEntry mockNonLocalRegionEntry = mock(NonLocalRegionEntry.class); + RegionEntryContext mockRegionEntryContext = mock(RegionEntryContext.class); + LocalRegion mockLocalRegion = mock(LocalRegion.class); + Object valueInVM = new Object(); + Object valueOnDisk = new Object(); + + when(mockNonLocalRegionEntry.getValueInVM(eq(mockRegionEntryContext))).thenReturn(valueInVM); + when(mockNonLocalRegionEntry.getValueInVMOrDiskWithoutFaultIn(eq(mockLocalRegion))) + .thenReturn(valueOnDisk); + + assertThat(mockNonLocalRegionEntry.getValueInVM(mockRegionEntryContext)).isSameAs(valueInVM); + assertThat(mockNonLocalRegionEntry.getValueInVMOrDiskWithoutFaultIn(mockLocalRegion)) + .isSameAs(valueOnDisk); + } +}
http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java index ed23f2a..1e56d00 100755 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java @@ -487,7 +487,7 @@ public class PartitionedRegionBucketCreationDistributionDUnitTest * <p> * Added specifically to test scenario of defect #47181. */ - private final Cache createLonerCacheWithEnforceUniqueHost() { + private Cache createLonerCacheWithEnforceUniqueHost() { Cache myCache = null; try { System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", @@ -519,7 +519,7 @@ public class PartitionedRegionBucketCreationDistributionDUnitTest * <p> * Added specifically to test scenario of defect #47181. */ - private final InternalDistributedSystem getLonerSystemWithEnforceUniqueHost() { + private InternalDistributedSystem getLonerSystemWithEnforceUniqueHost() { Properties props = getDistributedSystemProperties(); props.put(MCAST_PORT, "0"); props.put(LOCATORS, ""); http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/PlaceHolderDiskRegionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PlaceHolderDiskRegionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PlaceHolderDiskRegionTest.java new file mode 100644 index 0000000..a638b14 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PlaceHolderDiskRegionTest.java @@ -0,0 +1,34 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class PlaceHolderDiskRegionTest { + + @Test + public void shouldBeMockable() throws Exception { + PlaceHolderDiskRegion mockPlaceHolderDiskRegion = mock(PlaceHolderDiskRegion.class); + when(mockPlaceHolderDiskRegion.getName()).thenReturn("NAME"); + assertThat(mockPlaceHolderDiskRegion.getName()).isEqualTo("NAME"); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/ProxyBucketRegionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ProxyBucketRegionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ProxyBucketRegionTest.java new file mode 100644 index 0000000..115a1d9 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ProxyBucketRegionTest.java @@ -0,0 +1,37 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class ProxyBucketRegionTest { + + @Test + public void shouldBeMockable() throws Exception { + ProxyBucketRegion mockProxyBucketRegion = mock(ProxyBucketRegion.class); + BucketAdvisor mockBucketAdvisor = mock(BucketAdvisor.class); + + when(mockProxyBucketRegion.getBucketAdvisor()).thenReturn(mockBucketAdvisor); + + assertThat(mockProxyBucketRegion.getBucketAdvisor()).isSameAs(mockBucketAdvisor); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteFetchEntryMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteFetchEntryMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteFetchEntryMessageTest.java new file mode 100644 index 0000000..f02da45 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteFetchEntryMessageTest.java @@ -0,0 +1,43 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RemoteFetchEntryMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RemoteFetchEntryMessage mockRemoteFetchEntryMessage = mock(RemoteFetchEntryMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + LocalRegion mockLocalRegion = mock(LocalRegion.class); + long startTime = System.currentTimeMillis(); + + when(mockRemoteFetchEntryMessage.operateOnRegion(eq(mockDistributionManager), + eq(mockLocalRegion), eq(startTime))).thenReturn(true); + + assertThat(mockRemoteFetchEntryMessage.operateOnRegion(mockDistributionManager, mockLocalRegion, + startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RemotePutAllMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RemotePutAllMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RemotePutAllMessageTest.java new file mode 100644 index 0000000..29c5a78 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RemotePutAllMessageTest.java @@ -0,0 +1,39 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.DataInput; + +@Category(UnitTest.class) +public class RemotePutAllMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RemotePutAllMessage mockRemotePutAllMessage = mock(RemotePutAllMessage.class); + DataInput mockDataInput = mock(DataInput.class); + + mockRemotePutAllMessage.fromData(mockDataInput); + + verify(mockRemotePutAllMessage, times(1)).fromData(mockDataInput); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteRemoveAllMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteRemoveAllMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteRemoveAllMessageTest.java new file mode 100644 index 0000000..1205c9a --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RemoteRemoveAllMessageTest.java @@ -0,0 +1,39 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.DataInput; + +@Category(UnitTest.class) +public class RemoteRemoveAllMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RemoteRemoveAllMessage mockRemoteRemoveAllMessage = mock(RemoteRemoveAllMessage.class); + DataInput mockDataInput = mock(DataInput.class); + + mockRemoteRemoveAllMessage.fromData(mockDataInput); + + verify(mockRemoteRemoveAllMessage, times(1)).fromData(mockDataInput); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java new file mode 100644 index 0000000..96c312f --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.InitialImageOperation.RequestFilterInfoMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RequestFilterInfoMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RequestFilterInfoMessage mockRequestFilterInfoMessage = mock(RequestFilterInfoMessage.class); + when(mockRequestFilterInfoMessage.getProcessorType()).thenReturn(1); + assertThat(mockRequestFilterInfoMessage.getProcessorType()).isEqualTo(1); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RequestImageMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RequestImageMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestImageMessageTest.java new file mode 100644 index 0000000..11f633a --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestImageMessageTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.InitialImageOperation.RequestImageMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RequestImageMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RequestImageMessage mockRequestImageMessage = mock(RequestImageMessage.class); + when(mockRequestImageMessage.getProcessorType()).thenReturn(1); + assertThat(mockRequestImageMessage.getProcessorType()).isEqualTo(1); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/RequestRVVMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RequestRVVMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestRVVMessageTest.java new file mode 100644 index 0000000..8355e5c --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestRVVMessageTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.InitialImageOperation.RequestRVVMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RequestRVVMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RequestRVVMessage mockRequestRVVMessage = mock(RequestRVVMessage.class); + when(mockRequestRVVMessage.getProcessorType()).thenReturn(1); + assertThat(mockRequestRVVMessage.getProcessorType()).isEqualTo(1); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/StateMarkerMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/StateMarkerMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/StateMarkerMessageTest.java new file mode 100644 index 0000000..761064f --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/StateMarkerMessageTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.StateFlushOperation.StateMarkerMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class StateMarkerMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + StateMarkerMessage mockStateMarkerMessage = mock(StateMarkerMessage.class); + when(mockStateMarkerMessage.getProcessorType()).thenReturn(1); + assertThat(mockStateMarkerMessage.getProcessorType()).isEqualTo(1); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/TXEventTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/TXEventTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/TXEventTest.java new file mode 100644 index 0000000..052d174 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/TXEventTest.java @@ -0,0 +1,36 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.cache.Cache; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class TXEventTest { + + @Test + public void shouldBeMockable() throws Exception { + TXEvent mockTXEvent = mock(TXEvent.class); + Cache mockCache = mock(Cache.class); + when(mockTXEvent.getCache()).thenReturn(mockCache); + assertThat(mockTXEvent.getCache()).isSameAs(mockCache); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/TXMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/TXMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/TXMessageTest.java new file mode 100644 index 0000000..76c1e79 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/TXMessageTest.java @@ -0,0 +1,36 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class TXMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + TXMessage mockTXMessage = mock(TXMessage.class); + InternalDistributedMember mockInternalDistributedMember = mock(InternalDistributedMember.class); + when(mockTXMessage.getMemberToMasqueradeAs()).thenReturn(mockInternalDistributedMember); + assertThat(mockTXMessage.getMemberToMasqueradeAs()).isSameAs(mockInternalDistributedMember); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/TXStateStubTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/TXStateStubTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/TXStateStubTest.java new file mode 100644 index 0000000..6c5a349 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/TXStateStubTest.java @@ -0,0 +1,38 @@ +/* + * 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 org.apache.geode.internal.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.tx.TXRegionStub; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class TXStateStubTest { + + @Test + public void shouldBeMockable() throws Exception { + TXStateStub mockTXStateStub = mock(TXStateStub.class); + TXRegionStub mockTXRegionStub = mock(TXRegionStub.class); + LocalRegion mockLocalRegion = mock(LocalRegion.class); + when(mockTXStateStub.getTXRegionStub(eq(mockLocalRegion))).thenReturn(mockTXRegionStub); + assertThat(mockTXStateStub.getTXRegionStub(mockLocalRegion)).isSameAs(mockTXRegionStub); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/UnzipUtil.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/UnzipUtil.java b/geode-core/src/test/java/org/apache/geode/internal/cache/UnzipUtil.java index f6558c0..77f3867 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/UnzipUtil.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/UnzipUtil.java @@ -32,7 +32,7 @@ import java.util.zip.ZipInputStream; */ public class UnzipUtil { - public static final void unzip(InputStream input, String targetDir) throws IOException { + public static void unzip(InputStream input, String targetDir) throws IOException { File dir = new File(targetDir); if (!dir.exists() && !dir.mkdir()) { @@ -62,7 +62,7 @@ public class UnzipUtil { zipInput.close(); } - public static final void copyInputStream(InputStream in, OutputStream out) throws IOException { + public static void copyInputStream(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int len; http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/control/ResourceAdvisorTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/control/ResourceAdvisorTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/control/ResourceAdvisorTest.java new file mode 100644 index 0000000..324c121 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/control/ResourceAdvisorTest.java @@ -0,0 +1,37 @@ +/* + * 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 org.apache.geode.internal.cache.control; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class ResourceAdvisorTest { + + @Test + public void shouldBeMockable() throws Exception { + ResourceAdvisor mockResourceAdvisor = mock(ResourceAdvisor.class); + InternalDistributedMember mockInternalDistributedMember = mock(InternalDistributedMember.class); + when(mockResourceAdvisor.isHeapCritical(eq((mockInternalDistributedMember)))).thenReturn(true); + assertThat(mockResourceAdvisor.isHeapCritical(mockInternalDistributedMember)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/ha/ConflatableObject.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/ConflatableObject.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/ConflatableObject.java index 438d938..915cddf 100755 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/ConflatableObject.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/ConflatableObject.java @@ -121,70 +121,70 @@ public class ConflatableObject implements Conflatable, Serializable { /** * @return Returns the conflate. */ - final boolean isConflate() { + boolean isConflate() { return conflate; } /** * @param conflate The conflate to set. */ - final void setConflate(boolean conflate) { + void setConflate(boolean conflate) { this.conflate = conflate; } /** * @return Returns the id. */ - final EventID getId() { + EventID getId() { return id; } /** * @param id The id to set. */ - final void setId(EventID id) { + void setId(EventID id) { this.id = id; } /** * @return Returns the key. */ - final Object getKey() { + Object getKey() { return key; } /** * @param key The key to set. */ - final void setKey(Object key) { + void setKey(Object key) { this.key = key; } /** * @return Returns the regionname. */ - final String getRegionname() { + String getRegionname() { return regionname; } /** * @param regionname The regionname to set. */ - final void setRegionname(String regionname) { + void setRegionname(String regionname) { this.regionname = regionname; } /** * @return Returns the value. */ - final Object getValue() { + Object getValue() { return value; } /** * @param value The value to set. */ - final void setValue(Object value) { + void setValue(Object value) { this.value = value; } } http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/lru/LRUAlgorithmTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/lru/LRUAlgorithmTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/lru/LRUAlgorithmTest.java new file mode 100644 index 0000000..3341083 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/lru/LRUAlgorithmTest.java @@ -0,0 +1,34 @@ +/* + * 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 org.apache.geode.internal.cache.lru; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class LRUAlgorithmTest { + + @Test + public void shouldBeMockable() throws Exception { + LRUAlgorithm mockLRUAlgorithm = mock(LRUAlgorithm.class); + EnableLRU mockEnableLRU = mock(EnableLRU.class); + when(mockLRUAlgorithm.getLRUHelper()).thenReturn(mockEnableLRU); + assertThat(mockLRUAlgorithm.getLRUHelper()).isEqualTo(mockEnableLRU); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessageTest.java new file mode 100644 index 0000000..9dd1cd8 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessageTest.java @@ -0,0 +1,34 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class BucketBackupMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + BucketBackupMessage mockBucketBackupMessage = mock(BucketBackupMessage.class); + when(mockBucketBackupMessage.failIfRegionMissing()).thenReturn(true); + assertThat(mockBucketBackupMessage.failIfRegionMissing()).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/ColocatedRegionDetailsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/ColocatedRegionDetailsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/ColocatedRegionDetailsJUnitTest.java index b95e11a..c5fea71 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/ColocatedRegionDetailsJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/ColocatedRegionDetailsJUnitTest.java @@ -15,43 +15,26 @@ package org.apache.geode.internal.cache.partitioned; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutput; import java.io.DataOutputStream; -import java.io.IOException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import org.apache.geode.test.junit.categories.UnitTest; @Category(UnitTest.class) public class ColocatedRegionDetailsJUnitTest { - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception {} - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception {} - - /** - * Test method for - * {@link org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails#ColocatedRegionDetails(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}. - */ @Test - public final void testColocatedRegionDetailsConstructor() { + public void testColocatedRegionDetailsConstructor() { ColocatedRegionDetails crd = new ColocatedRegionDetails("host", "member name", "parent region", "child region"); assertNotNull(crd); @@ -61,12 +44,8 @@ public class ColocatedRegionDetailsJUnitTest { assertEquals("child region", crd.getChild()); } - /** - * Test method for - * {@link org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails#ColocatedRegionDetails()}. - */ @Test - public final void testColocatedRegion0ArgConstructor() { + public void testColocatedRegion0ArgConstructor() { ColocatedRegionDetails crd = new ColocatedRegionDetails(); assertNotNull(crd); assertNull(crd.getHost()); @@ -77,7 +56,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testContructingWithNulls() { + public void testConstructingWithNulls() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails(null, "member name", "parent region", "child region"); ColocatedRegionDetails crd2 = @@ -93,15 +72,8 @@ public class ColocatedRegionDetailsJUnitTest { assertNotNull(crd4); } - /** - * Test method for - * {@link org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails#toData(java.io.DataOutput)}. - * - * @throws IOException - * @throws ClassNotFoundException - */ @Test - public final void testSerialization() throws IOException, ClassNotFoundException { + public void testSerialization() throws Exception { ColocatedRegionDetails crd = new ColocatedRegionDetails("host", "member name", "parent region", "child region"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -114,8 +86,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testSerializationOfEmptyColocatedRegionDetails() - throws IOException, ClassNotFoundException { + public void testSerializationOfEmptyColocatedRegionDetails() throws Exception { ColocatedRegionDetails crd = new ColocatedRegionDetails(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutput out = new DataOutputStream(baos); @@ -127,7 +98,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testHostNotEquals() { + public void testHostNotEquals() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails(); ColocatedRegionDetails crd2 = new ColocatedRegionDetails("host1", "member name", "parent region", "child region"); @@ -139,7 +110,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testMemberNotEquals() { + public void testMemberNotEquals() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails("host", null, "parent region", "child region"); ColocatedRegionDetails crd2 = @@ -152,7 +123,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testParentNotEquals() { + public void testParentNotEquals() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails("host", "member1", null, "child region"); ColocatedRegionDetails crd2 = @@ -165,7 +136,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testChildNotEquals() { + public void testChildNotEquals() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails("host", "member1", "parent region", null); ColocatedRegionDetails crd2 = @@ -178,7 +149,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testClassInequality() { + public void testClassInequality() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails("host", "member1", "parent region", null); String crd2 = crd1.toString(); @@ -187,7 +158,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void nullColocatedRegionDetailsEqualsTests() { + public void nullColocatedRegionDetailsEqualsTests() { ColocatedRegionDetails crd1 = null; ColocatedRegionDetails crd2 = new ColocatedRegionDetails("host", "member1", "parent region", "child1"); @@ -198,7 +169,7 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testToString() { + public void testToString() { ColocatedRegionDetails crd = new ColocatedRegionDetails("host1", "member name", "parent region", "child region"); assertEquals("[host:host1, member:member name, parent:parent region, child:child region]", @@ -206,13 +177,13 @@ public class ColocatedRegionDetailsJUnitTest { } @Test - public final void testToStringOfEmptyColocatedRegionDetails() { + public void testToStringOfEmptyColocatedRegionDetails() { ColocatedRegionDetails crd = new ColocatedRegionDetails(); assertEquals("[,,,]", crd.toString()); } @Test - public final void testHashCode() { + public void testHashCode() { ColocatedRegionDetails crd1 = new ColocatedRegionDetails(); ColocatedRegionDetails crd2 = new ColocatedRegionDetails("host1", "member name", "parent region", "child region"); http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessageTest.java new file mode 100644 index 0000000..f1847f4 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessageTest.java @@ -0,0 +1,42 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class DeposePrimaryBucketMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + DeposePrimaryBucketMessage mockDeposePrimaryBucketMessage = + mock(DeposePrimaryBucketMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class); + long startTime = System.currentTimeMillis(); + when(mockDeposePrimaryBucketMessage.operateOnPartitionedRegion(eq(mockDistributionManager), + eq(mockPartitionedRegion), eq(startTime))).thenReturn(true); + assertThat(mockDeposePrimaryBucketMessage.operateOnPartitionedRegion(mockDistributionManager, + mockPartitionedRegion, startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessageTest.java new file mode 100644 index 0000000..4cf44e4 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessageTest.java @@ -0,0 +1,48 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class FetchEntryMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + FetchEntryMessage mockFetchEntryMessage = mock(FetchEntryMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class); + long startTime = System.currentTimeMillis(); + Object key = new Object(); + + when(mockFetchEntryMessage.operateOnPartitionedRegion(eq(mockDistributionManager), + eq(mockPartitionedRegion), eq(startTime))).thenReturn(true); + + mockFetchEntryMessage.setKey(key); + + verify(mockFetchEntryMessage, times(1)).setKey(key); + + assertThat(mockFetchEntryMessage.operateOnPartitionedRegion(mockDistributionManager, + mockPartitionedRegion, startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessageTest.java new file mode 100644 index 0000000..921017a --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessageTest.java @@ -0,0 +1,45 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class FetchPartitionDetailsMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + FetchPartitionDetailsMessage mockFetchPartitionDetailsMessage = + mock(FetchPartitionDetailsMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class); + long startTime = System.currentTimeMillis(); + Object key = new Object(); + + when(mockFetchPartitionDetailsMessage.operateOnPartitionedRegion(eq(mockDistributionManager), + eq(mockPartitionedRegion), eq(startTime))).thenReturn(true); + + assertThat(mockFetchPartitionDetailsMessage.operateOnPartitionedRegion(mockDistributionManager, + mockPartitionedRegion, startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessageTest.java new file mode 100644 index 0000000..2c37cc8 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessageTest.java @@ -0,0 +1,44 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class MoveBucketMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + MoveBucketMessage mockMoveBucketMessage = mock(MoveBucketMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class); + long startTime = System.currentTimeMillis(); + Object key = new Object(); + + when(mockMoveBucketMessage.operateOnPartitionedRegion(eq(mockDistributionManager), + eq(mockPartitionedRegion), eq(startTime))).thenReturn(true); + + assertThat(mockMoveBucketMessage.operateOnPartitionedRegion(mockDistributionManager, + mockPartitionedRegion, startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionMessageTest.java index b3bb02b..01099d3 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionMessageTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionMessageTest.java @@ -14,18 +14,17 @@ */ package org.apache.geode.internal.cache.partitioned; -import static org.mockito.Mockito.*; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.mockito.internal.stubbing.answers.CallsRealMethods; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import org.apache.geode.cache.CacheException; import org.apache.geode.cache.query.QueryException; import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; import org.apache.geode.internal.cache.DataLocationException; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.PartitionedRegion; @@ -34,7 +33,12 @@ import org.apache.geode.internal.cache.TXStateProxy; import org.apache.geode.internal.cache.TXStateProxyImpl; import org.apache.geode.test.fake.Fakes; import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.mockito.internal.stubbing.answers.CallsRealMethods; +import java.io.IOException; @Category(UnitTest.class) public class PartitionMessageTest { @@ -67,6 +71,17 @@ public class PartitionMessageTest { } @Test + public void shouldBeMockable() throws Exception { + PartitionMessage mockPartitionMessage = mock(PartitionMessage.class); + InternalDistributedMember mockInternalDistributedMember = mock(InternalDistributedMember.class); + + when(mockPartitionMessage.getMemberToMasqueradeAs()).thenReturn(mockInternalDistributedMember); + + assertThat(mockPartitionMessage.getMemberToMasqueradeAs()) + .isSameAs(mockInternalDistributedMember); + } + + @Test public void messageWithNoTXPerformsOnRegion() throws InterruptedException, CacheException, QueryException, DataLocationException, IOException { when(txMgr.masqueradeAs(msg)).thenReturn(null); http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java new file mode 100644 index 0000000..92b1d2d --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java @@ -0,0 +1,37 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RemoveAllPRMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RemoveAllPRMessage mockRemoveAllPRMessage = mock(RemoveAllPRMessage.class); + StringBuilder stringBuilder = new StringBuilder(); + + mockRemoveAllPRMessage.appendFields(stringBuilder); + + verify(mockRemoveAllPRMessage, times(1)).appendFields(stringBuilder); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessageTest.java new file mode 100644 index 0000000..3b18079 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessageTest.java @@ -0,0 +1,44 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class RemoveBucketMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + RemoveBucketMessage mockRemoveBucketMessage = mock(RemoveBucketMessage.class); + DistributionManager mockDistributionManager = mock(DistributionManager.class); + PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class); + long startTime = System.currentTimeMillis(); + Object key = new Object(); + + when(mockRemoveBucketMessage.operateOnPartitionedRegion(eq(mockDistributionManager), + eq(mockPartitionedRegion), eq(startTime))).thenReturn(true); + + assertThat(mockRemoveBucketMessage.operateOnPartitionedRegion(mockDistributionManager, + mockPartitionedRegion, startTime)).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/SizeMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/SizeMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/SizeMessageTest.java new file mode 100644 index 0000000..da3b94b --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/SizeMessageTest.java @@ -0,0 +1,33 @@ +/* + * 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 org.apache.geode.internal.cache.partitioned; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class SizeMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + SizeMessage mockSizeMessage = mock(SizeMessage.class); + when(mockSizeMessage.failIfRegionMissing()).thenReturn(true); + assertThat(mockSizeMessage.failIfRegionMissing()).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/CCUStatsTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/CCUStatsTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/CCUStatsTest.java new file mode 100644 index 0000000..e7d918d --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/CCUStatsTest.java @@ -0,0 +1,39 @@ +/* + * 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 org.apache.geode.internal.cache.tier.sockets; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.apache.geode.internal.cache.tier.sockets.CacheClientUpdater.CCUStats; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class CCUStatsTest { + + @Test + public void shouldBeMockable() throws Exception { + CCUStats mockCCUStats = mock(CCUStats.class); + + mockCCUStats.incReceivedBytes(1L); + mockCCUStats.incSentBytes(1L); + + verify(mockCCUStats, times(1)).incReceivedBytes(1L); + verify(mockCCUStats, times(1)).incSentBytes(1L); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/PartTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/PartTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/PartTest.java new file mode 100644 index 0000000..5720357 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/PartTest.java @@ -0,0 +1,41 @@ +/* + * 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 org.apache.geode.internal.cache.tier.sockets; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.OutputStream; +import java.nio.ByteBuffer; + +@Category(UnitTest.class) +public class PartTest { + + @Test + public void shouldBeMockable() throws Exception { + Part mockPart = mock(Part.class); + OutputStream mockOutputStream = mock(OutputStream.class); + ByteBuffer mockByteBuffer = mock(ByteBuffer.class); + + mockPart.writeTo(mockOutputStream, mockByteBuffer); + + verify(mockPart, times(1)).writeTo(mockOutputStream, mockByteBuffer); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionHolderJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionHolderJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionHolderJUnitTest.java index 0514e19..24b53f0 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionHolderJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionHolderJUnitTest.java @@ -49,7 +49,7 @@ public class RegionVersionHolderJUnitTest { RegionVersionHolder.BIT_SET_WIDTH = originalBitSetWidth; } - protected final InternalDistributedMember member() { + protected InternalDistributedMember member() { return member; } http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/versions/TombstoneDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/TombstoneDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/TombstoneDUnitTest.java index e178708..cb03cbe 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/TombstoneDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/TombstoneDUnitTest.java @@ -84,7 +84,7 @@ public class TombstoneDUnitTest extends JUnit4CacheTestCase { } } - private final void createRegion(String regionName, boolean persistent) { + private void createRegion(String regionName, boolean persistent) { if (persistent) { getCache().createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).create(regionName); } else { http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java index 5d4fd98..6fe7ee9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java @@ -1580,7 +1580,7 @@ public class AsyncEventQueueTestBase extends JUnit4DistributedTestCase { } @Override - public final Properties getDistributedSystemProperties() { + public Properties getDistributedSystemProperties() { // For now all WANTestBase tests allocate off-heap memory even though // many of them never use it. // The problem is that WANTestBase has static methods that create instances http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java index 049513b..b21ca90 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java @@ -118,7 +118,7 @@ public class AsyncEventQueueValidationsJUnitTest { .until(() -> filter.getAfterAcknowledgementInvocations() == numPuts); } - private final Object[] getCacheXmlFileBaseNames() { + private Object[] getCacheXmlFileBaseNames() { return $(new Object[] {"testSerialAsyncEventQueueConfiguredFromXmlUsesFilter"}, new Object[] {"testParallelAsyncEventQueueConfiguredFromXmlUsesFilter"}); } http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/DestroyMessageTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/DestroyMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/DestroyMessageTest.java new file mode 100644 index 0000000..2d52783 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/DestroyMessageTest.java @@ -0,0 +1,43 @@ +/* + * 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 org.apache.geode.internal.cache.wan.serial; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.internal.cache.DistributedRegion; +import org.apache.geode.internal.cache.InternalCacheEvent; +import org.apache.geode.internal.cache.wan.serial.BatchDestroyOperation.DestroyMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class DestroyMessageTest { + + @Test + public void shouldBeMockable() throws Exception { + DestroyMessage mockDestroyMessageX = mock(DestroyMessage.class); + InternalCacheEvent mockInternalCacheEvent = mock(InternalCacheEvent.class); + DistributedRegion mockDistributedRegion = mock(DistributedRegion.class); + + when(mockDestroyMessageX.createEvent(eq(mockDistributedRegion))) + .thenReturn(mockInternalCacheEvent); + + assertThat(mockDestroyMessageX.createEvent(mockDistributedRegion)) + .isSameAs(mockInternalCacheEvent); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreationTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreationTest.java new file mode 100644 index 0000000..f89622b --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreationTest.java @@ -0,0 +1,47 @@ +/* + * 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 org.apache.geode.internal.cache.xmlcache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.geode.cache.TransactionListener; +import org.apache.geode.cache.TransactionWriter; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class CacheTransactionManagerCreationTest { + + @Test + public void shouldBeMockable() throws Exception { + CacheTransactionManagerCreation mockCacheTransactionManagerCreation = + mock(CacheTransactionManagerCreation.class); + TransactionListener mockTransactionListener = mock(TransactionListener.class); + TransactionWriter mockTransactionWriter = mock(TransactionWriter.class); + + when(mockCacheTransactionManagerCreation.getListener()).thenReturn(mockTransactionListener); + + mockCacheTransactionManagerCreation.setWriter(mockTransactionWriter); + + verify(mockCacheTransactionManagerCreation, times(1)).setWriter(mockTransactionWriter); + + assertThat(mockCacheTransactionManagerCreation.getListener()).isSameAs(mockTransactionListener); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2Test.java new file mode 100644 index 0000000..8142949 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2Test.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.geode.internal.cache.xmlcache; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.xml.sax.InputSource; + +@Category(UnitTest.class) +public class DefaultEntityResolver2Test { + + @Test + public void shouldBeMockable() throws Exception { + DefaultEntityResolver2 mockDefaultEntityResolver2 = mock(DefaultEntityResolver2.class); + InputSource inputSource = new InputSource(); + + when(mockDefaultEntityResolver2.getClassPathInputSource(eq("publicId"), eq("systemId"), + eq("path"))).thenReturn(inputSource); + + assertThat(mockDefaultEntityResolver2.getClassPathInputSource("publicId", "systemId", "path")) + .isSameAs(inputSource); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/jta/functional/CacheJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/CacheJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/CacheJUnitTest.java index 66d72d8..67d12de 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/CacheJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/CacheJUnitTest.java @@ -1170,7 +1170,7 @@ public class CacheJUnitTest { this.tableName = str; } - public final Object load(LoaderHelper helper) throws CacheLoaderException { + public Object load(LoaderHelper helper) throws CacheLoaderException { System.out.println("In Loader.load for" + helper.getKey()); return loadFromDatabase(helper.getKey()); } http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java index 1585486..351c642 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java +++ b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java @@ -34,7 +34,7 @@ public class TestXACacheLoader implements CacheLoader { public static String tableName = ""; - public final Object load(LoaderHelper helper) throws CacheLoaderException { + public Object load(LoaderHelper helper) throws CacheLoaderException { System.out.println("In Loader.load for" + helper.getKey()); return loadFromDatabase(helper.getKey()); } http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/logging/LogServiceJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/LogServiceJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/LogServiceJUnitTest.java index 5c7ccaa..7238664 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/logging/LogServiceJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/logging/LogServiceJUnitTest.java @@ -101,7 +101,7 @@ public class LogServiceJUnitTest { } @SuppressWarnings("unused") - private static final Object[] getToLevelParameters() { + private static Object[] getToLevelParameters() { return $(new Object[] {0, Level.OFF}, new Object[] {100, Level.FATAL}, new Object[] {200, Level.ERROR}, new Object[] {300, Level.WARN}, new Object[] {400, Level.INFO}, new Object[] {500, Level.DEBUG}, http://git-wip-us.apache.org/repos/asf/geode/blob/97a6e1ae/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java index 5717253..faf1f6a 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java @@ -70,7 +70,7 @@ public class AlertAppenderJUnitTest { * Verify that adding/removing/replacing listeners works correctly. */ @Test - public final void testListenerHandling() throws Exception { + public void testListenerHandling() throws Exception { DistributedMember member1 = createTestDistributedMember("Member1"); DistributedMember member2 = createTestDistributedMember("Member2"); DistributedMember member3 = createTestDistributedMember("Member3"); @@ -146,7 +146,7 @@ public class AlertAppenderJUnitTest { * when the configuration is changed the appender is still there. */ @Test - public final void testAppenderToConfigHandling() throws Exception { + public void testAppenderToConfigHandling() throws Exception { LogService.setBaseLogLevel(Level.WARN); final String appenderName = AlertAppender.getInstance().getName();