@@ -154,7 +154,9 @@ public String deleteJSON(String docUri) {
154154 @ BeforeClass
155155 public static void setUpBeforeClass () throws Exception {
156156 System .out .println ("In setup" );
157- setupJavaRESTServer (dbName , fNames [0 ], restServerName ,restPort );
157+ setupJavaRESTServer (dbName , fNames [0 ], restServerName ,restPort ,false );
158+ createUserRolesWithPrevilages ("test-eval" ,"xdbc:eval" , "xdbc:eval-in" ,"xdmp:eval-in" ,"any-uri" ,"xdbc:invoke" );
159+ createRESTUser ("eval-user" , "x" , "test-eval" ,"rest-admin" ,"rest-writer" ,"rest-reader" );
158160 // System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
159161
160162 }
@@ -167,7 +169,7 @@ public static void tearDownAfterClass() throws Exception {
167169
168170 @ Before
169171 public void setUp () throws Exception {
170- client = DatabaseClientFactory .newClient ("localhost" , restPort , "rest-admin " , "x" , Authentication .DIGEST );
172+ client = DatabaseClientFactory .newClient ("localhost" , restPort ,dbName , "eval-user " , "x" , Authentication .DIGEST );
171173 resourceMgr = client .newServerConfigManager ().newResourceExtensionsManager ();
172174 ExtensionMetadata resextMetadata = new ExtensionMetadata ();
173175 resextMetadata .setTitle ("BasicJSTest" );
@@ -203,7 +205,7 @@ public void test1GetAllResourceServices() throws Exception {
203205 TestJSExtension tjs = new TestJSExtension (client );
204206 String expectedResponse ="{\" response\" :[200, \" OK\" ]}" ;
205207 JSONAssert .assertEquals (expectedResponse , tjs .putJSON ("helloJS.json" ), false );
206- String expAftrPut ="{\" argument1\" :\" helloJS.json\" , \" argument2\" :\" Earth\" , \" document-count\" :1, \" content\" :\" This is a JSON document\" , \" document-content\" :{\" argument1\" :\" hello\" , \" argument2\" :\" Earth\" , \" content\" :\" This is a JSON document\" , \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }, \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
208+ String expAftrPut ="{\" argument1\" :\" helloJS.json\" , \" argument2\" :\" Earth\" ,\" database-name \" : \" TestJSResourceExtensionDB \" , \" document-count\" :1, \" content\" :\" This is a JSON document\" , \" document-content\" :{\" argument1\" :\" hello\" , \" argument2\" :\" Earth\" , \" content\" :\" This is a JSON document\" , \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }, \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
207209 JSONAssert .assertEquals (expAftrPut , tjs .getJSON ("helloJS.json" ), false );
208210 JSONAssert .assertEquals (expectedResponse , tjs .postJSON ("helloJS.json" ), false );
209211 String expAftrPost ="{\" argument1\" :\" helloJS.json\" , \" argument2\" :\" Earth\" , \" document-count\" :1, \" content\" :\" This is a JSON document\" , \" document-content\" :{\" argument1\" :\" hello\" , \" argument2\" :\" Earth\" , \" content\" :\" This is a JSON document\" , \" array\" :[1, 2, 3], \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }, \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
@@ -235,7 +237,7 @@ public void test2GetAllResourceServicesMultipleTimes() throws Exception {
235237 assertEquals ("Total documents loaded are" ,150 ,jh .get ().get ("document-count" ).intValue ());
236238
237239 String expAftrPut ="{\" argument1\" :\" hello\" , \" argument2\" :\" Earth\" , \" content\" :\" This is a JSON document\" , \" array\" :[1, 2, 3], \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
238- String expected ="{\" argument1\" :\" helloJS.json\" , \" argument2\" :\" Earth\" , \" document-count\" :0, \" content\" :\" This is a JSON document\" , \" document-content\" :null, \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
240+ String expected ="{\" argument1\" :\" helloJS.json\" , \" argument2\" :\" Earth\" , \" database-name \" : \" TestJSResourceExtensionDB \" , \" document-count\" :0, \" content\" :\" This is a JSON document\" , \" document-content\" :null, \" response\" :[200, \" OK\" ], \" outputTypes\" :\" application/json\" }" ;
239241// verify by reading all the documents to see put and post services correctly inserted documents and delete them
240242 for (int j =0 ;j <150 ;j ++){
241243 jh .set (jh2 .getMapper ().readTree (tjs .getJSON ("helloJS" +j +".json" )));
0 commit comments