From 4e5803592494853537aff9fa90c9451d890e69fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=A7=84=ED=98=81?= Date: Wed, 8 Mar 2023 17:05:52 +0900 Subject: [PATCH 1/2] test: modify Java test code - Fixed some variable names that do not conform to the Java naming convention - Remove unnecessary public --- .../collecting/CodeBaseScannerBlogTest.java | 4 +- .../CodeBaseScannerExplodedTest.java | 18 ++++---- .../collecting/CodeBaseScannerKinTest.java | 4 +- .../collecting/CodeBaseScannerTest.java | 18 ++++---- .../collecting/ElementMatcherBuilderTest.java | 46 +++++++++---------- .../collecting/InvocationRegistryTest.java | 16 +++---- .../collecting/MethodRegistryTest.java | 4 +- .../scavenger/javaagent/model/ConfigTest.java | 2 +- .../scavenger/javaagent/model/MethodTest.java | 4 +- .../scheduling/SchedulerStateTest.java | 16 +++---- .../javaagent/scheduling/SchedulerTest.java | 30 ++++++------ .../javaagent/util/ConfigUtilsTest.java | 34 +++++++------- 12 files changed, 98 insertions(+), 98 deletions(-) diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerBlogTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerBlogTest.java index ffbf58fe..a3540314 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerBlogTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerBlogTest.java @@ -47,14 +47,14 @@ class AllMethodTest { @Test @DisplayName("it finds all methods") - public void scanAllMethod() throws IOException { + void scanAllMethod() throws IOException { assertThat(scanner.scan().getMethods()) .hasSizeGreaterThan(9000).hasSizeLessThan(10000); } @Test @DisplayName("it returns same codeBaseFingerprint for every scan") - public void codeBaseFingerprint() throws IOException { + void codeBaseFingerprint() throws IOException { String expectedFingerprint = scanner.scan().getCodeBaseFingerprint(); assertThat(scanner.scan().getCodeBaseFingerprint()) diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerExplodedTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerExplodedTest.java index 2f9fa369..c8367fb4 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerExplodedTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerExplodedTest.java @@ -61,14 +61,14 @@ class AllMethodTest { @Test @DisplayName("it finds correct number of methods") - public void scanAllMethod() throws IOException { + void scanAllMethod() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(64); } @Test @DisplayName("it returns same codeBaseFingerprint for every scan") - public void codeBaseFingerprint() throws IOException { + void codeBaseFingerprint() throws IOException { String expectedFingerprint = scanner.scan().getCodeBaseFingerprint(); assertThat(scanner.scan().getCodeBaseFingerprint()).isEqualTo(expectedFingerprint); } @@ -85,7 +85,7 @@ public void setConstructorFilter() { @Test @DisplayName("it does not contain constructor") - public void scanFilterConstructor() throws IOException { + void scanFilterConstructor() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).map(Method::isConstructor).containsOnly(false); } @@ -102,7 +102,7 @@ public void setVisibilityFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterVisibility() throws IOException { + void scanFilterVisibility() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(65); } @@ -120,7 +120,7 @@ public void setExcludedPackages() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterExcludedPackages() throws IOException { + void scanFilterExcludedPackages() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).allSatisfy(e -> assertThat(e.getSignature()).doesNotContain("com.example.demo.additional")); } @@ -137,7 +137,7 @@ public void setAnnotationFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterAnnotation() throws IOException { + void scanFilterAnnotation() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).allSatisfy(each -> assertThat(each.getDeclaringType()).contains("Controller")); } @@ -155,7 +155,7 @@ public void setFilters() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterAdditionalPackage() throws IOException { + void scanFilterAdditionalPackage() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(19); } @@ -174,7 +174,7 @@ public void setFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterGetterSetter() throws IOException { + void scanFilterGetterSetter() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(50); } @@ -191,7 +191,7 @@ public void setPackages() { @Test @DisplayName("it finds methods successfully") - public void scanRecursively() throws IOException { + void scanRecursively() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).isNotEmpty(); } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerKinTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerKinTest.java index 22510cea..9467bbbc 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerKinTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerKinTest.java @@ -52,7 +52,7 @@ class AllMethodTest { @Test @DisplayName("it finds all methods") - public void scanAllMethod() throws IOException { + void scanAllMethod() throws IOException { CodeBase scan = scanner.scan(); List methods = scan.getMethods(); methods.forEach(method -> System.out.println(method.getSignature())); @@ -60,7 +60,7 @@ public void scanAllMethod() throws IOException { @Test @DisplayName("it returns same codeBaseFingerprint for every scan") - public void codeBaseFingerprint() throws IOException { + void codeBaseFingerprint() throws IOException { String expectedFingerprint = scanner.scan().getCodeBaseFingerprint(); assertThat(scanner.scan().getCodeBaseFingerprint()) diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerTest.java index 5b6d1a25..b754d0de 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/CodeBaseScannerTest.java @@ -45,14 +45,14 @@ class AllMethodTest { @Test @DisplayName("it finds correct number of methods") - public void scanAllMethod() throws IOException { + void scanAllMethod() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(64); } @Test @DisplayName("it returns same codeBaseFingerprint for every scan") - public void codeBaseFingerprint() throws IOException { + void codeBaseFingerprint() throws IOException { String expected = scanner.scan().getCodeBaseFingerprint(); assertThat(scanner.scan().getCodeBaseFingerprint()) .isEqualTo(expected); @@ -70,7 +70,7 @@ public void setConstructorFilter() { @Test @DisplayName("it does not contain constructor") - public void scanFilterConstructor() throws IOException { + void scanFilterConstructor() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).map(Method::isConstructor).containsOnly(false); } @@ -87,7 +87,7 @@ public void setVisibilityFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterVisibility() throws IOException { + void scanFilterVisibility() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(65); } @@ -105,7 +105,7 @@ public void setExcludedPackages() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterExcludedPackages() throws IOException { + void scanFilterExcludedPackages() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).allSatisfy(e -> assertThat(e.getSignature()).doesNotContain("com.example.demo.additional")); } @@ -123,7 +123,7 @@ public void setAnnotationFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterAnnotation() throws IOException { + void scanFilterAnnotation() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).allSatisfy(each -> assertThat(each.getDeclaringType()).contains("Controller")); } @@ -141,7 +141,7 @@ public void setFilters() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterAdditionalPackage() throws IOException { + void scanFilterAdditionalPackage() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(19); } @@ -160,7 +160,7 @@ public void setFilter() { @Test @DisplayName("it finds correct number of methods") - public void scanFilterGetterSetter() throws IOException { + void scanFilterGetterSetter() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).hasSize(50); } @@ -177,7 +177,7 @@ public void setPackages() { @Test @DisplayName("it finds methods successfully") - public void scanRecursively() throws IOException { + void scanRecursively() throws IOException { List actual = scanner.scan().getMethods(); assertThat(actual).isNotEmpty(); } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/ElementMatcherBuilderTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/ElementMatcherBuilderTest.java index 02e5db2b..04229b75 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/ElementMatcherBuilderTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/ElementMatcherBuilderTest.java @@ -69,20 +69,20 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for types prefixed by the given package") - public void prefixed() { + void prefixed() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue(); assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue(); } @Test @DisplayName("it returns false for empty string") - public void emptyString() { + void emptyString() { assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse(); } @Test @DisplayName("it returns false for types not prefixed by the given package") - public void notPrefixed() { + void notPrefixed() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.Clazz"))).isFalse(); assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse(); } @@ -104,27 +104,27 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for types prefixed by first given package") - public void firstPackage() { + void firstPackage() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue(); assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue(); } @Test @DisplayName("it returns true for types prefixed by second given package") - public void secondPackage() { + void secondPackage() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.test.Clazz"))).isTrue(); assertThat(matcher.matches(withClazzNameWithPackage("com.example.test.included.Clazz"))).isTrue(); } @Test @DisplayName("it returns false for empty string") - public void emptyString() { + void emptyString() { assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse(); } @Test @DisplayName("it returns false for types not prefixed by either packages") - public void notPrefixed() { + void notPrefixed() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.Clazz"))).isFalse(); assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse(); } @@ -147,27 +147,27 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for types prefixed by the given packages") - public void prefixed() { + void prefixed() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue(); assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue(); } @Test @DisplayName("it returns false for empty string") - public void emptyString() { + void emptyString() { assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse(); } @Test @DisplayName("it returns false for types prefixed by the excludePackages") - public void excludedPackages() { + void excludedPackages() { assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.excluded.Clazz"))).isFalse(); assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.excluded.test.Clazz"))).isFalse(); } @Test @DisplayName("it returns false for types not prefixed by the given packages") - public void notPrefixed() { + void notPrefixed() { assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse(); } } @@ -189,7 +189,7 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for packages prefixed by the given option") - public void matchingPackages() { + void matchingPackages() { assertThat(matcher.matches( withAnnotations("com.example.demo.Clazz", "com.example.annotation") )).isTrue(); @@ -200,7 +200,7 @@ public void matchingPackages() { @Test @DisplayName("it returns true for packages that has extra annotations") - public void extraAnnotation() { + void extraAnnotation() { assertThat(matcher.matches( withAnnotations( "com.example.demo.Clazz", @@ -211,7 +211,7 @@ public void extraAnnotation() { @Test @DisplayName("it returns false for packages not prefixed by the given option") - public void notPrefixed() { + void notPrefixed() { assertThat(matcher.matches( withAnnotations("com.example.Clazz", "com.example.annotation") )).isFalse(); @@ -219,7 +219,7 @@ public void notPrefixed() { @Test @DisplayName("it returns false for packages not annotated with given annotation") - public void notExact() { + void notExact() { assertThat(matcher.matches( withAnnotations("com.example.demo.Clazz", "com.com.example.annotation") )).isFalse(); @@ -227,7 +227,7 @@ public void notExact() { @Test @DisplayName("it returns false for packages with annotation prefixed by the given annotation") - public void prefixedAnnotation() { + void prefixedAnnotation() { assertThat(matcher.matches( withAnnotations("com.example.demo.Clazz", "com.example.annotation.test") )).isFalse(); @@ -252,7 +252,7 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for matching packages and annotations") - public void matched() { + void matched() { assertThat(matcher.matches( withAnnotations("com.example.demo.Clazz", "com.example.annotation") )).isTrue(); @@ -272,7 +272,7 @@ public void matched() { @Test @DisplayName("it returns true for additional packages without annotations") - public void additionalPackageWithoutAnnotation() { + void additionalPackageWithoutAnnotation() { assertThat(matcher.matches( withClazzNameWithPackage("com.example.demo.additional..Clazz") )).isTrue(); @@ -280,7 +280,7 @@ public void additionalPackageWithoutAnnotation() { @Test @DisplayName("it returns false for unmatched type") - public void unmatched() { + void unmatched() { assertThat(matcher.matches( withAnnotations("com.example.Clazz", "com.example.annotation") )).isFalse(); @@ -314,25 +314,25 @@ public void prepareMatcher() { @Test @DisplayName("it returns true for protected methods") - public void protectedMethods() { + void protectedMethods() { assertThat(matcher.matches(withModifiers(Opcodes.ACC_PROTECTED))).isTrue(); } @Test @DisplayName("it returns false for public methods") - public void publicMethods() { + void publicMethods() { assertThat(matcher.matches(withModifiers(Opcodes.ACC_PUBLIC))).isTrue(); } @Test @DisplayName("it returns false for private methods") - public void privateMethods() { + void privateMethods() { assertThat(matcher.matches(withModifiers(Opcodes.ACC_PRIVATE))).isFalse(); } @Test @DisplayName("it returns false for package-private methods") - public void packagePrivateMethods() { + void packagePrivateMethods() { assertThat(matcher.matches(withModifiers(0))).isFalse(); } } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/InvocationRegistryTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/InvocationRegistryTest.java index 1295e3f9..29ccc2d1 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/InvocationRegistryTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/InvocationRegistryTest.java @@ -50,7 +50,7 @@ public void registerHash() { @Test @DisplayName("it contains hash") - public void containsHash() { + void containsHash() { assertThat(getInvocations()) .extracting(InvocationDataPublication.InvocationDataEntry::getHash) .containsOnly(hash); @@ -70,7 +70,7 @@ public void registerHashTwice() { @Test @DisplayName("it contains only one hash") - public void containsHashOnce() { + void containsHashOnce() { assertThat(getInvocations()) .extracting(InvocationDataPublication.InvocationDataEntry::getHash) .containsOnlyOnce(hash); @@ -88,13 +88,13 @@ class NothingRegisteredTest { @Test @DisplayName("it returns empty collection") - public void empty() { + void empty() { assertThat(getInvocations()).isEmpty(); } @Test @DisplayName("it fills in commonData") - public void commonData() { + void commonData() { assertThat(sut.getPublication(config, codeBaseFingerprint).getCommonData().getCodeBaseFingerprint()) .isEqualTo(codeBaseFingerprint); } @@ -112,7 +112,7 @@ public void registerHash() { @Test @DisplayName("it returns collection containing hash") - public void containsHash() { + void containsHash() { assertThat(getInvocations()) .extracting(InvocationDataPublication.InvocationDataEntry::getHash) .containsOnly(hash); @@ -120,14 +120,14 @@ public void containsHash() { @Test @DisplayName("it clears registry") - public void clear() { + void clear() { getInvocations(); assertThat(getInvocations()).isEmpty(); } @Test @DisplayName("it fills in commonData") - public void commonData() { + void commonData() { assertThat(sut.getPublication(config, codeBaseFingerprint).getCommonData().getCodeBaseFingerprint()) .isEqualTo(codeBaseFingerprint); } @@ -147,7 +147,7 @@ public void getPublicationMultipleTimes() { @Test @DisplayName("it only returns invocations after last getPublication") - public void alternating() { + void alternating() { assertThat(getInvocations()) .extracting(InvocationDataPublication.InvocationDataEntry::getHash) .containsOnly(hash); diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/MethodRegistryTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/MethodRegistryTest.java index 3b415fde..304302e8 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/MethodRegistryTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/collecting/MethodRegistryTest.java @@ -34,7 +34,7 @@ public void cacheMethod() { @Test @DisplayName("it returns cached value") - public void cached() { + void cached() { assertThat(sut.getHash(signature, false)).isEqualTo(expected); } } @@ -46,7 +46,7 @@ class CglibTest { @Test @DisplayName("it returns empty string") - public void returnNull() { + void returnNull() { assertThat(sut.getHash(cglibSignature, false)) .isEqualTo(""); } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/ConfigTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/ConfigTest.java index 1aea6574..f3a2f268 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/ConfigTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/ConfigTest.java @@ -19,7 +19,7 @@ private static List mandatoryKeys() { @ParameterizedTest @MethodSource("mandatoryKeys") @DisplayName("should be disabled when mandatory value is not provided") - public void isEnabledCheck(String excludedKey) { + void isEnabledCheck(String excludedKey) { // given Stream keysWithoutExcludedKey = mandatoryKeys().stream() .filter(key -> !key.equals(excludedKey)); diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/MethodTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/MethodTest.java index a2e06bca..01e1711a 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/MethodTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/model/MethodTest.java @@ -12,7 +12,7 @@ void testMethodCreation() { Method method = new Method( "name", Visibility.PRIVATE, "static", false, false, "packageName.declaringType", "int a,int wow", "name(int a, int wow)" ); - assertThat(method.toCodeBaseEntry()).satisfies((it) -> { + assertThat(method.toCodeBaseEntry()).satisfies(it -> { assertThat(it.getDeclaringType()).isEqualTo("packageName.declaringType"); assertThat(it.getMethodName()).isEqualTo("name"); assertThat(it.getVisibility()).isEqualTo("private"); @@ -23,7 +23,7 @@ void testMethodCreation() { }); Method method2 = new Method(null, Visibility.PRIVATE, null, false, false, "", "int a,int wow", null); - assertThat(method2.toCodeBaseEntry()).satisfies((it) -> { + assertThat(method2.toCodeBaseEntry()).satisfies(it -> { assertThat(it.getDeclaringType()).isEqualTo(""); assertThat(it.getMethodName()).isEqualTo(""); assertThat(it.getVisibility()).isEqualTo("private"); diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerStateTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerStateTest.java index 0aaeba64..07c96102 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerStateTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerStateTest.java @@ -80,13 +80,13 @@ public void scheduleNext() { @Test @DisplayName("it makes due after 10 seconds") - public void dueAfter10Seconds() { + void dueAfter10Seconds() { verifyDueInSeconds(10); } @Test @DisplayName("it resets retryIntervalFactor") - public void resetRetryFactor() { + void resetRetryFactor() { assertThat(sut.getRetryIntervalFactor()).isEqualTo(1); } } @@ -109,7 +109,7 @@ public void scheduleNow() { @Test @DisplayName("it makes due now") - public void dueNow() { + void dueNow() { assertThat(sut.isDueTime()).isTrue(); } } @@ -125,7 +125,7 @@ class RetryTest { @Test @DisplayName("it schedules retry with given interval factors") - public void intervalFactors() { + void intervalFactors() { List retryIntervalFactors = Arrays.asList( 1, 1, 1, 1, 1, 2, 4, 8, 16, 16 ); @@ -153,13 +153,13 @@ public void updateInterval() { @Test @DisplayName("it does not change ongoing due") - public void onGoingDue() { + void onGoingDue() { verifyDueInSeconds(10); } @Test @DisplayName("it changes upcoming due to 20 seconds") - public void upcomingDue() { + void upcomingDue() { sut.scheduleNext(); verifyDueInSeconds(20); } @@ -171,7 +171,7 @@ class UpdateToShorterIntervalTest { @Test @DisplayName("it changes ongoing due") - public void onGoingDue() { + void onGoingDue() { sut.scheduleNext(); sut.updateIntervals(5, 5); verifyDueInSeconds(5); @@ -179,7 +179,7 @@ public void onGoingDue() { @Test @DisplayName("it should start immediately when it is first time") - public void firstTime() { + void firstTime() { sut.updateIntervals(5, 5); verifyDueInSeconds(0); } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerTest.java index 29b8b8b6..dd67e166 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/scheduling/SchedulerTest.java @@ -111,19 +111,19 @@ public void setUpAndRun() { @Test @DisplayName("it polls dynamic config") - public void pollConfig() { + void pollConfig() { verify(publisher).pollDynamicConfig(); } @Test @DisplayName("it published codebase") - public void publishCodeBase() { + void publishCodeBase() { verify(publisher).publishCodeBase(any()); } @Test @DisplayName("it publishes invocation data") - public void publishInvocationData() { + void publishInvocationData() { verify(publisher).publishInvocationData(any()); } } @@ -140,19 +140,19 @@ public void setUpAndRun() throws IOException { @Test @DisplayName("it polls dynamic config") - public void pollConfig() { + void pollConfig() { verify(publisher).pollDynamicConfig(); } @Test @DisplayName("it publishes codebase") - public void publishCodeBase() { + void publishCodeBase() { verify(publisher).publishCodeBase(any()); } @Test @DisplayName("it publishes invocation") - public void doesNotPublishInvocationData() { + void doesNotPublishInvocationData() { verify(publisher).publishInvocationData(any()); } } @@ -172,7 +172,7 @@ public void setUpAndRun() { @Test @DisplayName("it only polls dynamic config") - public void onlyPollConfig() { + void onlyPollConfig() { verify(publisher).pollDynamicConfig(); verifyNoMoreInteractions(publisher); } @@ -199,13 +199,13 @@ public void setUpAndRunThreeTimes() throws IOException { @Test @DisplayName("it runs codebase scan only once") - public void scanOnce() throws IOException { + void scanOnce() throws IOException { verify(codeBaseScannerMock, times(1)).scan(); } @Test @DisplayName("it tries to publish codebase three times") - public void publishThreeTimes() { + void publishThreeTimes() { verify(publisher, times(3)).publishCodeBase(any()); } } @@ -237,13 +237,13 @@ public void setUpAndRunThreeTimes() throws IOException { @Test @DisplayName("it runs getPublication only once") - public void getOnce() { + void getOnce() { verify(registry, atMostOnce()).getPublication(any(), anyString()); } @Test @DisplayName("it tries to publish codebase three times") - public void publishThreeTimes() { + void publishThreeTimes() { verify(publisher, times(3)).publishInvocationData(any()); } } @@ -264,7 +264,7 @@ public void shutdown() { @Test @DisplayName("it should not publish anything") - public void publishCodeBase() { + void publishCodeBase() { verifyNoInteractions(publisher); } } @@ -293,19 +293,19 @@ public void runsAndShutdown() throws IOException { @Test @DisplayName("it polls dynamic config") - public void pollConfig() { + void pollConfig() { verify(publisher).pollDynamicConfig(); } @Test @DisplayName("it publishes last invocations before shutdown") - public void lastInvocations() { + void lastInvocations() { verify(publisher, times(2)).publishInvocationData(any()); } @Test @DisplayName("it does not publish additional codebase") - public void codeBasePublishedOnlyOnce() { + void codeBasePublishedOnlyOnce() { verify(publisher, atMostOnce()).publishCodeBase(any()); } } diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java index 19c48198..1edabe24 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java @@ -32,7 +32,7 @@ class GetEnvVarNameMethod { @Test @DisplayName("should compute scavenger prefixed env var names") - public void getEnvVarNameTest() { + void getEnvVarNameTest() { assertThat(ConfigUtils.getEnvVarName("foo")) .isEqualTo("SCAVENGER_FOO"); @@ -47,7 +47,7 @@ class GetSystemPropertyNameMethod { @Test @DisplayName("should compute scavenger prefixed system property names") - public void getSystemPropertyNameTest() { + void getSystemPropertyNameTest() { assertThat(ConfigUtils.getSystemPropertyName("fooBar")) .isEqualTo("scavenger.fooBar"); } @@ -74,7 +74,7 @@ public void setProperties() { @Test @DisplayName("it expands variables with braces") - public void expandVariables_with_braces() { + void expandVariablesWithBraces() { String actual = ConfigUtils.expandVariables( props, userVariableName @@ -92,7 +92,7 @@ public void expandVariables_with_braces() { @Test @DisplayName("it expands variables without braces") - public void expandVariables_without_braces() { + void expandVariablesWithoutBraces() { String actual = ConfigUtils.expandVariables( props, userVariableName @@ -120,7 +120,7 @@ class Missing { @Test @DisplayName("it prints variable names") - public void expandVariables_missing() { + void expandVariablesMissing() { String actual = ConfigUtils.expandVariables(new Properties(), "foo $missingProp1 bar ${missing.prop2} baz"); assertThat(actual).isEqualTo("foo $missingProp1 bar ${missing.prop2} baz"); @@ -145,7 +145,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - public void getIntValue_present() { + void getIntValuePresent() { int actual = ConfigUtils.getIntValue(props, "key", 17); assertThat(actual).isEqualTo(4711); @@ -158,7 +158,7 @@ class Missing { @Test @DisplayName("it returns the default value") - public void getIntValue_missing() { + void getIntValueMissing() { int actual = ConfigUtils.getIntValue(new Properties(), "key", 17); assertThat(actual).isEqualTo(17); @@ -183,7 +183,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - public void getBooleanValue_present() { + void getBooleanValuePresent() { boolean actual = ConfigUtils.getBooleanValue(props, "key", true); assertThat(actual).isFalse(); @@ -196,7 +196,7 @@ class Missing { @Test @DisplayName("it returns the default value") - public void getBooleanValue_missing() { + void getBooleanValueMissing() { boolean actual = ConfigUtils.getBooleanValue(new Properties(), "key", true); assertThat(actual).isTrue(); @@ -223,7 +223,7 @@ public void setProperties() { @Test @DisplayName("it returns system property") - public void getStringValue_system_properties_priority() { + void getStringValueSystemPropertiesPriority() { String actual = ConfigUtils.getStringValue(props, "appVersion", "default-app-version"); assertThat(actual).isEqualTo("sysprop-appVersion"); @@ -236,7 +236,7 @@ class Null { @Test @DisplayName("it returns null") - public void getStringValue_null() { + void getStringValueNull() { String actual = ConfigUtils.getStringValue(new Properties(), "key", null); assertThat(actual).isNull(); @@ -256,7 +256,7 @@ public void setProperties() { @Test @DisplayName("it returns null") - public void getStringValue_blank() { + void getStringValueBlank() { String actual = ConfigUtils.getStringValue(props, "key", null); assertThat(actual).isNull(); @@ -276,7 +276,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - public void getStringValue_present() { + void getStringValuePresent() { String actual = ConfigUtils.getStringValue(props, "key", "default"); assertThat(actual).isEqualTo("value"); @@ -301,7 +301,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - public void getAliasedStringValue_alias() { + void getAliasedStringValueAlias() { String actual = ConfigUtils.getAliasedStringValue(props, "alternateKey", "key", "defaultValue"); assertThat(actual).isEqualTo("value"); @@ -321,7 +321,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - public void getAliasedStringValue_primary() { + void getAliasedStringValuePrimary() { String actual = ConfigUtils.getAliasedStringValue(props, "key", "alternateKey", "defaultValue"); assertThat(actual).isEqualTo("value"); @@ -341,7 +341,7 @@ public void setProperties() { @Test @DisplayName("it returns default value") - public void getAliasedStringValue_missing() { + void getAliasedStringValueMissing() { String actual = ConfigUtils.getAliasedStringValue(props, "key", "alternateKey", "defaultValue"); assertThat(actual).isEqualTo("defaultValue"); @@ -355,7 +355,7 @@ class SeparateValuesMethod { @Test @DisplayName("should separate colon, semicolon separated values") - public void separateValuesTest() { + void separateValuesTest() { assertThat(ConfigUtils.separateValues("prefix.")) .containsExactly("prefix"); From a37157e19555447128487c089e41a9cf892bf286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A9=E1=84=8C=E1=85=B5=E1=86=AB=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=A8?= Date: Sat, 11 Mar 2023 14:10:35 +0900 Subject: [PATCH 2/2] test: modify method names --- .../javaagent/util/ConfigUtilsTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java index 1edabe24..386e7e4c 100644 --- a/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java +++ b/scavenger-agent-java/src/test/java/com/navercorp/scavenger/javaagent/util/ConfigUtilsTest.java @@ -74,7 +74,7 @@ public void setProperties() { @Test @DisplayName("it expands variables with braces") - void expandVariablesWithBraces() { + void expandVariables_with_braces() { String actual = ConfigUtils.expandVariables( props, userVariableName @@ -120,7 +120,7 @@ class Missing { @Test @DisplayName("it prints variable names") - void expandVariablesMissing() { + void expandVariables_missing() { String actual = ConfigUtils.expandVariables(new Properties(), "foo $missingProp1 bar ${missing.prop2} baz"); assertThat(actual).isEqualTo("foo $missingProp1 bar ${missing.prop2} baz"); @@ -145,7 +145,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - void getIntValuePresent() { + void getIntValue_present() { int actual = ConfigUtils.getIntValue(props, "key", 17); assertThat(actual).isEqualTo(4711); @@ -158,7 +158,7 @@ class Missing { @Test @DisplayName("it returns the default value") - void getIntValueMissing() { + void getIntValue_missing() { int actual = ConfigUtils.getIntValue(new Properties(), "key", 17); assertThat(actual).isEqualTo(17); @@ -183,7 +183,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - void getBooleanValuePresent() { + void getBooleanValue_present() { boolean actual = ConfigUtils.getBooleanValue(props, "key", true); assertThat(actual).isFalse(); @@ -196,7 +196,7 @@ class Missing { @Test @DisplayName("it returns the default value") - void getBooleanValueMissing() { + void getBooleanValue_missing() { boolean actual = ConfigUtils.getBooleanValue(new Properties(), "key", true); assertThat(actual).isTrue(); @@ -223,7 +223,7 @@ public void setProperties() { @Test @DisplayName("it returns system property") - void getStringValueSystemPropertiesPriority() { + void getStringValue_system_properties_priority() { String actual = ConfigUtils.getStringValue(props, "appVersion", "default-app-version"); assertThat(actual).isEqualTo("sysprop-appVersion"); @@ -236,7 +236,7 @@ class Null { @Test @DisplayName("it returns null") - void getStringValueNull() { + void getStringValue_null() { String actual = ConfigUtils.getStringValue(new Properties(), "key", null); assertThat(actual).isNull(); @@ -256,7 +256,7 @@ public void setProperties() { @Test @DisplayName("it returns null") - void getStringValueBlank() { + void getStringValue_blank() { String actual = ConfigUtils.getStringValue(props, "key", null); assertThat(actual).isNull(); @@ -276,7 +276,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - void getStringValuePresent() { + void getStringValue_present() { String actual = ConfigUtils.getStringValue(props, "key", "default"); assertThat(actual).isEqualTo("value"); @@ -301,7 +301,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - void getAliasedStringValueAlias() { + void getAliasedStringValue_alias() { String actual = ConfigUtils.getAliasedStringValue(props, "alternateKey", "key", "defaultValue"); assertThat(actual).isEqualTo("value"); @@ -321,7 +321,7 @@ public void setProperties() { @Test @DisplayName("it returns the value") - void getAliasedStringValuePrimary() { + void getAliasedStringValue_primary() { String actual = ConfigUtils.getAliasedStringValue(props, "key", "alternateKey", "defaultValue"); assertThat(actual).isEqualTo("value"); @@ -341,7 +341,7 @@ public void setProperties() { @Test @DisplayName("it returns default value") - void getAliasedStringValueMissing() { + void getAliasedStringValue_missing() { String actual = ConfigUtils.getAliasedStringValue(props, "key", "alternateKey", "defaultValue"); assertThat(actual).isEqualTo("defaultValue");