Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3CC79200C78 for ; Thu, 18 May 2017 21:39:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3B294160BD6; Thu, 18 May 2017 19:39:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 13FB6160B9D for ; Thu, 18 May 2017 21:39:06 +0200 (CEST) Received: (qmail 81446 invoked by uid 500); 18 May 2017 19:39:06 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 81435 invoked by uid 99); 18 May 2017 19:39:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 May 2017 19:39:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2018ADFCBE; Thu, 18 May 2017 19:39:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.apache.org Date: Thu, 18 May 2017 19:39:06 -0000 Message-Id: <327361154d0147339318017cfe20c1d7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] geode git commit: GEODE-2929: remove superfluous final from methods [Forced Update!] archived-at: Thu, 18 May 2017 19:39:09 -0000 Repository: geode Updated Branches: refs/heads/feature/GEODE-2929-1 f28c415c8 -> 4d61b82e9 (forced update) http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogWriterAppenderJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogWriterAppenderJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogWriterAppenderJUnitTest.java index dbdebea..5a81b6e 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogWriterAppenderJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogWriterAppenderJUnitTest.java @@ -65,7 +65,7 @@ public class LogWriterAppenderJUnitTest { * when the configuration is changed the appender is still there. */ @Test - public final void testAppenderToConfigHandling() throws IOException { + public void testAppenderToConfigHandling() throws IOException { LogService.setBaseLogLevel(Level.TRACE); final AppenderContext rootContext = LogService.getAppenderContext(); @@ -110,7 +110,7 @@ public class LogWriterAppenderJUnitTest { * Verifies that writing to a Log4j logger will end up in the LogWriter's output. */ @Test - public final void testLogOutput() throws IOException { + public void testLogOutput() throws IOException { // Create the appender final StringWriter stringWriter = new StringWriter(); final PureLogWriter logWriter = @@ -178,7 +178,7 @@ public class LogWriterAppenderJUnitTest { * Verifies that logging occurs at the levels set in the LogWriter */ @Test - public final void testLogWriterLevels() throws IOException { + public void testLogWriterLevels() throws IOException { final String loggerName = LogService.MAIN_LOGGER_NAME; // this.getClass().getName(); LogService.getLogger(); // Force logging to be initialized http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWriterTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWriterTest.java b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWriterTest.java new file mode 100644 index 0000000..84dc959 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWriterTest.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.statistics; + +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 StatArchiveWriterTest { + + @Test + public void shouldBeMockable() throws Exception { + StatArchiveWriter mockStatArchiveWriter = mock(StatArchiveWriter.class); + + when(mockStatArchiveWriter.bytesWritten()).thenReturn(1L); + + mockStatArchiveWriter.close(); + + verify(mockStatArchiveWriter, times(1)).close(); + + assertThat(mockStatArchiveWriter.bytesWritten()).isEqualTo(1L); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java b/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java new file mode 100644 index 0000000..ca141b4 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.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.tcp; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.distributed.internal.DistributionMessage; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; + +@Category(UnitTest.class) +public class ConnectionTest { + + @Test + public void shouldBeMockable() throws Exception { + Connection mockConnection = mock(Connection.class); + SocketChannel channel = null; + ByteBuffer buffer = null; + boolean forceAsync = true; + DistributionMessage mockDistributionMessage = mock(DistributionMessage.class); + + mockConnection.nioWriteFully(channel, buffer, forceAsync, mockDistributionMessage); + + verify(mockConnection, times(1)).nioWriteFully(channel, buffer, forceAsync, + mockDistributionMessage); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaFromTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaFromTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaFromTest.java new file mode 100644 index 0000000..2c23ddc --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaFromTest.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.management.internal; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.management.internal.OpenTypeConverter.CompositeBuilderViaFrom; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import javax.management.openmbean.CompositeData; + +@Category(UnitTest.class) +public class CompositeBuilderViaFromTest { + + @Test + public void shouldBeMockable() throws Exception { + CompositeBuilderViaFrom mockCompositeBuilderViaFrom = mock(CompositeBuilderViaFrom.class); + CompositeData compositeData = null; + String[] itemNames = new String[1]; + OpenTypeConverter[] converters = new OpenTypeConverter[1]; + Object result = new Object(); + + when(mockCompositeBuilderViaFrom.fromCompositeData(eq(compositeData), eq(itemNames), + eq(converters))).thenReturn(result); + + assertThat(mockCompositeBuilderViaFrom.fromCompositeData(compositeData, itemNames, converters)) + .isSameAs(result); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaProxyTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaProxyTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaProxyTest.java new file mode 100644 index 0000000..8fea2b6 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/CompositeBuilderViaProxyTest.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.management.internal; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.management.internal.OpenTypeConverter.CompositeBuilderViaProxy; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import javax.management.openmbean.CompositeData; + +@Category(UnitTest.class) +public class CompositeBuilderViaProxyTest { + + @Test + public void shouldBeMockable() throws Exception { + CompositeBuilderViaProxy mockCompositeBuilderViaProxy = mock(CompositeBuilderViaProxy.class); + CompositeData compositeData = null; + String[] itemNames = new String[1]; + OpenTypeConverter[] converters = new OpenTypeConverter[1]; + Object result = new Object(); + + when(mockCompositeBuilderViaProxy.fromCompositeData(eq(compositeData), eq(itemNames), + eq(converters))).thenReturn(result); + + assertThat(mockCompositeBuilderViaProxy.fromCompositeData(compositeData, itemNames, converters)) + .isSameAs(result); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/IdentityConverterTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/IdentityConverterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/IdentityConverterTest.java new file mode 100644 index 0000000..2dea75b --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/IdentityConverterTest.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.management.internal; + +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 IdentityConverterTest { + + @Test + public void shouldBeMockable() throws Exception { + IdentityConverter mockIdentityConverter = mock(IdentityConverter.class); + Object value = new Object(); + Object result = new Object(); + + when(mockIdentityConverter.toNonNullOpenValue(value)).thenReturn(result); + assertThat(mockIdentityConverter.toNonNullOpenValue(value)).isSameAs(result); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java index f624ab4..b582e52 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java @@ -197,7 +197,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase { /** * Destroy all of the components created for the default setup. */ - protected final void destroyDefaultSetup() { + protected void destroyDefaultSetup() { if (this.shell != null) { executeCommand(shell, "exit"); this.shell.terminate(); @@ -276,7 +276,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase { * * @return The default shell */ - protected synchronized final HeadlessGfsh getDefaultShell() { + protected synchronized HeadlessGfsh getDefaultShell() { if (this.shell == null) { this.shell = createShell(); } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigCommandsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigCommandsDUnitTest.java index 760d2c4..edec00a 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigCommandsDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigCommandsDUnitTest.java @@ -554,7 +554,7 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase { }); } - private final void deleteTestFiles() throws IOException { + private void deleteTestFiles() throws IOException { this.managerConfigFile.delete(); this.managerPropsFile.delete(); this.vm1ConfigFile.delete(); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportedLogsSizeInfoTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportedLogsSizeInfoTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportedLogsSizeInfoTest.java index 77a2453..0bfbefa 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportedLogsSizeInfoTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportedLogsSizeInfoTest.java @@ -17,8 +17,6 @@ package org.apache.geode.management.internal.cli.functions; import static org.assertj.core.api.Assertions.*; import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -30,18 +28,9 @@ import java.io.DataOutputStream; @Category(UnitTest.class) public class ExportedLogsSizeInfoTest { - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } @Test - public final void testExportedLogsSizeInfoConstructor() { + public void testExportedLogsSizeInfoConstructor() { ExportedLogsSizeInfo sizeDetail = new ExportedLogsSizeInfo(1L, 11L, 111L); assertThat(sizeDetail).isNotNull(); assertThat(sizeDetail.getLogsSize()).isEqualTo(1L); @@ -50,7 +39,7 @@ public class ExportedLogsSizeInfoTest { } @Test - public final void testExportedLogsSizeInfoZeroArgConstructor() { + public void testExportedLogsSizeInfoZeroArgConstructor() { ExportedLogsSizeInfo sizeDetail = new ExportedLogsSizeInfo(); assertThat(sizeDetail).isNotNull(); assertThat(sizeDetail.getLogsSize()).isEqualTo(0L); @@ -99,7 +88,7 @@ public class ExportedLogsSizeInfoTest { } @Test - public final void testClassInequality() { + public void testClassInequality() { ExportedLogsSizeInfo sizeDeatai1 = new ExportedLogsSizeInfo(7L, 77L, 777L); String sizeDetail2 = sizeDeatai1.toString(); assertThat(sizeDeatai1.equals(sizeDetail2)).isFalse(); @@ -119,7 +108,6 @@ public class ExportedLogsSizeInfoTest { assertThat(sizeDetail1.hashCode()).isEqualTo(29791); assertThat(sizeDetail2.hashCode()).isEqualTo(41095); assertThat(sizeDetail3.hashCode()).isEqualTo(115495); - } @Test http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java index ba436c5..0bd0ee9 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.management.internal.cli.functions; import static org.junit.Assert.*; @@ -63,6 +62,7 @@ import org.apache.geode.test.junit.categories.UnitTest; @Category(UnitTest.class) public class ShowMissingDiskStoresFunctionJUnitTest { + private GemFireCacheImpl cache; private GemFireCacheImpl oldCacheInstance; private InternalDistributedSystem system; @@ -81,9 +81,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - /** - * @throws java.lang.Exception - */ @Before public void setUp() throws Exception { cache = Fakes.cache(); @@ -100,9 +97,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest { memberManager = mock(PersistentMemberManager.class); } - /** - * @throws java.lang.Exception - */ @After public void tearDown() throws Exception { GemFireCacheImpl.setInstanceForTests(oldCacheInstance); @@ -122,21 +116,14 @@ public class ShowMissingDiskStoresFunctionJUnitTest { } } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#getCache()}. - */ @Test - public final void testGetCache() { + public void testGetCache() { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); assertTrue(smdsFunc.getCache() instanceof Cache); } - /** - * Test method for {@link ShowMissingDiskStoresFunction#execute(FunctionContext)}. - */ @Test - public final void testExecute() { + public void testExecute() { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); List results = null; @@ -152,12 +139,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { assertNotNull(results); } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - */ @Test - public final void testExecuteWithNullContextThrowsRuntimeException() { + public void testExecuteWithNullContextThrowsRuntimeException() { expectedException.expect(RuntimeException.class); ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); @@ -170,7 +153,7 @@ public class ShowMissingDiskStoresFunctionJUnitTest { * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. */ @Test - public final void testExecuteWithNullCacheInstanceHasEmptyResults() throws Throwable { + public void testExecuteWithNullCacheInstanceHasEmptyResults() throws Throwable { TestSMDSFFunc1 testSMDSFunc = new TestSMDSFFunc1(); List results = null; @@ -181,12 +164,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { assertNull(results.get(0)); } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - */ @Test - public final void testExecuteWithNullGFCIResultValueIsNull() throws Throwable { + public void testExecuteWithNullGFCIResultValueIsNull() throws Throwable { TestSMDSFFunc2 testSMDSFunc = new TestSMDSFFunc2(); List results = null; @@ -200,12 +179,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { assertNull(results.get(0)); } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - */ @Test - public final void testExecuteWhenGFCIClosedResultValueIsNull() throws Throwable { + public void testExecuteWhenGFCIClosedResultValueIsNull() throws Throwable { TestSMDSFFunc2 testSMDSFunc = new TestSMDSFFunc2(); List results = null; @@ -216,14 +191,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { assertNotNull(results); } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - * - * @throws UnknownHostException - */ @Test - public final void testExecuteReturnsMissingDiskStores() throws Throwable { + public void testExecuteReturnsMissingDiskStores() throws Throwable { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); List results = null; @@ -261,12 +230,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { } } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - */ @Test - public final void testExecuteReturnsMissingColocatedRegions() throws Throwable { + public void testExecuteReturnsMissingColocatedRegions() throws Throwable { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); List results = null; @@ -300,14 +265,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { } } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - * - * @throws UnknownHostException - */ @Test - public final void testExecuteReturnsMissingStoresAndRegions() throws Throwable { + public void testExecuteReturnsMissingStoresAndRegions() throws Throwable { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); List results = null; @@ -372,14 +331,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { } } - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#execute(org.apache.geode.cache.execute.FunctionContext)}. - * - * @throws Throwable - */ @Test - public final void testExecuteCatchesExceptions() throws Throwable { + public void testExecuteCatchesExceptions() throws Exception { expectedException.expect(RuntimeException.class); ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); @@ -391,13 +344,8 @@ public class ShowMissingDiskStoresFunctionJUnitTest { fail("Failed to catch expected RuntimeException"); } - - /** - * Test method for - * {@link org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction#getId()}. - */ @Test - public final void testGetId() { + public void testGetId() { ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction(); assertEquals(ShowMissingDiskStoresFunction.class.getName(), smdsFunc.getId()); } @@ -406,9 +354,9 @@ public class ShowMissingDiskStoresFunctionJUnitTest { private final List results = new LinkedList(); - private Throwable t; + private Exception t; - protected List getResults() throws Throwable { + protected List getResults() throws Exception { if (t != null) { throw t; } @@ -427,7 +375,7 @@ public class ShowMissingDiskStoresFunctionJUnitTest { @Override public void sendException(final Throwable t) { - this.t = t; + this.t = (Exception) t; } } } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/cli/json/TypedJsonTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/json/TypedJsonTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/json/TypedJsonTest.java new file mode 100644 index 0000000..c894594 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/json/TypedJsonTest.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.management.internal.cli.json; + +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.Writer; + +@Category(UnitTest.class) +public class TypedJsonTest { + + @Test + public void shouldBeMockable() throws Exception { + TypedJson mockTypedJson = mock(TypedJson.class); + Writer writer = null; + Object value = new Object(); + + mockTypedJson.writeVal(writer, value); + + verify(mockTypedJson, times(1)).writeVal(writer, value); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/web/controllers/WanCommandsControllerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/web/controllers/WanCommandsControllerJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/web/controllers/WanCommandsControllerJUnitTest.java index 2731b95..8ee3e0f 100755 --- a/geode-core/src/test/java/org/apache/geode/management/internal/web/controllers/WanCommandsControllerJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/web/controllers/WanCommandsControllerJUnitTest.java @@ -117,7 +117,7 @@ public class WanCommandsControllerJUnitTest { .contains("--" + START_GATEWAYSENDER__ID + "=" + ""); } - private static final Object[] getParametersWithGroupsAndMembers() { + private static Object[] getParametersWithGroupsAndMembers() { return $(new Object[] {"sender1", new String[] {}, new String[] {}, false, false}, new Object[] {"sender2", new String[] {"group1"}, new String[] {}, true, false}, new Object[] {"sender3", new String[] {"group1", "group2"}, new String[] {}, true, false}, http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/web/domain/LinkTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/web/domain/LinkTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/web/domain/LinkTest.java new file mode 100644 index 0000000..ff98b7e --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/web/domain/LinkTest.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.management.internal.web.domain; + +import static org.mockito.Mockito.*; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.net.URI; + +import org.apache.geode.management.internal.web.http.HttpMethod; + +@Category(UnitTest.class) +public class LinkTest { + + @Test + public void shouldBeMockable() throws Exception { + Link mockLink = mock(Link.class); + URI href = null; + HttpMethod method = HttpMethod.CONNECT; + String relation = ""; + + mockLink.setHref(href); + mockLink.setMethod(method); + mockLink.setRelation(relation); + + verify(mockLink, times(1)).setHref(href); + verify(mockLink, times(1)).setMethod(method); + verify(mockLink, times(1)).setRelation(relation); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/management/internal/web/http/ClientHttpRequestTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/web/http/ClientHttpRequestTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/web/http/ClientHttpRequestTest.java new file mode 100644 index 0000000..4a5a0d4 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/web/http/ClientHttpRequestTest.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.management.internal.web.http; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import org.apache.geode.management.internal.web.domain.Link; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class ClientHttpRequestTest { + + @Test + public void shouldBeMockable() throws Exception { + ClientHttpRequest mockClientHttpRequest = mock(ClientHttpRequest.class); + Link mockLink = mock(Link.class); + + when(mockClientHttpRequest.getLink()).thenReturn(mockLink); + + assertThat(mockClientHttpRequest.getLink()).isSameAs(mockLink); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/pdx/PdxSerializableDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/pdx/PdxSerializableDUnitTest.java b/geode-core/src/test/java/org/apache/geode/pdx/PdxSerializableDUnitTest.java index 4e8a271..497f428 100644 --- a/geode-core/src/test/java/org/apache/geode/pdx/PdxSerializableDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/pdx/PdxSerializableDUnitTest.java @@ -433,7 +433,7 @@ public class PdxSerializableDUnitTest extends JUnit4CacheTestCase { * add a listener and writer that will throw an exception when invoked if events are for internal * regions */ - public final void addPoisonedTransactionListeners() { + public void addPoisonedTransactionListeners() { MyTestTransactionListener listener = new MyTestTransactionListener(); getCache().getCacheTransactionManager().addListener(listener); getCache().getCacheTransactionManager().setWriter(listener); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/redis/internal/executor/AbstractScanExecutorTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/redis/internal/executor/AbstractScanExecutorTest.java b/geode-core/src/test/java/org/apache/geode/redis/internal/executor/AbstractScanExecutorTest.java new file mode 100644 index 0000000..2644741 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/redis/internal/executor/AbstractScanExecutorTest.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.redis.internal.executor; + +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 java.util.regex.Pattern; + +@Category(UnitTest.class) +public class AbstractScanExecutorTest { + + @Test + public void shouldBeMockable() throws Exception { + AbstractScanExecutor mockAbstractScanExecutor = mock(AbstractScanExecutor.class); + Pattern pattern = Pattern.compile("."); + + when(mockAbstractScanExecutor.convertGlobToRegex(eq("pattern"))).thenReturn(pattern); + + assertThat(mockAbstractScanExecutor.convertGlobToRegex("pattern")).isSameAs(pattern); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java index 244f4e5..9d3f721 100644 --- a/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java +++ b/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java @@ -102,7 +102,7 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC postSetUpClientAuthorizationTestBase(); } - private final void setUpClientAuthorizationTestBase() throws Exception { + private void setUpClientAuthorizationTestBase() throws Exception { server1 = getHost(0).getVM(0); server2 = getHost(0).getVM(1); client1 = getHost(0).getVM(2); @@ -110,7 +110,7 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC setUpIgnoredExceptions(); } - private final void setUpIgnoredExceptions() { + private void setUpIgnoredExceptions() { Set serverExceptions = new HashSet<>(); serverExceptions.addAll(Arrays.asList(serverIgnoredExceptions())); if (serverExceptions.isEmpty()) { http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/security/DeltaClientAuthorizationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/security/DeltaClientAuthorizationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/DeltaClientAuthorizationDUnitTest.java index 9a3ce86..1b09a83 100644 --- a/geode-core/src/test/java/org/apache/geode/security/DeltaClientAuthorizationDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/security/DeltaClientAuthorizationDUnitTest.java @@ -155,7 +155,7 @@ public class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestCa } } - private final void setUpDeltas() { + private void setUpDeltas() { for (int i = 0; i < 8; i++) { deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0)); } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/security/DeltaClientPostAuthorizationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/DeltaClientPostAuthorizationDUnitTest.java index 4cc8442..dc4ffac 100644 --- a/geode-core/src/test/java/org/apache/geode/security/DeltaClientPostAuthorizationDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/security/DeltaClientPostAuthorizationDUnitTest.java @@ -130,7 +130,7 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe } @Override - protected final void executeOpBlock(final List opBlock, final int port1, + protected void executeOpBlock(final List opBlock, final int port1, final int port2, final String authInit, final Properties extraAuthProps, final Properties extraAuthzProps, final TestCredentialGenerator credentialGenerator, final Random random) throws InterruptedException { http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/security/generator/AuthzCredentialGenerator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/security/generator/AuthzCredentialGenerator.java b/geode-core/src/test/java/org/apache/geode/security/generator/AuthzCredentialGenerator.java index 13d68b5..3a61bfc 100755 --- a/geode-core/src/test/java/org/apache/geode/security/generator/AuthzCredentialGenerator.java +++ b/geode-core/src/test/java/org/apache/geode/security/generator/AuthzCredentialGenerator.java @@ -373,7 +373,7 @@ public abstract class AuthzCredentialGenerator { * @return the name of this class code. */ @Override - public final String toString() { + public String toString() { return this.name; } @@ -383,7 +383,7 @@ public abstract class AuthzCredentialGenerator { * @return true if other object is same as this one. */ @Override - public final boolean equals(final Object obj) { + public boolean equals(final Object obj) { if (obj == this) { return true; } @@ -399,7 +399,7 @@ public abstract class AuthzCredentialGenerator { * * @return true if other {@code ClassCode} is same as this one. */ - public final boolean equals(final ClassCode opCode) { + public boolean equals(final ClassCode opCode) { return opCode != null && opCode.ordinal == this.ordinal; } @@ -409,7 +409,7 @@ public abstract class AuthzCredentialGenerator { * @return the ordinal of this {@code ClassCode}. */ @Override - public final int hashCode() { + public int hashCode() { return this.ordinal; } } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/security/generator/CredentialGenerator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/security/generator/CredentialGenerator.java b/geode-core/src/test/java/org/apache/geode/security/generator/CredentialGenerator.java index 8695451..0ab4252 100755 --- a/geode-core/src/test/java/org/apache/geode/security/generator/CredentialGenerator.java +++ b/geode-core/src/test/java/org/apache/geode/security/generator/CredentialGenerator.java @@ -283,7 +283,7 @@ public abstract class CredentialGenerator { * @return the name of this operation. */ @Override - public final String toString() { + public String toString() { return this.name; } @@ -293,7 +293,7 @@ public abstract class CredentialGenerator { * @return true if other object is same as this one. */ @Override - public final boolean equals(final Object obj) { + public boolean equals(final Object obj) { if (obj == this) { return true; } @@ -309,7 +309,7 @@ public abstract class CredentialGenerator { * * @return true if other {@code ClassCode} is same as this one. */ - public final boolean equals(final ClassCode opCode) { + public boolean equals(final ClassCode opCode) { return opCode != null && opCode.ordinal == this.ordinal; } @@ -319,7 +319,7 @@ public abstract class CredentialGenerator { * @return the ordinal of this operation. */ @Override - public final int hashCode() { + public int hashCode() { return this.ordinal; } } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/dunit/DUnitEnv.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/DUnitEnv.java b/geode-core/src/test/java/org/apache/geode/test/dunit/DUnitEnv.java index 42ccf38..45fb919 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/DUnitEnv.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/DUnitEnv.java @@ -35,7 +35,7 @@ public abstract class DUnitEnv { public static DUnitEnv instance = null; - public static final DUnitEnv get() { + public static DUnitEnv get() { if (instance == null) { try { // for tests that are still being migrated to the open-source http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java index 5b8e615..72b8190 100755 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java @@ -122,7 +122,7 @@ public class DistributedTestUtils { } } - public final static Properties getAllDistributedSystemProperties(final Properties properties) { + public static Properties getAllDistributedSystemProperties(final Properties properties) { Properties dsProperties = DUnitEnv.get().getDistributedSystemProperties(); // our tests do not expect auto-reconnect to be on by default http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/dunit/Wait.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/Wait.java b/geode-core/src/test/java/org/apache/geode/test/dunit/Wait.java index 20fbb5b..a2ff978 100755 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/Wait.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/Wait.java @@ -135,7 +135,7 @@ public class Wait { * * @deprecated Please use {@link org.awaitility.Awaitility} instead. */ - public static final void pause(final int milliseconds) { + public static void pause(final int milliseconds) { if (milliseconds >= 1000 || logger.isDebugEnabled()) { // check for debug but log at info logger.info("Pausing for {} ms...", milliseconds); } @@ -211,7 +211,7 @@ public class Wait { * @return the last time stamp observed * @deprecated Please use {@link org.awaitility.Awaitility} instead. */ - public static final long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource) { + public static long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource) { return waitForExpiryClockToChange(cacheTimeMillisSource, cacheTimeMillisSource.cacheTimeMillis()); } @@ -224,7 +224,7 @@ public class Wait { * @return the last time stamp observed * @deprecated Please use {@link org.awaitility.Awaitility} instead. */ - public static final long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource, + public static long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource, final long baseTime) { long nowTime; do { http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java index 1d67dcd..4c7d7f2 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java @@ -44,7 +44,7 @@ public class OverridingGetPropertiesDisconnectsAllDUnitTest extends JUnit4Distri } @Override - public final Properties getDistributedSystemProperties() { + public Properties getDistributedSystemProperties() { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); return props; http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/golden/FailOutputTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/golden/FailOutputTestCase.java b/geode-core/src/test/java/org/apache/geode/test/golden/FailOutputTestCase.java index 71040ef..ceb1586 100755 --- a/geode-core/src/test/java/org/apache/geode/test/golden/FailOutputTestCase.java +++ b/geode-core/src/test/java/org/apache/geode/test/golden/FailOutputTestCase.java @@ -20,7 +20,6 @@ import java.io.InputStreamReader; /** * Abstract test case for tests verifying that unexpected test output will cause expected failures. - * */ public abstract class FailOutputTestCase extends GoldenTestCase implements ExecutableProcess { @@ -38,7 +37,7 @@ public abstract class FailOutputTestCase extends GoldenTestCase implements Execu abstract void outputProblemInProcess(String message); @Override - public final void executeInProcess() throws IOException { + public void executeInProcess() throws IOException { outputLine("Begin " + name() + ".main"); outputLine("Press Enter to continue."); new BufferedReader(new InputStreamReader(System.in)).readLine(); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/golden/PassJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/golden/PassJUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/golden/PassJUnitTest.java index 2e9b8f9..e3374f4 100755 --- a/geode-core/src/test/java/org/apache/geode/test/golden/PassJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/test/golden/PassJUnitTest.java @@ -68,7 +68,7 @@ public class PassJUnitTest extends GoldenTestCase implements ExecutableProcess { } @Override - public final void executeInProcess() throws IOException { + public void executeInProcess() throws IOException { outputLine("Begin " + name() + ".main"); outputLine("Press Enter to continue."); new BufferedReader(new InputStreamReader(System.in)).readLine(); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-core/src/test/java/org/apache/geode/test/golden/PassWithExpectedProblemTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/golden/PassWithExpectedProblemTestCase.java b/geode-core/src/test/java/org/apache/geode/test/golden/PassWithExpectedProblemTestCase.java index 2d60c27..e88a11d 100755 --- a/geode-core/src/test/java/org/apache/geode/test/golden/PassWithExpectedProblemTestCase.java +++ b/geode-core/src/test/java/org/apache/geode/test/golden/PassWithExpectedProblemTestCase.java @@ -74,7 +74,7 @@ public abstract class PassWithExpectedProblemTestCase extends GoldenTestCase } @Override - public final void executeInProcess() throws IOException { + public void executeInProcess() throws IOException { outputLine("Begin " + name() + ".main"); outputLine("Press Enter to continue."); new BufferedReader(new InputStreamReader(System.in)).readLine(); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-cq/src/test/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java index e979f72..5e8bdac 100755 --- a/geode-cq/src/test/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java +++ b/geode-cq/src/test/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java @@ -225,7 +225,7 @@ public class CQListGIIDUnitTest extends JUnit4DistributedTestCase { return Integer.valueOf(server1.getPort()); } - public static final Region createRegion(String name, String rootName, RegionAttributes attrs) + public static Region createRegion(String name, String rootName, RegionAttributes attrs) throws CacheException { Region root = cache.getRegion(rootName); if (root == null) { http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java index b80f5de..aa1b084 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java @@ -66,7 +66,7 @@ public abstract class LuceneDUnitTest extends JUnit4CacheTestCase { RegionTestableType.PARTITION_PERSISTENT, RegionTestableType.FIXED_PARTITION}; } - protected final Object[] parameterCombiner(Object[] aValues, Object[] bValues) { + protected Object[] parameterCombiner(Object[] aValues, Object[] bValues) { Object[] parameters = new Object[aValues.length * bValues.length]; for (int i = 0; i < aValues.length; i++) { for (int j = 0; j < bValues.length; j++) { http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java index a16646e..b83ca44 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java @@ -41,13 +41,13 @@ import static org.junit.Assert.*; @RunWith(JUnitParamsRunner.class) public class LuceneIndexCreationDUnitTest extends LuceneDUnitTest { - private final Object[] parametersForMultipleIndexCreates() { + private Object[] parametersForMultipleIndexCreates() { Integer[] numIndexes = {1, 2, 10}; RegionTestableType[] regionTestTypes = getListOfRegionTestTypes(); return parameterCombiner(numIndexes, regionTestTypes); } - protected final Object[] parametersForIndexAndRegions() { + protected Object[] parametersForIndexAndRegions() { Object[] indexCreations = new Object[] {getFieldsIndexWithOneField(), getFieldsIndexWithTwoFields(), get2FieldsIndexes(), getAnalyzersIndexWithOneField(), getAnalyzersIndexWithTwoFields(), getAnalyzersIndexWithNullField1()}; @@ -282,9 +282,7 @@ public class LuceneIndexCreationDUnitTest extends LuceneDUnitTest { dataStore2.invoke(() -> verifyIndexList(0)); } - - - protected final Object[] getXmlAndExceptionMessages() { + protected Object[] getXmlAndExceptionMessages() { return $( new Object[] {"verifyDifferentFieldsFails", CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS}, new Object[] {"verifyDifferentFieldAnalyzerSizesFails1", http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java index bed6f13..a8ab8d3 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java @@ -224,8 +224,7 @@ public class LuceneIndexCreationPersistenceIntegrationTest extends LuceneIntegra LuceneTestUtilities.verifyInternalRegions(luceneService, cache, verify); } - - private static final Object[] getRegionShortcuts() { + private static Object[] getRegionShortcuts() { return $(new Object[] {PARTITION}, new Object[] {PARTITION_REDUNDANT}, new Object[] {PARTITION_PERSISTENT}, new Object[] {PARTITION_REDUNDANT_PERSISTENT}, new Object[] {PARTITION_OVERFLOW}, new Object[] {PARTITION_REDUNDANT_OVERFLOW}, http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java index 67adfb9..a6252c8 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java @@ -73,7 +73,7 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest { accessor = Host.getHost(0).getVM(3); } - private final Object[] parametersForIndexDestroys() { + private Object[] parametersForIndexDestroys() { String[] destroyDataRegionParameters = {"true", "false"}; RegionTestableType[] regionTestTypes = getListOfRegionTestTypes(); return parameterCombiner(destroyDataRegionParameters, regionTestTypes); http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java index 4d72639..b378ca5 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java @@ -50,7 +50,7 @@ public class LuceneIndexCreationProfileJUnitTest { assertEquals(profile.getFieldAnalyzers(), copy.getFieldAnalyzers()); } - private final Object[] getSerializationProfiles() { + private Object[] getSerializationProfiles() { return $(new Object[] {getOneFieldLuceneIndexCreationProfile()}, new Object[] {getTwoFieldLuceneIndexCreationProfile()}, new Object[] {getTwoAnalyzersLuceneIndexCreationProfile()}, @@ -64,7 +64,7 @@ public class LuceneIndexCreationProfileJUnitTest { assertEquals(expectedResult, otherProfile.checkCompatibility("/" + REGION_NAME, myProfile)); } - private final Object[] getCheckCompatibilityProfiles() { + private Object[] getCheckCompatibilityProfiles() { return $( new Object[] {getOneFieldLuceneIndexCreationProfile(), getTwoFieldLuceneIndexCreationProfile(), CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS}, http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-old-client-support/src/main/java/com/gemstone/gemfire/cache/execute/FunctionException.java ---------------------------------------------------------------------- diff --git a/geode-old-client-support/src/main/java/com/gemstone/gemfire/cache/execute/FunctionException.java b/geode-old-client-support/src/main/java/com/gemstone/gemfire/cache/execute/FunctionException.java index d19d900..de8825b 100644 --- a/geode-old-client-support/src/main/java/com/gemstone/gemfire/cache/execute/FunctionException.java +++ b/geode-old-client-support/src/main/java/com/gemstone/gemfire/cache/execute/FunctionException.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package com.gemstone.gemfire.cache.execute; import java.util.ArrayList; @@ -36,12 +35,9 @@ import org.apache.geode.cache.execute.FunctionService; * This allows for separation of business and error handling logic, as client code that processes * function execution results does not have to deal with errors; errors can be dealt with in the * exception handling logic, by catching this exception. - * *

* The exception string provides details on the cause of failure. - *

- * - * + * * @since GemFire 6.0 * @see FunctionService * @deprecated please use the org.apache.geode version of this class @@ -96,7 +92,7 @@ public class FunctionException extends GemFireException { * @param cause * @since GemFire 6.5 */ - public final void addException(Throwable cause) { + public void addException(Throwable cause) { Assert.assertTrue(cause != null, "unexpected null exception to add to FunctionException"); getExceptions().add(cause); } @@ -106,7 +102,7 @@ public class FunctionException extends GemFireException { * * @since GemFire 6.5 */ - public final List getExceptions() { + public List getExceptions() { if (this.exceptions == null) { this.exceptions = new ArrayList(); } @@ -118,7 +114,7 @@ public class FunctionException extends GemFireException { * * @since GemFire 6.5 */ - public final void addExceptions(Collection ex) { + public void addExceptions(Collection ex) { getExceptions().addAll(ex); } } http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-old-client-support/src/test/java/com/gemstone/gemfire/cache/execute/FunctionExceptionTest.java ---------------------------------------------------------------------- diff --git a/geode-old-client-support/src/test/java/com/gemstone/gemfire/cache/execute/FunctionExceptionTest.java b/geode-old-client-support/src/test/java/com/gemstone/gemfire/cache/execute/FunctionExceptionTest.java new file mode 100644 index 0000000..5104466 --- /dev/null +++ b/geode-old-client-support/src/test/java/com/gemstone/gemfire/cache/execute/FunctionExceptionTest.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 com.gemstone.gemfire.cache.execute; + +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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +@Category(UnitTest.class) +public class FunctionExceptionTest { + + @Test + public void shouldBeMockable() throws Exception { + FunctionException mockFunctionException = mock(FunctionException.class); + Throwable cause = new Exception("message"); + List listOfThrowables = new ArrayList<>(); + Collection collectionOfThrowables = new ArrayList<>(); + + when(mockFunctionException.getExceptions()).thenReturn(listOfThrowables); + + mockFunctionException.addException(cause); + mockFunctionException.addExceptions(collectionOfThrowables); + + verify(mockFunctionException, times(1)).addException(cause); + verify(mockFunctionException, times(1)).addExceptions(collectionOfThrowables); + + assertThat(mockFunctionException.getExceptions()).isSameAs(listOfThrowables); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java ---------------------------------------------------------------------- diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java index f101027..8aa88b2 100644 --- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java +++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java @@ -3768,7 +3768,7 @@ public class WANTestBase 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/4d61b82e/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/RegionData.java ---------------------------------------------------------------------- diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/RegionData.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/RegionData.java index ea9237e..03dc0ad 100644 --- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/RegionData.java +++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/RegionData.java @@ -15,45 +15,31 @@ package org.apache.geode.rest.internal.web.controllers.support; -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializable; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; -import org.apache.geode.cache.query.Struct; -import org.apache.geode.cache.query.internal.StructImpl; import org.apache.geode.pdx.JSONFormatter; import org.apache.geode.pdx.PdxInstance; -import org.apache.geode.rest.internal.web.util.JSONUtils; import org.apache.geode.rest.internal.web.util.JsonWriter; - import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + /** * The RegionData class is a container for data fetched from a GemFire Cache Region. - *

- * + * * @see com.fasterxml.jackson.databind.JsonSerializable * @see java.lang.Iterable * @since GemFire 8.0 */ - @SuppressWarnings("unused") @XmlRootElement(name = "region") @XmlType(name = "org.gopivotal.app.web.controllers.support.RegionData") @@ -75,18 +61,13 @@ public class RegionData implements Iterable, JsonSerializable { return regionNamePath; } - public final void setRegionNamePath(final String regionNamePath) { + public void setRegionNamePath(final String regionNamePath) { Assert.hasText(regionNamePath, "The name or path of the Region must be specified!"); this.regionNamePath = regionNamePath; } public RegionData add(final T data) { - // We are adding null data into the response - // Assert.notNull(data, String.format("The data to add to Region (%1$s) cannot be null!", - // getRegionNamePath())); - // if(data != null) { this.data.add(data); - // } return this; } @@ -102,10 +83,6 @@ public class RegionData implements Iterable, JsonSerializable { public RegionData add(final Iterable data) { for (final T element : data) { - // Adding null data into the response - /* - * if (element != null) { add(element); } - */ add(element); } @@ -139,19 +116,15 @@ public class RegionData implements Iterable, JsonSerializable { public void serialize(final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { - // if(this!=null && this.size() > 1) { jsonGenerator.writeStartObject(); jsonGenerator.writeArrayFieldStart(getRegionNamePath()); - // } for (T element : this) { JsonWriter.writeValueAsJson(jsonGenerator, element, null); } - // if(this!=null && this.size() > 1) { jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); - // } } public void serializeWithType(final JsonGenerator jsonGenerator, http://git-wip-us.apache.org/repos/asf/geode/blob/4d61b82e/geode-web-api/src/test/java/org/apache/geode/rest/internal/web/controllers/support/RegionDataTest.java ---------------------------------------------------------------------- diff --git a/geode-web-api/src/test/java/org/apache/geode/rest/internal/web/controllers/support/RegionDataTest.java b/geode-web-api/src/test/java/org/apache/geode/rest/internal/web/controllers/support/RegionDataTest.java new file mode 100644 index 0000000..5f32d13 --- /dev/null +++ b/geode-web-api/src/test/java/org/apache/geode/rest/internal/web/controllers/support/RegionDataTest.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.rest.internal.web.controllers.support; + +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 RegionDataTest { + + @Test + public void shouldBeMockable() throws Exception { + RegionData mockRegionData = mock(RegionData.class); + String regionNamePath = "regionNamePath"; + + mockRegionData.setRegionNamePath(regionNamePath); + + verify(mockRegionData, times(1)).setRegionNamePath(regionNamePath); + } +}