This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 415f42e8df1 Revise #23514 (#23522)
415f42e8df1 is described below
commit 415f42e8df105db4372b167babdf0c7691ad7687
Author: zhaojinchao <[email protected]>
AuthorDate: Thu Jan 12 18:03:51 2023 +0800
Revise #23514 (#23522)
---
.../agent/core/plugin/PluginContextTest.java | 64 ++++------------------
1 file changed, 12 insertions(+), 52 deletions(-)
diff --git
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginContextTest.java
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginContextTest.java
index 7db5eec8a56..6898c93e7bb 100644
---
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginContextTest.java
+++
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginContextTest.java
@@ -17,75 +17,35 @@
package org.apache.shardingsphere.agent.core.plugin;
-import net.bytebuddy.utility.RandomString;
import org.junit.Test;
-import java.util.Random;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public final class PluginContextTest {
- private static final String PLUGIN_ENABLED_KEY = "AGENT_PLUGINS_ENABLED";
-
@Test
- public void assertKeyNotExistsReturnFalse() {
+ public void assertNotPluginEnabledKey() {
assertFalse(PluginContext.isPluginEnabled());
}
-
- @Test
- public void assertPropertyValueIsAnyOtherStringBut0ReturnTrue() {
- String randomString;
- while (true) {
- randomString = RandomString.make(new Random().nextInt(20));
- if (!"0".equals(randomString)) {
- break;
- }
- }
- System.setProperty(PLUGIN_ENABLED_KEY, randomString);
- assertTrue(PluginContext.isPluginEnabled());
- }
-
+
@Test
- public void assertPropertyValueIs0ReturnFalse() {
- System.setProperty(PLUGIN_ENABLED_KEY, "0");
+ public void assertPluginEnabledKeyIsFalse() {
+ System.setProperty("AGENT_PLUGINS_ENABLED", "false");
assertFalse(PluginContext.isPluginEnabled());
}
-
+
@Test
- public void assertPropertyValueIsLowercaseTrueReturnTrue() {
- System.setProperty(PLUGIN_ENABLED_KEY,
Boolean.TRUE.toString().toLowerCase());
- assertTrue(PluginContext.isPluginEnabled());
+ public void assertPluginEnabledKeyIsZero() {
+ System.setProperty("AGENT_PLUGINS_ENABLED", "0");
+ assertFalse(PluginContext.isPluginEnabled());
}
-
+
@Test
- public void assertPropertyValueIsUppercaseTrueReturnTrue() {
- System.setProperty(PLUGIN_ENABLED_KEY,
Boolean.TRUE.toString().toUpperCase());
+ public void assertPluginEnabled() {
+ System.setProperty("AGENT_PLUGINS_ENABLED", "1");
assertTrue(PluginContext.isPluginEnabled());
- }
-
- @Test
- public void assertPropertyValueIsMixedCaseTrueReturnTrue() {
- System.setProperty(PLUGIN_ENABLED_KEY, "True");
+ System.setProperty("AGENT_PLUGINS_ENABLED", "true");
assertTrue(PluginContext.isPluginEnabled());
}
-
- @Test
- public void assertPropertyValueIsLowercaseFalseReturnFalse() {
- System.setProperty(PLUGIN_ENABLED_KEY,
Boolean.FALSE.toString().toLowerCase());
- assertFalse(PluginContext.isPluginEnabled());
- }
-
- @Test
- public void assertPropertyValueIsUppercaseFalseReturnFalse() {
- System.setProperty(PLUGIN_ENABLED_KEY,
Boolean.FALSE.toString().toUpperCase());
- assertFalse(PluginContext.isPluginEnabled());
- }
-
- @Test
- public void assertPropertyValueIsMixedCaseFalseReturnFalse() {
- System.setProperty(PLUGIN_ENABLED_KEY, "False");
- assertFalse(PluginContext.isPluginEnabled());
- }
}