@BeforeClass public static void beforeClass() { libMgr = adminClient.newServerConfigManager().newExtensionLibrariesManager(); Common.connectEval(); septFirst.set(2014, Calendar.SEPTEMBER, 1, 0, 0, 0); septFirst.set(Calendar.MILLISECOND, 0); } @AfterClass
private void prepareQueryOption() { QueryOptionsManager qryOptMgr = connectionClient.newServerConfigManager().newQueryOptionsManager(); if (StringUtils.isNotEmpty(settings.queryOptionLiterals)) { StringHandle strHandle = new StringHandle(); switch (settings.queryLiteralType) { case "JSON": { strHandle.withFormat(Format.JSON); break; } case "XML": { strHandle.withFormat(Format.XML); break; } } strHandle.set(settings.queryOptionLiterals); qryOptMgr.writeOptions(settings.queryOptionName, strHandle); } }
private static void installModule() throws Exception { // get a modules manager ExtensionLibrariesManager libsMgr = adminClient.newServerConfigManager().newExtensionLibrariesManager(); // write server-side javascript module file to the modules database libsMgr.write("/ext" + directory + "filterUrisReferencedByHolds.sjs", new FileHandle(new File("src/test/resources/legal_holds/filterUrisReferencedByHolds.sjs")) .withFormat(Format.TEXT)); }
public static void installModule() { Common.newAdminClient().newServerConfigManager().newTransformExtensionsManager().writeJavascriptTransform( transformName1, new FileHandle(new File("src/test/resources/" + transformName1))); Common.newAdminClient().newServerConfigManager().newTransformExtensionsManager().writeJavascriptTransform( transformName2, new FileHandle(new File("src/test/resources/" + transformName2))); }
public static void installModule() { Common.newAdminClient().newServerConfigManager().newTransformExtensionsManager().writeJavascriptTransform( transform, new FileHandle(new File("src/test/resources/" + transform))); }
@Test public void testNewQueryOptionsManager() { QueryOptionsManager mgr = Common.adminClient.newServerConfigManager().newQueryOptionsManager(); assertNotNull("Client could not create query options manager", mgr); }
private static void deleteEnvironment() { XMLDocumentManager docMgr = Common.client.newXMLDocumentManager(); docMgr.delete("usa.xml", "cuba.xml", "mexico.xml", "p1.xml", "p2.xml","newpolygon.xml"); Common.adminClient.newServerConfigManager().setQueryValidation(false); Common.propertyWait(); }
@BeforeClass public static void beforeClass() { Common.connectAdmin(); // get a manager libsMgr = Common.adminClient .newServerConfigManager().newExtensionLibrariesManager(); // write XQuery file to the modules database libsMgr.write("/ext/my-lib.xqy", new FileHandle( new File("src/test/resources/my-lib.xqy")).withFormat(Format.TEXT)); Common.connect(); } @AfterClass
@BeforeClass public static void beforeClass() { Common.connectAdmin(); // get a manager libsMgr = Common.adminClient .newServerConfigManager().newExtensionLibrariesManager(); // write XQuery file to the modules database libsMgr.write("/ext/my-lib.xqy", new FileHandle( new File("src/test/resources/my-lib.xqy")).withFormat(Format.TEXT)); Common.connect(); }
@BeforeClass public static void setupTestOptions() throws FileNotFoundException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException { Common.connectAdmin(); QueryOptionsManager queryOptionsManager = Common.adminClient.newServerConfigManager().newQueryOptionsManager(); File options = new File("src/test/resources/alerting-options.xml"); queryOptionsManager.writeOptions("alerts", new FileHandle(options)); Common.adminClient.newServerConfigManager().setServerRequestLogging(true); Common.connect(); JSONDocumentManager jsonDocMgr = Common.client.newJSONDocumentManager(); jsonDocMgr.write("/basic1.json", new FileHandle(new File("src/test/resources/basic1.json"))); // write three files for alert tests. XMLDocumentManager docMgr = Common.client.newXMLDocumentManager(); docMgr.write("/alert/first.xml", new FileHandle(new File("src/test/resources/alertFirst.xml"))); docMgr.write("/alert/second.xml", new FileHandle(new File("src/test/resources/alertSecond.xml"))); docMgr.write("/alert/third.xml", new FileHandle(new File("src/test/resources/alertThird.xml"))); }
@BeforeClass public static void setUp() throws Exception { System.out.println("In setup"); configureRESTServer(dbName, fNames); client = getDatabaseClient("rest-admin", "x", getConnType()); // create a manager for the server configuration configMgr = client.newServerConfigManager(); // read the server configuration from the database configMgr.readConfiguration(); // require content versions for updates and deletes // use Policy.OPTIONAL to allow but not require versions configMgr.setUpdatePolicy(UpdatePolicy.VERSION_REQUIRED); System.out.println("set optimistic locking to required"); // write the server configuration to the database configMgr.writeConfiguration(); }
@Test public void testQueryOptionsManager() throws JAXBException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException { QueryOptionsManager mgr = Common.adminClient.newServerConfigManager().newQueryOptionsManager(); assertNotNull("Client could not create query options manager", mgr); mgr.writeOptions("testempty", new StringHandle("{\"options\":{}}").withFormat(Format.JSON)); String optionsResult = mgr.readOptions("testempty", new StringHandle()).get(); logger.debug("Empty options from server {}", optionsResult); assertTrue("Empty options result not empty",optionsResult.contains("options")); assertTrue("Empty options result not empty",optionsResult.contains("\"http://marklogic.com/appservices/search\"/>")); mgr.deleteOptions("testempty"); };
@BeforeClass public static void beforeClass() throws FailedRequestException, ForbiddenUserException, ResourceNotFoundException, ResourceNotResendableException { serverConfig = adminClient.newServerConfigManager(); serverConfig.readConfiguration(); serverConfig.setUpdatePolicy(UpdatePolicy.VERSION_REQUIRED); serverConfig.writeConfiguration(); Common.propertyWait(); Common.connect(); } @AfterClass
@Test /** Avoid regression on https://github.com/marklogic/java-client-api/issues/761 */ public void test_issue_761() { DatabaseClient client = Common.newClient("Documents"); try { client.newServerConfigManager().newResourceExtensionsManager() .listServices(new DOMHandle()); } finally { client.release(); } }
@Test /** Avoid regression on https://github.com/marklogic/java-client-api/issues/172 */ public void test_172() { ResourceExtensionsManager extensionMgr = Common.adminClient.newServerConfigManager().newResourceExtensionsManager(); Common.adminClient.release(); // since we released the existing connection, clear it out Common.adminClient = null; String expectedMessage = "You cannot use this connected object anymore--connection has already been released"; try { extensionMgr.writeServices(ResourceExtensionsTest.RESOURCE_NAME, null, null); } catch (IllegalStateException e) { assertEquals("Wrong error", expectedMessage, e.getMessage()); } try { extensionMgr.readServices(ResourceExtensionsTest.RESOURCE_NAME, new StringHandle()); } catch (IllegalStateException e) { assertEquals("Wrong error", expectedMessage, e.getMessage()); } try { extensionMgr.listServices(new DOMHandle()); } catch (IllegalStateException e) { assertEquals("Wrong error", expectedMessage, e.getMessage()); } try { extensionMgr.deleteServices(ResourceExtensionsTest.RESOURCE_NAME); } catch (IllegalStateException e) { assertEquals("Wrong error", expectedMessage, e.getMessage()); } }
@Test public void testJSONOptions() throws JAXBException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException { QueryOptionsManager mgr = Common.adminClient.newServerConfigManager().newQueryOptionsManager(); assertNotNull("Client could not create query options manager", mgr); FileHandle jsonHandle = new FileHandle(new File("src/test/resources/json-config.json")); jsonHandle.setFormat(Format.JSON); mgr.writeOptions("jsonoptions", jsonHandle); JsonNode options = mgr.readOptions("jsonoptions", new JacksonHandle()).get(); assertEquals("JSON options came back incorrectly", options.findPath("constraint").get(0).get("name").textValue(), "decade"); StringHandle jsonStringHandle = new StringHandle(); jsonStringHandle.setFormat(Format.JSON); mgr.readOptions("jsonoptions", jsonStringHandle); assertTrue("JSON String from QueryManager must start with json options", jsonStringHandle.get().startsWith("{\"options\":")); mgr.deleteOptions("jsonoptions"); }; }
@AfterClass public static void teardown() throws ForbiddenUserException, FailedRequestException, ResourceNotFoundException { XMLDocumentManager docMgr = adminClient.newXMLDocumentManager(); docMgr.delete("/alert/first.xml"); docMgr.delete("/alert/second.xml"); docMgr.delete("/alert/third.xml"); teardownMatchRules(); transformManager = adminClient.newServerConfigManager().newTransformExtensionsManager(); transformManager.deleteTransform("ruleTransform"); }
@Test public void testValuesPaging() throws IOException, ParserConfigurationException, SAXException { String optionsName = makeValuesOptions(); QueryManager queryMgr = Common.client.newQueryManager(); queryMgr.setPageLength(2); ValuesDefinition vdef = queryMgr.newValuesDefinition("double", optionsName); ValuesHandle v = queryMgr.values(vdef, new ValuesHandle(), 2); CountedDistinctValue dv[] = v.getValues(); assertNotNull("There should be values", dv); assertEquals("There should be 2 values", 2, dv.length); assertEquals("The first value should be '1.2'", dv[0].get("xs:double", Double.class).toString(), "1.2"); assertEquals("The second value should be '2.2'", dv[1].get("xs:double", Double.class).toString(), "2.2"); Common.adminClient.newServerConfigManager().newQueryOptionsManager().deleteOptions(optionsName); }
@BeforeClass public static void setup() throws FileNotFoundException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException { XMLUnit.setIgnoreWhitespace(true); Common.connectAdmin(); writeOptions(Common.adminClient); Common.adminClient.newServerConfigManager().setServerRequestLogging(true); Common.connect(); // write three files for alert tests. XMLDocumentManager docMgr = Common.client.newXMLDocumentManager(); docMgr.write("/sample/suggestion.xml", new StringHandle("<suggest><string>FINDME</string>Something I love to suggest is sugar with savory succulent limes.</suggest>")); docMgr.write("/sample2/suggestion.xml", new StringHandle("<suggest>Something I hate to suggest is liver with lard.</suggest>")); }
@Test public void serverOptionsListRaw() throws IOException, ParserConfigurationException, SAXException, ForbiddenUserException, FailedRequestException { QueryManager queryMgr = Common.client.newQueryManager(); QueryOptionsManager queryOptionsMgr = Common.adminClient.newServerConfigManager().newQueryOptionsManager(); StringHandle results = queryMgr.optionsList(new StringHandle()); assertNotNull(results); String resultsString = results.get(); assertNotNull(resultsString); StringHandle results2 = queryOptionsMgr.optionsList(new StringHandle()); assertNotNull(results2); assertEquals(resultsString, results2.get()); assertNotNull(resultsString); }