|
16 | 16 |
|
17 | 17 | package com.marklogic.client.fastfunctest;
|
18 | 18 |
|
| 19 | +import com.marklogic.client.ContentNoVersionException; |
19 | 20 | import com.marklogic.client.FailedRequestException;
|
20 | 21 | import com.marklogic.client.admin.ServerConfigurationManager;
|
21 | 22 | import com.marklogic.client.admin.ServerConfigurationManager.UpdatePolicy;
|
|
29 | 30 |
|
30 | 31 | import java.io.File;
|
31 | 32 |
|
| 33 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 34 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
32 | 35 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
33 | 36 |
|
34 | 37 | public class TestBug18920 extends AbstractFunctionalTest {
|
@@ -81,23 +84,9 @@ public void testBug18920() {
|
81 | 84 | String docUri = desc.getUri();
|
82 | 85 | System.out.println(docUri);
|
83 | 86 |
|
84 |
| - String exception = ""; |
85 |
| - String statusCode = ""; |
86 |
| - String expectedException = "com.marklogic.client.FailedRequestException: Local message: Content version required to write document. Server Message: RESTAPI-CONTENTNOVERSION: (err:FOER0000) No content version supplied: uri /bug18920/xml-original.xml"; |
87 |
| - int expCode = 0; |
88 | 87 | // update document with no content version
|
89 |
| - try { |
90 |
| - docMgr.write(docUri, handle); |
91 |
| - } catch (FailedRequestException e) { |
92 |
| - exception = e.toString(); |
93 |
| - statusCode = e.getFailedRequest().getMessageCode(); |
94 |
| - expCode = e.getFailedRequest().getStatusCode(); |
95 |
| - } |
96 |
| - System.out.println("Exception is " + exception); |
97 |
| - System.out.println("Status message --- codenumber are " + statusCode + " --- " + expCode); |
98 |
| - assertTrue( statusCode.contains("RESTAPI-CONTENTNOVERSION")); |
99 |
| - assertTrue( expCode == 428); |
100 |
| - assertTrue( exception.contains(expectedException)); |
| 88 | + ContentNoVersionException ex = assertThrows(ContentNoVersionException.class, () -> docMgr.write(docUri, handle)); |
| 89 | + assertEquals(428, ex.getServerStatusCode()); |
101 | 90 | }
|
102 | 91 |
|
103 | 92 | @AfterAll
|
|
0 commit comments