protected void loadSchemasIntoSchemasDatabase(CommandContext context) { AppConfig config = context.getAppConfig(); DatabaseClient client = config.newSchemasDatabaseClient(); SchemasLoader schemasLoader = buildSchemasLoader(context, client); try { String schemasPath = config.getSchemasPath(); logger.info("Loading schemas from path: " + schemasPath); schemasLoader.loadSchemas(schemasPath); logger.info("Finished loading schemas from: " + schemasPath); } catch (FailedRequestException fre) { if (fre.getMessage().contains("NOSUCHDB")) { logger.warn("Unable to load schemas because no schemas database exists; cause: " + fre.getMessage()); } else { throw fre; } } finally { client.release(); } }
assertEquals( "Local message: /config/query write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: Operation results in invalid Options: Operator or constraint name \"blah\" is used more than once (must be unique).", e.getMessage()); assertEquals(400, e.getFailedRequest().getStatusCode()); assertEquals("Bad Request", e.getFailedRequest().getStatus());
@Test public void test_582_need_privilege() throws Exception{ try { assertEquals("hello", adminClient.newServerEval() .xquery("'hello'").eval().next().getString()); fail("a FailedRequestException should have been thrown since rest_admin doesn't have eval privileges"); } catch (FailedRequestException fre) { assertTrue(fre.getMessage().contains("SEC-PRIV: Need privilege: http://marklogic.com/xdmp/privileges/xdbc-eval")); } }
@Ignore public void testErrorOnNonREST() throws ForbiddenUserException { DatabaseClient badClient = DatabaseClientFactory.newClient(Common.HOST, 8001, new DigestAuthContext(Common.USER, Common.PASS)); ServerConfigurationManager serverConfig = badClient .newServerConfigManager(); try { serverConfig.readConfiguration(); } catch (FailedRequestException e) { assertEquals( "Local message: config/properties read failed: Not Found. Server Message: Server (not a REST instance?) did not respond with an expected REST Error message.", e.getMessage()); assertEquals(404, e.getFailedRequest().getStatusCode()); assertEquals("UNKNOWN", e.getFailedRequest().getStatus()); } finally { badClient.release(); } }
assertTrue(e.getMessage().contains("TEMPORAL-GTLSQT"));