Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/schedulers/SchedulerPoolFactoryTest.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.schedulers;
15
16 import static org.junit.Assert.*;
17
18 import org.junit.Test;
19
20 import io.reactivex.rxjava3.core.RxJavaTest;
21 import io.reactivex.rxjava3.functions.Function;
22 import io.reactivex.rxjava3.internal.functions.Functions;
23 import io.reactivex.rxjava3.testsupport.TestHelper;
24
25 public class SchedulerPoolFactoryTest extends RxJavaTest {
26
27 @Test
28 public void utilityClass() {
29 TestHelper.checkUtilityClass(SchedulerPoolFactory.class);
30 }
31
32 @Test
33 public void boolPropertiesDisabledReturnsDefaultDisabled() throws Throwable {
34 assertTrue(SchedulerPoolFactory.getBooleanProperty(false, "key", false, true, failingPropertiesAccessor));
35 assertFalse(SchedulerPoolFactory.getBooleanProperty(false, "key", true, false, failingPropertiesAccessor));
36 }
37
38 @Test
39 public void boolPropertiesEnabledMissingReturnsDefaultMissing() throws Throwable {
40 assertTrue(SchedulerPoolFactory.getBooleanProperty(true, "key", true, false, missingPropertiesAccessor));
41 assertFalse(SchedulerPoolFactory.getBooleanProperty(true, "key", false, true, missingPropertiesAccessor));
42 }
43
44 @Test
45 public void boolPropertiesFailureReturnsDefaultMissing() throws Throwable {
46 assertTrue(SchedulerPoolFactory.getBooleanProperty(true, "key", true, false, failingPropertiesAccessor));
47 assertFalse(SchedulerPoolFactory.getBooleanProperty(true, "key", false, true, failingPropertiesAccessor));
48 }
49
50 @Test
51 public void boolPropertiesReturnsValue() throws Throwable {
52 assertTrue(SchedulerPoolFactory.getBooleanProperty(true, "true", true, false, Functions.<String>identity()));
53 assertFalse(SchedulerPoolFactory.getBooleanProperty(true, "false", false, true, Functions.<String>identity()));
54 }
55
56 static final Function<String, String> failingPropertiesAccessor = new Function<String, String>() {
57 @Override
58 public String apply(String v) throws Throwable {
59 throw new SecurityException();
60 }
61 };
62
63 static final Function<String, String> missingPropertiesAccessor = new Function<String, String>() {
64 @Override
65 public String apply(String v) throws Throwable {
66 return null;
67 }
68 };
69 }