You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/10 15:41:50 UTC

svn commit: r1431394 - /syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/

Author: jbernhardt
Date: Thu Jan 10 14:41:50 2013
New Revision: 1431394

URL: http://svn.apache.org/viewvc?rev=1431394&view=rev
Log:
[SYNCOPE-268]

Modified:
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Thu Jan 10 14:41:50 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.syncope.core.rest;
 
+import java.util.UUID;
+
 import javax.sql.DataSource;
 
 import org.apache.http.auth.UsernamePasswordCredentials;
@@ -89,7 +91,7 @@ public abstract class AbstractTest {
     public static final String ADMIN_UID = "admin";
 
     public static final String ADMIN_PWD = "password";
-
+    
     protected PolicyServiceProxy policyService;
 
     @Autowired
@@ -124,6 +126,10 @@ public abstract class AbstractTest {
     @Autowired
     protected DataSource testDataSource;
 
+    public static String getUUIDString() {
+    	return UUID.randomUUID().toString().substring(0, 8);
+    }
+
     protected RestTemplate anonymousRestTemplate() {
         return new RestTemplate();
     }
@@ -154,4 +160,5 @@ public abstract class AbstractTest {
         schemaService = new SchemaServiceProxy(BASE_URL, restTemplate);
         userRequestService = new UserRequestServiceProxy(BASE_URL, restTemplate);
     }
+    
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java Thu Jan 10 14:41:50 2013
@@ -68,7 +68,7 @@ public class AuthenticationTestITCase ex
     public void testUserSchemaAuthorization() {
         // 0. create a role that can only read schemas
         RoleTO authRoleTO = new RoleTO();
-        authRoleTO.setName("authRole");
+        authRoleTO.setName("authRole" + getUUIDString());
         authRoleTO.setParent(8L);
         authRoleTO.addEntitlement("SCHEMA_READ");
 
@@ -85,7 +85,7 @@ public class AuthenticationTestITCase ex
         assertEquals(schemaTO, newSchemaTO);
 
         // 2. create an user with the role created above (as admin)
-        UserTO userTO = UserTestITCase.getSampleTO("auth@test.org");
+        UserTO userTO = UserTestITCase.getSampleUniqueTO();
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(authRoleTO.getId());
@@ -130,7 +130,7 @@ public class AuthenticationTestITCase ex
 
     @Test
     public void testUserRead() {
-        UserTO userTO = UserTestITCase.getSampleTO("testuserread@test.org");
+        UserTO userTO = UserTestITCase.getSampleUniqueTO();
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(7L);
@@ -166,7 +166,7 @@ public class AuthenticationTestITCase ex
 
     @Test
     public void testUserSearch() {
-        UserTO userTO = UserTestITCase.getSampleTO("testusersearch@test.org");
+        UserTO userTO = UserTestITCase.getSampleUniqueTO();
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(7L);
@@ -214,8 +214,7 @@ public class AuthenticationTestITCase ex
 
     @Test
     public void checkFailedLogins() {
-        UserTO userTO = UserTestITCase
-                .getSampleTO("checkFailedLogin@syncope.apache.org");
+        UserTO userTO = UserTestITCase.getSampleUniqueTO();
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(7L);
@@ -277,8 +276,7 @@ public class AuthenticationTestITCase ex
 
     @Test
     public void checkUserSuspension() {
-        UserTO userTO = UserTestITCase
-                .getSampleTO("checkSuspension@syncope.apache.org");
+        UserTO userTO = UserTestITCase.getSampleUniqueTO();
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(7L);
@@ -398,7 +396,7 @@ public class AuthenticationTestITCase ex
     public void issueSYNCOPE48() {
         // Parent role, able to create users with role 1
         RoleTO parentRole = new RoleTO();
-        parentRole.setName("parentAdminRole");
+        parentRole.setName("parentAdminRole" + getUUIDString());
         parentRole.addEntitlement("USER_CREATE");
         parentRole.addEntitlement("ROLE_1");
         parentRole.setParent(1L);
@@ -415,8 +413,7 @@ public class AuthenticationTestITCase ex
         assertNotNull(childRole);
 
         // User with child role, created by admin
-        UserTO role1Admin = UserTestITCase
-                .getSampleTO("syncope48admin@apache.org");
+        UserTO role1Admin = UserTestITCase.getSampleUniqueTO();
         role1Admin.setPassword("password");
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(childRole.getId());
@@ -428,8 +425,7 @@ public class AuthenticationTestITCase ex
         super.setupRestTemplate(role1Admin.getUsername(), "password");
 
         // User with role 1, created by user with child role created above
-        UserTO role1User = UserTestITCase
-                .getSampleTO("syncope48user@apache.org");
+        UserTO role1User = UserTestITCase.getSampleUniqueTO();
         membershipTO = new MembershipTO();
         membershipTO.setRoleId(1L);
         role1User.addMembership(membershipTO);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java Thu Jan 10 14:41:50 2013
@@ -256,7 +256,7 @@ public class ConnInstanceTestITCase exte
 
         // Make it new.
         connInstanceTO.setId(0);
-        connInstanceTO.setDisplayName("newDisplayName");
+        connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
         // ----------------------------------
 
         // ----------------------------------
@@ -516,90 +516,100 @@ public class ConnInstanceTestITCase exte
         assertFalse(schemaNames.isEmpty());
     }
 
-    @Test
-    public void issueSYNCOPE112() {
-
-        // ----------------------------------------
-        // Create a new connector
-        // ----------------------------------------
-        ConnInstanceTO connectorTO = new ConnInstanceTO();
-
-        // set connector version
-        connectorTO.setVersion(connidSoapVersion);
-
-        // set connector name
-        connectorTO.setConnectorName("org.connid.bundles.soap.WebServiceConnector");
-
-        // set bundle name
-        connectorTO.setBundleName("org.connid.bundles.soap");
-
-        // set display name
-        connectorTO.setDisplayName("WSSoap");
-
-        // set the connector configuration using PropertyTO
-        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();
+	@Test
+	public void issueSYNCOPE112() {
 
-        ConnConfPropSchema userSchema = new ConnConfPropSchema();
-        userSchema.setName("endpoint");
-        userSchema.setType(String.class.getName());
-        userSchema.setRequired(true);
-        ConnConfProperty endpoint = new ConnConfProperty();
-        endpoint.setSchema(userSchema);
-        endpoint.setValues(Collections.singletonList("http://localhost:9080/does_not_work"));
-        endpoint.setOverridable(true);
-
-        ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
-        keyColumnSchema.setName("servicename");
-        keyColumnSchema.setType(String.class.getName());
-        keyColumnSchema.setRequired(true);
-        ConnConfProperty servicename = new ConnConfProperty();
-        servicename.setSchema(keyColumnSchema);
-        servicename.setValues(Collections
-                .singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
-        servicename.setOverridable(false);
-
-        conf.add(endpoint);
-        conf.add(servicename);
-
-        // set connector configuration
-        connectorTO.setConfiguration(conf);
-
-        assertFalse(connectorService.validate(connectorTO));
-
-        connectorTO = connectorService.create(connectorTO);
-        assertNotNull(connectorTO);
-        // ----------------------------------------
-
-        // ----------------------------------------
-        // create a resourceTO
-        // ----------------------------------------
-        String resourceName = "checkForPropOverriding";
-        ResourceTO resourceTO = new ResourceTO();
-
-        resourceTO.setName(resourceName);
-        resourceTO.setConnectorId(connectorTO.getId());
-
-        conf = new HashSet<ConnConfProperty>();
-        endpoint.setValues(Collections.singletonList("http://localhost:9080/wssample/services/provisioning"));
-        conf.add(endpoint);
-
-        resourceTO.setConnectorConfigurationProperties(conf);
-
-        MappingTO mapping = new MappingTO();
-        resourceTO.setUmapping(mapping);
-
-        MappingItemTO mapItem = new MappingItemTO();
-        mapItem.setExtAttrName("uid");
-        mapItem.setIntAttrName("userId");
-        mapItem.setIntMappingType(IntMappingType.UserSchema);
-        mapItem.setAccountid(true);
-        mapping.setAccountIdItem(mapItem);
-        // ----------------------------------------
-
-        // ----------------------------------------
-        // Check connection without saving the resource ....
-        // ----------------------------------------
-        assertTrue(resourceService.check(resourceTO));
-        // ----------------------------------------
-    }
+		// ----------------------------------------
+		// Create a new connector
+		// ----------------------------------------
+		ConnInstanceTO connectorTO = new ConnInstanceTO();
+
+		// set connector version
+		connectorTO.setVersion(connidSoapVersion);
+
+		// set connector name
+		connectorTO
+				.setConnectorName("org.connid.bundles.soap.WebServiceConnector");
+
+		// set bundle name
+		connectorTO.setBundleName("org.connid.bundles.soap");
+
+		// set display name
+		connectorTO.setDisplayName("WSSoap");
+
+		// set the connector configuration using PropertyTO
+		Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();
+
+		ConnConfPropSchema userSchema = new ConnConfPropSchema();
+		userSchema.setName("endpoint");
+		userSchema.setType(String.class.getName());
+		userSchema.setRequired(true);
+		ConnConfProperty endpoint = new ConnConfProperty();
+		endpoint.setSchema(userSchema);
+		endpoint.setValues(Collections
+				.singletonList("http://localhost:9080/does_not_work"));
+		endpoint.setOverridable(true);
+
+		ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
+		keyColumnSchema.setName("servicename");
+		keyColumnSchema.setType(String.class.getName());
+		keyColumnSchema.setRequired(true);
+		ConnConfProperty servicename = new ConnConfProperty();
+		servicename.setSchema(keyColumnSchema);
+		servicename
+				.setValues(Collections
+						.singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
+		servicename.setOverridable(false);
+
+		conf.add(endpoint);
+		conf.add(servicename);
+
+		// set connector configuration
+		connectorTO.setConfiguration(conf);
+
+		try {
+
+			assertFalse(connectorService.validate(connectorTO));
+
+			connectorTO = connectorService.create(connectorTO);
+			assertNotNull(connectorTO);
+			// ----------------------------------------
+
+			// ----------------------------------------
+			// create a resourceTO
+			// ----------------------------------------
+			String resourceName = "checkForPropOverriding";
+			ResourceTO resourceTO = new ResourceTO();
+
+			resourceTO.setName(resourceName);
+			resourceTO.setConnectorId(connectorTO.getId());
+
+			conf = new HashSet<ConnConfProperty>();
+			endpoint.setValues(Collections
+					.singletonList("http://localhost:9080/wssample/services/provisioning"));
+			conf.add(endpoint);
+
+			resourceTO.setConnectorConfigurationProperties(conf);
+
+			MappingTO mapping = new MappingTO();
+			resourceTO.setUmapping(mapping);
+
+			MappingItemTO mapItem = new MappingItemTO();
+			mapItem.setExtAttrName("uid");
+			mapItem.setIntAttrName("userId");
+			mapItem.setIntMappingType(IntMappingType.UserSchema);
+			mapItem.setAccountid(true);
+			mapping.setAccountIdItem(mapItem);
+			// ----------------------------------------
+
+			// ----------------------------------------
+			// Check connection without saving the resource ....
+			// ----------------------------------------
+			assertTrue(resourceService.check(resourceTO));
+			// ----------------------------------------
+		} finally {
+			// Remove connector from db to make test re-runnable
+			connectorService.delete(connectorTO.getId());
+		}
+	}
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java Thu Jan 10 14:41:50 2013
@@ -82,6 +82,10 @@ public class DerivedSchemaTestITCase ext
         } catch (SyncopeClientCompositeErrorException e) {
             t = e;
             assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));
+        } finally {
+        	// Recreate schema to make test re-runnable
+        	schema = schemaService.create(ROLE, SchemaService.SchemaType.DERIVED, schemaToDelete);
+        	assertNotNull(schema);
         }
         assertNotNull(t);
     }
@@ -91,14 +95,20 @@ public class DerivedSchemaTestITCase ext
         DerivedSchemaTO schema = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.DERIVED, "mderiveddata");
         assertNotNull(schema);
         assertEquals("mderived_sx + '-' + mderived_dx", schema.getExpression());
+        try {
+            schema.setExpression("mderived_sx + '.' + mderived_dx");
 
-        schema.setExpression("mderived_sx + '.' + mderived_dx");
+            schema = schemaService.update(MEMBERSHIP, SchemaService.SchemaType.DERIVED, schema.getName(), schema);
+            assertNotNull(schema);
 
-        schema = schemaService.update(MEMBERSHIP, SchemaService.SchemaType.DERIVED, schema.getName(), schema);
-        assertNotNull(schema);
-
-        schema = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.DERIVED, "mderiveddata");
-        assertNotNull(schema);
-        assertEquals("mderived_sx + '.' + mderived_dx", schema.getExpression());
+            schema = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.DERIVED, "mderiveddata");
+            assertNotNull(schema);
+            assertEquals("mderived_sx + '.' + mderived_dx", schema.getExpression());
+        } finally {
+    		// Set updated back to make test re-runnable
+    		schema.setExpression("mderived_sx + '-' + mderived_dx");
+            schema = schemaService.update(MEMBERSHIP, SchemaService.SchemaType.DERIVED, schema.getName(), schema);
+            assertNotNull(schema);
+    	}
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java Thu Jan 10 14:41:50 2013
@@ -107,9 +107,7 @@ public class PolicyTestITCase extends Ab
 
     @Test
     public void create() {
-        SyncPolicyTO policy = new SyncPolicyTO();
-        policy.setSpecification(new SyncPolicySpec());
-        policy.setDescription("Sync policy");
+        SyncPolicyTO policy = buildSyncPolicyTO();
 
         SyncPolicyTO policyTO = policyService.create(policy);
 
@@ -149,17 +147,17 @@ public class PolicyTestITCase extends Ab
 
     @Test
     public void delete() {
-        final SyncPolicyTO policyTO = policyService.read(7L, SyncPolicyTO.class);
-
-        assertNotNull("find to delete did not work", policyTO);
+        SyncPolicyTO policy = buildSyncPolicyTO();
+        SyncPolicyTO policyTO = policyService.create(policy);
+        assertNotNull(policyTO);
 
         PolicyTO policyToDelete =
-                policyService.delete(7L, SyncPolicyTO.class);
+                policyService.delete(policyTO.getId(), SyncPolicyTO.class);
         assertNotNull(policyToDelete);
 
         Throwable t = null;
         try {
-        	policyService.read(7L, SyncPolicyTO.class);
+        	policyService.read(policyTO.getId(), SyncPolicyTO.class);
         } catch (SyncopeClientCompositeErrorException e) {
             t = e;
         }
@@ -167,4 +165,10 @@ public class PolicyTestITCase extends Ab
         assertNotNull(t);
     }
 
+	private SyncPolicyTO buildSyncPolicyTO() {
+		SyncPolicyTO policy = new SyncPolicyTO();
+        policy.setSpecification(new SyncPolicySpec());
+        policy.setDescription("Sync policy");
+		return policy;
+	}
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Thu Jan 10 14:41:50 2013
@@ -96,7 +96,7 @@ public class ReportTestITCase extends Ab
     @Test
     public void create() {
         ReportTO report = new ReportTO();
-        report.setName("testReportForCreate");
+        report.setName("testReportForCreate" + getUUIDString());
         report.addReportletConf(new UserReportletConf("first"));
         report.addReportletConf(new UserReportletConf("second"));
 
@@ -112,7 +112,7 @@ public class ReportTestITCase extends Ab
     @Test
     public void update() {
         ReportTO report = new ReportTO();
-        report.setName("testReportForUpdate");
+        report.setName("testReportForUpdate" + getUUIDString());
         report.addReportletConf(new UserReportletConf("first"));
         report.addReportletConf(new UserReportletConf("second"));
 
@@ -180,7 +180,7 @@ public class ReportTestITCase extends Ab
 
         ReportTO reportTO = reportService.read(1L);
         reportTO.setId(0);
-        reportTO.setName("executeAndExport");
+        reportTO.setName("executeAndExport" + getUUIDString());
         reportTO = reportService.create(reportTO);
         assertNotNull(reportTO);
 
@@ -252,7 +252,7 @@ public class ReportTestITCase extends Ab
     @Test
     public void issueSYNCOPE43() {
         ReportTO reportTO = new ReportTO();
-        reportTO.setName("issueSYNCOPE43");
+        reportTO.setName("issueSYNCOPE43" + getUUIDString());
         reportTO = reportService.create(reportTO);
         assertNotNull(reportTO);
 
@@ -279,7 +279,7 @@ public class ReportTestITCase extends Ab
         // Create
         ReportTO reportTO = reportService.read(1L);
         reportTO.setId(0);
-        reportTO.setName("issueSYNCOPE102");
+        reportTO.setName("issueSYNCOPE102" + getUUIDString());
         reportTO = reportService.create(reportTO);
         assertNotNull(reportTO);
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Thu Jan 10 14:41:50 2013
@@ -54,34 +54,7 @@ public class ResourceTestITCase extends 
     @Test
     public void create() {
         String resourceName = "ws-target-resource-create";
-        ResourceTO resourceTO = new ResourceTO();
-
-        resourceTO.setName(resourceName);
-        resourceTO.setConnectorId(102L);
-
-        MappingTO mapping = new MappingTO();
-
-        MappingItemTO item = new MappingItemTO();
-        item.setExtAttrName("uid");
-        item.setIntAttrName("userId");
-        item.setIntMappingType(IntMappingType.UserSchema);
-        mapping.addItem(item);
-
-        item = new MappingItemTO();
-        item.setExtAttrName("username");
-        item.setIntAttrName("fullname");
-        item.setIntMappingType(IntMappingType.UserId);
-        item.setAccountid(true);
-        mapping.setAccountIdItem(item);
-
-        item = new MappingItemTO();
-        item.setExtAttrName("fullname");
-        item.setIntAttrName("cn");
-        item.setIntMappingType(IntMappingType.UserSchema);
-        item.setAccountid(false);
-        mapping.addItem(item);
-
-        resourceTO.setUmapping(mapping);
+        ResourceTO resourceTO = buildResourceTO(resourceName);
 
         ResourceTO actual = resourceService.create(resourceTO);
         assertNotNull(actual);
@@ -335,23 +308,26 @@ public class ResourceTestITCase extends 
 
     @Test
     public void updateResetSyncToken() {
-        // pre condition: sync token is set
-        String resourceName = "ws-target-resource-update-resetsynctoken";
-        ResourceTO pre = resourceService.read(resourceName);
-        assertNotNull(pre.getUsyncToken());
-
-        pre.setUsyncToken(null);
-
-        ResourceTO actual = resourceService.update(pre.getName(), pre);
-
-        // check that the synctoken has been reset
-        assertNull(actual.getUsyncToken());
+        // create resource with sync token
+        String resourceName = "ws-target-resource-update-resetsynctoken" + getUUIDString();
+    	ResourceTO pre = buildResourceTO(resourceName);
+    	pre.setUsyncToken("test");
+    	resourceService.create(pre);
+
+		pre.setUsyncToken(null);
+		ResourceTO actual = resourceService.update(pre.getName(), pre);
+		// check that the synctoken has been reset
+		assertNull(actual.getUsyncToken());
     }
 
     @Test
     public void delete() {
         final String resourceName = "ws-target-resource-delete";
 
+        ResourceTO resource = buildResourceTO(resourceName);
+        ResourceTO actual = resourceService.create(resource);
+        assertNotNull(actual);
+        
         ResourceTO deletedResource = resourceService.delete(resourceName);
         assertNotNull(deletedResource);
 
@@ -387,4 +363,37 @@ public class ResourceTestITCase extends 
 
         assertNotNull(actual);
     }
+
+	private ResourceTO buildResourceTO(String resourceName) {
+		ResourceTO resourceTO = new ResourceTO();
+
+        resourceTO.setName(resourceName);
+        resourceTO.setConnectorId(102L);
+
+        MappingTO mapping = new MappingTO();
+
+        MappingItemTO item = new MappingItemTO();
+        item.setExtAttrName("uid");
+        item.setIntAttrName("userId");
+        item.setIntMappingType(IntMappingType.UserSchema);
+        mapping.addItem(item);
+
+        item = new MappingItemTO();
+        item.setExtAttrName("username");
+        item.setIntAttrName("fullname");
+        item.setIntMappingType(IntMappingType.UserId);
+        item.setAccountid(true);
+        mapping.setAccountIdItem(item);
+
+        item = new MappingItemTO();
+        item.setExtAttrName("fullname");
+        item.setIntAttrName("cn");
+        item.setIntMappingType(IntMappingType.UserSchema);
+        item.setAccountid(false);
+        mapping.addItem(item);
+
+        resourceTO.setUmapping(mapping);
+		return resourceTO;
+	}
+
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1431394&r1=1431393&r2=1431394&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Thu Jan 10 14:41:50 2013
@@ -69,17 +69,22 @@ public class UserTestITCase extends Abst
         return resourceService.getConnector(resourceName, AttributableType.USER, userId);
     }
 
+    public static UserTO getSampleUniqueTO() {
+    	return getSampleTO(getUUIDString() + "@test.com");
+    }
+    
     public static UserTO getSampleTO(final String email) {
+    	String uid = email;
         UserTO userTO = new UserTO();
         userTO.setPassword("password123");
-        userTO.setUsername(email);
+        userTO.setUsername(uid);
 
-        userTO.addAttribute(attributeTO("fullname", email));
-        userTO.addAttribute(attributeTO("firstname", email));
+        userTO.addAttribute(attributeTO("fullname", uid));
+        userTO.addAttribute(attributeTO("firstname", uid));
         userTO.addAttribute(attributeTO("surname", "surname"));
         userTO.addAttribute(attributeTO("type", "a type"));
-        userTO.addAttribute(attributeTO("userId", email));
-        userTO.addAttribute(attributeTO("email", email));
+        userTO.addAttribute(attributeTO("userId", uid));
+        userTO.addAttribute(attributeTO("email", uid));
         DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         userTO.addAttribute(attributeTO("loginDate", sdf.format(new Date())));
         userTO.addDerivedAttribute(attributeTO("cn", null));