openmeetings-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebawag...@apache.org
Subject svn commit: r1441695 - in /openmeetings/trunk/singlewebapp/src/org/apache/openmeetings: data/conference/dao/ClientDao.java persistence/beans/rooms/Client.java session/SessionManager.java test/session/TestDbSession.java
Date Sat, 02 Feb 2013 03:36:31 GMT
Author: sebawagner
Date: Sat Feb  2 03:36:30 2013
New Revision: 1441695

URL: http://svn.apache.org/viewvc?rev=1441695&view=rev
Log:
OPENMEETINGS-460 Complete and update Test with new methods and fix existing ones in ClientDao

Modified:
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSession.java

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java?rev=1441695&r1=1441694&r2=1441695&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
Sat Feb  2 03:36:30 2013
@@ -95,6 +95,7 @@ public class ClientDao {
 	public List<Client> getClientsByPublicSIDAndServer(Server server, String publicSID)
{
 		TypedQuery<Client> q = em.createNamedQuery("getClientsByPublicSIDAndServer", Client.class);
 		q.setParameter("server", server);
+		q.setParameter("publicSID", publicSID);
 		return q.getResultList();
 	}
 
@@ -109,5 +110,9 @@ public class ClientDao {
 		q.setParameter("server", server);	
 		return q.getResultList();
 	}
+
+	public List<Client> getClients() {
+		return em.createNamedQuery("getClients", Client.class).getResultList();
+	}
 	
 }

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java?rev=1441695&r1=1441694&r2=1441695&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
Sat Feb  2 03:36:30 2013
@@ -49,9 +49,8 @@ import org.apache.openmeetings.utils.mat
 	@NamedQuery(name = "getClientByServerAndStreamId", query = "SELECT c FROM Client c WHERE
c.streamid LIKE :streamid AND c.server = :server"),
 	@NamedQuery(name = "getClientsByPublicSIDAndServer", query = "SELECT c FROM Client c WHERE
c.publicSID LIKE :publicSID AND c.server = :server"),
 	@NamedQuery(name = "getClientsByPublicSID", query = "SELECT c FROM Client c WHERE c.publicSID
LIKE :publicSID"),
-	@NamedQuery(name = "getClientsByServer", query = "SELECT c FROM Client c WHERE c.publicSID
LIKE :publicSID")
-	
-	
+	@NamedQuery(name = "getClientsByServer", query = "SELECT c FROM Client c WHERE c.server
= :server"),
+	@NamedQuery(name = "getClients", query = "SELECT c FROM Client c")
 })
 @Table(name = "client")
 public class Client implements Serializable {

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java?rev=1441695&r1=1441694&r2=1441695&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
Sat Feb  2 03:36:30 2013
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -116,11 +115,7 @@ public class SessionManager implements I
 		}
 
 		public synchronized Collection<Client> getAllClients() {
-			HashMap<String, Client> clients = cache.getClientsByServer(null);
-			if (clients == null) {
-				return new ArrayList<Client>(0);
-			}
-			return clients.values();
+			return cache.getClients();
 		}
 
 		public synchronized Client getClientByStreamId(String streamId, Server server) {

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSession.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSession.java?rev=1441695&r1=1441694&r2=1441695&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSession.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSession.java
Sat Feb  2 03:36:30 2013
@@ -20,6 +20,8 @@ package org.apache.openmeetings.test.ses
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.List;
+
 import org.apache.openmeetings.OpenmeetingsVariables;
 import org.apache.openmeetings.data.basic.dao.ServerDao;
 import org.apache.openmeetings.data.conference.dao.ClientDao;
@@ -46,11 +48,16 @@ public class TestDbSession extends Abstr
 	public void testDbSessionFunctions() {
 
 		clientDao.cleanAllClients();
+		
+		List<Server> serverList = serverDao.getActiveServers();
 
-		Server server = serverDao.get(1);
-		if (server == null) {
+		Server server = null;
+		if (serverList.size() > 0) {
+			server = serverList.get(0);
+		} else {
 			server = new Server();
-			server.setName("Server 1");
+			server.setName("Test Server");
+			server.setActive(true);
 			serverDao.update(server, 0);
 		}
 
@@ -74,7 +81,7 @@ public class TestDbSession extends Abstr
 		cl3.setRoom_id(3L);
 		cl3.setPublicSID("public3");
 		clientDao.add(cl3);
-
+		
 		Client clTest = clientDao.getClientByServerAndStreamId(null, "1");
 
 		log.debug("cl1 " + cl1);
@@ -93,6 +100,44 @@ public class TestDbSession extends Abstr
 
 		log.debug("clTest_NOT_3 " + clTest_NOT_3);
 		assertEquals(null, clTest_NOT_3);
+		
+		long numberOfClients1 = clientDao.countClientsByServerAndStreamId(null, "1");
+		assertEquals(1, numberOfClients1);
+		
+		long numberOfClients3 = clientDao.countClientsByServerAndStreamId(server, "3");
+		assertEquals(1, numberOfClients3);
+		
+		long numberOfClients4 = clientDao.countClientsByServerAndStreamId(null, "3");
+		assertEquals(0, numberOfClients4);
+		
+		List<Client> clTest_Pub_1_list = clientDao.getClientsByPublicSIDAndServer(null, "public1");
+		assertEquals(cl1.getId(), clTest_Pub_1_list.get(0).getId());
+		
+		List<Client> clTest_Pub_3_list = clientDao.getClientsByPublicSIDAndServer(server,
"public3");
+		assertEquals(cl3.getId(), clTest_Pub_3_list.get(0).getId());
+		
+		List<Client> clTest_Fail_list = clientDao.getClientsByPublicSIDAndServer(null, "public3");
+		assertEquals(0, clTest_Fail_list.size());
+		
+		List<Client> clTest_PubAll_1_list = clientDao.getClientsByPublicSID("public1");
+		assertEquals(cl1.getId(), clTest_PubAll_1_list.get(0).getId());
+		
+		List<Client> clTest_PubAll_3_list = clientDao.getClientsByPublicSID("public3");
+		assertEquals(cl3.getId(), clTest_PubAll_3_list.get(0).getId());
+		
+		List<Client> clTest_FailAll_list = clientDao.getClientsByPublicSID("public4");
+		assertEquals(0, clTest_FailAll_list.size());
+		
+		List<Client> clientsByServerNull = clientDao.getClientsByServer(null);
+		assertEquals(2, clientsByServerNull.size());
+		
+		List<Client> clientsByServer = clientDao.getClientsByServer(server);
+		assertEquals(1, clientsByServer.size());
+		
+		List<Client> clientsAll = clientDao.getClients();
+		assertEquals(3, clientsAll.size());
+		
+		clientDao.cleanAllClients();
 
 	}
 



Mime
View raw message