Skip to content

Commit 7d09d72

Browse files
author
ehennum
committed
use REST API modules database for Data Services #1061
1 parent ea7f8db commit 7d09d72

File tree

4 files changed

+59
-161
lines changed

4 files changed

+59
-161
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/CallManagerImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,18 @@ public Stream<byte[]> many(MultipleCallResponse response) {
16201620
return response.asStreamOfBytes();
16211621
}
16221622
});
1623+
/* TODO: related to #1055
1624+
put(File.class, new ReturnConverter<File>() {
1625+
@Override
1626+
public File one(SingleCallResponse response) {
1627+
return null;
1628+
}
1629+
@Override
1630+
public Stream<File> many(MultipleCallResponse response) {
1631+
return null;
1632+
}
1633+
});
1634+
*/
16231635
put(InputStream.class, new ReturnConverter<InputStream>() {
16241636
@Override
16251637
public InputStream one(SingleCallResponse response) {

marklogic-client-api/src/test/java/com/marklogic/client/test/Common.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public class Common {
6363
final public static int MODULES_WAIT = Integer.parseInt(System.getProperty("TEST_MODULES_WAIT", WITH_WAIT ? "1200" : "0"));
6464
final public static int PROPERTY_WAIT = Integer.parseInt(System.getProperty("TEST_PROPERTY_WAIT", WITH_WAIT ? "8200" : "0"));
6565

66-
final public static int DATA_SERVICE_PORT = Integer.parseInt(System.getProperty("TEST_DATA_SERVICE_PORT", "8016"));
67-
6866
final public static DatabaseClient.ConnectionType CONNECTION_TYPE =
6967
DatabaseClient.ConnectionType.valueOf(System.getProperty("TEST_CONNECT_TYPE", "DIRECT"));
7068

@@ -102,11 +100,6 @@ public static DatabaseClient connectReadOnly() {
102100
readOnlyClient = newReadOnlyClient();
103101
return readOnlyClient;
104102
}
105-
public static DatabaseClient connectDataService() {
106-
if (dataServiceClient == null)
107-
dataServiceClient = newDataServiceClient();
108-
return dataServiceClient;
109-
}
110103
public static DatabaseClient newClient() {
111104
return newClient(null);
112105
}
@@ -144,11 +137,6 @@ public static DatabaseClient newReadOnlyClient() {
144137
Common.HOST, Common.PORT, new DigestAuthContext(Common.READ_ONLY_USER, Common.READ_ONLY_PASS),
145138
CONNECTION_TYPE);
146139
}
147-
public static DatabaseClient newDataServiceClient() {
148-
return DatabaseClientFactory.newClient(Common.HOST, Common.DATA_SERVICE_PORT,
149-
new DatabaseClientFactory.DigestAuthContext(Common.USER, Common.PASS),
150-
CONNECTION_TYPE);
151-
}
152140

153141
public static byte[] streamToBytes(InputStream is) throws IOException {
154142
ByteArrayOutputStream baos = new ByteArrayOutputStream();

marklogic-client-api/src/test/java/com/marklogic/client/test/dataservices/CallManagerTest.java

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class CallManagerTest {
6565

6666
private final static Map<String, Format> NODE_FORMATS = new HashMap<>();
6767

68-
private DatabaseClient db = Common.connectDataService();
68+
private DatabaseClient db = Common.connect();
6969
private CallManager callMgr = CallManager.on(db);
7070

7171
private JacksonHandle serviceHandle;
@@ -86,7 +86,7 @@ public static void setup() {
8686
NODE_FORMATS.put("textDocument", Format.TEXT);
8787
NODE_FORMATS.put("xmlDocument", Format.XML);
8888

89-
DatabaseClient adminClient = Common.newServerAdminClient("DBFUnitTestModules");
89+
DatabaseClient adminClient = Common.newServerAdminClient("java-unittest-modules");
9090
JSONDocumentManager docMgr = adminClient.newJSONDocumentManager();
9191

9292
DocumentMetadataHandle docMeta = new DocumentMetadataHandle();
@@ -131,13 +131,11 @@ public static void setup() {
131131
setupNoParamReturnEndpoint(docMgr, docMeta, "noParamReturn", "double", "5.6");
132132
setupNoParamNoReturnEndpoint(docMgr, docMeta, "noParamNoReturn");
133133

134-
// TODO: negative tests
135-
136134
adminClient.release();
137135
}
138136
@AfterClass
139137
public static void teardown() {
140-
DatabaseClient adminClient = Common.newServerAdminClient("DBFUnitTestModules");
138+
DatabaseClient adminClient = Common.newServerAdminClient("java-unittest-modules");
141139

142140
QueryManager queryMgr = adminClient.newQueryManager();
143141
DeleteQueryDefinition deletedef = queryMgr.newDeleteDefinition();
@@ -792,13 +790,19 @@ public void testBinaryDocument() {
792790

793791
testNode(functionName, callableEndpoint, values);
794792

795-
// TODO: File
796-
797793
BytesHandle[] values2 = convert(values, CallManagerTest::BytesHandle, BytesHandle.class);
798-
CallManager.ManyCaller<BinaryReadHandle> caller4 = makeManyCaller(callableEndpoint, BinaryReadHandle.class);
794+
CallManager.ManyCaller<BinaryReadHandle> caller2 = makeManyCaller(callableEndpoint, BinaryReadHandle.class);
795+
testConvertedCall(
796+
functionName, caller2, caller2.args().param("param1", values2), values, CallManagerTest::string
797+
);
798+
799+
/* TODO:
800+
File value3 = new File("src/test/resources/test.bin");
801+
CallManager.ManyCaller<File> caller3 = makeManyCaller(callableEndpoint, File.class);
799802
testConvertedCall(
800-
functionName, caller4, caller4.args().param("param1", values2), values, CallManagerTest::string
803+
functionName, caller3, caller3.args().param("param1", value3), new String[]{CallManagerTest.string(value3)}, CallManagerTest::string
801804
);
805+
*/
802806
}
803807
@Test
804808
public void testJsonDocument() {
@@ -810,8 +814,6 @@ public void testJsonDocument() {
810814

811815
testCharacterNode(functionName, callableEndpoint, values);
812816

813-
// TODO: File
814-
815817
JsonNode[] values2 = convert(values, CallManagerTest::jsonNode, JsonNode.class);
816818
CallManager.ManyCaller<JsonNode> caller2 = makeManyCaller(callableEndpoint, JsonNode.class);
817819
testConvertedCall(
@@ -829,6 +831,15 @@ public void testJsonDocument() {
829831
testConvertedCall(
830832
functionName, caller4, caller4.args().param("param1", values4), values, CallManagerTest::string
831833
);
834+
835+
/* TODO:
836+
File value5 = new File("src/test/resources/basic1.json");
837+
CallManager.ManyCaller<File> caller5 = makeManyCaller(callableEndpoint, File.class);
838+
testConvertedCall(
839+
functionName, caller3, caller3.args().param("param1", value5),
840+
new String[]{CallManagerTest.string(value5)}, CallManagerTest::string
841+
);
842+
*/
832843
}
833844
@Test
834845
public void testArray() {
@@ -941,13 +952,20 @@ public void testTextDocument() {
941952

942953
testCharacterNode(functionName, callableEndpoint, values);
943954

944-
// TODO: File
945-
946955
StringHandle[] values2 = convert(values, StringHandle::new, StringHandle.class);
947956
CallManager.ManyCaller<TextReadHandle> caller2 = makeManyCaller(callableEndpoint, TextReadHandle.class);
948957
testConvertedCall(
949958
functionName, caller2, caller2.args().param("param1", values2), values, CallManagerTest::string
950959
);
960+
961+
/* TODO:
962+
File value3 = new File("src/test/resources/hola.txt");
963+
CallManager.ManyCaller<File> caller3 = makeManyCaller(callableEndpoint, File.class);
964+
testConvertedCall(
965+
functionName, caller3, caller3.args().param("param1", value3),
966+
new String[]{CallManagerTest.string(value3)}, CallManagerTest::string
967+
);
968+
*/
951969
}
952970
@Test
953971
public void testMultipleNullNode() {
@@ -973,8 +991,6 @@ public void testXmlDocument() {
973991
functionName, caller2, caller2.args().param("param1", values2), values, CallManagerTest::xmlString
974992
);
975993

976-
// TODO: File
977-
978994
InputStream[] values3 = convert(values, CallManagerTest::inputStream, InputStream.class);
979995
CallManager.ManyCaller<InputStream> caller3 = makeManyCaller(callableEndpoint, InputStream.class);
980996
testConvertedCall(
@@ -1027,6 +1043,15 @@ public void testXmlDocument() {
10271043
testConvertedCall(
10281044
functionName, caller11, caller11.args().param("param1", values11), values, CallManagerTest::xmlString
10291045
);
1046+
1047+
/* TODO:
1048+
File value12 = new File("src/test/resources/test.xml");
1049+
CallManager.ManyCaller<File> caller12 = makeManyCaller(callableEndpoint, File.class);
1050+
testConvertedCall(
1051+
functionName, caller3, caller3.args().param("param1", value12),
1052+
new String[]{CallManagerTest.string(value12)}, CallManagerTest::string
1053+
);
1054+
*/
10301055
}
10311056
@Test
10321057
public void testNullNode() {
@@ -1166,6 +1191,13 @@ private static String string(byte[] value) {
11661191
private static String string(Document value) {
11671192
return string(new DOMSource(value));
11681193
}
1194+
private static String string(File value) {
1195+
try {
1196+
return string(new FileInputStream(value));
1197+
} catch (FileNotFoundException e) {
1198+
throw new RuntimeException(e);
1199+
}
1200+
}
11691201
private static String string(InputStreamHandle value) {
11701202
return string(value.get());
11711203
}

marklogic-client-api/src/test/java/com/marklogic/client/test/util/DataServiceBootstrapper.java

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)