You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2017/06/30 07:57:15 UTC

openmeetings git commit: [OPENMEETINGS-1646] tests are fixed

Repository: openmeetings
Updated Branches:
  refs/heads/master 117e8d6bc -> 661d6410a


[OPENMEETINGS-1646] tests are fixed


Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/661d6410
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/661d6410
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/661d6410

Branch: refs/heads/master
Commit: 661d6410a3b1dde1044144b9bd2e61e354df82d1
Parents: 117e8d6
Author: Maxim Solodovnik <so...@gmail.com>
Authored: Fri Jun 30 14:57:06 2017 +0700
Committer: Maxim Solodovnik <so...@gmail.com>
Committed: Fri Jun 30 14:57:06 2017 +0700

----------------------------------------------------------------------
 .../openmeetings/db/dao/room/ClientDao.java     | 25 +++-----
 .../db/entity/room/StreamClient.java            |  4 +-
 openmeetings-server/src/site/site.xml           |  1 +
 .../src/site/xdoc/ExternalVideo.xml             | 33 ++++++++++
 openmeetings-server/src/site/xdoc/oauth2.xml    |  4 +-
 .../test/session/TestDbSession.java             | 64 ++++++++++++++------
 6 files changed, 89 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
index 8ba572d..f7e61af 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
@@ -18,8 +18,8 @@
  */
 package org.apache.openmeetings.db.dao.room;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
@@ -38,12 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Transactional
 public class ClientDao {
-
 	@PersistenceContext
 	private EntityManager em;
 
-	private static List<Long> EMPTY_LIST = new ArrayList<>(0);
-
 	public void cleanAllClients() {
 		em.createNamedQuery("deleteClientAll").executeUpdate();
 	}
@@ -76,7 +73,7 @@ public class ClientDao {
 	}
 
 	public void remove(Long id) {
-		Query q = em.createNamedQuery("deletedClientById");
+		Query q = em.createNamedQuery("deleteClientById");
 		q.setParameter("id", id);
 		q.executeUpdate();
 	}
@@ -126,8 +123,8 @@ public class ClientDao {
 	}
 
 	public List<StreamClient> getClientsByRoomId(Long roomId) {
-		TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByRoomId", StreamClient.class);
-		q.setParameter("roomId", roomId);
+		TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByScope", StreamClient.class);
+		q.setParameter("scope", "" + roomId);
 		return q.getResultList();
 	}
 
@@ -138,16 +135,8 @@ public class ClientDao {
 	 * @return
 	 */
 	public List<Long> getRoomsIdsByServer(Server server) {
-		Query q = em.createNamedQuery("getRoomsIdsByServer");
-		q.setParameter("server", server);
-		@SuppressWarnings("unchecked")
-		List<Long> resultList = q.getResultList();
-		//if the result list contains only a value null, it means it
-		//was empty and no roomid's have been found
-		if (resultList.size() == 1 && resultList.get(0) == null) {
-			return EMPTY_LIST;
-		}
-		return resultList;
+		return em.createNamedQuery("getRoomsIdsByServer", String.class)
+				.setParameter("server", server).getResultList()
+				.stream().map(Long::valueOf).collect(Collectors.toList());
 	}
-
 }

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
index dbdef46..9e661e7 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
@@ -60,8 +60,8 @@ import org.apache.wicket.util.string.StringValue;
 	@NamedQuery(name = "getClients", query = "SELECT c FROM StreamClient c"),
 	@NamedQuery(name = "getClientsWithServer", query = "SELECT c FROM StreamClient c LEFT JOIN FETCH c.server"),
 	@NamedQuery(name = "getClientsByUserId", query = "SELECT c FROM StreamClient c WHERE c.server = :server AND c.userId = :userId"),
-	@NamedQuery(name = "getClientsByRoomId", query = "SELECT c FROM StreamClient c WHERE c.scope = :roomId"),
-	@NamedQuery(name = "getRoomsIdsByServer", query = "SELECT c.roomId FROM StreamClient c WHERE c.server = :server GROUP BY c.scope")
+	@NamedQuery(name = "getClientsByScope", query = "SELECT c FROM StreamClient c WHERE c.scope = :scope"),
+	@NamedQuery(name = "getRoomsIdsByServer", query = "SELECT c.scope FROM StreamClient c WHERE c.server = :server GROUP BY c.scope")
 })
 @Table(name = "client")
 @XmlRootElement

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-server/src/site/site.xml
----------------------------------------------------------------------
diff --git a/openmeetings-server/src/site/site.xml b/openmeetings-server/src/site/site.xml
index f69f84a..be0875d 100644
--- a/openmeetings-server/src/site/site.xml
+++ b/openmeetings-server/src/site/site.xml
@@ -59,6 +59,7 @@
 				<item name="VoIP and SIP" href="/voip-sip-integration.html" />
 				<item name="Errors table" href="/errorvalues.html" />
 				<item name="CalDAV and Google Calendar integration" href="/CalDAVandGCal.html" />
