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 2015/12/28 09:54:39 UTC

svn commit: r1721886 - in /openmeetings/application: branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/ branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ trunk/openmeetings-web/...

Author: solomax
Date: Mon Dec 28 08:54:38 2015
New Revision: 1721886

URL: http://svn.apache.org/viewvc?rev=1721886&view=rev
Log:
[OPENMEETINGS-1305] tests for recording service are added

Added:
    openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java
    openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java
Modified:
    openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java
    openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java
    openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java
    openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java

Added: openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java?rev=1721886&view=auto
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java (added)
+++ openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java Mon Dec 28 08:54:38 2015
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.openmeetings.test.webservice;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Random;
+
+import org.apache.openmeetings.db.dao.record.RecordingDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.record.RecordingDTO;
+import org.apache.openmeetings.db.entity.record.Recording;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.test.AbstractJUnitDefaults;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class RecordingServiceTest extends AbstractJUnitDefaults {
+	public final static String RECORD_SERVICE_URL = UserServiceTest.BASE_SERVICES_URL + "/record";
+	private final static String UNIT_TEST_GROUP = "om_unit_tests";
+	private final Random rnd = new Random();
+	@Autowired
+	private RecordingDao recordingDao;
+	@Autowired
+	private UserDao userDao;
+
+	@Test
+	public void testExternal() throws Exception {
+		User u = getUser(rnd.nextInt());
+		u.setExternalType(UNIT_TEST_GROUP);
+		u.setExternalId("" + rnd.nextInt());
+		userDao.update(u, null);
+		Recording r = new Recording();
+		r.setCreator(u);
+		r.setComment("Created by Unit Tests");
+		r = recordingDao.update(r);
+		ServiceResult sr = UserServiceTest.login();
+		Collection<? extends RecordingDTO> recs = UserServiceTest.getClient(RECORD_SERVICE_URL).path("/" + UNIT_TEST_GROUP).query("sid", sr.getMessage())
+				.getCollection(RecordingDTO.class);
+		assertNotNull("Valid collection should be returned", recs);
+		assertFalse("Collection of the recordings shoould not be empty", recs.isEmpty());
+		boolean found = false;
+		for (RecordingDTO rdo : recs) {
+			if (r.getId().equals(rdo.getId())) {
+				found = true;
+				break;
+			}
+		}
+		assertTrue("Just created recording was not found by the service", found);
+	}
+}

Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java?rev=1721886&r1=1721885&r2=1721886&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java Mon Dec 28 08:54:38 2015
@@ -36,21 +36,25 @@ public class UserServiceTest extends Abs
 	public final static String BASE_SERVICES_URL = "http://localhost:5080/openmeetings/services";
 	public final static String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
 	
