Skip to content

Commit 1aefded

Browse files
authored
Remove plexus-utils from firebase-database's test dependency (#4233)
firebase-database only uses StringUtils#repeat in test code, and it is easy to port repeat method to test file and remove plexus-utils from test dependency. Signed-off-by: utzcoz <[email protected]> Signed-off-by: utzcoz <[email protected]>
1 parent 6498bd0 commit 1aefded

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

firebase-database/firebase-database.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ dependencies {
100100

101101
testImplementation 'junit:junit:4.12'
102102
testImplementation 'org.mockito:mockito-core:2.25.0'
103-
testImplementation 'org.codehaus.plexus:plexus-utils:3.4.2'
104103
testImplementation "org.robolectric:robolectric:$robolectricVersion"
105104
testImplementation 'com.firebase:firebase-token-generator:2.0.0'
106105
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'

firebase-database/src/test/java/com/google/firebase/database/PushIdGeneratorTest.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static org.junit.Assert.assertEquals;
2020

2121
import com.google.firebase.database.core.utilities.PushIdGenerator;
22-
import org.codehaus.plexus.util.StringUtils;
2322
import org.junit.Test;
2423
import org.robolectric.RobolectricTestRunner;
2524
import org.robolectric.annotation.Config;
@@ -41,8 +40,7 @@ public void testSuccessorSpecialValue() {
4140
PushIdGenerator.successor(String.valueOf(Integer.MAX_VALUE)));
4241
assertEquals(
4342
MAX_KEY_NAME,
44-
PushIdGenerator.successor(
45-
StringUtils.repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN)));
43+
PushIdGenerator.successor(repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN)));
4644
}
4745

4846
@Test
@@ -51,9 +49,7 @@ public void testSuccessorBasic() {
5149
assertEquals(
5250
"abd",
5351
PushIdGenerator.successor(
54-
"abc"
55-
+ StringUtils.repeat(
56-
Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length())));
52+
"abc" + repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length())));
5753
assertEquals(
5854
"abc" + MIN_PUSH_CHAR + MIN_PUSH_CHAR, PushIdGenerator.successor("abc" + MIN_PUSH_CHAR));
5955
}
@@ -69,8 +65,18 @@ public void testPredecessorSpecialValue() {
6965
@Test
7066
public void testPredecessorBasicValue() {
7167
assertEquals(
72-
"abb" + StringUtils.repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length()),
68+
"abb" + repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length()),
7369
PushIdGenerator.predecessor("abc"));
7470
assertEquals("abc", PushIdGenerator.predecessor("abc" + MIN_PUSH_CHAR));
7571
}
72+
73+
private static String repeat(String str, int repeat) {
74+
// Copied from
75+
// https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/StringUtils.java.
76+
StringBuilder buffer = new StringBuilder(repeat * str.length());
77+
for (int i = 0; i < repeat; i++) {
78+
buffer.append(str);
79+
}
80+
return buffer.toString();
81+
}
7682
}

0 commit comments

Comments
 (0)