+				<item name="External Video/Camera" href="/ExternalVideo.html" />
 			</item>
 			<item name="Plugins" href="#plugins">
 				<item name="Moodle Plugin" href="/MoodlePlugin.html" />

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-server/src/site/xdoc/ExternalVideo.xml
----------------------------------------------------------------------
diff --git a/openmeetings-server/src/site/xdoc/ExternalVideo.xml b/openmeetings-server/src/site/xdoc/ExternalVideo.xml
new file mode 100644
index 0000000..21b75f8
--- /dev/null
+++ b/openmeetings-server/src/site/xdoc/ExternalVideo.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ -->
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+	<properties>
+		<title>External Video/Camera</title>
+		<author email="dev@openmeetings.apache.org">Apache OpenMeetings Team</author>
+	</properties>
+	<body>
+		<section name="Connecting external video source">
+			correct ffmpeg command for testing (width/height only works if both specified)
+			<source>
+<![CDATA[
+ffmpeg -re -i Avengers2.mp4 -vcodec flv -f flv -rtmp_conn "O:1 NS:securityCode:SID_OF_EXISTENT_USER NN:width:720 NN:height:480 O:0" rtmp://localhost:1935/openmeetings/ROOM_ID/UNIQUE_BROADCAST_ID_STRING
+]]>
+			</source>
+			SID_OF_EXISTENT_USER == Admin->Connections -> client "sid" parameter (NOT broadcastId, NOT uid)
+		</section>
+	</body>
+</document>

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-server/src/site/xdoc/oauth2.xml
----------------------------------------------------------------------
diff --git a/openmeetings-server/src/site/xdoc/oauth2.xml b/openmeetings-server/src/site/xdoc/oauth2.xml
index c1b2f86..95a73d3 100644
--- a/openmeetings-server/src/site/xdoc/oauth2.xml
+++ b/openmeetings-server/src/site/xdoc/oauth2.xml
@@ -13,8 +13,8 @@
    limitations under the License.
  -->
 <document xmlns="http://maven.apache.org/XDOC/2.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
 	<properties>
 		<title>OAuth2 integration</title>
 		<author email="dev@openmeetings.apache.org">Apache OpenMeetings Team</author>

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/661d6410/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
index ccd01d5..675a4e2 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
@@ -28,6 +28,7 @@ import org.apache.openmeetings.db.dao.server.ServerDao;
 import org.apache.openmeetings.db.entity.room.StreamClient;
 import org.apache.openmeetings.db.entity.server.Server;
 import org.apache.openmeetings.test.AbstractJUnitDefaults;
+import org.junit.Before;
 import org.junit.Test;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
