Skip to content

Commit 189419b

Browse files
authored
Update CombinedWidgetTest.java
1 parent a232681 commit 189419b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/test/java/io/appium/java_client/pagefactory_tests/widget/tests/combined/CombinedWidgetTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
@SuppressWarnings({"unchecked", "unused"})
3030
public class CombinedWidgetTest {
3131

32+
/**
33+
* Based on how many Proxy Classes are created during this test class,
34+
* this number is used to determine if the cache is being purged correctly between tests.
35+
*/
36+
private static final int THRESHOLD_SIZE = 50;
37+
3238
/**
3339
* Test data generation.
3440
*
@@ -176,11 +182,10 @@ public List<PartiallyCombinedWidget> getWidgets() {
176182
*/
177183
private void assertProxyClassCacheGrowth() {
178184
System.gc(); //Trying to force a collection for more accurate check numbers
179-
int thresholdSize = 50;
180185
assertThat(
181-
"Proxy Class Cache threshold is " + thresholdSize,
186+
"Proxy Class Cache threshold is " + THRESHOLD_SIZE,
182187
getCachedProxyClassesSize(),
183-
lessThan(thresholdSize)
188+
lessThan(THRESHOLD_SIZE)
184189
);
185190
}
186191

@@ -190,7 +195,7 @@ private int getCachedProxyClassesSize() {
190195
cpc.setAccessible(true);
191196
Map<?, ?> cachedProxyClasses = (Map<?, ?>) cpc.get(null);
192197
return cachedProxyClasses.size();
193-
} catch (Exception e) {
198+
} catch (NoSuchFieldException | ClassNotFoundException | IllegalAccessException e) {
194199
throw new RuntimeException(e);
195200
}
196201
}

0 commit comments

Comments
 (0)