james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [1/2] james-project git commit: JAMES-1747 Ensure every backend throw an AlreadyExistInUsersRepository exception when adding an already existing user
Date Mon, 06 Jun 2016 14:08:39 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 81d88bf73 -> f6cfad601


JAMES-1747 Ensure every backend throw an AlreadyExistInUsersRepository exception when adding
an already existing user


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dec1efe7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dec1efe7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dec1efe7

Branch: refs/heads/master
Commit: dec1efe75bd4ba15ed71e1f767f648622f359ff3
Parents: be69ed1
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Fri Jun 3 15:22:56 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Fri Jun 3 15:22:56 2016 +0200

----------------------------------------------------------------------
 .../james/user/cassandra/CassandraUsersRepository.java   |  3 ++-
 .../james/user/jdbc/DefaultUsersJdbcRepository.java      | 11 ++++++-----
 .../james/user/lib/AbstractUsersRepositoryTest.java      |  5 +++--
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/dec1efe7/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
index 958dca9..f8d2770 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
@@ -39,6 +39,7 @@ import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraConstants;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
+import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.api.model.User;
 import org.apache.james.user.lib.AbstractUsersRepository;
@@ -155,7 +156,7 @@ public class CassandraUsersRepository extends AbstractUsersRepository
{
             .getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED);
 
         if (!executed) {
-            throw new UsersRepositoryException("User with username " + username + " already
exist!");
+            throw new AlreadyExistInUsersRepositoryException("User with username " + username
+ " already exist!");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/dec1efe7/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
index 9460824..df10f85 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
@@ -19,14 +19,15 @@
 
 package org.apache.james.user.jdbc;
 
-import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.james.user.api.model.User;
-import org.apache.james.user.lib.model.DefaultUser;
-
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
+import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.api.model.User;
+import org.apache.james.user.lib.model.DefaultUser;
+
 /**
  * A Jdbc-backed UserRepository which handles User instances of the
  * <code>DefaultUser</code> class.<br>
@@ -68,7 +69,7 @@ public class DefaultUsersJdbcRepository extends AbstractJdbcUsersRepository
{
     @Override
     public void addUser(String username, String password) throws UsersRepositoryException
{
         if (contains(username)) {
-            throw new UsersRepositoryException("User " + username + " already exist");
+            throw new AlreadyExistInUsersRepositoryException("User " + username + " already
exist");
         }
         isValidUsername(username);
         User newbie = new DefaultUser(username, "SHA");

http://git-wip-us.apache.org/repos/asf/james-project/blob/dec1efe7/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
index ac130f0..830aa4e 100644
--- a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
 
 import org.apache.james.domainlist.api.mock.SimpleDomainList;
 import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.api.model.User;
 import org.junit.After;
@@ -142,7 +143,7 @@ public abstract class AbstractUsersRepositoryTest {
         assertThat(usersRepository.contains(user3)).isTrue();
     }
     
-    @Test(expected = UsersRepositoryException.class)
+    @Test(expected = AlreadyExistInUsersRepositoryException.class)
     public void addUserShouldThrowWhenSameUsernameWithDifferentCase() throws UsersRepositoryException
{
         //Given
         usersRepository.addUser(login("myUsername"), "password");
@@ -150,7 +151,7 @@ public abstract class AbstractUsersRepositoryTest {
         usersRepository.addUser(login("MyUsername"), "password"); 
     }
     
-    @Test(expected = UsersRepositoryException.class)
+    @Test(expected = AlreadyExistInUsersRepositoryException.class)
     public void addUserShouldThrowWhenUserAlreadyPresentInRepository() throws UsersRepositoryException
{
         //Given
         usersRepository.addUser(user1, "password");


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message