-	protected static WebClient getClient(String url) {
+	public static WebClient getClient(String url) {
 		return WebClient.create(url).accept("application/json").type("application/json");
 	}
 	
+	public static ServiceResult login() {
+		ServiceResult sr = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
+		assertEquals("Login should be successful", sr.getType(), Type.SUCCESS.name());
+		return sr;
+	}
+	
 	@Test
 	public void loginTest() {
-		ServiceResult r = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
+		ServiceResult r = login();
 		assertNotNull("Valid ServiceResult should be returned", r);
-		assertEquals("Login should be successful", r.getType(), Type.SUCCESS.name());
 	}
 
 	@Test
 	public void hashTest() {
-		ServiceResult r = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
-		assertEquals("Login should be successful", r.getType(), Type.SUCCESS.name());
+		ServiceResult r = login();
 		ExternalUserDTO user = new ExternalUserDTO();
 		user.setExternalId("1");
 		user.setExternalType("OmJunitTests");

Modified: openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java?rev=1721886&r1=1721885&r2=1721886&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java Mon Dec 28 08:54:38 2015
@@ -169,9 +169,9 @@ public class RecordingWebService {
 	 */
 	@WebMethod
 	@GET
-	@Path("/room/{id}")
+	@Path("/room/{roomid}")
 	public List<RecordingDTO> getExternalByRoom(@WebParam(name="sid") @QueryParam("sid") String sid
-			, @PathParam("id") @WebParam(name="id") Long roomId) throws ServiceException {
+			, @PathParam("roomid") @WebParam(name="roomid") Long roomId) throws ServiceException {
 		try {
 			Long userId = sessionDao.checkSession(sid);
 

Added: openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java?rev=1721886&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java (added)
+++ openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/RecordingServiceTest.java Mon Dec 28 08:54:38 2015
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.openmeetings.test.webservice;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Random;
+
+import org.apache.openmeetings.db.dao.record.RecordingDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.record.RecordingDTO;
+import org.apache.openmeetings.db.entity.record.Recording;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.test.AbstractJUnitDefaults;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class RecordingServiceTest extends AbstractJUnitDefaults {
+	public final static String RECORD_SERVICE_URL = UserServiceTest.BASE_SERVICES_URL + "/record";
+	private final static String UNIT_TEST_GROUP = "om_unit_tests";
+	private final Random rnd = new Random();
+	@Autowired
+	private RecordingDao recordingDao;
+	@Autowired
+	private UserDao userDao;
+
+	@Test
+	public void testExternal() throws Exception {
+		User u = getUser(rnd.nextInt());
+		u.setExternalType(UNIT_TEST_GROUP);
+		u.setExternalId("" + rnd.nextInt());
+		userDao.update(u, null);
+		Recording r = new Recording();
+		r.setCreator(u);
+		r.setComment("Created by Unit Tests");
+		r = recordingDao.update(r);
+		ServiceResult sr = UserServiceTest.login();
+		Collection<? extends RecordingDTO> recs = UserServiceTest.getClient(RECORD_SERVICE_URL).path("/" + UNIT_TEST_GROUP).query("sid", sr.getMessage())
+				.getCollection(RecordingDTO.class);
+		assertNotNull("Valid collection should be returned", recs);
+		assertFalse("Collection of the recordings shoould not be empty", recs.isEmpty());
+		boolean found = false;
+		for (RecordingDTO rdo : recs) {
+			if (r.getId().equals(rdo.getId())) {
+				found = true;
+				break;
+			}
+		}
+		assertTrue("Just created recording was not found by the service", found);
+	}
+}

Modified: openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java?rev=1721886&r1=1721885&r2=1721886&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java Mon Dec 28 08:54:38 2015
@@ -36,21 +36,25 @@ public class UserServiceTest extends Abs
 	public final static String BASE_SERVICES_URL = "http://localhost:5080/openmeetings/services";
 	public final static String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
 	
-	protected static WebClient getClient(String url) {
+	public static WebClient getClient(String url) {
 		return WebClient.create(url).accept("application/json").type("application/json");
 	}
 	
+	public static ServiceResult login() {
+		ServiceResult sr = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
+		assertEquals("Login should be successful", sr.getType(), Type.SUCCESS.name());
+		return sr;
+	}
+	
 	@Test
 	public void loginTest() {
-		ServiceResult r = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
+		ServiceResult r = login();
 		assertNotNull("Valid ServiceResult should be returned", r);
-		assertEquals("Login should be successful", r.getType(), Type.SUCCESS.name());
 	}
 
 	@Test
 	public void hashTest() {
-		ServiceResult r = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class);
-		assertEquals("Login should be successful", r.getType(), Type.SUCCESS.name());
+		ServiceResult r = login();
 		ExternalUserDTO user = new ExternalUserDTO();
 		user.setExternalId("1");
 		user.setExternalType("OmJunitTests");

Modified: openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java?rev=1721886&r1=1721885&r2=1721886&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java (original)
+++ openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java Mon Dec 28 08:54:38 2015
@@ -169,9 +169,9 @@ public class RecordingWebService {
 	 */
 	@WebMethod
 	@GET
-	@Path("/room/{id}")
+	@Path("/room/{roomid}")
 	public List<RecordingDTO> getExternalByRoom(@WebParam(name="sid") @QueryParam("sid") String sid
-			, @PathParam("id") @WebParam(name="id") Long roomId) throws ServiceException {
+			, @PathParam("roomid") @WebParam(name="roomid") Long roomId) throws ServiceException {
 		try {
 			Long userId = sessionDao.checkSession(sid);