You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2012/03/15 11:17:24 UTC
svn commit: r1300882 [22/22] - in /incubator/syncope/trunk:
build-tools/src/main/java/org/syncope/buildtools/
client/src/main/java/org/syncope/annotation/
client/src/main/java/org/syncope/client/
client/src/main/java/org/syncope/client/http/ client/src...
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/SchemaTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/SchemaTestITCase.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/SchemaTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/SchemaTestITCase.java Thu Mar 15 10:17:12 2012
@@ -45,12 +45,10 @@ public class SchemaTestITCase extends Ab
schemaTO.setMandatoryCondition("false");
schemaTO.setType(SchemaType.String);
- SchemaTO newSchemaTO = restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ SchemaTO newSchemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
assertEquals(schemaTO, newSchemaTO);
- newSchemaTO = restTemplate.postForObject(BASE_URL
- + "schema/membership/create", schemaTO, SchemaTO.class);
+ newSchemaTO = restTemplate.postForObject(BASE_URL + "schema/membership/create", schemaTO, SchemaTO.class);
assertEquals(schemaTO, newSchemaTO);
}
@@ -61,17 +59,14 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.String);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidUSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
assertNotNull(sce.getElements());
assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().
- contains(EntityViolationType.InvalidUSchema.name()));
+ assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidUSchema.name()));
}
}
@@ -82,17 +77,14 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.Enum);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/role/create", schemaTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/role/create", schemaTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidRSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
assertNotNull(sce.getElements());
assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().
- contains(
+ assertTrue(sce.getElements().iterator().next().contains(
EntityViolationType.InvalidSchemaTypeSpecification.name()));
}
}
@@ -104,17 +96,14 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.Enum);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidUSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
assertNotNull(sce.getElements());
assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().
- contains(
+ assertTrue(sce.getElements().iterator().next().contains(
EntityViolationType.InvalidSchemaTypeSpecification.name()));
}
}
@@ -124,8 +113,7 @@ public class SchemaTestITCase extends Ab
restTemplate.delete(BASE_URL + "schema/user/delete/cool.json");
SchemaTO firstname = null;
try {
- firstname = restTemplate.getForObject(BASE_URL
- + "schema/user/read/cool.json", SchemaTO.class);
+ firstname = restTemplate.getForObject(BASE_URL + "schema/user/read/cool.json", SchemaTO.class);
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -134,24 +122,21 @@ public class SchemaTestITCase extends Ab
@Test
public void list() {
- List<SchemaTO> userSchemas = Arrays.asList(
- restTemplate.getForObject(BASE_URL
- + "schema/user/list.json", SchemaTO[].class));
+ List<SchemaTO> userSchemas = Arrays.asList(restTemplate.getForObject(BASE_URL + "schema/user/list.json",
+ SchemaTO[].class));
assertFalse(userSchemas.isEmpty());
for (SchemaTO schemaTO : userSchemas) {
assertNotNull(schemaTO);
}
- List<SchemaTO> roleSchemas = Arrays.asList(
- restTemplate.getForObject(BASE_URL
- + "schema/role/list.json", SchemaTO[].class));
+ List<SchemaTO> roleSchemas = Arrays.asList(restTemplate.getForObject(BASE_URL + "schema/role/list.json",
+ SchemaTO[].class));
assertFalse(roleSchemas.isEmpty());
for (SchemaTO schemaTO : roleSchemas) {
assertNotNull(schemaTO);
}
- List<SchemaTO> membershipSchemas = Arrays.asList(
- restTemplate.getForObject(BASE_URL
+ List<SchemaTO> membershipSchemas = Arrays.asList(restTemplate.getForObject(BASE_URL
+ "schema/membership/list.json", SchemaTO[].class));
assertFalse(membershipSchemas.isEmpty());
for (SchemaTO schemaTO : membershipSchemas) {
@@ -161,22 +146,18 @@ public class SchemaTestITCase extends Ab
@Test
public void update() {
- SchemaTO schemaTO = restTemplate.getForObject(BASE_URL
- + "schema/role/read/icon.json", SchemaTO.class);
+ SchemaTO schemaTO = restTemplate.getForObject(BASE_URL + "schema/role/read/icon.json", SchemaTO.class);
assertNotNull(schemaTO);
- SchemaTO updatedTO = restTemplate.postForObject(BASE_URL
- + "schema/role/update", schemaTO, SchemaTO.class);
+ SchemaTO updatedTO = restTemplate.postForObject(BASE_URL + "schema/role/update", schemaTO, SchemaTO.class);
assertEquals(schemaTO, updatedTO);
updatedTO.setType(SchemaType.Date);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/role/update", updatedTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/role/update", updatedTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidRSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
assertNotNull(sce);
}
}
@@ -187,29 +168,24 @@ public class SchemaTestITCase extends Ab
schemaTO.setName("schema_issue258");
schemaTO.setType(SchemaType.Double);
- schemaTO = restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
assertNotNull(schemaTO);
- UserTO userTO = UserTestITCase.getSampleTO(
- "issue258@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("issue258@syncope-idm.org");
AttributeTO attrTO = new AttributeTO();
attrTO.setSchema(schemaTO.getName());
attrTO.addValue("1.2");
userTO.addAttribute(attrTO);
- userTO = restTemplate.postForObject(BASE_URL + "user/create",
- userTO, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
schemaTO.setType(SchemaType.Long);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/user/update", schemaTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/user/update", schemaTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidUSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
assertNotNull(sce);
}
}
@@ -221,19 +197,16 @@ public class SchemaTestITCase extends Ab
schemaTO.setUniqueConstraint(true);
schemaTO.setType(SchemaType.Long);
- schemaTO = restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
assertNotNull(schemaTO);
- UserTO userTO = UserTestITCase.getSampleTO(
- "issue259@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("issue259@syncope-idm.org");
AttributeTO attrTO = new AttributeTO();
attrTO.setSchema(schemaTO.getName());
attrTO.addValue("1");
userTO.addAttribute(attrTO);
- userTO = restTemplate.postForObject(BASE_URL + "user/create",
- userTO, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
UserTO newUserTO = AttributableOperations.clone(userTO);
@@ -243,8 +216,7 @@ public class SchemaTestITCase extends Ab
UserMod userMod = AttributableOperations.diff(newUserTO, userTO);
- userTO = restTemplate.postForObject(BASE_URL + "user/update",
- userMod, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(userTO);
}
@@ -255,29 +227,24 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.Double);
schemaTO.setUniqueConstraint(true);
- schemaTO = restTemplate.postForObject(BASE_URL
- + "schema/user/create", schemaTO, SchemaTO.class);
+ schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
assertNotNull(schemaTO);
- UserTO userTO = UserTestITCase.getSampleTO(
- "issue260@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("issue260@syncope-idm.org");
AttributeTO attrTO = new AttributeTO();
attrTO.setSchema(schemaTO.getName());
attrTO.addValue("1.2");
userTO.addAttribute(attrTO);
- userTO = restTemplate.postForObject(BASE_URL + "user/create",
- userTO, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
schemaTO.setUniqueConstraint(false);
try {
- restTemplate.postForObject(BASE_URL
- + "schema/user/update", schemaTO, SchemaTO.class);
+ restTemplate.postForObject(BASE_URL + "schema/user/update", schemaTO, SchemaTO.class);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
- SyncopeClientException sce = scce.getException(
- SyncopeClientExceptionType.InvalidUSchema);
+ SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
assertNotNull(sce);
}
}
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/TaskTestITCase.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/TaskTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/TaskTestITCase.java Thu Mar 15 10:17:12 2012
@@ -41,16 +41,14 @@ public class TaskTestITCase extends Abst
@Test
public void getJobClasses() {
- Set<String> jobClasses = restTemplate.getForObject(
- BASE_URL + "task/jobClasses.json", Set.class);
+ Set<String> jobClasses = restTemplate.getForObject(BASE_URL + "task/jobClasses.json", Set.class);
assertNotNull(jobClasses);
assertFalse(jobClasses.isEmpty());
}
@Test
public void getJobActionsClasses() {
- Set<String> actions = restTemplate.getForObject(
- BASE_URL + "task/jobActionsClasses.json", Set.class);
+ Set<String> actions = restTemplate.getForObject(BASE_URL + "task/jobActionsClasses.json", Set.class);
assertNotNull(actions);
assertFalse(actions.isEmpty());
}
@@ -67,14 +65,10 @@ public class TaskTestITCase extends Abst
template.addMembership(membershipTO);
task.setUserTemplate(template);
- SyncTaskTO actual = restTemplate.postForObject(
- BASE_URL + "task/create/sync",
- task, SyncTaskTO.class);
+ SyncTaskTO actual = restTemplate.postForObject(BASE_URL + "task/create/sync", task, SyncTaskTO.class);
assertNotNull(actual);
- task = restTemplate.getForObject(
- BASE_URL + "task/read/{taskId}", SyncTaskTO.class,
- actual.getId());
+ task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, actual.getId());
assertNotNull(task);
assertEquals(actual.getId(), task.getId());
assertEquals(actual.getJobClassName(), task.getJobClassName());
@@ -82,18 +76,14 @@ public class TaskTestITCase extends Abst
@Test
public void update() {
- SchedTaskTO task = restTemplate.getForObject(
- BASE_URL + "task/read/{taskId}", SchedTaskTO.class,
- 5);
+ SchedTaskTO task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SchedTaskTO.class, 5);
assertNotNull(task);
SchedTaskTO taskMod = new SchedTaskTO();
taskMod.setId(5);
taskMod.setCronExpression(null);
- SchedTaskTO actual = restTemplate.postForObject(
- BASE_URL + "task/update/sched",
- taskMod, SchedTaskTO.class);
+ SchedTaskTO actual = restTemplate.postForObject(BASE_URL + "task/update/sched", taskMod, SchedTaskTO.class);
assertNotNull(actual);
assertEquals(task.getId(), actual.getId());
assertNull(actual.getCronExpression());
@@ -101,17 +91,15 @@ public class TaskTestITCase extends Abst
@Test
public void count() {
- Integer count = restTemplate.getForObject(
- BASE_URL + "task/propagation/count.json", Integer.class);
+ Integer count = restTemplate.getForObject(BASE_URL + "task/propagation/count.json", Integer.class);
assertNotNull(count);
assertTrue(count > 0);
}
@Test
public void list() {
- List<PropagationTaskTO> tasks = Arrays.asList(
- restTemplate.getForObject(
- BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list",
+ PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
for (TaskTO task : tasks) {
@@ -121,9 +109,8 @@ public class TaskTestITCase extends Abst
@Test
public void paginatedList() {
- List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(
- BASE_URL + "task/propagation/list/{page}/{size}.json",
- PropagationTaskTO[].class, 1, 2));
+ List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(BASE_URL
+ + "task/propagation/list/{page}/{size}.json", PropagationTaskTO[].class, 1, 2));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
@@ -133,8 +120,7 @@ public class TaskTestITCase extends Abst
assertNotNull(task);
}
- tasks = Arrays.asList(restTemplate.getForObject(
- BASE_URL + "task/propagation/list/{page}/{size}.json",
+ tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list/{page}/{size}.json",
PropagationTaskTO[].class, 2, 2));
assertNotNull(tasks);
@@ -144,8 +130,7 @@ public class TaskTestITCase extends Abst
assertNotNull(task);
}
- tasks = Arrays.asList(restTemplate.getForObject(
- BASE_URL + "task/propagation/list/{page}/{size}.json",
+ tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list/{page}/{size}.json",
PropagationTaskTO[].class, 100, 2));
assertNotNull(tasks);
@@ -154,10 +139,8 @@ public class TaskTestITCase extends Abst
@Test
public void listExecutions() {
- List<TaskExecTO> executions = Arrays.asList(
- restTemplate.getForObject(
- BASE_URL + "task/propagation/execution/list",
- TaskExecTO[].class));
+ List<TaskExecTO> executions = Arrays.asList(restTemplate.getForObject(BASE_URL
+ + "task/propagation/execution/list", TaskExecTO[].class));
assertNotNull(executions);
assertFalse(executions.isEmpty());
for (TaskExecTO execution : executions) {
@@ -167,8 +150,8 @@ public class TaskTestITCase extends Abst
@Test
public void read() {
- PropagationTaskTO taskTO = restTemplate.getForObject(
- BASE_URL + "task/read/{taskId}", PropagationTaskTO.class, 3);
+ PropagationTaskTO taskTO = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class,
+ 3);
assertNotNull(taskTO);
assertNotNull(taskTO.getExecutions());
@@ -177,9 +160,7 @@ public class TaskTestITCase extends Abst
@Test
public void readExecution() {
- TaskExecTO taskTO = restTemplate.getForObject(
- BASE_URL + "task/execution/read/{taskId}",
- TaskExecTO.class, 1);
+ TaskExecTO taskTO = restTemplate.getForObject(BASE_URL + "task/execution/read/{taskId}", TaskExecTO.class, 1);
assertNotNull(taskTO);
}
@@ -191,25 +172,19 @@ public class TaskTestITCase extends Abst
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
- TaskExecTO execution = restTemplate.postForObject(
- BASE_URL + "task/execute/{taskId}", null,
- TaskExecTO.class, 1);
- assertEquals(PropagationTaskExecStatus.SUBMITTED.name(),
- execution.getStatus());
-
- execution = restTemplate.getForObject(
- BASE_URL + "task/execution/report/{executionId}"
- + "?executionStatus=SUCCESS&message=OK",
- TaskExecTO.class, execution.getId());
- assertEquals(PropagationTaskExecStatus.SUCCESS.name(),
- execution.getStatus());
+ TaskExecTO execution = restTemplate
+ .postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class, 1);
+ assertEquals(PropagationTaskExecStatus.SUBMITTED.name(), execution.getStatus());
+
+ execution = restTemplate.getForObject(BASE_URL + "task/execution/report/{executionId}"
+ + "?executionStatus=SUCCESS&message=OK", TaskExecTO.class, execution.getId());
+ assertEquals(PropagationTaskExecStatus.SUCCESS.name(), execution.getStatus());
assertEquals("OK", execution.getMessage());
restTemplate.delete(BASE_URL + "task/delete/{taskId}", 1);
try {
- restTemplate.getForObject(
- BASE_URL + "task/execution/read/{executionId}",
- TaskExecTO.class, execution.getId());
+ restTemplate.getForObject(BASE_URL + "task/execution/read/{executionId}", TaskExecTO.class, execution
+ .getId());
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -310,8 +285,8 @@ public class TaskTestITCase extends Abst
// read executions before sync (dryrun test could be executed before)
int preSyncSize = taskTO.getExecutions().size();
- TaskExecTO execution = restTemplate.postForObject(
- BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class, taskTO.getId());
+ TaskExecTO execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class,
+ taskTO.getId());
assertEquals("JOB_FIRED", execution.getStatus());
int i = 0;
@@ -364,7 +339,7 @@ public class TaskTestITCase extends Abst
// Check for issue 215:
// * expected disabled user test1
// * expected enabled user test2
-
+
userTO = restTemplate.getForObject(BASE_URL + "user/read.json?username=test1", UserTO.class);
assertNotNull(userTO);
assertEquals("suspended", userTO.getStatus());
@@ -412,8 +387,8 @@ public class TaskTestITCase extends Abst
// read executions before sync (dryrun test could be executed before)
int preSyncSize = actual.getExecutions().size();
- TaskExecTO execution = restTemplate.postForObject(
- BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class, actual.getId());
+ TaskExecTO execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class,
+ actual.getId());
assertEquals("JOB_FIRED", execution.getStatus());
int i = 0;
@@ -449,8 +424,8 @@ public class TaskTestITCase extends Abst
@Test
public void issue196() {
- TaskExecTO execution = restTemplate.postForObject(
- BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class, 6);
+ TaskExecTO execution = restTemplate
+ .postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class, 6);
assertNotNull(execution);
assertEquals(0, execution.getId());
assertNotNull(execution.getTask());
@@ -465,8 +440,8 @@ public class TaskTestITCase extends Abst
int preDryRunSize = taskTO.getExecutions().size();
- TaskExecTO execution = restTemplate.postForObject(
- BASE_URL + "task/execute/{taskId}?dryRun=true", null, TaskExecTO.class, 4);
+ TaskExecTO execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}?dryRun=true", null,
+ TaskExecTO.class, 4);
assertNotNull(execution);
// wait for sync completion (executions incremented)
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserRequestTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserRequestTestITCase.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserRequestTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserRequestTestITCase.java Thu Mar 15 10:17:12 2012
@@ -42,27 +42,21 @@ public class UserRequestTestITCase exten
@Test
public void selfRead() {
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory) restTemplate.
- getRequestFactory());
- ((DefaultHttpClient) requestFactory.getHttpClient()).
- getCredentialsProvider().setCredentials(
- requestFactory.getAuthScope(),
- new UsernamePasswordCredentials("user1", "password"));
+ PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
+ .getRequestFactory());
+ ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
+ requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));
SyncopeClientException exception = null;
try {
- restTemplate.getForObject(
- BASE_URL + "user/read/{userId}.json", UserTO.class, 1);
+ restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, 1);
fail();
} catch (SyncopeClientCompositeErrorException e) {
- exception = e.getException(
- SyncopeClientExceptionType.UnauthorizedRole);
+ exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
}
assertNotNull(exception);
- UserTO userTO = restTemplate.getForObject(
- BASE_URL + "user/request/read/self", UserTO.class);
+ UserTO userTO = restTemplate.getForObject(BASE_URL + "user/request/read/self", UserTO.class);
assertEquals("user1", userTO.getUsername());
}
@@ -73,37 +67,32 @@ public class UserRequestTestITCase exten
configurationTO.setKey("createRequest.allowed");
configurationTO.setValue("false");
- configurationTO = restTemplate.postForObject(
- BASE_URL + "configuration/create",
- configurationTO, ConfigurationTO.class);
+ configurationTO = restTemplate.postForObject(BASE_URL + "configuration/create", configurationTO,
+ ConfigurationTO.class);
assertNotNull(configurationTO);
- UserTO userTO = UserTestITCase.getSampleTO(
- "selfcreate@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("selfcreate@syncope-idm.org");
// 2. get unauthorized when trying to request user create
SyncopeClientException exception = null;
try {
- restTemplate.postForObject(BASE_URL + "user/request/create",
- userTO, UserRequestTO.class);
+ restTemplate.postForObject(BASE_URL + "user/request/create", userTO, UserRequestTO.class);
fail();
} catch (SyncopeClientCompositeErrorException e) {
- exception = e.getException(
- SyncopeClientExceptionType.UnauthorizedRole);
+ exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
}
assertNotNull(exception);
// 3. set create request allowed
configurationTO.setValue("true");
- configurationTO = restTemplate.postForObject(
- BASE_URL + "configuration/create",
- configurationTO, ConfigurationTO.class);
+ configurationTO = restTemplate.postForObject(BASE_URL + "configuration/create", configurationTO,
+ ConfigurationTO.class);
assertNotNull(configurationTO);
// 4. as anonymous, request user create works
- UserRequestTO request = anonymousRestTemplate().postForObject(
- BASE_URL + "user/request/create", userTO, UserRequestTO.class);
+ UserRequestTO request = anonymousRestTemplate().postForObject(BASE_URL + "user/request/create", userTO,
+ UserRequestTO.class);
assertNotNull(request);
// 5. switch back to admin
@@ -114,26 +103,22 @@ public class UserRequestTestITCase exten
attrCond.setSchema("userId");
attrCond.setExpression("selfcreate@syncope-idm.org");
- final List<UserTO> matchingUsers = Arrays.asList(
- restTemplate.postForObject(BASE_URL + "user/search",
- NodeCond.getLeafCond(attrCond), UserTO[].class));
+ final List<UserTO> matchingUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search", NodeCond
+ .getLeafCond(attrCond), UserTO[].class));
assertTrue(matchingUsers.isEmpty());
// 7. actually create user
- userTO = restTemplate.postForObject(
- BASE_URL + "user/create", request.getUserTO(), UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", request.getUserTO(), UserTO.class);
assertNotNull(userTO);
}
@Test
public void update() {
// 1. create an user (as admin)
- UserTO userTO = UserTestITCase.getSampleTO(
- "selfupdate@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("selfupdate@syncope-idm.org");
String initialPassword = userTO.getPassword();
- userTO = restTemplate.postForObject(
- BASE_URL + "user/create", userTO, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
UserMod userMod = new UserMod();
@@ -143,62 +128,48 @@ public class UserRequestTestITCase exten
// 2. try to request user update as admin: failure
SyncopeClientException exception = null;
try {
- restTemplate.postForObject(BASE_URL + "user/request/update",
- userMod, UserRequestTO.class);
+ restTemplate.postForObject(BASE_URL + "user/request/update", userMod, UserRequestTO.class);
fail();
} catch (SyncopeClientCompositeErrorException e) {
- exception = e.getException(
- SyncopeClientExceptionType.UnauthorizedRole);
+ exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
}
assertNotNull(exception);
// 3. auth as user just created
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory) restTemplate.
- getRequestFactory());
- ((DefaultHttpClient) requestFactory.getHttpClient()).
- getCredentialsProvider().setCredentials(
- requestFactory.getAuthScope(),
- new UsernamePasswordCredentials(userTO.getUsername(),
- initialPassword));
+ PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
+ .getRequestFactory());
+ ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
+ requestFactory.getAuthScope(), new UsernamePasswordCredentials(userTO.getUsername(), initialPassword));
// 4. update with same password: not matching password policy
exception = null;
try {
- restTemplate.postForObject(BASE_URL + "user/request/update",
- userMod, UserRequestTO.class);
+ restTemplate.postForObject(BASE_URL + "user/request/update", userMod, UserRequestTO.class);
} catch (SyncopeClientCompositeErrorException scce) {
- exception = scce.getException(
- SyncopeClientExceptionType.InvalidSyncopeUser);
+ exception = scce.getException(SyncopeClientExceptionType.InvalidSyncopeUser);
}
assertNotNull(exception);
// 5. now request user update works
userMod.setPassword("new" + initialPassword);
- UserRequestTO request = restTemplate.postForObject(
- BASE_URL + "user/request/update",
- userMod, UserRequestTO.class);
+ UserRequestTO request = restTemplate.postForObject(BASE_URL + "user/request/update", userMod,
+ UserRequestTO.class);
assertNotNull(request);
// 6. switch back to admin
super.setupRestTemplate();
// 7. user password has not changed yet
- Boolean verify = restTemplate.getForObject(
- BASE_URL + "user/verifyPassword/{userId}?password="
- + userMod.getPassword(),
- Boolean.class, userTO.getId());
+ Boolean verify = restTemplate.getForObject(BASE_URL + "user/verifyPassword/{userId}?password="
+ + userMod.getPassword(), Boolean.class, userTO.getId());
assertFalse(verify);
// 8. actually update user
- userTO = restTemplate.postForObject(BASE_URL + "user/update",
- userMod, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(userTO);
// 9. user password has now changed
- verify = restTemplate.getForObject(
- BASE_URL + "user/verifyPassword/{userId}?password="
- + userMod.getPassword(),
+ verify = restTemplate.getForObject(BASE_URL + "user/verifyPassword/{userId}?password=" + userMod.getPassword(),
Boolean.class, userTO.getId());
assertTrue(verify);
}
@@ -206,59 +177,46 @@ public class UserRequestTestITCase exten
@Test
public void delete() {
// 1. create an user (as admin)
- UserTO userTO = UserTestITCase.getSampleTO(
- "selfdelete@syncope-idm.org");
+ UserTO userTO = UserTestITCase.getSampleTO("selfdelete@syncope-idm.org");
String initialPassword = userTO.getPassword();
- userTO = restTemplate.postForObject(
- BASE_URL + "user/create", userTO, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
// 2. try to request user delete as admin: failure
SyncopeClientException exception = null;
try {
- restTemplate.postForObject(BASE_URL + "user/request/delete/",
- userTO.getId(), UserRequestTO.class);
+ restTemplate.postForObject(BASE_URL + "user/request/delete/", userTO.getId(), UserRequestTO.class);
fail();
} catch (SyncopeClientCompositeErrorException e) {
- exception = e.getException(
- SyncopeClientExceptionType.UnauthorizedRole);
+ exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
}
assertNotNull(exception);
// 3. auth as user just created
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory) restTemplate.
- getRequestFactory());
- ((DefaultHttpClient) requestFactory.getHttpClient()).
- getCredentialsProvider().setCredentials(
- requestFactory.getAuthScope(),
- new UsernamePasswordCredentials(userTO.getUsername(),
- initialPassword));
+ PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
+ .getRequestFactory());
+ ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
+ requestFactory.getAuthScope(), new UsernamePasswordCredentials(userTO.getUsername(), initialPassword));
// 4. now request user delete works
- UserRequestTO request = restTemplate.postForObject(
- BASE_URL + "user/request/delete",
- userTO.getId(), UserRequestTO.class);
+ UserRequestTO request = restTemplate.postForObject(BASE_URL + "user/request/delete", userTO.getId(),
+ UserRequestTO.class);
assertNotNull(request);
// 5. switch back to admin
super.setupRestTemplate();
// 6. user still exists
- UserTO actual = restTemplate.getForObject(
- BASE_URL + "user/read/{userId}.json",
- UserTO.class, userTO.getId());
+ UserTO actual = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userTO.getId());
assertNotNull(actual);
// 7. actually delete user
- restTemplate.getForObject(BASE_URL + "user/delete/{userId}",
- UserTO.class, userTO.getId());
+ restTemplate.getForObject(BASE_URL + "user/delete/{userId}", UserTO.class, userTO.getId());
// 8. user does not exist any more
try {
- restTemplate.getForObject(BASE_URL + "user/read/{userId}.json",
- UserTO.class, userTO.getId());
+ restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userTO.getId());
fail();
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserTestITCase.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserTestITCase.java Thu Mar 15 10:17:12 2012
@@ -124,9 +124,8 @@ public class UserTestITCase extends Abst
@Test
public void createUserWithNoPropagation() {
// get task list
- List<PropagationTaskTO> tasks = Arrays.asList(
- restTemplate.getForObject(
- BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list",
+ PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
@@ -166,13 +165,10 @@ public class UserTestITCase extends Abst
userTO.setPassword("password123");
userTO.addResource("ws-target-resource-nopropagation");
- restTemplate.postForObject(BASE_URL + "user/create",
- userTO, UserTO.class);
+ restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
// get the new task list
- tasks = Arrays.asList(
- restTemplate.getForObject(
- BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
@@ -188,8 +184,7 @@ public class UserTestITCase extends Abst
assertTrue(newMaxId > maxId);
// get last task
- PropagationTaskTO taskTO = restTemplate.getForObject(
- BASE_URL + "task/read/{taskId}", PropagationTaskTO.class,
+ PropagationTaskTO taskTO = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class,
newMaxId);
assertNotNull(taskTO);
@@ -204,8 +199,7 @@ public class UserTestITCase extends Abst
* introducing a simple control.
*/
public void issue172() {
- PolicyTO policyTO = restTemplate.getForObject(
- BASE_URL + "policy/read/{id}", PasswordPolicyTO.class, 2L);
+ PolicyTO policyTO = restTemplate.getForObject(BASE_URL + "policy/read/{id}", PasswordPolicyTO.class, 2L);
assertNotNull(policyTO);
@@ -235,12 +229,9 @@ public class UserTestITCase extends Abst
attributeTO.addValue("issue172");
userTO.addAttribute(attributeTO);
- restTemplate.postForObject(
- BASE_URL + "user/create", userTO, UserTO.class);
+ restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
- policyTO = restTemplate.postForObject(
- BASE_URL + "policy/password/create",
- policyTO, PasswordPolicyTO.class);
+ policyTO = restTemplate.postForObject(BASE_URL + "policy/password/create", policyTO, PasswordPolicyTO.class);
assertNotNull(policyTO);
}
@@ -280,11 +271,9 @@ public class UserTestITCase extends Abst
SyncopeClientException sce = null;
try {
- userTO = restTemplate.postForObject(
- BASE_URL + "user/update", userMod, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
} catch (SyncopeClientCompositeErrorException scce) {
- sce = scce.getException(
- SyncopeClientExceptionType.RequiredValuesMissing);
+ sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
}
assertNotNull(sce);
@@ -297,8 +286,7 @@ public class UserTestITCase extends Abst
sce = null;
try {
- userTO = restTemplate.postForObject(BASE_URL + "user/update",
- userMod, UserTO.class);
+ userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
} catch (SyncopeClientCompositeErrorException scce) {
sce = scce.getException(SyncopeClientExceptionType.Propagation);
}
@@ -338,8 +326,7 @@ public class UserTestITCase extends Abst
try {
userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
} catch (SyncopeClientCompositeErrorException scce) {
- sce = scce.getException(
- SyncopeClientExceptionType.RequiredValuesMissing);
+ sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
}
assertNotNull(sce);
@@ -447,8 +434,8 @@ public class UserTestITCase extends Abst
@Test
public void create() {
// get task list
- List<PropagationTaskTO> tasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list",
+ PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
@@ -460,8 +447,8 @@ public class UserTestITCase extends Abst
maxId = task.getId();
}
}
- PropagationTaskTO taskTO =
- restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class, maxId);
+ PropagationTaskTO taskTO = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class,
+ maxId);
assertNotNull(taskTO);
int maxTaskExecutions = taskTO.getExecutions().size();
@@ -535,12 +522,12 @@ public class UserTestITCase extends Abst
assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
// 3. verify password
- Boolean verify = restTemplate.getForObject(
- BASE_URL + "user/verifyPassword/{userId}?password=password123", Boolean.class, newUserTO.getId());
+ Boolean verify = restTemplate.getForObject(BASE_URL + "user/verifyPassword/{userId}?password=password123",
+ Boolean.class, newUserTO.getId());
assertTrue(verify);
- verify = restTemplate.getForObject(
- BASE_URL + "user/verifyPassword/{userId}?password=passwordXX", Boolean.class, newUserTO.getId());
+ verify = restTemplate.getForObject(BASE_URL + "user/verifyPassword/{userId}?password=passwordXX",
+ Boolean.class, newUserTO.getId());
assertFalse(verify);
// 4. try (and fail) to create another user with same (unique) values
@@ -630,23 +617,23 @@ public class UserTestITCase extends Abst
assertEquals("createApproval", userTO.getStatus());
// 2. request if there is any pending task for user just created
- WorkflowFormTO form = restTemplate.getForObject(
- BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class, userTO.getId());
+ WorkflowFormTO form = restTemplate.getForObject(BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class,
+ userTO.getId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
// 3. claim task from user1, not in role 7 (designated for
// approval in workflow definition): fail
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());
+ PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
+ .getRequestFactory());
((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));
SyncopeClientException sce = null;
try {
- restTemplate.getForObject(
- BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.getTaskId());
+ restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form
+ .getTaskId());
} catch (SyncopeClientCompositeErrorException scce) {
sce = scce.getException(SyncopeClientExceptionType.Workflow);
}
@@ -656,8 +643,8 @@ public class UserTestITCase extends Abst
((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
requestFactory.getAuthScope(), new UsernamePasswordCredentials("user4", "password"));
- form = restTemplate.getForObject(
- BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.getTaskId());
+ form = restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form
+ .getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNotNull(form.getOwner());
@@ -706,15 +693,15 @@ public class UserTestITCase extends Abst
assertNotNull(exception);
// 2. request if there is any pending task for user just created
- WorkflowFormTO form = restTemplate.getForObject(
- BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class, userTO.getId());
+ WorkflowFormTO form = restTemplate.getForObject(BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class,
+ userTO.getId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
// 4. claim task (from admin)
- form = restTemplate.getForObject(
- BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.getTaskId());
+ form = restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form
+ .getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNotNull(form.getOwner());
@@ -730,8 +717,8 @@ public class UserTestITCase extends Abst
exception = null;
try {
- final String username =
- jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class, userTO.getUsername());
+ final String username = jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class, userTO
+ .getUsername());
assertEquals(userTO.getUsername(), username);
} catch (EmptyResultDataAccessException e) {
exception = e;
@@ -811,8 +798,8 @@ public class UserTestITCase extends Abst
@Test
public void paginatedList() {
- List<UserTO> users = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 1, 2));
+ List<UserTO> users = Arrays.asList(restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json",
+ UserTO[].class, 1, 2));
assertNotNull(users);
assertFalse(users.isEmpty());
@@ -822,15 +809,15 @@ public class UserTestITCase extends Abst
assertNotNull(user);
}
- users = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 2, 2));
+ users = Arrays.asList(restTemplate
+ .getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 2, 2));
assertNotNull(users);
assertFalse(users.isEmpty());
assertEquals(2, users.size());
- users = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 100, 2));
+ users = Arrays.asList(restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 100,
+ 2));
assertNotNull(users);
assertTrue(users.isEmpty());
@@ -856,13 +843,13 @@ public class UserTestITCase extends Abst
fullnameLeafCond2.setSchema("fullname");
fullnameLeafCond2.setExpression("%i%");
- NodeCond searchCondition =
- NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond.getLeafCond(fullnameLeafCond2));
+ NodeCond searchCondition = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond
+ .getLeafCond(fullnameLeafCond2));
assertTrue(searchCondition.checkValidity());
- List<UserTO> matchedUsers = Arrays.asList(
- restTemplate.postForObject(BASE_URL + "user/search", searchCondition, UserTO[].class));
+ List<UserTO> matchedUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search", searchCondition,
+ UserTO[].class));
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
for (UserTO user : matchedUsers) {
@@ -874,8 +861,8 @@ public class UserTestITCase extends Abst
isNullCond.setSchema("loginDate");
searchCondition = NodeCond.getLeafCond(isNullCond);
- matchedUsers = Arrays.asList(
- restTemplate.postForObject(BASE_URL + "user/search", searchCondition, UserTO[].class));
+ matchedUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search", searchCondition,
+ UserTO[].class));
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
@@ -897,13 +884,13 @@ public class UserTestITCase extends Abst
idRightCond.setSchema("id");
idRightCond.setExpression("2");
- final NodeCond searchCondition = NodeCond.getAndCond(
- NodeCond.getLeafCond(usernameLeafCond), NodeCond.getLeafCond(idRightCond));
+ final NodeCond searchCondition = NodeCond.getAndCond(NodeCond.getLeafCond(usernameLeafCond), NodeCond
+ .getLeafCond(idRightCond));
assertTrue(searchCondition.checkValidity());
- final List<UserTO> matchingUsers = Arrays.asList(
- restTemplate.postForObject(BASE_URL + "user/search", searchCondition, UserTO[].class));
+ final List<UserTO> matchingUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search",
+ searchCondition, UserTO[].class));
assertNotNull(matchingUsers);
assertEquals(1, matchingUsers.size());
@@ -923,8 +910,8 @@ public class UserTestITCase extends Abst
assertTrue(searchCondition.checkValidity());
- List<UserTO> matchedUsers = Arrays.asList(
- restTemplate.postForObject(BASE_URL + "user/search", searchCondition, UserTO[].class));
+ List<UserTO> matchedUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search", searchCondition,
+ UserTO[].class));
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
@@ -948,13 +935,13 @@ public class UserTestITCase extends Abst
fullnameLeafCond2.setSchema("fullname");
fullnameLeafCond2.setExpression("%i%");
- NodeCond searchCondition =
- NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond.getLeafCond(fullnameLeafCond2));
+ NodeCond searchCondition = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond
+ .getLeafCond(fullnameLeafCond2));
assertTrue(searchCondition.checkValidity());
- List<UserTO> matchedUsers = Arrays.asList(restTemplate.postForObject(
- BASE_URL + "user/search/{page}/{size}", searchCondition, UserTO[].class, 1, 2));
+ List<UserTO> matchedUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search/{page}/{size}",
+ searchCondition, UserTO[].class, 1, 2));
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
@@ -967,8 +954,8 @@ public class UserTestITCase extends Abst
isNullCond.setSchema("loginDate");
searchCondition = NodeCond.getLeafCond(isNullCond);
- matchedUsers = Arrays.asList(restTemplate.postForObject(
- BASE_URL + "user/search/{page}/{size}", searchCondition, UserTO[].class, 1, 2));
+ matchedUsers = Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search/{page}/{size}",
+ searchCondition, UserTO[].class, 1, 2));
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
@@ -1101,8 +1088,8 @@ public class UserTestITCase extends Abst
@Test
public void updatePasswordOnly() {
- List<PropagationTaskTO> beforeTasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> beforeTasks = Arrays.asList(restTemplate.getForObject(BASE_URL
+ + "task/propagation/list", PropagationTaskTO[].class));
assertNotNull(beforeTasks);
assertFalse(beforeTasks.isEmpty());
@@ -1130,8 +1117,8 @@ public class UserTestITCase extends Abst
passwordTestUser.setPassword("newPassword", CipherAlgorithm.MD5, 0);
assertEquals(passwordTestUser.getPassword(), userTO.getPassword());
- List<PropagationTaskTO> afterTasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> afterTasks = Arrays.asList(restTemplate.getForObject(
+ BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
assertNotNull(afterTasks);
assertFalse(afterTasks.isEmpty());
@@ -1141,8 +1128,8 @@ public class UserTestITCase extends Abst
@Test
public void verifyTaskRegistration() {
// get task list
- List<PropagationTaskTO> tasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ List<PropagationTaskTO> tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list",
+ PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
@@ -1205,8 +1192,7 @@ public class UserTestITCase extends Abst
assertNotNull(userTO);
// get the new task list
- tasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
// get max task id
maxId = newMaxId;
@@ -1227,8 +1213,7 @@ public class UserTestITCase extends Abst
restTemplate.getForObject(BASE_URL + "user/delete/{userId}", UserTO.class, userTO.getId());
// get the new task list
- tasks = Arrays.asList(
- restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
+ tasks = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
// get max task id
maxId = newMaxId;
@@ -1276,14 +1261,14 @@ public class UserTestITCase extends Abst
userTO.getMemberships().clear();
userTO.getResources().clear();
- ResourceTO dbTable = restTemplate.getForObject(
- BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class, "resource-testdb");
+ ResourceTO dbTable = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json",
+ ResourceTO.class, "resource-testdb");
assertNotNull(dbTable);
userTO.addResource(dbTable.getName());
- ResourceTO ldap = restTemplate.getForObject(
- BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class, "resource-ldap");
+ ResourceTO ldap = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class,
+ "resource-ldap");
assertNotNull(ldap);
userTO.addResource(ldap.getName());
@@ -1293,8 +1278,7 @@ public class UserTestITCase extends Abst
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
- String query = "?resourceNames=" + dbTable.getName()
- + "&resourceNames=" + ldap.getName()
+ String query = "?resourceNames=" + dbTable.getName() + "&resourceNames=" + ldap.getName()
+ "&performLocally=true"; // check also performLocally
userTO = restTemplate.getForObject(BASE_URL + "user/suspend/" + userTO.getId() + query, UserTO.class);
@@ -1305,12 +1289,11 @@ public class UserTestITCase extends Abst
String dbTableUID = userTO.getUsername();
assertNotNull(dbTableUID);
- ConnObjectTO connObjectTO = restTemplate.getForObject(
- BASE_URL + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, dbTable.getName(),
- dbTableUID);
+ ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
+ + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, dbTable.getName(), dbTableUID);
- assertFalse(Boolean.parseBoolean(
- connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME).getValues().get(0)));
+ assertFalse(Boolean.parseBoolean(connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME)
+ .getValues().get(0)));
String ldapUID = userTO.getUsername();
assertNotNull(ldapUID);
@@ -1320,8 +1303,7 @@ public class UserTestITCase extends Abst
assertNotNull(connObjectTO);
- query = "?resourceNames=" + ldap.getName()
- + "&performLocally=false"; // check also performLocally
+ query = "?resourceNames=" + ldap.getName() + "&performLocally=false"; // check also performLocally
userTO = restTemplate.getForObject(BASE_URL + "user/reactivate/" + userTO.getId() + query, UserTO.class);
@@ -1331,8 +1313,8 @@ public class UserTestITCase extends Abst
connObjectTO = restTemplate.getForObject(BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
ConnObjectTO.class, dbTable.getName(), dbTableUID);
- assertFalse(Boolean.parseBoolean(
- connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME).getValues().get(0)));
+ assertFalse(Boolean.parseBoolean(connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME)
+ .getValues().get(0)));
query = "?resourceNames=" + dbTable.getName() + "&performLocally=true"; // check also performLocally
@@ -1344,8 +1326,8 @@ public class UserTestITCase extends Abst
connObjectTO = restTemplate.getForObject(BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
ConnObjectTO.class, dbTable.getName(), dbTableUID);
- assertTrue(Boolean.parseBoolean(
- connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME).getValues().get(0)));
+ assertTrue(Boolean.parseBoolean(connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME)
+ .getValues().get(0)));
}
@Test(expected = EmptyResultDataAccessException.class)
@@ -1358,8 +1340,8 @@ public class UserTestITCase extends Abst
JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
- String username =
- jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class, userTO.getUsername());
+ String username = jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class, userTO
+ .getUsername());
assertEquals(userTO.getUsername(), username);
@@ -1408,8 +1390,8 @@ public class UserTestITCase extends Abst
assertTrue(original.getVirtualAttributes().isEmpty());
- UserTO toBeUpdated = restTemplate.getForObject(
- BASE_URL + "user/read/{userId}.json", UserTO.class, original.getId());
+ UserTO toBeUpdated = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, original
+ .getId());
AttributeTO virtual = new AttributeTO();
@@ -1529,9 +1511,9 @@ public class UserTestITCase extends Abst
assertNotNull(actual);
assertNotNull(actual.getDerivedAttributeMap().get("csvuserid"));
- ConnObjectTO connObjectTO = restTemplate.getForObject(
- BASE_URL + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv",
- actual.getDerivedAttributeMap().get("csvuserid").getValues().get(0));
+ ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
+ + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv", actual
+ .getDerivedAttributeMap().get("csvuserid").getValues().get(0));
assertNotNull(connObjectTO);
@@ -1576,9 +1558,9 @@ public class UserTestITCase extends Abst
assertNotNull(actual);
assertNotNull(actual.getDerivedAttributeMap().get("csvuserid"));
- ConnObjectTO connObjectTO = restTemplate.getForObject(
- BASE_URL + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv",
- actual.getDerivedAttributeMap().get("csvuserid").getValues().get(0));
+ ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
+ + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv", actual
+ .getDerivedAttributeMap().get("csvuserid").getValues().get(0));
assertNotNull(connObjectTO);
@@ -1604,18 +1586,18 @@ public class UserTestITCase extends Abst
UserMod userMod = new UserMod();
userMod.setId(actual.getId());
-
+
AttributeMod virtualdata = new AttributeMod();
virtualdata.setSchema("virtualdata");
virtualdata.addValueToBeAdded("virtualupdated");
-
+
userMod.addVirtualAttributeToBeRemoved("virtualdata");
userMod.addVirtualAttributeToBeUpdated(virtualdata);
-
+
// 3. update virtual attribute
actual = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(actual);
-
+
// 4. check for virtual attribute value
actual = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, actual.getId());
assertNotNull(actual);
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/VirtualSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/VirtualSchemaTestITCase.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/VirtualSchemaTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/VirtualSchemaTestITCase.java Thu Mar 15 10:17:12 2012
@@ -30,8 +30,7 @@ public class VirtualSchemaTestITCase ext
@Test
public void list() {
- List<VirtualSchemaTO> VirtualSchemas = Arrays.asList(
- restTemplate.getForObject(BASE_URL
+ List<VirtualSchemaTO> VirtualSchemas = Arrays.asList(restTemplate.getForObject(BASE_URL
+ "virtualSchema/user/list.json", VirtualSchemaTO[].class));
assertFalse(VirtualSchemas.isEmpty());
for (VirtualSchemaTO VirtualSchemaTO : VirtualSchemas) {
@@ -42,8 +41,7 @@ public class VirtualSchemaTestITCase ext
@Test
public void read() {
VirtualSchemaTO VirtualSchemaTO = restTemplate.getForObject(BASE_URL
- + "virtualSchema/membership/read/mvirtualdata.json",
- VirtualSchemaTO.class);
+ + "virtualSchema/membership/read/mvirtualdata.json", VirtualSchemaTO.class);
assertNotNull(VirtualSchemaTO);
}
@@ -52,33 +50,26 @@ public class VirtualSchemaTestITCase ext
VirtualSchemaTO schema = new VirtualSchemaTO();
schema.setName("virtual");
- VirtualSchemaTO actual = restTemplate.postForObject(BASE_URL
- + "virtualSchema/user/create.json",
- schema,
+ VirtualSchemaTO actual = restTemplate.postForObject(BASE_URL + "virtualSchema/user/create.json", schema,
VirtualSchemaTO.class);
assertNotNull(actual);
- actual = restTemplate.getForObject(BASE_URL
- + "virtualSchema/user/read/" + actual.getName() + ".json",
+ actual = restTemplate.getForObject(BASE_URL + "virtualSchema/user/read/" + actual.getName() + ".json",
VirtualSchemaTO.class);
assertNotNull(actual);
}
@Test
public void delete() {
- VirtualSchemaTO schema = restTemplate.getForObject(BASE_URL
- + "virtualSchema/role/read/rvirtualdata.json",
+ VirtualSchemaTO schema = restTemplate.getForObject(BASE_URL + "virtualSchema/role/read/rvirtualdata.json",
VirtualSchemaTO.class);
assertNotNull(schema);
- restTemplate.delete(
- BASE_URL + "virtualSchema/role/delete/{schema}",
- schema.getName());
+ restTemplate.delete(BASE_URL + "virtualSchema/role/delete/{schema}", schema.getName());
Throwable t = null;
try {
- schema = restTemplate.getForObject(BASE_URL
- + "virtualSchema/role/read/rvirtualdata.json",
+ schema = restTemplate.getForObject(BASE_URL + "virtualSchema/role/read/rvirtualdata.json",
VirtualSchemaTO.class);
} catch (SyncopeClientCompositeErrorException e) {
t = e;
Modified: incubator/syncope/trunk/core/src/test/java/org/syncope/core/scheduling/TestSyncJobActions.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/syncope/core/scheduling/TestSyncJobActions.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/syncope/core/scheduling/TestSyncJobActions.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/syncope/core/scheduling/TestSyncJobActions.java Thu Mar 15 10:17:12 2012
@@ -31,8 +31,7 @@ public class TestSyncJobActions extends
private int counter = 0;
@Override
- public SyncDelta beforeCreate(final SyncDelta delta, final UserTO user)
- throws JobExecutionException {
+ public SyncDelta beforeCreate(final SyncDelta delta, final UserTO user) throws JobExecutionException {
AttributeTO attrTO = null;
for (int i = 0; i < user.getAttributes().size(); i++) {
Modified: incubator/syncope/trunk/hibernate-enhancer/src/main/java/org/syncope/hibernate/HibernateEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/hibernate-enhancer/src/main/java/org/syncope/hibernate/HibernateEnhancer.java?rev=1300882&r1=1300881&r2=1300882&view=diff
==============================================================================
--- incubator/syncope/trunk/hibernate-enhancer/src/main/java/org/syncope/hibernate/HibernateEnhancer.java (original)
+++ incubator/syncope/trunk/hibernate-enhancer/src/main/java/org/syncope/hibernate/HibernateEnhancer.java Thu Mar 15 10:17:12 2012
@@ -47,36 +47,27 @@ public final class HibernateEnhancer {
private HibernateEnhancer() {
}
- public static void main(final String[] args)
- throws Exception {
+ public static void main(final String[] args) throws Exception {
if (args.length != 1) {
- throw new IllegalArgumentException(
- "Expecting classpath as single argument");
+ throw new IllegalArgumentException("Expecting classpath as single argument");
}
ClassPool classPool = ClassPool.getDefault();
classPool.appendClassPath(args[0]);
- PathMatchingResourcePatternResolver resResolver =
- new PathMatchingResourcePatternResolver(
- classPool.getClassLoader());
- CachingMetadataReaderFactory cachingMetadataReaderFactory =
- new CachingMetadataReaderFactory();
-
- for (Resource resource : resResolver.getResources(
- "classpath*:org/syncope/core/**/*.class")) {
-
- MetadataReader metadataReader =
- cachingMetadataReaderFactory.getMetadataReader(resource);
- if (metadataReader.getAnnotationMetadata().
- isAnnotated(Entity.class.getName())) {
+ PathMatchingResourcePatternResolver resResolver = new PathMatchingResourcePatternResolver(classPool
+ .getClassLoader());
+ CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
- Class entity = Class.forName(
- metadataReader.getClassMetadata().getClassName());
+ for (Resource resource : resResolver.getResources("classpath*:org/syncope/core/**/*.class")) {
+
+ MetadataReader metadataReader = cachingMetadataReaderFactory.getMetadataReader(resource);
+ if (metadataReader.getAnnotationMetadata().isAnnotated(Entity.class.getName())) {
+
+ Class entity = Class.forName(metadataReader.getClassMetadata().getClassName());
classPool.appendClassPath(new ClassClassPath(entity));
- CtClass ctClass =
- ClassPool.getDefault().get(entity.getName());
+ CtClass ctClass = ClassPool.getDefault().get(entity.getName());
if (ctClass.isFrozen()) {
ctClass.defrost();
}
@@ -85,18 +76,14 @@ public final class HibernateEnhancer {
for (Field field : entity.getDeclaredFields()) {
if (field.isAnnotationPresent(Lob.class)) {
- AnnotationsAttribute typeAttr =
- new AnnotationsAttribute(
- constPool, AnnotationsAttribute.visibleTag);
- Annotation typeAnnot = new Annotation(
- "org.hibernate.annotations.Type", constPool);
- typeAnnot.addMemberValue("type", new StringMemberValue(
- "org.hibernate.type.StringClobType",
+ AnnotationsAttribute typeAttr = new AnnotationsAttribute(constPool,
+ AnnotationsAttribute.visibleTag);
+ Annotation typeAnnot = new Annotation("org.hibernate.annotations.Type", constPool);
+ typeAnnot.addMemberValue("type", new StringMemberValue("org.hibernate.type.StringClobType",
constPool));
typeAttr.addAnnotation(typeAnnot);
- CtField lobField = ctClass.getDeclaredField(field.
- getName());
+ CtField lobField = ctClass.getDeclaredField(field.getName());
lobField.getFieldInfo().addAttribute(typeAttr);
}
}