|
16 | 16 |
|
17 | 17 | package com.mongodb.reactivestreams.client; |
18 | 18 |
|
19 | | -import com.mongodb.client.test.CollectionHelper; |
20 | 19 | import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient; |
21 | 20 | import org.bson.Document; |
22 | | -import org.bson.codecs.DocumentCodec; |
23 | | -import org.junit.jupiter.api.BeforeEach; |
| 21 | +import org.junit.jupiter.api.Disabled; |
24 | 22 | import org.junit.jupiter.api.Test; |
25 | 23 |
|
26 | | -import java.util.concurrent.ExecutionException; |
27 | | -import java.util.concurrent.TimeoutException; |
28 | | - |
29 | 24 | /** |
30 | | - * See |
31 | | - * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#prose-tests">Retryable Write Prose Tests</a>. |
| 25 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#prose-tests"> |
| 26 | + * Prose Tests</a>. |
32 | 27 | */ |
33 | | -public class RetryableWritesProseTest extends DatabaseTestCase { |
34 | | - private CollectionHelper<Document> collectionHelper; |
35 | | - |
36 | | - @BeforeEach |
37 | | - @Override |
38 | | - public void setUp() { |
39 | | - super.setUp(); |
40 | | - |
41 | | - collectionHelper = new CollectionHelper<>(new DocumentCodec(), collection.getNamespace()); |
42 | | - collectionHelper.create(); |
43 | | - } |
44 | | - |
| 28 | +final class RetryableWritesProseTest { |
45 | 29 | /** |
46 | | - * Prose test #2. |
| 30 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#2-test-that-drivers-properly-retry-after-encountering-poolclearederrors"> |
| 31 | + * 2. Test that drivers properly retry after encountering PoolClearedErrors</a>. |
47 | 32 | */ |
48 | 33 | @Test |
49 | | - public void poolClearedExceptionMustBeRetryable() throws InterruptedException, ExecutionException, TimeoutException { |
| 34 | + void poolClearedExceptionMustBeRetryable() throws Exception { |
50 | 35 | com.mongodb.client.RetryableWritesProseTest.poolClearedExceptionMustBeRetryable( |
51 | 36 | SyncMongoClient::new, |
52 | 37 | mongoCollection -> mongoCollection.insertOne(new Document()), "insert", true); |
53 | 38 | } |
54 | 39 |
|
55 | 40 | /** |
56 | | - * Prose test #3. |
| 41 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#3-test-that-drivers-return-the-original-error-after-encountering-a-writeconcernerror-with-a-retryablewriteerror-label"> |
| 42 | + * 3. Test that drivers return the original error after encountering a WriteConcernError with a RetryableWriteError label</a>. |
57 | 43 | */ |
58 | 44 | @Test |
59 | | - public void originalErrorMustBePropagatedIfNoWritesPerformed() throws InterruptedException { |
| 45 | + void originalErrorMustBePropagatedIfNoWritesPerformed() throws Exception { |
60 | 46 | com.mongodb.client.RetryableWritesProseTest.originalErrorMustBePropagatedIfNoWritesPerformed( |
61 | 47 | SyncMongoClient::new); |
62 | 48 | } |
63 | 49 |
|
64 | 50 | /** |
65 | | - * Prose test #4. |
| 51 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#4-test-that-in-a-sharded-cluster-writes-are-retried-on-a-different-mongos-when-one-is-available"> |
| 52 | + * 4. Test that in a sharded cluster writes are retried on a different mongos when one is available</a>. |
66 | 53 | */ |
67 | 54 | @Test |
68 | | - public void retriesOnDifferentMongosWhenAvailable() { |
| 55 | + void retriesOnDifferentMongosWhenAvailable() { |
69 | 56 | com.mongodb.client.RetryableWritesProseTest.retriesOnDifferentMongosWhenAvailable( |
70 | 57 | SyncMongoClient::new, |
71 | 58 | mongoCollection -> mongoCollection.insertOne(new Document()), "insert", true); |
72 | 59 | } |
73 | 60 |
|
74 | 61 | /** |
75 | | - * Prose test #5. |
| 62 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#5-test-that-in-a-sharded-cluster-writes-are-retried-on-the-same-mongos-when-no-others-are-available"> |
| 63 | + * 5. Test that in a sharded cluster writes are retried on the same mongos when no others are available</a>. |
76 | 64 | */ |
77 | 65 | @Test |
78 | | - public void retriesOnSameMongosWhenAnotherNotAvailable() { |
| 66 | + void retriesOnSameMongosWhenAnotherNotAvailable() { |
79 | 67 | com.mongodb.client.RetryableWritesProseTest.retriesOnSameMongosWhenAnotherNotAvailable( |
80 | 68 | SyncMongoClient::new, |
81 | 69 | mongoCollection -> mongoCollection.insertOne(new Document()), "insert", true); |
82 | 70 | } |
| 71 | + |
| 72 | + /** |
| 73 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#case-1-test-that-drivers-return-the-correct-error-when-receiving-only-errors-without-nowritesperformed"> |
| 74 | + * 6. Test error propagation after encountering multiple errors. |
| 75 | + * Case 1: Test that drivers return the correct error when receiving only errors without NoWritesPerformed</a>. |
| 76 | + */ |
| 77 | + @Test |
| 78 | + @Disabled("TODO-BACKPRESSURE Valentin Enable when implementing JAVA-6055") |
| 79 | + void errorPropagationAfterEncounteringMultipleErrorsCase1() throws Exception { |
| 80 | + com.mongodb.client.RetryableWritesProseTest.errorPropagationAfterEncounteringMultipleErrorsCase1(SyncMongoClient::new); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#case-2-test-that-drivers-return-the-correct-error-when-receiving-only-errors-with-nowritesperformed"> |
| 85 | + * 6. Test error propagation after encountering multiple errors. |
| 86 | + * Case 2: Test that drivers return the correct error when receiving only errors with NoWritesPerformed</a>. |
| 87 | + */ |
| 88 | + @Test |
| 89 | + void errorPropagationAfterEncounteringMultipleErrorsCase2() throws Exception { |
| 90 | + com.mongodb.client.RetryableWritesProseTest.errorPropagationAfterEncounteringMultipleErrorsCase2(SyncMongoClient::new); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/retryable-writes/tests/README.md#case-3-test-that-drivers-return-the-correct-error-when-receiving-some-errors-with-nowritesperformed-and-some-without-nowritesperformed"> |
| 95 | + * 6. Test error propagation after encountering multiple errors. |
| 96 | + * Case 3: Test that drivers return the correct error when receiving some errors with NoWritesPerformed and some without NoWritesPerformed</a>. |
| 97 | + */ |
| 98 | + @Test |
| 99 | + void errorPropagationAfterEncounteringMultipleErrorsCase3() throws Exception { |
| 100 | + com.mongodb.client.RetryableWritesProseTest.errorPropagationAfterEncounteringMultipleErrorsCase3(SyncMongoClient::new); |
| 101 | + } |
83 | 102 | } |
0 commit comments