Skip to content
Snippets Groups Projects
Commit 1a751853 authored by srosse's avatar srosse
Browse files

FXOLAT-207: remove to tests which are only print.out (but print out of 10'000...

FXOLAT-207: remove to tests which are only print.out (but print out of 10'000 users  while the maven test)
parent 039581d0
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,7 @@ import org.codehaus.jackson.map.ObjectMapper; ...@@ -60,6 +60,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.BaseSecurityManager;
...@@ -174,9 +175,9 @@ public class UserMgmtTest extends OlatJerseyTestCase { ...@@ -174,9 +175,9 @@ public class UserMgmtTest extends OlatJerseyTestCase {
HttpMethod method = createGet("/users", MediaType.APPLICATION_JSON, true); HttpMethod method = createGet("/users", MediaType.APPLICATION_JSON, true);
int code = c.executeMethod(method); int code = c.executeMethod(method);
assertEquals(code, 200); assertEquals(code, 200);
String body = method.getResponseBodyAsString(); InputStream body = method.getResponseBodyAsStream();
method.releaseConnection();
List<UserVO> vos = parseUserArray(body); List<UserVO> vos = parseUserArray(body);
method.releaseConnection();
List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT); List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT);
assertNotNull(vos); assertNotNull(vos);
...@@ -195,9 +196,9 @@ public class UserMgmtTest extends OlatJerseyTestCase { ...@@ -195,9 +196,9 @@ public class UserMgmtTest extends OlatJerseyTestCase {
}); });
int code = c.executeMethod(method); int code = c.executeMethod(method);
assertEquals(code, 200); assertEquals(code, 200);
String body = method.getResponseBodyAsString(); InputStream body = method.getResponseBodyAsStream();
method.releaseConnection();
List<UserVO> vos = parseUserArray(body); List<UserVO> vos = parseUserArray(body);
method.releaseConnection();
String[] authProviders = new String[]{"OLAT"}; String[] authProviders = new String[]{"OLAT"};
List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch("administrator", null, true, null, null, authProviders, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT); List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch("administrator", null, true, null, null, authProviders, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT);
...@@ -226,9 +227,9 @@ public class UserMgmtTest extends OlatJerseyTestCase { ...@@ -226,9 +227,9 @@ public class UserMgmtTest extends OlatJerseyTestCase {
method.addRequestHeader("Accept-Language", "en"); method.addRequestHeader("Accept-Language", "en");
int code = c.executeMethod(method); int code = c.executeMethod(method);
assertEquals(code, 200); assertEquals(code, 200);
String body = method.getResponseBodyAsString(); InputStream body = method.getResponseBodyAsStream();
method.releaseConnection();
List<UserVO> vos = parseUserArray(body); List<UserVO> vos = parseUserArray(body);
method.releaseConnection();
assertNotNull(vos); assertNotNull(vos);
assertFalse(vos.isEmpty()); assertFalse(vos.isEmpty());
...@@ -290,40 +291,6 @@ public class UserMgmtTest extends OlatJerseyTestCase { ...@@ -290,40 +291,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
//no properties for security reason //no properties for security reason
assertTrue(vo.getProperties().isEmpty()); assertTrue(vo.getProperties().isEmpty());
} }
/**
* Only print out the raw body of the response
* @throws IOException
*/
@Test
public void testGetRawJsonUsers() throws IOException {
HttpClient c = loginWithCookie("administrator", "olat");
HttpMethod method = createGet("/users", MediaType.APPLICATION_JSON, true);
int code = c.executeMethod(method);
assertEquals(code, 200);
String bodyJsons = method.getResponseBodyAsString();
System.out.println("Users JSON");
System.out.println(bodyJsons);
System.out.println("Users JSON");
}
/**
* Only print out the raw body of the response
* @throws IOException
*/
@Test
public void testGetRawXmlUsers() throws IOException {
HttpClient c = loginWithCookie("administrator", "olat");
HttpMethod method = createGet("/users", MediaType.APPLICATION_XML, true);
int code = c.executeMethod(method);
assertEquals(code, 200);
String bodyXmls = method.getResponseBodyAsString();
System.out.println("Users XML");
System.out.println(bodyXmls);
System.out.println("Users XML");
}
/** /**
* Only print out the raw body of the response * Only print out the raw body of the response
...@@ -625,6 +592,16 @@ public class UserMgmtTest extends OlatJerseyTestCase { ...@@ -625,6 +592,16 @@ public class UserMgmtTest extends OlatJerseyTestCase {
} }
} }
protected List<UserVO> parseUserArray(InputStream body) {
try {
ObjectMapper mapper = new ObjectMapper(jsonFactory);
return mapper.readValue(body, new TypeReference<List<UserVO>>(){/* */});
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
protected List<GroupVO> parseGroupArray(String body) { protected List<GroupVO> parseGroupArray(String body) {
try { try {
ObjectMapper mapper = new ObjectMapper(jsonFactory); ObjectMapper mapper = new ObjectMapper(jsonFactory);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment