Skip to content

Commit f479b2c

Browse files
georgeajitgeorgeajit
authored andcommitted
Functionl test changes for OKHttp
1 parent 3cb4b53 commit f479b2c

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/BasicJavaClientREST.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,6 @@
111111
import com.marklogic.client.io.XMLEventReaderHandle;
112112
import com.marklogic.client.io.XMLStreamReaderHandle;
113113

114-
115-
116-
//import com.sun.xml.internal.ws.util.xml.StAXSource;
117-
//Importing for http client calls
118-
import org.apache.http.HttpEntity;
119-
import org.apache.http.HttpResponse;
120-
import org.apache.http.util.*;
121-
import org.apache.http.auth.AuthScope;
122-
import org.apache.http.auth.UsernamePasswordCredentials;
123-
import org.apache.http.client.ClientProtocolException;
124-
import org.apache.http.client.methods.HttpDelete;
125-
import org.apache.http.client.methods.HttpPost;
126-
import org.apache.http.client.methods.HttpPut;
127-
import org.apache.http.entity.FileEntity;
128-
import org.apache.http.entity.StringEntity;
129-
import org.apache.http.impl.client.DefaultHttpClient;
130-
import org.apache.http.NameValuePair;
131-
import org.apache.http.message.BasicNameValuePair;
132-
import org.apache.http.client.entity.*;
133-
134-
135114
public abstract class BasicJavaClientREST extends ConnectedRESTQA
136115
{
137116
protected static String checkDoc =

test-complete/src/test/java/com/marklogic/client/functionaltest/TestCRUDModulesDb.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ public void testXQueryModuleCRUDBinaryFile() {
148148
String Path = "/ext/my/path/to/my/module.xqy";
149149

150150
// write XQuery file to the modules database
151-
libsMgr.write(Path, new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/binary.jpg")).withFormat(Format.BINARY));
151+
File fBin = new File("src/test/java/com/marklogic/client/functionaltest/data/binary.jpg");
152+
libsMgr.write(Path, new FileHandle(fBin).withFormat(Format.BINARY));
152153

153154
// read it back
154-
FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/binary.jpg"));
155-
assertEquals(f.getByteLength(),libsMgr.read(Path, new StringHandle()).getByteLength());
155+
assertEquals(fBin.length(), libsMgr.read(Path, new StringHandle()).getByteLength());
156156

157157
// get the list of descriptors
158158
ExtensionLibraryDescriptor[] descriptors = libsMgr.list();
@@ -170,8 +170,7 @@ public void testXQueryModuleCRUDBinaryFile() {
170170
libsMgr.read(Path, new StringHandle()).get();
171171
} catch (ResourceNotFoundException e) {
172172
// pass;
173-
}
174-
173+
}
175174
}
176175

177176

@@ -220,13 +219,16 @@ public void testXQueryModuleCRUDBinaryFile() {
220219
ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
221220

222221
String Path = "/ext/my/path/to/my/module.xqy";
223-
FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/all_well.xml")).withFormat(Format.XML);
224-
222+
File fXML = new File("src/test/java/com/marklogic/client/functionaltest/data/all_well.xml");
223+
FileHandle f = new FileHandle().with(fXML).withFormat(Format.XML);
225224
// write XQuery file to the modules database
226225
libsMgr.write(Path, f);
226+
StringHandle strHandle = new StringHandle();
227227

228228
// read it back
229-
assertEquals(f.getByteLength(), libsMgr.read(Path, new StringHandle()).getByteLength());
229+
assertTrue(libsMgr.read(Path, strHandle).getByteLength()>0);
230+
assertTrue(strHandle.get().contains("All's Well That Ends Well"));
231+
assertTrue(strHandle.get().contains("Exeunt"));
230232

231233
// get the list of descriptors
232234
ExtensionLibraryDescriptor[] descriptors = libsMgr.list();

test-complete/src/test/java/com/marklogic/client/functionaltest/TestDatabaseClientConnection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class TestDatabaseClientConnection extends BasicJavaClientREST{
8383
public static void setUp() throws Exception
8484
{
8585
System.out.println("In setup");
86-
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
86+
//System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
8787
setupJavaRESTServer(dbName, fNames[0], restServerName,8011);
8888

8989
/*
@@ -158,7 +158,7 @@ public void testDatabaseClientConnectionExist()
158158

159159
DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8033, "rest-reader", "x", Authentication.DIGEST);
160160

161-
String expectedException = "com.sun.jersey.api.client.ClientHandlerException: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8033 refused";
161+
String expectedException = "java.net.ConnectException: Failed to connect to localhost";
162162
String exception = "";
163163

164164
// write doc
@@ -167,7 +167,7 @@ public void testDatabaseClientConnectionExist()
167167
}
168168
catch (Exception e) { exception = e.toString(); }
169169

170-
assertEquals("Exception is not thrown", expectedException, exception);
170+
assertTrue("Exception is not thrown", exception.contains(expectedException));
171171

172172
// release client
173173
client.release();

0 commit comments

Comments
 (0)