@@ -41,14 +42,13 @@ public class TestDbSession extends AbstractJUnitDefaults {
 
 	@Autowired
 	private ClientDao clientDao;
+	private Server server = null;
+	StreamClient cl1, cl2, cl3;
 
-	@Test
-	public void testDbSessionFunctions() {
-		clientDao.cleanAllClients();
-
+	@Before
+	public void setup() {
 		List<Server> serverList = serverDao.getActiveServers();
 
-		Server server = null;
 		if (serverList.size() > 0) {
 			server = serverList.get(0);
 		} else {
@@ -58,27 +58,32 @@ public class TestDbSession extends AbstractJUnitDefaults {
 			serverDao.update(server, null);
 		}
 
-		StreamClient cl1 = new StreamClient();
+		clientDao.cleanAllClients();
+
+		cl1 = new StreamClient();
 		cl1.setServer(null);
 		cl1.setUserId(1L);
 		cl1.setScope("1");
 		cl1.setUid("public1");
 		clientDao.add(cl1);
 
-		StreamClient cl2 = new StreamClient();
+		cl2 = new StreamClient();
 		cl2.setServer(null);
 		cl2.setScope("1");
 		cl2.setUserId(2L);
 		cl2.setUid("public2");
 		clientDao.add(cl2);
 
-		StreamClient cl3 = new StreamClient();
+		cl3 = new StreamClient();
 		cl3.setServer(server);
 		cl3.setScope("3");
 		cl3.setUserId(3L);
 		cl3.setUid("public3");
 		clientDao.add(cl3);
+	}
 
+	@Test
+	public void testByUidAndServer() {
 		List<StreamClient> clTest_Pub_1_list = clientDao.getClientsByUidAndServer(null, "public1");
 		assertEquals(cl1.getId(), clTest_Pub_1_list.get(0).getId());
 
@@ -87,7 +92,10 @@ public class TestDbSession extends AbstractJUnitDefaults {
 
 		List<StreamClient> clTest_Fail_list = clientDao.getClientsByUidAndServer(null, "public3");
 		assertEquals(0, clTest_Fail_list.size());
+	}
 
+	@Test
+	public void testByUid() {
 		List<StreamClient> clTest_PubAll_1_list = clientDao.getClientsByUid("public1");
 		assertEquals(cl1.getId(), clTest_PubAll_1_list.get(0).getId());
 
@@ -96,16 +104,27 @@ public class TestDbSession extends AbstractJUnitDefaults {
 
 		List<StreamClient> clTest_FailAll_list = clientDao.getClientsByUid("public4");
 		assertEquals(0, clTest_FailAll_list.size());
+	}
 
+
+	@Test
+	public void testByServer() {
 		List<StreamClient> clientsByServerNull = clientDao.getClientsByServer(null);
 		assertEquals(2, clientsByServerNull.size());
 
 		List<StreamClient> clientsByServer = clientDao.getClientsByServer(server);
 		assertEquals(1, clientsByServer.size());
 
-		List<StreamClient> clientsAll = clientDao.getClients();
-		assertEquals(3, clientsAll.size());
+		//count by server
+		int clTest_Count_1_list = clientDao.countClientsByServer(null);
+		assertEquals(2, clTest_Count_1_list);
+
+		int clTest_Count_3_list = clientDao.countClientsByServer(server);
+		assertEquals(1, clTest_Count_3_list);
+	}
 
+	@Test
+	public void testByUser() {
 		//by userid
 		List<StreamClient> clTest_User_1_list = clientDao.getClientsByUserId(null, 1L);
 		assertEquals(cl1.getId(), clTest_User_1_list.get(0).getId());
@@ -115,7 +134,10 @@ public class TestDbSession extends AbstractJUnitDefaults {
 
 		List<StreamClient> clTest_UserFail_list = clientDao.getClientsByUserId(null, 3L);
 		assertEquals(0, clTest_UserFail_list.size());
+	}
 
+	@Test
+	public void testByRoom() {
 		//by roomid
 		List<StreamClient> clTest_Room_1_list = clientDao.getClientsByRoomId(1L);
 		assertEquals(2, clTest_Room_1_list.size());
@@ -125,18 +147,20 @@ public class TestDbSession extends AbstractJUnitDefaults {
 
 		List<StreamClient> clTest_RoomFail_list = clientDao.getClientsByRoomId(2L);
 		assertEquals(0, clTest_RoomFail_list.size());
+	}
+
+	@Test
+	public void testAll() {
+		//all
+		List<StreamClient> clientsAll = clientDao.getClients();
+		assertEquals(3, clientsAll.size());
 
-		//count all
 		int countAll = clientDao.countClients();
 		assertEquals(3, countAll);
+	}
 
-		//count by server
-		int clTest_Count_1_list = clientDao.countClientsByServer(null);
-		assertEquals(2, clTest_Count_1_list);
-
-		int clTest_Count_3_list = clientDao.countClientsByServer(server);
-		assertEquals(1, clTest_Count_3_list);
-
+	@Test
+	public void testRemove() {
 		//remove by id
 		clientDao.delete(cl1);
 
@@ -144,12 +168,12 @@ public class TestDbSession extends AbstractJUnitDefaults {
 		assertEquals(1, clTest_Count_Delete_list);
 
 		clTest_Count_Delete_list = clientDao.countClientsByServer(server);
-		assertEquals(0, clTest_Count_Delete_list);
+		assertEquals(1, clTest_Count_Delete_list);
 
 		//delete all
 		clientDao.cleanAllClients();
 
-		countAll = clientDao.countClients();
+		int countAll = clientDao.countClients();
 		assertEquals(0, countAll);
 	}
 }