| 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.subscriptions; |
| 15 |
|
| 16 |
import static org.junit.Assert.assertEquals; |
| 17 |
|
| 18 |
import org.junit.Test; |
| 19 |
|
| 20 |
import io.reactivex.rxjava3.annotations.Nullable; |
| 21 |
import io.reactivex.rxjava3.core.RxJavaTest; |
| 22 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 23 |
|
| 24 |
public class QueueSubscriptionTest extends RxJavaTest { |
| 25 |
static final class EmptyQS extends BasicQueueSubscription<Integer> { |
| 26 |
|
| 27 |
private static final long serialVersionUID = -5312809687598840520L; |
| 28 |
|
| 29 |
@Override |
| 30 |
public int requestFusion(int mode) { |
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
@Nullable |
| 35 |
@Override |
| 36 |
public Integer poll() throws Exception { |
| 37 |
return null; |
| 38 |
} |
| 39 |
|
| 40 |
@Override |
| 41 |
public boolean isEmpty() { |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public void clear() { |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public void request(long n) { |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
@Override |
| 56 |
public void cancel() { |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
static final class EmptyIntQS extends BasicIntQueueSubscription<Integer> { |
| 63 |
|
| 64 |
private static final long serialVersionUID = -1374033403007296252L; |
| 65 |
|
| 66 |
@Override |
| 67 |
public int requestFusion(int mode) { |
| 68 |
return 0; |
| 69 |
} |
| 70 |
|
| 71 |
@Nullable |
| 72 |
@Override |
| 73 |
public Integer poll() throws Exception { |
| 74 |
return null; |
| 75 |
} |
| 76 |
|
| 77 |
@Override |
| 78 |
public boolean isEmpty() { |
| 79 |
return false; |
| 80 |
} |
| 81 |
|
| 82 |
@Override |
| 83 |
public void clear() { |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
@Override |
| 88 |
public void request(long n) { |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
@Override |
| 93 |
public void cancel() { |
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
} |
| 98 |
|
| 99 |
@Test |
| 100 |
public void noOfferBasic() { |
| 101 |
TestHelper.assertNoOffer(new EmptyQS()); |
| 102 |
} |
| 103 |
|
| 104 |
@Test |
| 105 |
public void noOfferBasicInt() { |
| 106 |
TestHelper.assertNoOffer(new EmptyIntQS()); |
| 107 |
} |
| 108 |
|
| 109 |
@Test |
| 110 |
public void empty() { |
| 111 |
TestHelper.checkEnum(EmptySubscription.class); |
| 112 |
|
| 113 |
assertEquals("EmptySubscription", EmptySubscription.INSTANCE.toString()); |
| 114 |
|
| 115 |
TestHelper.assertNoOffer(EmptySubscription.INSTANCE); |
| 116 |
} |
| 117 |
} |