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/10/01 05:43:25 UTC
[1/4] openmeetings git commit: [OPENMEETINGS-1714] more issues are
fixed
Repository: openmeetings
Updated Branches:
refs/heads/master c08491a3f -> 3dac8e2fe
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRoomService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRoomService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRoomService.java
deleted file mode 100644
index 2a552c1..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRoomService.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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 javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
-import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import javax.ws.rs.core.Form;
-
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.file.FileItemDTO;
-import org.apache.openmeetings.db.dto.room.RoomDTO;
-import org.apache.openmeetings.db.dto.room.RoomFileDTO;
-import org.apache.openmeetings.db.entity.file.BaseFileItem;
-import org.apache.openmeetings.db.entity.room.Room;
-import org.junit.Test;
-
-public class TestRoomService extends AbstractWebServiceTest {
- public static final String ROOM_SERVICE_URL = BASE_SERVICES_URL + "/room";
- private static final long CAPACITY = 666L;
-
- @Test
- public void testExternal() {
- ServiceResult sr = login();
- String extId = UUID.randomUUID().toString();
- Room.Type type = Room.Type.presentation;
- String name = "Unit Test Ext Room";
- String comment = "Unit Test Ext Room Comments";
- RoomDTO r = new RoomDTO();
- r.setType(type);
- r.setName(name);
- r.setComment(comment);
- r.setCapacity(CAPACITY);
- RoomDTO room = getClient(ROOM_SERVICE_URL).path(String.format("/%s/%s/%s", type, UNIT_TEST_EXT_TYPE, extId))
- .query("sid", sr.getMessage())
- .query("room", r.toString())
- .get(RoomDTO.class);
- assertNotNull("Valid room should be returned", room);
- assertNotNull("Room ID should be not empty", room.getId());
-
- RoomDTO room1 = getClient(ROOM_SERVICE_URL).path(String.format("/%s/%s/%s", Room.Type.presentation, UNIT_TEST_EXT_TYPE, extId))
- .query("sid", sr.getMessage())
- .get(RoomDTO.class);
- assertNotNull("Valid room should be returned", room1);
- assertEquals("Same Room should be returned", room.getId(), room1.getId());
- }
-
- private static CallResult<RoomDTO> createAndValidate(RoomDTO r) {
- return createAndValidate(null, r);
- }
-
- private static CallResult<RoomDTO> createAndValidate(String sid, RoomDTO r) {
- if (sid == null) {
- ServiceResult sr = login();
- sid = sr.getMessage();
- }
- RoomDTO room = getClient(ROOM_SERVICE_URL)
- .query("sid", sid)
- .type(APPLICATION_FORM_URLENCODED)
- .post(new Form().param("room", r.toString()), RoomDTO.class);
- assertNotNull("Valid room should be returned", room);
- assertNotNull("Room ID should be not empty", room.getId());
-
- RoomDTO room1 = getClient(ROOM_SERVICE_URL).path(String.format("/%s", room.getId()))
- .query("sid", sid)
- .get(RoomDTO.class);
- assertNotNull("Valid room should be returned", room1);
- assertEquals("Room with same ID should be returned", room.getId(), room1.getId());
- assertEquals("Room with same Name should be returned", r.getName(), room1.getName());
- assertEquals("Room with same ExternalType should be returned", r.getExternalType(), room1.getExternalType());
- assertEquals("Room with same ExternalId should be returned", r.getExternalId(), room1.getExternalId());
- //TODO check other fields
- return new CallResult<>(sid, room1);
- }
-
- @Test
- public void testCreate1() {
- String extId = UUID.randomUUID().toString();
- Room.Type type = Room.Type.presentation;
- String name = "Unit Test Ext Room1";
- String comment = "Unit Test Ext Room Comments1";
- RoomDTO r = new RoomDTO();
- r.setType(type);
- r.setName(name);
- r.setComment(comment);
- r.setCapacity(CAPACITY);
- r.setExternalType(UNIT_TEST_EXT_TYPE);
- r.setExternalId(extId);
-
- createAndValidate(r);
- }
-
- @Test
- public void testCreate2() {
- Room.Type type = Room.Type.presentation;
- String name = "Unit Test Ext Room2";
- String comment = "Unit Test Ext Room Comments2";
- RoomDTO r = new RoomDTO();
- r.setType(type);
- r.setName(name);
- r.setComment(comment);
- r.setCapacity(CAPACITY);
-
- createAndValidate(r);
- }
-
- @Test
- public void testCreateWithFiles1() {
- Room.Type type = Room.Type.presentation;
- String name = "Unit Test Ext Room3";
- String comment = "Unit Test Ext Room Comments3";
- RoomDTO r = new RoomDTO();
- r.setType(type);
- r.setName(name);
- r.setComment(comment);
- r.setCapacity(CAPACITY);
- RoomFileDTO rf = new RoomFileDTO();
- rf.setFileId(-666L); //not existent
- r.getFiles().add(rf);
-
- CallResult<RoomDTO> res = createAndValidate(r);
- assertTrue("No room files should be added", res.getObj().getFiles().isEmpty());
- }
-
- @Test
- public void testCreateWithFiles2() throws IOException {
- //lets create real file
- CallResult<FileItemDTO> fileCall = createVerifiedFile(getDefaultProfilePicture(), "img.jpg", BaseFileItem.Type.Image);
-
- Room.Type type = Room.Type.presentation;
- String name = "Unit Test Ext Room4";
- String comment = "Unit Test Ext Room Comments4";
- RoomDTO r = new RoomDTO();
- r.setType(type);
- r.setName(name);
- r.setComment(comment);
- r.setCapacity(CAPACITY);
-
- RoomFileDTO rf = new RoomFileDTO();
- rf.setFileId(fileCall.getObj().getId()); //not existent
- r.getFiles().add(rf);
-
- CallResult<RoomDTO> res = createAndValidate(fileCall.getSid(), r);
- assertFalse("Room files should NOT be empty", res.getObj().getFiles().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java
deleted file mode 100644
index 01861d3..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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 javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Locale;
-import java.util.Random;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.Response;
-
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
-import org.apache.openmeetings.db.dto.room.RoomOptionsDTO;
-import org.apache.openmeetings.db.dto.user.ExternalUserDTO;
-import org.apache.openmeetings.db.dto.user.UserDTO;
-import org.apache.openmeetings.db.entity.user.Address;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.wicket.util.string.StringValue;
-import org.junit.Test;
-
-public class TestUserService extends AbstractWebServiceTest {
- @Test
- public void invalidLoginTest() {
- ServiceResult r = loginNoCheck("invalid-user", "bad pass");
- assertNotNull("Valid ServiceResult should be returned", r);
- assertEquals("Login should NOT be successful", Type.ERROR.name(), r.getType());
- }
-
- @Test
- public void loginTest() {
- ServiceResult r = login();
- assertNotNull("Valid ServiceResult should be returned", r);
- }
-
- @Test
- public void hashTest() {
- ServiceResult r = login();
- ExternalUserDTO user = new ExternalUserDTO();
- user.setExternalId("1");
- user.setExternalType("OmJunitTests");
- user.setEmail("user1@junit.openmeetings.apache.org");
- user.setFirstname("First Name 1");
- user.setLastname("Last Name 1");
- user.setLogin("login1");
- RoomOptionsDTO options = new RoomOptionsDTO();
- options.setRoomId(5L);
- options.setModerator(true);
- Response resp = getClient(USER_SERVICE_URL)
- .path("/hash")
- .query("sid", r.getMessage())
- .form(new Form().param("user", user.toString()).param("options", options.toString()));
- assertNotNull("Valid ServiceResult should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- ServiceResult r1 = resp.readEntity(ServiceResult.class);
- assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
-
- WebSession ws = WebSession.get();
- ws.checkHashes(StringValue.valueOf(r1.getMessage()), StringValue.valueOf(""));
- assertTrue("Login via secure hash should be successful", ws.isSignedIn());
- }
-
- @Test
- public void addUserTest() {
- Random rnd = new Random();
- String[] tzList = TimeZone.getAvailableIDs();
- String tz = TimeZone.getTimeZone(tzList[rnd.nextInt(tzList.length)]).getID();
- ServiceResult r = login();
- UserDTO u = new UserDTO();
- String uuid = UUID.randomUUID().toString();
- u.setLogin("test" + uuid);
- u.setPassword(createPass());
- u.setFirstname("testF" + uuid);
- u.setLastname("testL" + uuid);
- u.setAddress(new Address());
- u.getAddress().setEmail(uuid + "@local");
- u.getAddress().setCountry(Locale.getDefault().getCountry());
- u.setTimeZoneId(tz);
- u.setExternalId(uuid);
- u.setExternalType("OmJunitTests");
- UserDTO user = getClient(USER_SERVICE_URL)
- .path("/")
- .query("sid", r.getMessage())
- .type(APPLICATION_FORM_URLENCODED)
- .post(new Form().param("user", u.toString()).param("confirm", "" + false), UserDTO.class);
- assertNotNull("Valid UserDTO should be returned", user);
- assertNotNull("Id should not be NULL", user.getId());
- assertEquals("OM Call should be successful", u.getLogin(), user.getLogin());
- assertEquals("OM Call should be successful", tz, user.getTimeZoneId());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestWebConverters.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestWebConverters.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestWebConverters.java
deleted file mode 100644
index 31edf2e..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestWebConverters.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.assertEquals;
-
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.openmeetings.db.dto.user.UserDTO;
-import org.apache.openmeetings.webservice.util.CalendarParamConverter;
-import org.apache.openmeetings.webservice.util.DateParamConverter;
-import org.junit.Test;
-
-import com.github.openjson.JSONObject;
-
-public class TestWebConverters {
- @Test
- public void testDateConverter() {
- assertEquals("Null date should be parsed", null, DateParamConverter.get(null));
- assertEquals("Date should be parsed"
- , Date.from(LocalDate.of(2017, 01, 15).atStartOfDay(ZoneId.systemDefault()).toInstant())
- , DateParamConverter.get("2017-01-15"));
- assertEquals("Date should be parsed"
- , Date.from(ZonedDateTime.of(2017, 01, 20, 20, 30, 03, 0, ZoneId.of("Europe/Moscow")).toInstant())
- , DateParamConverter.get("2017-01-20T20:30:03+0300"));
- }
-
- @Test
- public void testCalendarConverter() {
- CalendarParamConverter c = new CalendarParamConverter();
- assertEquals("Null calendar should be parsed", null, c.fromString(null));
- Calendar cal = Calendar.getInstance();
- cal.setTime(Date.from(LocalDate.of(2017, 01, 15).atStartOfDay(ZoneId.systemDefault()).toInstant()));
- assertEquals("Calendar should be parsed", cal, c.fromString("2017-01-15"));
- }
-
- @Test
- public void testUserConverter() {
- assertEquals("Null UserDTO should be parsed", null, UserDTO.get((JSONObject)null));
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserContact.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserContact.java b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserContact.java
new file mode 100644
index 0000000..d5c8343
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserContact.java
@@ -0,0 +1,105 @@
+/*
+ * 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.user;
+
+import static org.apache.openmeetings.web.app.WebSession.getUserId;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.openmeetings.AbstractWicketTester;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestUserContact extends AbstractWicketTester {
+ @Autowired
+ private UserDao userDao;
+ @Autowired
+ private GroupDao groupDao;
+
+ @Test
+ public void testGetUser() {
+ assertNull("Null should be returned in case User does not exist", userDao.get(Long.MAX_VALUE));
+ }
+
+ @Test
+ public void createUserWithGroup() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
+ u = userDao.update(u, null);
+ assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), createPass()));
+
+ User u1 = userDao.get(u.getId());
+ assertNotNull("Just created user should not be null", u1);
+ assertNotNull("Just created user should have non null org-users", u1.getGroupUsers());
+ assertFalse("Just created user should have not empty org-users", u1.getGroupUsers().isEmpty());
+ }
+
+ @Test
+ public void testCreateUser() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = createUser(uuid);
+ assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), createPass()));
+ }
+
+ @Test
+ public void addContactByOwner() throws Exception {
+ login(null, null);
+
+ List<User> users = userDao.getAllUsers();
+ assertNotNull("User list should not be null ", users);
+ assertFalse("User list should not be empty ", users.isEmpty());
+
+ User contact = createUserContact(getUserId());
+ String email = contact.getAddress().getEmail();
+ List<User> l = userDao.get(email, false, 0, 9999);
+ // check that contact is visible for admin
+ assertNotNull("Contact list should not be null for admin ", l);
+ assertFalse("Contact list should not be empty for admin ", l.isEmpty());
+
+ // check that contact is visible for owner
+ l = userDao.get(email, 0, 9999, null, true, getUserId());
+ assertTrue("Contact list should not be empty for owner ", !l.isEmpty());
+ //delete contact
+ userDao.delete(contact, getUserId());
+ l = userDao.get(email, false, 0, 9999);
+ assertTrue("Contact list should be empty after deletion", l.isEmpty());
+
+ User u = createUser();
+ User u1 = createUser();
+ contact = createUserContact(u.getId());
+ email = contact.getAddress().getEmail();
+ // check that contact is not visible for user that is not owner of this contact
+ l = userDao.get(email, 0, 9999, null, true, u1.getId());
+ assertTrue("Contact list should be empty for another user", l.isEmpty());
+ //delete contact
+ userDao.delete(contact, u.getId());
+ l = userDao.get(email, false, 0, 9999);
+ assertTrue("Contact list should be empty after deletion", l.isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserCount.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserCount.java b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserCount.java
new file mode 100644
index 0000000..1a539fb
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserCount.java
@@ -0,0 +1,58 @@
+/*
+ * 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.user;
+
+import static org.apache.openmeetings.web.app.WebSession.getUserId;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openmeetings.AbstractWicketTester;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestUserCount extends AbstractWicketTester {
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testCountSearchUsers() throws Exception {
+ User u = createUser();
+ assertTrue("Account of search users should be one", userDao.count(u.getFirstname()) == 1);
+ }
+
+ @Test
+ public void testCountFilteredUsers() throws Exception {
+ User u = createUser();
+ User contact = createUserContact(u.getId());
+ assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getId()) == 1);
+ }
+
+ @Test
+ public void testCountUnfilteredUsers() throws Exception {
+ User u = createUser();
+ createUserContact(u.getId());
+ assertTrue("Account of unfiltered should be more then one", userDao.count("firstname", false, getUserId()) > 1);
+ }
+
+ @Test
+ public void testCountAllUsers() {
+ assertTrue("Account of users should be positive", userDao.count() > 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserGroup.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserGroup.java b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserGroup.java
new file mode 100644
index 0000000..1892e13
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/user/TestUserGroup.java
@@ -0,0 +1,132 @@
+/*
+ * 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.user;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.GroupUserDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.Group;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.selenium.HeavyTests;
+import org.apache.openmeetings.util.OmException;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestUserGroup extends AbstractJUnitDefaults {
+ @Autowired
+ private GroupUserDao groupUserDao;
+ @Autowired
+ private GroupDao groupDao;
+ @Autowired
+ private UserDao userDao;
+ public static final String GROUP_NAME = "Test Group";
+
+ private User getValidUser() {
+ for (User u : userDao.getAllBackupUsers()) {
+ if (!u.isDeleted() && u.getGroupUsers().size() > 0) {
+ return u;
+ }
+ }
+ fail("Unable to find valid user");
+ return null; //unreachable
+ }
+
+ @Test
+ public void getUsersByGroupId() {
+ User u = getValidUser();
+ Long groupId = u.getGroupUsers().get(0).getGroup().getId();
+ List<GroupUser> ul = groupUserDao.get(groupId, 0, 9999);
+ assertTrue("Default Group should contain at least 1 user: " + ul.size(), ul.size() > 0);
+
+ GroupUser ou = groupUserDao.getByGroupAndUser(groupId, u.getId());
+ assertNotNull("Unable to find [group, user] pair - [" + groupId + "," + u.getId() + "]", ou);
+ }
+
+ @Test
+ public void addGroup() {
+ Group g = new Group();
+ g.setName(GROUP_NAME);
+ Long groupId = groupDao.update(g, null).getId(); //inserted by not checked
+ assertNotNull("New Group have valid id", groupId);
+
+ List<GroupUser> ul = groupUserDao.get(groupId, 0, 9999);
+ assertTrue("New Group should contain NO users: " + ul.size(), ul.size() == 0);
+ }
+
+ @Test
+ public void addUserWithoutGroup() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u = userDao.update(u, null);
+ assertNotNull("User successfully created", u.getId());
+ checkEmptyGroup("dao.get()", userDao.get(u.getId()));
+ try {
+ checkEmptyGroup("dao.login()", userDao.login(u.getAddress().getEmail(), createPass()));
+ fail("User with no Group is unable to login");
+ } catch (OmException e) {
+ assertTrue("Expected Om Exception", "error.nogroup".equals(e.getKey()));
+ }
+ checkEmptyGroup("dao.getByLogin(user)", userDao.getByLogin(u.getLogin(), u.getType(), u.getDomainId()));
+ }
+
+
+ @Test
+ public void addLdapUserWithoutGroup() throws Exception {
+ User u1 = getUser();
+ u1.setType(User.Type.ldap);
+ u1.setDomainId(1L);
+ u1 = userDao.update(u1, null);
+ checkEmptyGroup("dao.getByLogin(ldap)", userDao.getByLogin(u1.getLogin(), u1.getType(), u1.getDomainId()));
+ }
+
+ private static void checkEmptyGroup(String prefix, User u) {
+ assertNotNull(prefix + ":: Created user should be available", u);
+ assertNotNull(prefix + ":: List<GroupUser> for newly created user should not be null", u.getGroupUsers());
+ assertTrue(prefix + ":: List<GroupUser> for newly created user should be empty", u.getGroupUsers().isEmpty());
+ }
+
+ @Test
+ @Category(HeavyTests.class)
+ public void add10kUsers() throws Exception {
+ List<Group> groups = groupDao.get(GROUP_NAME, 0, 1, null);
+ Group g = null;
+ if (groups == null || groups.isEmpty()) {
+ g = new Group();
+ g.setName(GROUP_NAME);
+ g = groupDao.update(g, null);
+ } else {
+ g = groups.get(0);
+ }
+ for (int i = 0; i < 10000; ++i) {
+ User u = createUser();
+ u.getGroupUsers().add(new GroupUser(g, u));
+ userDao.update(u, null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestAuth.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestAuth.java b/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestAuth.java
new file mode 100644
index 0000000..0155624
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestAuth.java
@@ -0,0 +1,44 @@
+/*
+ * 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.userdata;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.server.SessiondataDao;
+import org.apache.openmeetings.db.entity.server.Sessiondata;
+import org.apache.openmeetings.util.crypt.CryptProvider;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestAuth extends AbstractJUnitDefaults {
+ @Autowired
+ private SessiondataDao sessionDao;
+
+ @Test
+ public void testTestAuth() {
+ Sessiondata sessionData = sessionDao.create(1L, 1L);
+
+ System.out.println("sessionData: " + sessionData.getSessionId());
+
+ String tTemp = CryptProvider.get().hash("test");
+
+ System.out.println("tTemp: " + tTemp);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestLogin.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestLogin.java b/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestLogin.java
new file mode 100644
index 0000000..3f8ce5d
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/userdata/TestLogin.java
@@ -0,0 +1,45 @@
+/*
+ * 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.userdata;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.util.OmException;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestLogin extends AbstractJUnitDefaults {
+
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testTestLogin() throws OmException {
+ User us = userDao.login(username, userpass);
+
+ assertNotNull("User is unable to login", us);
+
+ //mService.getLanguageById(1);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/util/TestStoredFile.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/util/TestStoredFile.java b/openmeetings-web/src/test/java/org/apache/openmeetings/util/TestStoredFile.java
new file mode 100644
index 0000000..7091eff
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/util/TestStoredFile.java
@@ -0,0 +1,42 @@
+/*
+ * 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.util;
+
+import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.util.StoredFile;
+import org.junit.Test;
+
+public class TestStoredFile extends AbstractJUnitDefaults {
+ @Test
+ public void testJpeg() throws FileNotFoundException, IOException {
+ File f = getDefaultProfilePicture();
+ for (String ext : new String[] {null, "txt", "png"}) {
+ StoredFile sf = new StoredFile("test image", ext, f);
+ assertTrue("Type should be detected as image", sf.isImage());
+ assertTrue("Type should be detected as image", sf.isAsIs());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/web/LoginUI.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/web/LoginUI.java b/openmeetings-web/src/test/java/org/apache/openmeetings/web/LoginUI.java
new file mode 100644
index 0000000..addb44d
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/web/LoginUI.java
@@ -0,0 +1,77 @@
+/*
+ * 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.web;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openmeetings.AbstractWicketTester;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.openmeetings.web.pages.MainPage;
+import org.apache.openmeetings.web.pages.auth.SignInPage;
+import org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.util.tester.FormTester;
+import org.junit.Test;
+
+import com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior;
+
+public class LoginUI extends AbstractWicketTester {
+ @Test
+ public void testValidLogin() {
+ tester.startPage(MainPage.class);
+ tester.assertRenderedPage(SignInPage.class);
+
+ FormTester formTester = tester.newFormTester("signin:signin");
+ formTester.setValue("login", username);
+ formTester.setValue("pass", userpass);
+ formTester.submit("submit");
+
+ tester.assertNoErrorMessage();
+ tester.assertRenderedPage(MainPage.class);
+ WebSession ws = (WebSession)tester.getSession();
+ assertTrue("Login should be successful", ws.isSignedIn());
+ }
+
+ @Test
+ public void testEmptyLogin() {
+ tester.startPage(SignInPage.class);
+ tester.assertRenderedPage(SignInPage.class);
+
+ FormTester formTester = tester.newFormTester("signin:signin");
+ formTester.submit("submit");
+
+ assertEquals("There should be exactly 2 errors", 2,
+ tester.getFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)).size());
+ }
+
+
+ @Test
+ public void testEmptyRegister() {
+ tester.startPage(SignInPage.class);
+ tester.assertRenderedPage(SignInPage.class);
+
+ ButtonAjaxBehavior b = getButtonBehavior("signin", "register");
+ tester.executeBehavior(b);
+ FormTester formTester = tester.newFormTester("register:form");
+ formTester.submit("submit");
+ assertEquals("There should be exactly 7 errors", 7,
+ tester.getFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)).size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/web/app/TestOmAuthenticationStrategy.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/web/app/TestOmAuthenticationStrategy.java b/openmeetings-web/src/test/java/org/apache/openmeetings/web/app/TestOmAuthenticationStrategy.java
new file mode 100644
index 0000000..377e9fa
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/web/app/TestOmAuthenticationStrategy.java
@@ -0,0 +1,33 @@
+/*
+ * 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.web.app;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+
+public class TestOmAuthenticationStrategy {
+ @Test
+ public void test() {
+ OmAuthenticationStrategy s = new OmAuthenticationStrategy();
+ s.save(null, null, User.Type.oauth, null);
+ assertEquals(0, s.decode(null).length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java
new file mode 100644
index 0000000..1bf39a4
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.webservice;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static org.apache.openmeetings.db.util.ApplicationHelper.getWicketTester;
+import static org.apache.openmeetings.util.OmFileHelper.getOmHome;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+import org.apache.openmeetings.db.dto.user.UserDTO;
+import org.apache.openmeetings.db.entity.file.BaseFileItem;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.openmeetings.webservice.util.AppointmentMessageBodyReader;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+public class AbstractWebServiceTest extends AbstractJUnitDefaults {
+ private static Tomcat tomcat;
+ public static final String CONTEXT = "/openmeetings";
+ public static final String BASE_SERVICES_URL = "http://localhost:8080" + CONTEXT + "/services";
+ public static final String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
+ public static final String INFO_SERVICE_URL = BASE_SERVICES_URL + "/info";
+ public static final String FILE_SERVICE_URL = BASE_SERVICES_URL + "/file";
+ public static final String UNIT_TEST_EXT_TYPE = "om_unit_tests";
+ public static final long TIMEOUT = 5 * 60 * 1000;
+ protected WicketTester tester;
+
+ public static WebClient getClient(String url) {
+ WebClient c = WebClient.create(url, Arrays.asList(new AppointmentMessageBodyReader()))
+ .accept("application/json").type("application/json");
+ HTTPClientPolicy p = WebClient.getConfig(c).getHttpConduit().getClient();
+ p.setConnectionTimeout(TIMEOUT);
+ p.setReceiveTimeout(TIMEOUT);
+ return c;
+ }
+
+ public static ServiceResult login() {
+ return login(username, userpass);
+ }
+
+ public static ServiceResult loginNoCheck(String user, String pass) {
+ ServiceResult sr = getClient(USER_SERVICE_URL).path("/login").query("user", user).query("pass", pass)
+ .get(ServiceResult.class);
+ return sr;
+ }
+
+ public static ServiceResult login(String user, String pass) {
+ ServiceResult sr = loginNoCheck(user, pass);
+ assertEquals("Login should be successful", Type.SUCCESS.name(), sr.getType());
+ return sr;
+ }
+
+ @BeforeClass
+ public static void initialize() throws Exception {
+ tomcat = new Tomcat();
+ tomcat.setPort(8080);
+ File wd = Files.createTempDirectory("om" + UUID.randomUUID().toString()).toFile();
+ tomcat.setBaseDir(wd.getCanonicalPath());
+ tomcat.getHost().setAppBase(wd.getCanonicalPath());
+ tomcat.getHost().setAutoDeploy(true);
+ tomcat.getHost().setDeployOnStartup(true);
+ tomcat.addWebapp(CONTEXT, getOmHome().getAbsolutePath());
+ tomcat.start();
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ tester = getWicketTester();
+ assertNotNull("Web session should not be null", WebSession.get());
+ }
+
+ @After
+ public void tearDown() {
+ if (tester != null) {
+ //can be null in case exception on initialization
+ tester.destroy();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
+ if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
+ tomcat.stop();
+ }
+ tomcat.destroy();
+ }
+ }
+
+ public void webCreateUser(User u) {
+ ServiceResult r = login();
+ UserDTO dto = new UserDTO(u);
+ dto.setPassword(createPass());
+ UserDTO user = getClient(USER_SERVICE_URL)
+ .path("/")
+ .query("sid", r.getMessage())
+ .type(APPLICATION_FORM_URLENCODED)
+ .post(new Form().param("user", dto.toString()).param("confirm", "" + false), UserDTO.class);
+ Assert.assertNotNull(user.getId());
+ u.setId(user.getId());
+ }
+
+ public CallResult<FileItemDTO> createVerifiedFile(File fsFile, String name, BaseFileItem.Type type) throws IOException {
+ ServiceResult r = login();
+
+ FileItemDTO f1 = null;
+ try (InputStream is = new FileInputStream(fsFile)) {
+ FileItemDTO file = new FileItemDTO()
+ .setName(name)
+ .setHash(UUID.randomUUID().toString())
+ .setType(type);
+ List<Attachment> atts = new ArrayList<>();
+ atts.add(new Attachment("file", MediaType.APPLICATION_JSON, file));
+ atts.add(new Attachment("stream", MediaType.APPLICATION_OCTET_STREAM, is));
+ f1 = getClient(FILE_SERVICE_URL)
+ .path("/")
+ .query("sid", r.getMessage())
+ .type(MediaType.MULTIPART_FORM_DATA_TYPE).postCollection(atts, Attachment.class, FileItemDTO.class);
+ assertNotNull("Valid FileItem should be returned", f1);
+ assertNotNull("Valid FileItem should be returned", f1.getId());
+ }
+ return new CallResult<>(r.getMessage(), f1);
+ }
+
+ public static class CallResult<T> {
+ private final String sid;
+ private final T obj;
+
+ public CallResult(String sid, T obj) {
+ this.sid = sid;
+ this.obj = obj;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public T getObj() {
+ return obj;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java
new file mode 100644
index 0000000..44618a1
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java
@@ -0,0 +1,308 @@
+/*
+ * 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.webservice;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.room.InvitationDao;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.calendar.AppointmentDTO;
+import org.apache.openmeetings.db.dto.calendar.MeetingMemberDTO;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.calendar.MeetingMember;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.webservice.util.AppointmentParamConverter;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.github.openjson.JSONArray;
+import com.github.openjson.JSONObject;
+
+public class TestCalendarService extends AbstractWebServiceTest {
+ public static final String CALENDAR_SERVICE_URL = BASE_SERVICES_URL + "/calendar";
+ @Autowired
+ private GroupDao groupDao;
+ @Autowired
+ private RoomDao roomDao;
+ @Autowired
+ private MeetingMemberDao mmDao;
+ @Autowired
+ private InvitationDao invitationDao;
+ @Autowired
+ private UserDao userDao;
+
+ private void actualTest(Room r) throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
+ webCreateUser(u);
+ ServiceResult sr = login(u.getLogin(), createPass());
+
+ Date start = new Date();
+ Appointment a = createAppointment(getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
+
+ AppointmentDTO app = getClient(CALENDAR_SERVICE_URL).path("/room/" + a.getRoom().getId()).query("sid", sr.getMessage())
+ .get(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", app);
+ }
+
+ @Test
+ public void testGetByAppRoom() throws Exception {
+ actualTest(null);
+ }
+
+ @Test
+ public void testGetByPublicRoom() throws Exception {
+ actualTest(roomDao.get(5L)); //default public presentation room
+ }
+
+ private static JSONObject createAppointment(String title) {
+ return new JSONObject()
+ .put("title", title)
+ .put("start", "2025-01-20T20:30:03+0300")
+ .put("end", "2025-01-20T21:30:03+0300")
+ .put("description", "Русский Тест")
+ .put("reminder", "email")
+ .put("room", new JSONObject()
+ .put("name", "test24")
+ .put("comment", "appointment test room")
+ .put("type", "conference")
+ .put("capacity", 15)
+ .put("appointment", true)
+ .put("isPublic", false)
+ .put("demo", false)
+ .put("closed", false)
+ .put("externalId", 10)
+ .put("externalType", "HuntingLabCMS")
+ .put("redirectUrl", "")
+ .put("moderated", true)
+ .put("allowUserQuestions", true)
+ .put("allowRecording", false)
+ .put("waitForRecording", false)
+ .put("audioOnly", true)
+ .put("topBarHidden", false)
+ .put("chatHidden", false)
+ .put("activitiesHidden", false)
+ .put("filesExplorerHidden", false)
+ .put("actionsMenuHidden", false)
+ .put("screenSharingHidden", false)
+ .put("whiteboardHidden", false))
+ .put("languageId", 9)
+ .put("passwordProtected", false)
+ .put("connectedEvent", false)
+ .put("reminderEmailSend", false);
+ }
+
+ private String loginNewUser() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
+ webCreateUser(u);
+ ServiceResult sr = login(u.getLogin(), createPass());
+ return sr.getMessage();
+ }
+
+ private String createApp(String title) throws Exception {
+ JSONObject o = createAppointment(title);
+
+ String sid = loginNewUser();
+
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/")
+ .query("sid", sid)
+ .form(new Form().param("appointment", o.toString()));
+
+ assertNotNull("Valid AppointmentDTO should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", dto);
+ assertNotNull("DTO id should be valid", dto.getId());
+
+ return sid;
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ createApp("test");
+ }
+
+ @Test
+ public void testDelete() {
+ ServiceResult sr = login();
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/" + Long.MAX_VALUE) //non-existent ID
+ .query("sid", sr.getMessage())
+ .delete();
+
+ assertNotEquals("Call should NOT be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void testCreateWithOmMm() throws Exception {
+ JSONObject o = createAppointment("test")
+ .put("meetingMembers", new JSONArray()
+ .put(new JSONObject().put("user", new JSONObject()
+ .put("id", 1))));
+
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
+ u = createUser(u);
+ ServiceResult sr = login(u.getLogin(), createPass());
+
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/")
+ .query("sid", sr.getMessage())
+ .form(new Form().param("appointment", o.toString()));
+
+ assertNotNull("Valid AppointmentDTO should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", dto);
+ assertNotNull("DTO id should be valid", dto.getId());
+ }
+
+ private static AppointmentDTO createEventWithGuests(String sid) throws Exception {
+ JSONObject o = createAppointment("test")
+ .put("meetingMembers", new JSONArray()
+ .put(new JSONObject().put("user", new JSONObject()
+ .put("firstname", "John 1")
+ .put("lastname", "Doe")
+ .put("address", new JSONObject().put("email", "john1@doe.email"))
+ ))
+ .put(new JSONObject().put("user", new JSONObject()
+ .put("firstname", "John 2")
+ .put("lastname", "Doe")
+ .put("address", new JSONObject().put("email", "john2@doe.email"))
+ ))
+ );
+
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/")
+ .query("sid", sid)
+ .form(new Form().param("appointment", o.toString()));
+
+ assertNotNull("Valid AppointmentDTO should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", dto);
+ assertNotNull("DTO id should be valid", dto.getId());
+ assertEquals("DTO should have 2 attendees", 2, dto.getMeetingMembers().size());
+ for (MeetingMemberDTO mm : dto.getMeetingMembers()) {
+ assertNotNull("Email should be valid", mm.getUser().getAddress().getEmail());
+ }
+
+ return dto;
+ }
+
+ @Test
+ public void testCreateWithGuests() throws Exception {
+ String sid = loginNewUser();
+ AppointmentDTO dto = createEventWithGuests(sid);
+
+ //try to change MM list
+ JSONObject o1 = AppointmentParamConverter.json(dto)
+ .put("meetingMembers", new JSONArray()
+ .put(new JSONObject().put("user", new JSONObject()
+ .put("id", 1))));
+
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/")
+ .query("sid", sid)
+ .form(new Form().param("appointment", o1.toString()));
+
+ assertNotNull("Valid AppointmentDTO should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ dto = resp.readEntity(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", dto);
+ assertNotNull("DTO id should be valid", dto.getId());
+ assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
+ }
+
+ @Test
+ public void testCreateWithGuestsCleanOne() throws Exception {
+ String sid = loginNewUser();
+ AppointmentDTO dto = createEventWithGuests(sid);
+ List<MeetingMemberDTO> initialList = new ArrayList<>(dto.getMeetingMembers());
+ MeetingMember mm = mmDao.get(initialList.get(initialList.size() - 1).getId());
+ Long mmId = mm.getId(), mmUserId = mm.getUser().getId();
+ String hash = mm.getInvitation().getHash();
+ dto.getMeetingMembers().remove(initialList.size() - 1);
+
+ //try to change MM list
+ JSONObject o = AppointmentParamConverter.json(dto);
+ Response resp = getClient(CALENDAR_SERVICE_URL)
+ .path("/")
+ .query("sid", sid)
+ .form(new Form().param("appointment", o.toString()));
+
+ assertNotNull("Valid AppointmentDTO should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ dto = resp.readEntity(AppointmentDTO.class);
+ assertNotNull("Valid DTO should be returned", dto);
+ assertNotNull("DTO id should be valid", dto.getId());
+ assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
+
+ assertNull("Meeting member should deleted", mmDao.get(mmId));
+ assertNull("Invitation should deleted", invitationDao.getByHash(hash, true, false));
+ User uc = userDao.get(mmUserId);
+ assertNotNull("Meeting member user should not be deleted", uc);
+ assertFalse("Meeting member user should not be deleted", uc.isDeleted());
+ }
+
+ @Test
+ public void testGetByTitle() throws Exception {
+ String title = "title" + UUID.randomUUID().toString();
+ String sid = createApp(title);
+ @SuppressWarnings("unchecked")
+ List<AppointmentDTO> list = (List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
+ .path(String.format("/title/%s", title))
+ .query("sid", sid)
+ .getCollection(AppointmentDTO.class);
+
+ assertEquals("List of one item should be returned", 1, list.size());
+ assertEquals("Title should match", title, list.get(0).getTitle());
+
+ title = UUID.randomUUID().toString();
+ @SuppressWarnings("unchecked")
+ List<AppointmentDTO> list1 = (List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
+ .path(String.format("/title/%s", title))
+ .query("sid", sid)
+ .getCollection(AppointmentDTO.class);
+ assertEquals("None items should be returned", 0, list1.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestFileService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestFileService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestFileService.java
new file mode 100644
index 0000000..c662950
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestFileService.java
@@ -0,0 +1,73 @@
+/*
+ * 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.webservice;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.file.FileExplorerObject;
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+import org.apache.openmeetings.db.entity.file.BaseFileItem;
+import org.apache.openmeetings.util.NonJenkinsTests;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+public class TestFileService extends AbstractWebServiceTest {
+
+ @Test
+ @Category(NonJenkinsTests.class)
+ public void addFileTest() throws IOException {
+ File img = null;
+ try {
+ img = File.createTempFile("omtest", ".jpg");
+ final Integer width = 150;
+ final Integer height = 100;
+ BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ Graphics g = image.getGraphics();
+ g.drawString("Hello World!!!", 10, 20);
+ ImageIO.write(image, "jpg", img);
+ CallResult<FileItemDTO> cr = createVerifiedFile(img, "test.txt", BaseFileItem.Type.Presentation);
+ assertEquals("Type should be Image", BaseFileItem.Type.Image, cr.getObj().getType());
+ assertEquals("Width should be determined", width, cr.getObj().getWidth());
+ assertEquals("Height should be Image", height, cr.getObj().getHeight());
+ } finally {
+ if (img != null && img.exists()) {
+ img.delete();
+ }
+ }
+ }
+
+ @Test
+ public void testGetRoom() {
+ ServiceResult r = login();
+ FileExplorerObject fo = getClient(FILE_SERVICE_URL)
+ .path("/room/5")
+ .query("sid", r.getMessage())
+ .get(FileExplorerObject.class);
+ assertNotNull(fo);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
new file mode 100644
index 0000000..c93bcd4
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
@@ -0,0 +1,67 @@
+/*
+ * 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.webservice;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.junit.Test;
+
+public class TestGroupService extends AbstractWebServiceTest {
+ public static final String GROUP_SERVICE_URL = BASE_SERVICES_URL + "/group";
+
+ @Test
+ public void putTest() {
+ ServiceResult r = login();
+ Response resp = getClient(GROUP_SERVICE_URL)
+ .path("/")
+ .query("sid", r.getMessage()).put("");
+ assertEquals("Call should NOT be successful", Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void addRemoveTest() {
+ ServiceResult r = login();
+ Long groupId = -1L;
+ {
+ Response resp = getClient(GROUP_SERVICE_URL)
+ .path("/")
+ .query("sid", r.getMessage()).query("name", "Test Group").post("");
+ assertNotNull("Valid ServiceResult should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ ServiceResult r1 = resp.readEntity(ServiceResult.class);
+ assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
+ groupId = Long.valueOf(r1.getMessage());
+ }
+ //delete group created
+ {
+ Response resp = getClient(GROUP_SERVICE_URL)
+ .path("/" + groupId)
+ .query("sid", r.getMessage()).delete();
+ assertNotNull("Valid ServiceResult should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ ServiceResult r1 = resp.readEntity(ServiceResult.class);
+ assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java
new file mode 100644
index 0000000..a87a722
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java
@@ -0,0 +1,73 @@
+/*
+ * 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.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.UUID;
+
+import org.apache.openmeetings.db.dao.record.RecordingDao;
+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.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestRecordingService extends AbstractWebServiceTest {
+ public static final String RECORD_SERVICE_URL = BASE_SERVICES_URL + "/record";
+ @Autowired
+ private RecordingDao recordingDao;
+
+ private User getExternalUser() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ User u = getUser(uuid);
+ u.setExternalType(UNIT_TEST_EXT_TYPE);
+ u.setExternalId(uuid);
+ webCreateUser(u);
+ return u;
+ }
+
+ @Test
+ public void testExternal() throws Exception {
+ User u = getExternalUser();
+ Recording r = new Recording();
+ r.setInsertedBy(u.getId());
+ r.setComment("Created by Unit Tests");
+ r.setRoomId(5L);
+ r = recordingDao.update(r);
+ ServiceResult sr = login();
+ Collection<? extends RecordingDTO> recs = getClient(RECORD_SERVICE_URL).path("/" + UNIT_TEST_EXT_TYPE).query("sid", sr.getMessage())
+ .getCollection(RecordingDTO.class);
+ assertNotNull("Valid collection should be returned", recs);
+ assertFalse("Collection of the recordings should not be empty", recs.isEmpty());
+ boolean found = false;
+ for (RecordingDTO rdo : recs) {
+ if (r.getId().equals(rdo.getId())) {
+ //TODO check room, user
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Just created recording was not found by the service", found);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRoomService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRoomService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRoomService.java
new file mode 100644
index 0000000..0f2e68b
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRoomService.java
@@ -0,0 +1,169 @@
+/*
+ * 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.webservice;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.ws.rs.core.Form;
+
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+import org.apache.openmeetings.db.dto.room.RoomDTO;
+import org.apache.openmeetings.db.dto.room.RoomFileDTO;
+import org.apache.openmeetings.db.entity.file.BaseFileItem;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.junit.Test;
+
+public class TestRoomService extends AbstractWebServiceTest {
+ public static final String ROOM_SERVICE_URL = BASE_SERVICES_URL + "/room";
+ private static final long CAPACITY = 666L;
+
+ @Test
+ public void testExternal() {
+ ServiceResult sr = login();
+ String extId = UUID.randomUUID().toString();
+ Room.Type type = Room.Type.presentation;
+ String name = "Unit Test Ext Room";
+ String comment = "Unit Test Ext Room Comments";
+ RoomDTO r = new RoomDTO();
+ r.setType(type);
+ r.setName(name);
+ r.setComment(comment);
+ r.setCapacity(CAPACITY);
+ RoomDTO room = getClient(ROOM_SERVICE_URL).path(String.format("/%s/%s/%s", type, UNIT_TEST_EXT_TYPE, extId))
+ .query("sid", sr.getMessage())
+ .query("room", r.toString())
+ .get(RoomDTO.class);
+ assertNotNull("Valid room should be returned", room);
+ assertNotNull("Room ID should be not empty", room.getId());
+
+ RoomDTO room1 = getClient(ROOM_SERVICE_URL).path(String.format("/%s/%s/%s", Room.Type.presentation, UNIT_TEST_EXT_TYPE, extId))
+ .query("sid", sr.getMessage())
+ .get(RoomDTO.class);
+ assertNotNull("Valid room should be returned", room1);
+ assertEquals("Same Room should be returned", room.getId(), room1.getId());
+ }
+
+ private static CallResult<RoomDTO> createAndValidate(RoomDTO r) {
+ return createAndValidate(null, r);
+ }
+
+ private static CallResult<RoomDTO> createAndValidate(String sid, RoomDTO r) {
+ if (sid == null) {
+ ServiceResult sr = login();
+ sid = sr.getMessage();
+ }
+ RoomDTO room = getClient(ROOM_SERVICE_URL)
+ .query("sid", sid)
+ .type(APPLICATION_FORM_URLENCODED)
+ .post(new Form().param("room", r.toString()), RoomDTO.class);
+ assertNotNull("Valid room should be returned", room);
+ assertNotNull("Room ID should be not empty", room.getId());
+
+ RoomDTO room1 = getClient(ROOM_SERVICE_URL).path(String.format("/%s", room.getId()))
+ .query("sid", sid)
+ .get(RoomDTO.class);
+ assertNotNull("Valid room should be returned", room1);
+ assertEquals("Room with same ID should be returned", room.getId(), room1.getId());
+ assertEquals("Room with same Name should be returned", r.getName(), room1.getName());
+ assertEquals("Room with same ExternalType should be returned", r.getExternalType(), room1.getExternalType());
+ assertEquals("Room with same ExternalId should be returned", r.getExternalId(), room1.getExternalId());
+ //TODO check other fields
+ return new CallResult<>(sid, room1);
+ }
+
+ @Test
+ public void testCreate1() {
+ String extId = UUID.randomUUID().toString();
+ Room.Type type = Room.Type.presentation;
+ String name = "Unit Test Ext Room1";
+ String comment = "Unit Test Ext Room Comments1";
+ RoomDTO r = new RoomDTO();
+ r.setType(type);
+ r.setName(name);
+ r.setComment(comment);
+ r.setCapacity(CAPACITY);
+ r.setExternalType(UNIT_TEST_EXT_TYPE);
+ r.setExternalId(extId);
+
+ createAndValidate(r);
+ }
+
+ @Test
+ public void testCreate2() {
+ Room.Type type = Room.Type.presentation;
+ String name = "Unit Test Ext Room2";
+ String comment = "Unit Test Ext Room Comments2";
+ RoomDTO r = new RoomDTO();
+ r.setType(type);
+ r.setName(name);
+ r.setComment(comment);
+ r.setCapacity(CAPACITY);
+
+ createAndValidate(r);
+ }
+
+ @Test
+ public void testCreateWithFiles1() {
+ Room.Type type = Room.Type.presentation;
+ String name = "Unit Test Ext Room3";
+ String comment = "Unit Test Ext Room Comments3";
+ RoomDTO r = new RoomDTO();
+ r.setType(type);
+ r.setName(name);
+ r.setComment(comment);
+ r.setCapacity(CAPACITY);
+ RoomFileDTO rf = new RoomFileDTO();
+ rf.setFileId(-666L); //not existent
+ r.getFiles().add(rf);
+
+ CallResult<RoomDTO> res = createAndValidate(r);
+ assertTrue("No room files should be added", res.getObj().getFiles().isEmpty());
+ }
+
+ @Test
+ public void testCreateWithFiles2() throws IOException {
+ //lets create real file
+ CallResult<FileItemDTO> fileCall = createVerifiedFile(getDefaultProfilePicture(), "img.jpg", BaseFileItem.Type.Image);
+
+ Room.Type type = Room.Type.presentation;
+ String name = "Unit Test Ext Room4";
+ String comment = "Unit Test Ext Room Comments4";
+ RoomDTO r = new RoomDTO();
+ r.setType(type);
+ r.setName(name);
+ r.setComment(comment);
+ r.setCapacity(CAPACITY);
+
+ RoomFileDTO rf = new RoomFileDTO();
+ rf.setFileId(fileCall.getObj().getId()); //not existent
+ r.getFiles().add(rf);
+
+ CallResult<RoomDTO> res = createAndValidate(fileCall.getSid(), r);
+ assertFalse("Room files should NOT be empty", res.getObj().getFiles().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
new file mode 100644
index 0000000..ed4ec1e
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
@@ -0,0 +1,113 @@
+/*
+ * 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.webservice;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Locale;
+import java.util.Random;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.apache.openmeetings.db.dto.room.RoomOptionsDTO;
+import org.apache.openmeetings.db.dto.user.ExternalUserDTO;
+import org.apache.openmeetings.db.dto.user.UserDTO;
+import org.apache.openmeetings.db.entity.user.Address;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.wicket.util.string.StringValue;
+import org.junit.Test;
+
+public class TestUserService extends AbstractWebServiceTest {
+ @Test
+ public void invalidLoginTest() {
+ ServiceResult r = loginNoCheck("invalid-user", "bad pass");
+ assertNotNull("Valid ServiceResult should be returned", r);
+ assertEquals("Login should NOT be successful", Type.ERROR.name(), r.getType());
+ }
+
+ @Test
+ public void loginTest() {
+ ServiceResult r = login();
+ assertNotNull("Valid ServiceResult should be returned", r);
+ }
+
+ @Test
+ public void hashTest() {
+ ServiceResult r = login();
+ ExternalUserDTO user = new ExternalUserDTO();
+ user.setExternalId("1");
+ user.setExternalType("OmJunitTests");
+ user.setEmail("user1@junit.openmeetings.apache.org");
+ user.setFirstname("First Name 1");
+ user.setLastname("Last Name 1");
+ user.setLogin("login1");
+ RoomOptionsDTO options = new RoomOptionsDTO();
+ options.setRoomId(5L);
+ options.setModerator(true);
+ Response resp = getClient(USER_SERVICE_URL)
+ .path("/hash")
+ .query("sid", r.getMessage())
+ .form(new Form().param("user", user.toString()).param("options", options.toString()));
+ assertNotNull("Valid ServiceResult should be returned", resp);
+ assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
+ ServiceResult r1 = resp.readEntity(ServiceResult.class);
+ assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
+
+ WebSession ws = WebSession.get();
+ ws.checkHashes(StringValue.valueOf(r1.getMessage()), StringValue.valueOf(""));
+ assertTrue("Login via secure hash should be successful", ws.isSignedIn());
+ }
+
+ @Test
+ public void addUserTest() {
+ Random rnd = new Random();
+ String[] tzList = TimeZone.getAvailableIDs();
+ String tz = TimeZone.getTimeZone(tzList[rnd.nextInt(tzList.length)]).getID();
+ ServiceResult r = login();
+ UserDTO u = new UserDTO();
+ String uuid = UUID.randomUUID().toString();
+ u.setLogin("test" + uuid);
+ u.setPassword(createPass());
+ u.setFirstname("testF" + uuid);
+ u.setLastname("testL" + uuid);
+ u.setAddress(new Address());
+ u.getAddress().setEmail(uuid + "@local");
+ u.getAddress().setCountry(Locale.getDefault().getCountry());
+ u.setTimeZoneId(tz);
+ u.setExternalId(uuid);
+ u.setExternalType("OmJunitTests");
+ UserDTO user = getClient(USER_SERVICE_URL)
+ .path("/")
+ .query("sid", r.getMessage())
+ .type(APPLICATION_FORM_URLENCODED)
+ .post(new Form().param("user", u.toString()).param("confirm", "" + false), UserDTO.class);
+ assertNotNull("Valid UserDTO should be returned", user);
+ assertNotNull("Id should not be NULL", user.getId());
+ assertEquals("OM Call should be successful", u.getLogin(), user.getLogin());
+ assertEquals("OM Call should be successful", tz, user.getTimeZoneId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestWebConverters.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestWebConverters.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestWebConverters.java
new file mode 100644
index 0000000..5bd544a
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestWebConverters.java
@@ -0,0 +1,61 @@
+/*
+ * 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.webservice;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.openmeetings.db.dto.user.UserDTO;
+import org.apache.openmeetings.webservice.util.CalendarParamConverter;
+import org.apache.openmeetings.webservice.util.DateParamConverter;
+import org.junit.Test;
+
+import com.github.openjson.JSONObject;
+
+public class TestWebConverters {
+ @Test
+ public void testDateConverter() {
+ assertEquals("Null date should be parsed", null, DateParamConverter.get(null));
+ assertEquals("Date should be parsed"
+ , Date.from(LocalDate.of(2017, 01, 15).atStartOfDay(ZoneId.systemDefault()).toInstant())
+ , DateParamConverter.get("2017-01-15"));
+ assertEquals("Date should be parsed"
+ , Date.from(ZonedDateTime.of(2017, 01, 20, 20, 30, 03, 0, ZoneId.of("Europe/Moscow")).toInstant())
+ , DateParamConverter.get("2017-01-20T20:30:03+0300"));
+ }
+
+ @Test
+ public void testCalendarConverter() {
+ CalendarParamConverter c = new CalendarParamConverter();
+ assertEquals("Null calendar should be parsed", null, c.fromString(null));
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(Date.from(LocalDate.of(2017, 01, 15).atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ assertEquals("Calendar should be parsed", cal, c.fromString("2017-01-15"));
+ }
+
+ @Test
+ public void testUserConverter() {
+ assertEquals("Null UserDTO should be parsed", null, UserDTO.get((JSONObject)null));
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5f3272e..1a8f43c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -840,10 +840,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <configuration>
- <destFile>${sonar.jacoco.reportPath}</destFile>
- <append>true</append>
- </configuration>
<executions>
<execution>
<id>prepare-agent</id>
@@ -1042,6 +1038,10 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
+ <configuration>
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ <append>true</append>
+ </configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
[4/4] openmeetings git commit: [OPENMEETINGS-1714] more issues are
fixed
Posted by so...@apache.org.
[OPENMEETINGS-1714] more issues are fixed
Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/3dac8e2f
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/3dac8e2f
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/3dac8e2f
Branch: refs/heads/master
Commit: 3dac8e2feb36c1384bfb72afaca6dfd41646f20a
Parents: c08491a
Author: Maxim Solodovnik <so...@gmail.com>
Authored: Sun Oct 1 12:43:14 2017 +0700
Committer: Maxim Solodovnik <so...@gmail.com>
Committed: Sun Oct 1 12:43:14 2017 +0700
----------------------------------------------------------------------
.../util/crypt/AbstractCryptTest.java | 7 +
.../openmeetings/util/crypt/TestSCrypt.java | 1 +
.../openmeetings/AbstractJUnitDefaults.java | 194 ++++++++++++
.../apache/openmeetings/AbstractSpringTest.java | 55 ++++
.../openmeetings/AbstractWicketTester.java | 75 +++++
.../openmeetings/backup/TestOldBackups.java | 124 ++++++++
.../calendar/TestAppointmentAddAppointment.java | 149 +++++++++
.../calendar/TestAppointmentSchedulerTask.java | 50 +++
.../TestDatabaseStructureAppointment.java | 76 +++++
...tDatabaseStructureGetAppointmentByRange.java | 105 +++++++
.../TestDatabaseStructureGetUserStart.java | 44 +++
.../TestDatabaseStructureMeetingMember.java | 41 +++
.../TestDatabaseStructureUsersSearch.java | 49 +++
.../calendar/TestGetAppointment.java | 60 ++++
.../openmeetings/calendar/TestOmCalendar.java | 58 ++++
.../calendar/TestSendIcalMessage.java | 235 ++++++++++++++
.../apache/openmeetings/config/TestConfig.java | 74 +++++
.../core/file/TestFileProcessor.java | 58 ++++
.../openmeetings/derby/PrepareSystemFiles.java | 67 ++++
.../openmeetings/domain/TestAddGroup.java | 60 ++++
.../domain/TestUserGroupAggregation.java | 51 +++
.../invitiation/TestInvitation.java | 57 ++++
.../selenium/AbstractTestDefaults.java | 229 ++++++++++++++
.../openmeetings/selenium/HeavyTests.java | 23 ++
.../openmeetings/selenium/SeleniumTests.java | 23 ++
.../openmeetings/selenium/SeleniumUtils.java | 229 ++++++++++++++
.../openmeetings/selenium/TestSignUp.java | 128 ++++++++
.../openmeetings/smoke/TestSmokeBasic.java | 36 +++
.../test/AbstractJUnitDefaults.java | 194 ------------
.../openmeetings/test/AbstractSpringTest.java | 55 ----
.../openmeetings/test/AbstractWicketTester.java | 75 -----
.../test/backup/TestOldBackups.java | 124 --------
.../calendar/TestAppointmentAddAppointment.java | 149 ---------
.../calendar/TestAppointmentSchedulerTask.java | 50 ---
.../TestDatabaseStructureAppointment.java | 76 -----
...tDatabaseStructureGetAppointmentByRange.java | 105 -------
.../TestDatabaseStructureGetUserStart.java | 44 ---
.../TestDatabaseStructureMeetingMember.java | 41 ---
.../TestDatabaseStructureUsersSearch.java | 49 ---
.../test/calendar/TestGetAppointment.java | 60 ----
.../test/calendar/TestOmCalendar.java | 58 ----
.../test/calendar/TestSendIcalMessage.java | 235 --------------
.../openmeetings/test/config/TestConfig.java | 74 -----
.../test/core/file/TestFileProcessor.java | 58 ----
.../test/derby/PrepareSystemFiles.java | 67 ----
.../openmeetings/test/domain/TestAddGroup.java | 60 ----
.../test/domain/TestUserGroupAggregation.java | 51 ---
.../test/invitiation/TestInvitation.java | 57 ----
.../test/selenium/AbstractTestDefaults.java | 229 --------------
.../openmeetings/test/selenium/HeavyTests.java | 23 --
.../test/selenium/SeleniumTests.java | 23 --
.../test/selenium/SeleniumUtils.java | 229 --------------
.../openmeetings/test/selenium/TestSignUp.java | 128 --------
.../openmeetings/test/smoke/TestSmokeBasic.java | 36 ---
.../openmeetings/test/user/TestUserContact.java | 105 -------
.../openmeetings/test/user/TestUserCount.java | 58 ----
.../openmeetings/test/user/TestUserGroup.java | 132 --------
.../openmeetings/test/userdata/TestAuth.java | 44 ---
.../openmeetings/test/userdata/TestLogin.java | 45 ---
.../openmeetings/test/util/TestStoredFile.java | 42 ---
.../apache/openmeetings/test/web/LoginUI.java | 77 -----
.../test/webservice/AbstractWebServiceTest.java | 186 -----------
.../test/webservice/TestCalendarService.java | 308 -------------------
.../test/webservice/TestFileService.java | 73 -----
.../test/webservice/TestGroupService.java | 67 ----
.../test/webservice/TestRecordingService.java | 73 -----
.../test/webservice/TestRoomService.java | 169 ----------
.../test/webservice/TestUserService.java | 113 -------
.../test/webservice/TestWebConverters.java | 61 ----
.../openmeetings/user/TestUserContact.java | 105 +++++++
.../apache/openmeetings/user/TestUserCount.java | 58 ++++
.../apache/openmeetings/user/TestUserGroup.java | 132 ++++++++
.../apache/openmeetings/userdata/TestAuth.java | 44 +++
.../apache/openmeetings/userdata/TestLogin.java | 45 +++
.../openmeetings/util/TestStoredFile.java | 42 +++
.../org/apache/openmeetings/web/LoginUI.java | 77 +++++
.../web/app/TestOmAuthenticationStrategy.java | 33 ++
.../webservice/AbstractWebServiceTest.java | 186 +++++++++++
.../webservice/TestCalendarService.java | 308 +++++++++++++++++++
.../webservice/TestFileService.java | 73 +++++
.../webservice/TestGroupService.java | 67 ++++
.../webservice/TestRecordingService.java | 73 +++++
.../webservice/TestRoomService.java | 169 ++++++++++
.../webservice/TestUserService.java | 113 +++++++
.../webservice/TestWebConverters.java | 61 ++++
pom.xml | 8 +-
86 files changed, 3948 insertions(+), 3907 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/AbstractCryptTest.java
----------------------------------------------------------------------
diff --git a/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/AbstractCryptTest.java b/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/AbstractCryptTest.java
index c641db4..3b8ccf4 100644
--- a/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/AbstractCryptTest.java
+++ b/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/AbstractCryptTest.java
@@ -19,6 +19,7 @@
package org.apache.openmeetings.util.crypt;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -39,6 +40,12 @@ public abstract class AbstractCryptTest {
assertEquals("Hash for null should be null", null, hash);
assertTrue("Hash for null should be null", crypt.verify(null, null));
+ assertFalse("Hash for null should be null", crypt.verify(null, "abc"));
+ assertFalse("Hash for null should NOT be null", crypt.verify("abc", null));
+
+ assertTrue("Hash for null should be null", crypt.fallback(null, null));
+ assertFalse("Hash for null should be null", crypt.fallback(null, "abc"));
+ assertFalse("Hash for null should NOT be null", crypt.fallback("abc", null));
}
private static List<String> get(int count) {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestSCrypt.java
----------------------------------------------------------------------
diff --git a/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestSCrypt.java b/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestSCrypt.java
index 094d0b5..724817f 100644
--- a/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestSCrypt.java
+++ b/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestSCrypt.java
@@ -40,5 +40,6 @@ public class TestSCrypt extends AbstractCryptTest {
assertFalse("SHA256 is not valid hash", crypt.verify(TEST_PASS, SHA_HASH));
assertTrue("MD5 is valid fallback", crypt.fallback(TEST_PASS, MD5_HASH));
assertTrue("SHA256 is valid fallback", crypt.fallback(TEST_PASS, SHA_HASH));
+ assertFalse("Fallback can return false", crypt.fallback(TEST_PASS, "abc"));
}
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
new file mode 100644
index 0000000..5aebd72
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
@@ -0,0 +1,194 @@
+/*
+ * 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;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getConfigKeyCryptClassName;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.setWicketApplicationName;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.db.entity.user.Address;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.installation.ImportInitvalues;
+import org.apache.openmeetings.installation.InstallationConfig;
+import org.junit.Before;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
+ private static final Logger log = Red5LoggerFactory.getLogger(AbstractJUnitDefaults.class);
+ public static final int ONE_HOUR = 60 * 60 * 1000;
+
+ protected static final String username = "admin";
+ protected static final String userpass = "12345";
+ private static final String group = "smoketest";
+ private static final String timeZone = "Europe/Berlin";
+ private static final String email = "junit@openmeetings.apache.org";
+
+ @Autowired
+ private AppointmentDao appointmentDao;
+ @Autowired
+ private UserDao userDao;
+ @Autowired
+ private ImportInitvalues importInitvalues;
+ @Autowired
+ protected ConfigurationDao cfgDao;
+
+ @Before
+ public void setUp() throws Exception {
+ setWicketApplicationName("openmeetings");
+ cfgDao.getCryptKey();
+ if (userDao.count() < 1) {
+ makeDefaultScheme();
+ log.info("Default scheme created successfully");
+ } else {
+ log.info("Default scheme already created");
+ }
+ if (getConfigKeyCryptClassName() == null) {
+ assertNotNull("Crypt class name should not be null", cfgDao.getCryptKey());
+ }
+ }
+
+ public Appointment getAppointment() {
+ Date start = new Date();
+ Date end = new Date();
+ end.setTime(start.getTime() + ONE_HOUR);
+ return getAppointment(start, end);
+ }
+
+ public Appointment getAppointment(Date start, Date end) {
+ return getAppointment(userDao.get(1L), start, end);
+ }
+
+ public Appointment getAppointment(User owner, Date start, Date end) {
+ return getAppointment(owner, null, start, end);
+ }
+
+ public Appointment getAppointment(User owner, Room r, Date start, Date end) {
+ assertNotNull("Can't access to appointment dao implimentation", appointmentDao);
+
+ // add new appointment
+ Appointment ap = new Appointment();
+
+ ap.setTitle("appointmentName");
+ ap.setLocation("appointmentLocation");
+
+ ap.setStart(start);
+ ap.setEnd(end);
+ ap.setDescription("appointmentDescription");
+ ap.setInserted(new Date());
+ ap.setDeleted(false);
+ ap.setIsDaily(false);
+ ap.setIsWeekly(false);
+ ap.setIsMonthly(false);
+ ap.setIsYearly(false);
+ ap.setPasswordProtected(false);
+
+ ap.setOwner(owner);
+ ap.setConnectedEvent(false);
+
+ if (ap.getReminder() == null) {
+ ap.setReminder(Appointment.Reminder.none);
+ }
+
+ if (r == null) {
+ r = new Room();
+ r.setType(Room.Type.conference);
+ r.setAppointment(true);
+ }
+ ap.setRoom(r);
+ return ap;
+ }
+
+ public Appointment createAppointment(Appointment ap) {
+ // add new appointment
+ ap = appointmentDao.update(ap, null, false);
+ assertNotNull("Cann't add appointment", ap.getId());
+ return ap;
+ }
+
+ public User getUser() throws Exception {
+ return getUser(UUID.randomUUID().toString());
+ }
+
+ protected String createPass() {
+ return "pass1_!@#$%_A";
+ }
+
+ public User getUser(String uuid) throws Exception {
+ User u = new User();
+ // add user
+ u.setFirstname("firstname" + uuid);
+ u.setLastname("lastname" + uuid);
+ u.setLogin("login" + uuid);
+ u.setAddress(new Address());
+ u.getAddress().setEmail(String.format("email%s@local", uuid));
+ u.setRights(UserDao.getDefaultRights());
+ u.setTimeZoneId("Asia/Bangkok");
+ u.updatePassword(cfgDao, createPass());
+ u.setLanguageId(1L);
+ return u;
+ }
+
+ public User createUser() throws Exception {
+ return createUser(UUID.randomUUID().toString());
+ }
+
+ public User createUser(String uuid) throws Exception {
+ return createUser(getUser(uuid));
+ }
+
+ public User createUser(User u) {
+ u = userDao.update(u, null);
+ assertNotNull("Can't add user", u);
+ return u;
+ }
+
+ private void makeDefaultScheme() throws Exception {
+ InstallationConfig cfg = new InstallationConfig();
+ cfg.setUsername(username);
+ cfg.setPassword(userpass);
+ cfg.setEmail(email);
+ cfg.setGroup(group);
+ cfg.setTimeZone(timeZone);
+ importInitvalues.loadAll(cfg, false);
+ }
+
+ public User getContact(String uuid, Long ownerId) {
+ return userDao.getContact("email" + uuid, "firstname" + uuid, "lastname" + uuid, ownerId);
+ }
+
+ public User createUserContact(Long ownerId) {
+ return createUserContact(getContact(UUID.randomUUID().toString(), ownerId), ownerId);
+ }
+
+ public User createUserContact(User user, Long ownerId) {
+ user = userDao.update(user, ownerId);
+ assertNotNull("Cann't add user", user);
+ return user;
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractSpringTest.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractSpringTest.java b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractSpringTest.java
new file mode 100644
index 0000000..d3d974c
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractSpringTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import static org.junit.Assert.fail;
+
+import org.apache.openmeetings.db.dao.label.LabelDao;
+import org.apache.openmeetings.util.OmFileHelper;
+import org.apache.tomcat.util.scan.Constants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@TestExecutionListeners({})
+@ContextConfiguration(locations={"classpath:applicationContext.xml"}, inheritLocations = true)
+public abstract class AbstractSpringTest extends AbstractJUnit4SpringContextTests {
+
+ @BeforeClass
+ public static void init() {
+ setOmHome();
+ System.setProperty(Constants.SKIP_JARS_PROPERTY, "*");
+ LabelDao.initLanguageMap();
+ if (LabelDao.getLanguages().isEmpty()) {
+ fail("Failed to set languages");
+ }
+ }
+
+ protected static void setOmHome() {
+ String webappsDir = System.getProperty("om.home", ".");
+ OmFileHelper.setOmHome(webappsDir);
+ if (!OmFileHelper.getOmHome().exists() || !OmFileHelper.getOmHome().isDirectory()) {
+ fail("Invalid directory is specified as OM HOME: " + webappsDir);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
new file mode 100644
index 0000000..ec4b817
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+import static org.apache.openmeetings.db.util.ApplicationHelper.getWicketTester;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.openmeetings.db.entity.user.User.Type;
+import org.apache.openmeetings.util.OmException;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.tester.WicketTester;
+
+import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog;
+import com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior;
+
+public class AbstractWicketTester extends AbstractJUnitDefaults {
+ protected WicketTester tester;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ tester = getWicketTester();
+ assertNotNull("Web session should not be null", WebSession.get());
+ }
+
+ public void login(String login, String password) {
+ WebSession s = WebSession.get();
+ try {
+ if (login != null && password != null) {
+ s.signIn(login, password, Type.user, null);
+ } else {
+ s.signIn(username, userpass, Type.user, null);
+ }
+ } catch (OmException e) {
+ fail(e.getMessage());
+ }
+ assertTrue("Web session is not signed in for user: " + (login != null ? login : username), s.isSignedIn());
+ }
+
+ public <T extends Serializable> ButtonAjaxBehavior getButtonBehavior(String path, String name) {
+ Args.notNull(path, "path");
+ Args.notNull(name, "name");
+ @SuppressWarnings("unchecked")
+ AbstractDialog<T> dialog = (AbstractDialog<T>)tester.getComponentFromLastRenderedPage(path);
+ List<ButtonAjaxBehavior> bl = dialog.getBehaviors(ButtonAjaxBehavior.class);
+ for (ButtonAjaxBehavior bb : bl) {
+ if (name.equals(bb.getButton().getName())) {
+ return bb;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestOldBackups.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestOldBackups.java b/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestOldBackups.java
new file mode 100644
index 0000000..45509b3
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestOldBackups.java
@@ -0,0 +1,124 @@
+/*
+ * 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.backup;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_CRYPT;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.backup.BackupImport;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.room.RoomGroupDao;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.basic.Configuration;
+import org.junit.After;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestOldBackups extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestOldBackups.class, getWebAppRootKey());
+
+ @Autowired
+ private BackupImport backupController;
+ @Autowired
+ private GroupDao groupDao;
+ @Autowired
+ private UserDao userDao;
+ @Autowired
+ private RoomDao roomDao;
+ @Autowired
+ private AppointmentDao appointmentDao;
+ @Autowired
+ private MeetingMemberDao meetingMemberDao;
+ @Autowired
+ private RoomGroupDao roomGroupDao;
+ private String cryptClass = null;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // Crypt class need to be preserved here to avoid overriding by backup import
+ cryptClass = cfgDao.getCryptKey();
+ }
+
+ @After
+ public void tearDown() {
+ Configuration cfg = cfgDao.get(CONFIG_CRYPT);
+ assertNotNull("Not null config should be returned", cfg);
+ cfg.setValue(cryptClass);
+ cfgDao.update(cfg, null);
+ }
+
+ @Test
+ public void importOldVersions() {
+ String backupsDir = System.getProperty("backups.dir", ".");
+ File backupsHome = new File(backupsDir);
+
+ if (!backupsHome.exists() || !backupsHome.isDirectory()) {
+ fail("Invalid directory is specified for backup files: " + backupsDir);
+ }
+ long groupCount = 0;
+ long userCount = 0;
+ long roomCount = 0;
+ long roomGroupCount = 0;
+ long apptCount = 0;
+ long meetingMembersCount = 0;
+ for (File backup : backupsHome.listFiles()) {
+ String name = backup.getName();
+ log.debug("Import of backup file : '" + name + "' is started ...");
+ try (InputStream is = new FileInputStream(backup)) {
+ backupController.performImport(is);
+ long newGroupCount = groupDao.count();
+ long newUserCount = userDao.count();
+ long newRoomCount = roomDao.count();
+ long newRoomGroupCount = roomGroupDao.get().size();
+ long newApptCount = appointmentDao.get().size();
+ long newMeetingMembersCount = meetingMemberDao.getMeetingMembers().size();
+ assertTrue("Zero groups were imported from " + name, newGroupCount > groupCount);
+ assertTrue("Zero users were imported from " + name, newUserCount > userCount);
+ assertTrue("Zero rooms were imported from " + name, newRoomCount > roomCount);
+ assertTrue("Zero room groups were imported from " + name, newRoomGroupCount > roomGroupCount);
+ assertTrue("Zero appointments were imported from " + name, newApptCount > apptCount);
+ assertTrue("Zero meeting members were imported from " + name, newMeetingMembersCount > meetingMembersCount);
+
+ groupCount = newGroupCount;
+ userCount = newUserCount;
+ roomCount = newRoomCount;
+ roomGroupCount = newRoomGroupCount;
+ apptCount = newApptCount;
+ meetingMembersCount = newMeetingMembersCount;
+ } catch (Exception e) {
+ throw new RuntimeException("Unexpected exception while importing backup: " + name, e);
+ }
+ log.debug("... Done.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentAddAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentAddAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentAddAppointment.java
new file mode 100644
index 0000000..6339b9c
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentAddAppointment.java
@@ -0,0 +1,149 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.openmeetings.AbstractWicketTester;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.calendar.Appointment.Reminder;
+import org.apache.openmeetings.db.entity.calendar.MeetingMember;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.service.calendar.AppointmentLogic;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.wicket.util.string.StringValue;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestAppointmentAddAppointment extends AbstractWicketTester {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentAddAppointment.class, getWebAppRootKey());
+
+ @Autowired
+ private AppointmentLogic appointmentLogic;
+ @Autowired
+ private AppointmentDao appointmentDao;
+ @Autowired
+ private UserDao userDao;
+
+ private static void setTime(Appointment a) {
+ a.setStart(Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()));
+ a.setEnd(Date.from(LocalDateTime.now().plusHours(1).atZone(ZoneId.systemDefault()).toInstant()));
+ }
+
+ @Test
+ public void saveAppointment() throws Exception {
+ log.debug("- saveAppointment");
+
+ Calendar start = Calendar.getInstance();
+ start.setTimeInMillis(start.getTimeInMillis() + 600000);
+
+ Calendar end = Calendar.getInstance();
+ end.setTimeInMillis(start.getTimeInMillis() + 600000);
+
+ String appointmentName = "Test 01";
+ String appointmentDescription = "Descr";
+ Long userId = 1L;
+ String appointmentLocation = "office";
+ Boolean isMonthly = false;
+ Boolean isDaily = false;
+ Boolean isWeekly = false;
+ String remind = Appointment.Reminder.ical.name();
+ Boolean isYearly = false;
+ String[] mmClient = new String[1];
+ for (int i = 0; i < 1; i++) {
+ mmClient[0] = createClientObj("firstname" + i, "lastname" + i,
+ "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1");
+ }
+ Long languageId = 1L;
+ Long roomType = 1L;
+
+ Appointment a = appointmentLogic.getAppointment(appointmentName,
+ appointmentLocation, appointmentDescription,
+ start, end, isDaily, isWeekly,
+ isMonthly, isYearly, remind, mmClient,
+ roomType, languageId, false, "", -1, userId);
+ a = appointmentDao.update(a, userId);
+
+ Thread.sleep(3000);
+
+ appointmentLogic.doScheduledMeetingReminder();
+
+ Thread.sleep(3000);
+
+ assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
+ }
+
+ @Test
+ public void testCreate() {
+ Appointment a = new Appointment();
+ a.setTitle("Test title");
+ setTime(a);
+ a.setReminder(Reminder.ical);
+ a.setMeetingMembers(new ArrayList<>());
+ User owner = userDao.get(1L);
+ a.setOwner(owner);
+ a.setRoom(new Room());
+ a.getRoom().setAppointment(true);
+ a.getRoom().setType(Room.Type.conference);
+ for (int i = 0; i < 3; ++i) {
+ MeetingMember mm = new MeetingMember();
+ mm.setUser(getContact(UUID.randomUUID().toString(), owner.getId()));
+ a.getMeetingMembers().add(mm);
+ }
+ a = appointmentDao.update(a, owner.getId());
+ assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
+ assertEquals("Saved appointment should have corect count of guests: ", 3, a.getMeetingMembers().size());
+ for (MeetingMember mm : a.getMeetingMembers()) {
+ assertNotNull("Saved guest should have valid id: ", mm.getId());
+ assertNotNull("Saved guest should have valid invitation: ", mm.getInvitation());
+ assertNotNull("Saved guest should have invitation with ID: ", mm.getInvitation().getId());
+ }
+
+ WebSession ws = WebSession.get();
+ Appointment a1 = appointmentDao.get(a.getId());
+ ws.checkHashes(StringValue.valueOf(""), StringValue.valueOf(a1.getMeetingMembers().get(0).getInvitation().getHash()));
+ assertTrue("Login via secure hash should be successful", ws.isSignedIn());
+ }
+
+ private static String createClientObj(String firstname, String lastname, String email, String jNameTimeZone) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(",") //memberId
+ .append(firstname).append(",")
+ .append(lastname).append(",")
+ .append(email).append(",")
+ .append(",") //userId
+ .append(jNameTimeZone);
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentSchedulerTask.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentSchedulerTask.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentSchedulerTask.java
new file mode 100644
index 0000000..b28d254
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestAppointmentSchedulerTask.java
@@ -0,0 +1,50 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.service.calendar.AppointmentLogic;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestAppointmentSchedulerTask extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentSchedulerTask.class, getWebAppRootKey());
+
+ @Autowired
+ private AppointmentLogic appointmentLogic;
+
+ @Test
+ public void doIt() {
+ log.debug("- 1 MeetingReminderJob.execute");
+ log.warn("- 2 MeetingReminderJob.execute");
+ try {
+ appointmentLogic.doScheduledMeetingReminder();
+
+ assertTrue(true);
+ } catch (Exception err){
+ log.error("execute",err);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureAppointment.java
new file mode 100644
index 0000000..3cb9daf
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureAppointment.java
@@ -0,0 +1,76 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestDatabaseStructureAppointment extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureAppointment.class, getWebAppRootKey());
+
+ @Autowired
+ private AppointmentDao appointmentDao;
+
+ @Test
+ public void testAddingGroup() {
+ try {
+ Calendar cal = Calendar.getInstance();
+ cal.set(2008, 9, 2);
+ cal.get(Calendar.DAY_OF_MONTH);
+ cal.getTime();
+
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+ Date date = format.parse("2008-17-08");
+ Date date2 = format.parse("2008-18-08");
+
+ List<Appointment> listAppoints = appointmentDao.getInRange(1L, date, date2);
+ // List<Appointment> listAppoints = appointmentDao.searchAppointmentsByName("%");
+ // appointmentDao.getNextAppointmentById(1L);
+ // appointmentDao.addAppointment("mezo", 1L, "Pforzheim", "zweiter", Calendar.getInstance().getTime(),
+ // date, null, true, null, null, 1L,1L);
+ // appointmentDao.addAppointment("testap", "erster Test",Calendar.getInstance().getTime(),
+ // Calendar.getInstance().getTime(), true, false, false, false, new Long(1), 1L);
+ log.debug("Anzahl: " + listAppoints.size());
+
+ for (Appointment appoints : listAppoints) {
+ log.debug("Termin: " + appoints.getTitle() + " startDate: " + appoints.getStart() + " endDate: " + appoints.getEnd());
+ log.debug("MeetingMembers: " + appoints.getMeetingMembers().size());
+ }
+
+ for (Iterator<Appointment> iter = listAppoints.iterator(); iter.hasNext();) {
+ log.debug("" + iter.next());
+ }
+ } catch (Exception err) {
+ log.error("[testAddingGroup]", err);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetAppointmentByRange.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetAppointmentByRange.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetAppointmentByRange.java
new file mode 100644
index 0000000..ceacb41
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetAppointmentByRange.java
@@ -0,0 +1,105 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.calendar.MeetingMember;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestDatabaseStructureGetAppointmentByRange extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetAppointmentByRange.class, getWebAppRootKey());
+
+ @Autowired
+ private AppointmentDao appointmentDao;
+
+ @Test
+ public void test() {
+ log.debug("Test started");
+ Long userId = 1L;
+
+ Calendar now = Calendar.getInstance();
+ Calendar rangeStart = Calendar.getInstance();
+ rangeStart.setTime(now.getTime());
+ rangeStart.add(Calendar.DATE, -1);
+ Calendar rangeEnd = Calendar.getInstance();
+ rangeEnd.add(Calendar.DATE, 1);
+ rangeEnd.setTime(now.getTime());
+
+ Calendar a1End = Calendar.getInstance();
+ a1End.setTime(now.getTime());
+ a1End.add(Calendar.HOUR_OF_DAY, 1);
+ Appointment a1 = getAppointment(now.getTime(), a1End.getTime());
+ a1.setTitle("AppointmentByRange_a1");
+
+ Appointment a2 = getAppointment(now.getTime(), a1End.getTime());
+ a2.setTitle("AppointmentByRange_a2");
+ a2.setMeetingMembers(new ArrayList<MeetingMember>());
+ MeetingMember mm1 = new MeetingMember();
+ mm1.setUser(createUserContact(userId));
+ mm1.setAppointment(a2);
+ a2.getMeetingMembers().add(mm1);
+
+ Appointment a3 = getAppointment(now.getTime(), a1End.getTime());
+ a3.setTitle("AppointmentByRange_a3");
+ a3.setMeetingMembers(new ArrayList<MeetingMember>());
+ MeetingMember mm2 = new MeetingMember();
+ mm2.setUser(createUserContact(userId));
+ mm2.setAppointment(a3);
+ a3.getMeetingMembers().add(mm2);
+ MeetingMember mm3 = new MeetingMember();
+ mm3.setUser(createUserContact(userId));
+ mm3.setAppointment(a3);
+ a3.getMeetingMembers().add(mm3);
+
+ a1 = appointmentDao.update(a1, userId);
+ a2 = appointmentDao.update(a2, userId);
+ a3 = appointmentDao.update(a3, userId);
+
+ int a1found = 0, a2found = 0, a3found = 0;
+ for (Appointment a : appointmentDao.getInRange(userId, rangeStart.getTime(), rangeEnd.getTime())) {
+ int mmCount = a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size();
+ if (a.getId().equals(a1.getId())) {
+ assertEquals("Inapropriate MeetingMembers count", 0, mmCount);
+ a1found++;
+ }
+ if (a.getId().equals(a2.getId())) {
+ assertEquals("Inapropriate MeetingMembers count", 1, mmCount);
+ a2found++;
+ }
+ if (a.getId().equals(a3.getId())) {
+ assertEquals("Inapropriate MeetingMembers count", 2, mmCount);
+ a3found++;
+ }
+ }
+ assertEquals("Inappropriate count of appointments without members found", 1, a1found);
+ assertEquals("Inappropriate count of appointments with 1 member found", 1, a2found);
+ assertEquals("Inappropriate count of appointments with 2 members found", 1, a3found);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetUserStart.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetUserStart.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetUserStart.java
new file mode 100644
index 0000000..6c7b50c
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureGetUserStart.java
@@ -0,0 +1,44 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestDatabaseStructureGetUserStart extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetUserStart.class, getWebAppRootKey());
+
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testAddingGroup() {
+ try {
+ userDao.get(new Long(1));
+ } catch (Exception err) {
+ log.error("[testAddingGroup]", err);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureMeetingMember.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureMeetingMember.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureMeetingMember.java
new file mode 100644
index 0000000..20d3d54
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureMeetingMember.java
@@ -0,0 +1,41 @@
+/*
+ * 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.calendar;
+
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.junit.Test;
+
+
+public class TestDatabaseStructureMeetingMember extends AbstractJUnitDefaults {
+
+ @Test
+ public void testUpdateMeetingMember(){
+ //FIXME need to be refactored !!!!
+
+ //MeetingMemberDaoImpl.getInstance().addMeetingMember("Adddd", "dir", "1", "2", 1L, 1L, "test");
+ //MeetingMemberDaoImpl.getInstance().addMeetingMember(firstname, lastname, memberStatus, appointmentStatus, appointmentId, userid, email)
+
+
+ //MeetingMemberDaoImpl.getInstance().getMeetingMemberById(1L);
+ //MeetingMemberDaoImpl.getInstance().deleteMeetingMember(2L);
+
+ //meetingMemberDao.updateMeetingMember(1l,"bbbbbb", "dir", "1", "2", 1L, 1L, "test", "");
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureUsersSearch.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureUsersSearch.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureUsersSearch.java
new file mode 100644
index 0000000..cb6d228
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestDatabaseStructureUsersSearch.java
@@ -0,0 +1,49 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import java.util.List;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestDatabaseStructureUsersSearch extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureUsersSearch.class, getWebAppRootKey());
+
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testAddingGroup(){
+ try {
+ List<User> users = userDao.get("first", 0, 10, "lastname", false, 1L);
+ log.debug("[result]" + users.size());
+ log.debug("[records]"+ users);
+ } catch (Exception err) {
+ log.error("[testAddingGroup]",err);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestGetAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestGetAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestGetAppointment.java
new file mode 100644
index 0000000..3b907f6
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestGetAppointment.java
@@ -0,0 +1,60 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Calendar;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
+import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestGetAppointment extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestGetAppointment.class, getWebAppRootKey());
+
+ @Autowired
+ private AppointmentDao appointmentDao;
+
+ @Test
+ public void getAppoinment() {
+ log.debug("getAppoinment enter");
+ Long userId = 1L;
+
+ Calendar now = Calendar.getInstance();
+ Calendar a1End = Calendar.getInstance();
+ a1End.setTime(now.getTime());
+ a1End.add(Calendar.HOUR_OF_DAY, 1);
+ Appointment a1 = getAppointment(now.getTime(), a1End.getTime());
+ a1.setTitle("GetAppointment");
+
+ a1 = appointmentDao.update(a1, userId);
+
+ Appointment a = appointmentDao.get(a1.getId());
+ assertNotNull("Failed to get Appointment By id", a);
+ assertEquals("Inapropriate MeetingMembers count", 0, a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestOmCalendar.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestOmCalendar.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestOmCalendar.java
new file mode 100644
index 0000000..dbaf91c
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestOmCalendar.java
@@ -0,0 +1,58 @@
+/*
+ * 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.calendar;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestOmCalendar extends AbstractJUnitDefaults {
+ @Autowired
+ private OmCalendarDao calendarDao;
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void saveCalendar() {
+ OmCalendar calendar = new OmCalendar();
+ Long userId = 1L;
+ User owner = userDao.get(userId);
+ String title = "Calendar Title", href = "http://caldav.example.com/principals/user";
+
+ calendar.setOwner(owner);
+ calendar.setTitle(title);
+ calendar.setHref(href);
+ calendar.setSyncType(OmCalendar.SyncType.ETAG);
+
+ calendar = calendarDao.update(calendar);
+
+ assertTrue("Saved calendar should have valid id: " + calendar.getId(),
+ calendar.getId() != null && calendar.getId() > 0);
+
+ OmCalendar c = calendarDao.get(calendar.getId());
+ assertNotNull("Failed to find Calendar by id", c);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestSendIcalMessage.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestSendIcalMessage.java b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestSendIcalMessage.java
new file mode 100644
index 0000000..6c3c81b
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/calendar/TestSendIcalMessage.java
@@ -0,0 +1,235 @@
+/*
+ * 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.calendar;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.Multipart;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.core.mail.MailHandler;
+import org.apache.openmeetings.util.mail.ByteArrayDataSource;
+import org.apache.openmeetings.util.mail.IcalHandler;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import net.fortuna.ical4j.data.CalendarOutputter;
+import net.fortuna.ical4j.model.DateTime;
+import net.fortuna.ical4j.model.TimeZone;
+import net.fortuna.ical4j.model.TimeZoneRegistry;
+import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
+import net.fortuna.ical4j.model.component.VEvent;
+import net.fortuna.ical4j.model.component.VTimeZone;
+import net.fortuna.ical4j.model.parameter.Cn;
+import net.fortuna.ical4j.model.parameter.Role;
+import net.fortuna.ical4j.model.property.Attendee;
+import net.fortuna.ical4j.model.property.CalScale;
+import net.fortuna.ical4j.model.property.Method;
+import net.fortuna.ical4j.model.property.Organizer;
+import net.fortuna.ical4j.model.property.ProdId;
+import net.fortuna.ical4j.model.property.Uid;
+import net.fortuna.ical4j.model.property.Version;
+
+public class TestSendIcalMessage extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestSendIcalMessage.class, getWebAppRootKey());
+
+ @Autowired
+ private MailHandler mailHandler;
+
+ private byte[] iCalMimeBody;
+
+ String subject = "test iCal";
+ String recipients = "seba.wagner@gmail.com";
+ String htmlBody = "test";
+
+
+ public void simpleInvitionIcalLink() {
+ // Create a TimeZone
+ TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
+ TimeZone timezone = registry.getTimeZone("America/Mexico_City");
+ VTimeZone tz = timezone.getVTimeZone();
+
+ // Start Date is on: April 1, 2008, 9:00 am
+ java.util.Calendar startDate = new GregorianCalendar();
+ startDate.setTimeZone(timezone);
+ startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
+ startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
+ startDate.set(java.util.Calendar.YEAR, 2008);
+ startDate.set(java.util.Calendar.HOUR_OF_DAY, 9);
+ startDate.set(java.util.Calendar.MINUTE, 0);
+ startDate.set(java.util.Calendar.SECOND, 0);
+
+ // End Date is on: April 1, 2008, 13:00
+ java.util.Calendar endDate = new GregorianCalendar();
+ endDate.setTimeZone(timezone);
+ endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
+ endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
+ endDate.set(java.util.Calendar.YEAR, 2008);
+ endDate.set(java.util.Calendar.HOUR_OF_DAY, 13);
+ endDate.set(java.util.Calendar.MINUTE, 0);
+ endDate.set(java.util.Calendar.SECOND, 0);
+
+ // Create the event
+ String eventName = "Progress Meeting";
+ DateTime start = new DateTime(startDate.getTime());
+ DateTime end = new DateTime(endDate.getTime());
+ VEvent meeting = new VEvent(start, end, eventName);
+
+ // add timezone info..
+ meeting.getProperties().add(tz.getTimeZoneId());
+
+ // generate unique identifier..
+ Uid uid = new Uid(UUID.randomUUID().toString());
+ meeting.getProperties().add(uid);
+
+ // add attendees..
+ Attendee dev1 = new Attendee(URI.create("mailto:dev1@mycompany.com"));
+ dev1.getParameters().add(Role.REQ_PARTICIPANT);
+ dev1.getParameters().add(new Cn("Developer 1"));
+ meeting.getProperties().add(dev1);
+
+ Attendee dev2 = new Attendee(URI.create("mailto:dev2@mycompany.com"));
+ dev2.getParameters().add(Role.OPT_PARTICIPANT);
+ dev2.getParameters().add(new Cn("Developer 2"));
+ meeting.getProperties().add(dev2);
+
+ // Create a calendar
+ net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
+ icsCalendar.getProperties().add(
+ new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
+ icsCalendar.getProperties().add(CalScale.GREGORIAN);
+ icsCalendar.getProperties().add(Version.VERSION_2_0);
+
+ // Add the event and print
+ icsCalendar.getComponents().add(meeting);
+
+ Organizer orger = new Organizer(URI.create("seba.wagner@gmail.com"));
+ orger.getParameters().add(new Cn("Sebastian Wagner"));
+ meeting.getProperties().add(orger);
+
+ icsCalendar.getProperties().add(Method.REQUEST);
+
+ log.debug(icsCalendar.toString());
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ CalendarOutputter outputter = new CalendarOutputter();
+ try {
+ outputter.output(icsCalendar, bout);
+ iCalMimeBody = bout.toByteArray();
+
+ sendIcalMessage();
+ } catch (Exception e) {
+ log.error("Error", e);
+ }
+ }
+
+ @Test
+ public void sendInvitionIcalLink() {
+ try {
+ String email = "hans@webbase-design.de";
+ String username = "shans";
+ boolean invitor = false;
+
+ Calendar start = Calendar.getInstance();
+ Calendar end = Calendar.getInstance();
+ IcalHandler handler = new IcalHandler(IcalHandler.ICAL_METHOD_REQUEST);
+
+ // Transforming Meeting Members
+
+ Map<String, String> attendeeList = handler.getAttendeeData(email, username, invitor);
+ Map<String, String> organizerAttendee = handler.getAttendeeData(recipients, "seba-test", true);
+
+ List<Map<String, String>> atts = new ArrayList<>();
+ atts.add(attendeeList);
+
+ // Create ICal Message
+ String meetingId = handler.addNewMeeting(start.getTime(), end.getTime(), "test event",
+ atts, "localhost:5080/link_openmeetings",
+ organizerAttendee, "", java.util.TimeZone.getDefault().getID());
+
+ log.debug("meetingId " + meetingId);
+
+ iCalMimeBody = handler.getIcalAsByteArray();
+
+ sendIcalMessage();
+
+ // return MailHandler.sendMail(email, subject, template);
+
+ } catch (Exception err) {
+ log.error("sendInvitionIcalLink", err);
+ }
+ }
+
+ private void sendIcalMessage() throws Exception {
+ log.debug("sendIcalMessage");
+
+ // Building MimeMessage
+ MimeMessage mimeMessage = mailHandler.getBasicMimeMessage();
+ mimeMessage.setSubject(subject);
+ mimeMessage.addRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
+
+ // -- Create a new message --
+ BodyPart msg = new MimeBodyPart();
+ msg.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlBody,
+ "text/html; charset=\"utf-8\"")));
+
+ Multipart multipart = new MimeMultipart();
+
+ BodyPart iCalAttachment = new MimeBodyPart();
+ iCalAttachment.setDataHandler(new DataHandler(
+ new javax.mail.util.ByteArrayDataSource(
+ new ByteArrayInputStream(iCalMimeBody),
+ "text/calendar;method=REQUEST;charset=\"UTF-8\"")));
+ iCalAttachment.setFileName("invite.ics");
+
+ multipart.addBodyPart(iCalAttachment);
+ multipart.addBodyPart(msg);
+
+ mimeMessage.setSentDate(new Date());
+ mimeMessage.setContent(multipart);
+
+ // -- Set some other header information --
+ // mimeMessage.setHeader("X-Mailer", "XML-Mail");
+ // mimeMessage.setSentDate(new Date());
+
+ // Transport trans = session.getTransport("smtp");
+ Transport.send(mimeMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/config/TestConfig.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/config/TestConfig.java b/openmeetings-web/src/test/java/org/apache/openmeetings/config/TestConfig.java
new file mode 100644
index 0000000..ffcc28e
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/config/TestConfig.java
@@ -0,0 +1,74 @@
+/*
+ * 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.config;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_SERVER;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.List;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
+import org.apache.openmeetings.db.entity.basic.Configuration;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestConfig extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestConfig.class, getWebAppRootKey());
+
+ @Autowired
+ private ConfigurationDao configurationDao;
+
+ @Test
+ public void getConfigKey() {
+ System.err.println("THIS");
+
+ Configuration smtp_server = configurationDao.get(CONFIG_SMTP_SERVER);
+
+ System.err.println("smtp_server " + smtp_server.getUser());
+
+ assertNull(smtp_server.getUser());
+ }
+
+ @Test
+ public void getConfigs() {
+
+ try {
+ List<Configuration> list = configurationDao.get(4, 6);
+
+ for (Configuration conf : list) {
+ log.error("conf.getKey() " + conf.getKey());
+ log.error("conf.getUser() " + conf.getUser());
+ if (conf.getUser() != null) {
+ log.error("conf.getUsers() " + conf.getUser().getLogin());
+ }
+ }
+
+ assertEquals(list.size(), 6);
+
+ } catch (Exception err) {
+ log.error("[startConversion]", err);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/core/file/TestFileProcessor.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/core/file/TestFileProcessor.java b/openmeetings-web/src/test/java/org/apache/openmeetings/core/file/TestFileProcessor.java
new file mode 100644
index 0000000..8a556c4
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/core/file/TestFileProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * 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.core.file;
+
+import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.UUID;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.core.data.file.FileProcessor;
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+import org.apache.openmeetings.db.entity.file.BaseFileItem;
+import org.apache.openmeetings.db.entity.file.FileItem;
+import org.apache.openmeetings.util.process.ConverterProcessResultList;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestFileProcessor extends AbstractJUnitDefaults {
+ private static final String FILE_NAME = "test_name";
+
+ @Autowired
+ protected FileProcessor processor;
+
+ @Test
+ public void testProcessJpeg() throws Exception {
+ for (String ext : new String[] {null, "txt", "png"}) {
+ FileItem f = new FileItemDTO()
+ .setName(String.format("%s.%s", FILE_NAME, ext))
+ .setHash(UUID.randomUUID().toString())
+ .setType(BaseFileItem.Type.Recording).get();
+ try (InputStream is = new FileInputStream(getDefaultProfilePicture())) {
+ ConverterProcessResultList result = processor.processFile(f, is);
+ assertFalse("Conversion should be successful", result.hasError());
+ assertEquals("Type should be image", BaseFileItem.Type.Image, f.getType());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/derby/PrepareSystemFiles.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/derby/PrepareSystemFiles.java b/openmeetings-web/src/test/java/org/apache/openmeetings/derby/PrepareSystemFiles.java
new file mode 100644
index 0000000..6c142f0
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/derby/PrepareSystemFiles.java
@@ -0,0 +1,67 @@
+/*
+ * 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.derby;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+
+import java.io.File;
+
+import org.apache.openmeetings.cli.ConnectionPropertiesPatcher;
+import org.apache.openmeetings.util.ConnectionProperties.DbType;
+import org.apache.openmeetings.util.OmFileHelper;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * This file is called from command line to patch the derby configuration
+ * during the automated run of Selenium
+ *
+ * @author swagner
+ *
+ */
+public class PrepareSystemFiles {
+ private static final Logger log = Red5LoggerFactory.getLogger(PrepareSystemFiles.class, getWebAppRootKey());
+
+ public static void main(String... args) {
+ try {
+ OmFileHelper.setOmHome(args[0]);
+
+ String databaseHomeDirectory = args[1];
+
+ String persistanceFileToPatch = args[2];
+
+ File conf = new File(persistanceFileToPatch);
+
+ if (conf.exists()) {
+ conf.delete();
+ }
+
+ ConnectionPropertiesPatcher.patch(DbType.derby.name()
+ , "localhost"
+ , "1527"
+ , databaseHomeDirectory + "openmeetings"
+ , "user"
+ , "secret"
+ );
+ } catch (Exception err) {
+ log.error("Error", err);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestAddGroup.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestAddGroup.java b/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestAddGroup.java
new file mode 100644
index 0000000..552b900
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestAddGroup.java
@@ -0,0 +1,60 @@
+/*
+ * 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.domain;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.Group;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestAddGroup extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestAddGroup.class, getWebAppRootKey());
+
+ @Autowired
+ private GroupDao groupDao;
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testAddingGroup() {
+ Group o = new Group();
+ o.setName("default");
+ o = groupDao.update(o, null);
+ assertNotNull("Id of group created should not be null", o.getId());
+
+ User us = userDao.get(1L);
+ assertNotNull("User should exist", us);
+
+ assertNotNull("Group User list should exist", us.getGroupUsers());
+ us.getGroupUsers().add(new GroupUser(o, us));
+ us = userDao.update(us, null);
+
+ log.error(us.getLastname());
+ log.error(us.getAddress().getTown());
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestUserGroupAggregation.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestUserGroupAggregation.java b/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestUserGroupAggregation.java
new file mode 100644
index 0000000..accdcd0
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/domain/TestUserGroupAggregation.java
@@ -0,0 +1,51 @@
+/*
+ * 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.domain;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestUserGroupAggregation extends AbstractJUnitDefaults {
+ private static final Logger log = Red5LoggerFactory.getLogger(TestUserGroupAggregation.class, getWebAppRootKey());
+
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void testitNow() {
+ User u = userDao.get(1L);
+
+ assertNotNull("Group list for default user must not be null", u.getGroupUsers());
+ assertTrue("Default user must belong to at least one group", u.getGroupUsers().size() > 0);
+
+ for (GroupUser orgUserObj : u.getGroupUsers()) {
+ log.error("testitNow: group Id: '" + orgUserObj.getGroup().getId() + "'; name: '" + orgUserObj.getGroup().getName() + "'");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/invitiation/TestInvitation.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/invitiation/TestInvitation.java b/openmeetings-web/src/test/java/org/apache/openmeetings/invitiation/TestInvitation.java
new file mode 100644
index 0000000..e0152b7
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/invitiation/TestInvitation.java
@@ -0,0 +1,57 @@
+/*
+ * 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.invitiation;
+
+import static org.apache.openmeetings.util.CalendarHelper.getDate;
+
+import java.time.LocalDateTime;
+
+import org.apache.openmeetings.AbstractWicketTester;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
+import org.apache.openmeetings.db.entity.room.Invitation.Valid;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.service.room.InvitationManager;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestInvitation extends AbstractWicketTester {
+ @Autowired
+ private InvitationManager invitationManager;
+ @Autowired
+ private UserDao userDao;
+ @Autowired
+ private RoomDao roomDao;
+
+ @Test
+ public void testSendInvitationLink() throws Exception {
+ User us = userDao.getByLogin(username, User.Type.user, null);
+
+ LocalDateTime from = LocalDateTime.now().plusDays(1).withHour(12).withMinute(0).withSecond(0);
+ User invitee = userDao.getContact("sebawagner@apache.org", "Testname", "Testlastname", us.getId());
+ Invitation i = invitationManager.getInvitation(invitee, roomDao.get(1L),
+ false, "", Valid.OneTime
+ , us, us.getLanguageId(),
+ getDate(from, "GMT"), getDate(from.plusHours(2), "GMT"), null);
+
+ invitationManager.sendInvitationLink(i, MessageType.Create, "subject", "message", false);
+ }
+}
[3/4] openmeetings git commit: [OPENMEETINGS-1714] more issues are
fixed
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/AbstractTestDefaults.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/AbstractTestDefaults.java b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/AbstractTestDefaults.java
new file mode 100644
index 0000000..af854f4
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/AbstractTestDefaults.java
@@ -0,0 +1,229 @@
+/*
+ * 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.selenium;
+
+import java.util.List;
+
+import org.apache.openmeetings.AbstractSpringTest;
+import org.apache.openmeetings.db.dao.label.LabelDao;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.experimental.categories.Category;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.firefox.FirefoxOptions;
+import org.openqa.selenium.firefox.FirefoxProfile;
+
+@Category(SeleniumTests.class)
+public abstract class AbstractTestDefaults extends AbstractSpringTest {
+ public WebDriver driver = null;
+
+ private String BASE_URL = "http://localhost:5080/openmeetings";
+ private String username = "swagner";
+ private String userpass = "qweqwe";
+ private String groupName = "seleniumtest";
+ private String email = "selenium@openmeetings.apache.org";
+ private String locale = "en-us";
+
+
+ public String getBASE_URL() {
+ return BASE_URL;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getUserpass() {
+ return userpass;
+ }
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public Long getLanguageId() {
+ return 1L;
+ }
+
+ public String getLocale() {
+ return locale;
+ }
+
+ // setting this to false can be handy if you run the test from inside
+ // Eclipse, the browser will not shut down after the test so you can start
+ // to diagnose the test issue
+ public boolean doTearDownAfterTest = false;
+
+ public String getString(String key) {
+ return LabelDao.getString(key, getLanguageId());
+ }
+
+ /**
+ * Make method overwrite possible to have custom behavior in tests
+ *
+ * @return
+ */
+ public boolean getDoTearDownAfterTest() {
+ return doTearDownAfterTest;
+ }
+
+ @Before
+ public void setUp() {
+ FirefoxProfile profile = new FirefoxProfile();
+ profile.setPreference("intl.accept_languages", getLocale());
+ driver = new FirefoxDriver(new FirefoxOptions().setProfile(profile));
+ }
+
+ /**
+ * This test is a basic test to verify the default loader mechanism works
+ * it is not intend to be a part of any sub test
+ *
+ * @throws Exception
+ */
+ //@Test
+ public void smokeTest() throws Exception {
+ try {
+ driver.get(getBASE_URL());
+
+ testIsInstalledAndDoInstallation();
+
+ SeleniumUtils.inputText(driver, "login", getUsername());
+ SeleniumUtils.inputText(driver, "pass", getUserpass());
+
+ WebElement signInButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), 'Sign in')]]", true, true);
+ signInButton.click();
+
+ SeleniumUtils.elementExists(driver,
+ "//h3[contains(text(), 'Help and support')]", true);
+ } catch (Exception e) {
+ SeleniumUtils.makeScreenShot(this.getClass().getSimpleName(), e,
+ driver);
+ throw e;
+ }
+ }
+
+ /**
+ * Throws exception in case that test fails, so it is important to not catch
+ * that exception but really let the test fail!
+ *
+ * @throws Exception
+ */
+ protected void testIsInstalledAndDoInstallation() throws Exception {
+
+ WebElement wicketExtensionsWizardHeaderTitle = SeleniumUtils
+ .findElement(driver, "wicketExtensionsWizardHeaderTitle", false, true);
+ if (wicketExtensionsWizardHeaderTitle == null) {
+ return;
+ }
+ if (wicketExtensionsWizardHeaderTitle.getText()
+ .contains("Installation")) {
+ System.out.println("Do Installation");
+ doInstallation();
+ }
+
+ }
+
+ private void doInstallation() throws Exception {
+ Thread.sleep(3000L);
+
+ List<WebElement> buttons_next = SeleniumUtils.findElements(driver,
+ "buttons:next", true);
+
+ buttons_next.get(1).sendKeys(Keys.RETURN);
+
+ Thread.sleep(1000L);
+
+ SeleniumUtils.inputText(driver, "view:cfg.username", getUsername());
+ SeleniumUtils.inputText(driver, "view:cfg.password", getUserpass());
+ SeleniumUtils.inputText(driver, "view:cfg.email", getEmail());
+ SeleniumUtils.inputText(driver, "view:cfg.group", getGroupName());
+
+ buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
+
+ buttons_next.get(1).sendKeys(Keys.RETURN);
+
+ Thread.sleep(1000L);
+
+ buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
+
+ buttons_next.get(1).sendKeys(Keys.RETURN);
+
+ Thread.sleep(1000L);
+
+ buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
+
+ buttons_next.get(1).sendKeys(Keys.RETURN);
+
+ Thread.sleep(1000L);
+
+ buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
+
+ buttons_next.get(1).sendKeys(Keys.RETURN);
+
+ Thread.sleep(2000L);
+
+ List<WebElement> elements = SeleniumUtils.findElements(driver,
+ "buttons:finish", true);
+
+ elements.get(1).sendKeys(Keys.RETURN);
+
+ long maxMilliSecondsWait = 120000;
+
+ while (maxMilliSecondsWait > 0) {
+
+ // check if installation is complete by searching for the link on
+ // the success page
+ WebElement enterApplicationLink = SeleniumUtils.findElement(driver,
+ "//a[contains(@href,'install')]", false, true);
+
+ if (enterApplicationLink == null) {
+ System.out
+ .println("Installation running - wait 3 more seconds and check again");
+
+ Thread.sleep(3000L);
+ maxMilliSecondsWait -= 3000;
+ } else {
+ maxMilliSecondsWait = 0;
+
+ enterApplicationLink.click();
+
+ return;
+ }
+ }
+
+ throw new Exception("Timeout during installation");
+ }
+
+ @After
+ public void tearDown() {
+ if (getDoTearDownAfterTest()) {
+ driver.close();
+ driver.quit();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/HeavyTests.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/HeavyTests.java b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/HeavyTests.java
new file mode 100644
index 0000000..a1eaca6
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/HeavyTests.java
@@ -0,0 +1,23 @@
+/*
+ * 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.selenium;
+
+public @interface HeavyTests {
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumTests.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumTests.java b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumTests.java
new file mode 100644
index 0000000..5b4351c
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumTests.java
@@ -0,0 +1,23 @@
+/*
+ * 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.selenium;
+
+public @interface SeleniumTests {
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumUtils.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumUtils.java b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumUtils.java
new file mode 100644
index 0000000..8b860a8
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/SeleniumUtils.java
@@ -0,0 +1,229 @@
+/*
+ * 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.selenium;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.openqa.selenium.By;
+import org.openqa.selenium.OutputType;
+import org.openqa.selenium.TakesScreenshot;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+public class SeleniumUtils {
+ private static final Logger log = Red5LoggerFactory.getLogger(SeleniumUtils.class, getWebAppRootKey());
+ // we need to retry some actions because our web site is dynamic
+ static int numberOfRetries = 10;
+
+ // we need to sleep to make sure Ajax could complete whatever it does
+ static long defaultSleepInterval = 1000;
+
+ public static void inputText(WebDriver driver, String search,
+ String inputText) throws Exception {
+ WebElement element = SeleniumUtils.findElement(driver, search, true, true);
+
+ //clear text before adding input
+ element.clear();
+
+ // Would make send to check if this element is really an input text
+ element.sendKeys(inputText);
+ }
+
+ public static void click(WebDriver driver, String search) throws Exception {
+ WebElement element = SeleniumUtils.findElement(driver, search, true, true);
+ element.click();
+ }
+
+ /**
+ *
+ * @param driver
+ * @param search
+ * @param throwException
+ * under some circumstance you do't want to exit the test here
+ * @return
+ * @throws Exception
+ */
+ public static List<WebElement> findElements(WebDriver driver, String search,
+ boolean throwException) throws Exception {
+ for (int i = 0; i < numberOfRetries; i++) {
+ List<WebElement> elements = _findElement(driver, search);
+ if (elements != null) {
+ return elements;
+ }
+
+ Thread.sleep(defaultSleepInterval);
+ }
+
+ if (throwException) {
+ throw new Exception("Could not find element with specified path "
+ + search);
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param driver
+ * @param search
+ * @param throwException
+ * under some circumstance you do't want to exit the test here
+ * @param onlyReturnVisisbleElement TODO
+ * @return
+ * @throws Exception
+ */
+ public static WebElement findElement(WebDriver driver, String search,
+ boolean throwException, boolean onlyReturnVisisbleElement) throws Exception {
+ for (int i = 0; i < numberOfRetries; i++) {
+ List<WebElement> elements = _findElement(driver, search);
+ if (elements != null) {
+
+ if (!onlyReturnVisisbleElement) {
+ return elements.get(0);
+ }
+
+ for (WebElement element : elements) {
+ if (element.isDisplayed()) {
+ return element;
+ }
+ }
+
+ }
+
+ Thread.sleep(defaultSleepInterval);
+ }
+
+ if (throwException) {
+ throw new Exception("Could not find element with specified path "
+ + search);
+ }
+
+ return null;
+ }
+
+ private static By[] _getSearchArray(String search) {
+ //If xpath we have to use it, if xpath is used with By.className(...) there will be an exception
+ if (search.startsWith("//")) {
+ return new By[] { By.xpath(search) };
+ } else {
+ return new By[] { By.id(search), By.name(search), By.className(search),
+ By.tagName(search), By.xpath(search) };
+ }
+ }
+
+ private static List<WebElement> _findElement(WebDriver driver, String search) {
+ for (By by : _getSearchArray(search)) {
+ try {
+ List<WebElement> elements = driver.findElements(by);
+ if (elements != null && elements.size() > 0) {
+ return elements;
+ }
+ } catch (Exception e) {
+ // Do not show any warnings
+ }
+ }
+ return null;
+ }
+
+ public static void elementExists(WebDriver driver, String search,
+ boolean shouldExist) throws Exception {
+ Thread.sleep(defaultSleepInterval);
+
+ boolean doesExist = !shouldExist;
+
+ for (int i = 0; i < numberOfRetries; i++) {
+ doesExist = checkExists(driver, search);
+ if (doesExist == shouldExist) {
+ break;
+ }
+
+ Thread.sleep(defaultSleepInterval);
+ }
+
+ if (doesExist != shouldExist) {
+ if (shouldExist) {
+ throw new Exception("Element could not be found: " + search);
+ } else {
+ throw new Exception("Unexpected Element was found: " + search);
+ }
+ }
+ }
+
+ private static boolean checkExists(WebDriver driver, String search) {
+ for (By by : _getSearchArray(search)) {
+ try {
+ List<WebElement> element = driver.findElements(by);
+ if (element.size() > 0) {
+ return true;
+ }
+ } catch (Exception e) {
+ // Do not show any warnings
+ }
+ }
+ return false;
+ }
+
+ public static void makeScreenShot(String testName, Exception e,
+ WebDriver driver) {
+ try {
+ DateFormat df = new SimpleDateFormat("MM-dd-yyyy_HH-mm-ss");
+ String fileName = e.getMessage().replace(" ", "_");
+ fileName = fileName.replaceAll("(\r\n|\n)", "");
+ fileName = fileName.replaceAll("/", "");
+
+ if (fileName.length() > 100) {
+ fileName = fileName.substring(0, 100);
+ }
+
+ fileName = fileName + "_" + df.format(new Date()) + ".png";
+ File screenShotFile = ((TakesScreenshot) driver)
+ .getScreenshotAs(OutputType.FILE);
+
+ String path = "." + File.separatorChar + "build"
+ + File.separatorChar + "screenshots" + File.separatorChar
+ + testName;
+
+ File screenshotFolder = new File(path);
+ if (!screenshotFolder.exists()) {
+ screenshotFolder.mkdirs();
+ }
+
+ System.out.println("screenshot copy from: "
+ + screenShotFile.getAbsolutePath());
+ System.out.println("Length Filename: " + fileName.length()
+ + " - Writing screenshot to: " + path + File.separatorChar
+ + fileName);
+
+ FileUtils.moveFile(screenShotFile, new File(path
+ + File.separatorChar + fileName));
+ } catch (Exception err) {
+ log.error("Error", err);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/TestSignUp.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/TestSignUp.java b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/TestSignUp.java
new file mode 100644
index 0000000..4ee6d17
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/selenium/TestSignUp.java
@@ -0,0 +1,128 @@
+/*
+ * 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.selenium;
+
+import java.util.Date;
+
+import org.junit.Test;
+import org.openqa.selenium.Alert;
+import org.openqa.selenium.WebElement;
+
+import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButtons;
+
+public class TestSignUp extends AbstractTestDefaults {
+ String pass = "pass";
+
+ @Override
+ public boolean getDoTearDownAfterTest() {
+ return false;
+ }
+
+ @Test
+ public void testSignUp() throws Exception {
+ try {
+ driver.get(getBASE_URL());
+
+ String currentRandomCounter = "" + ((new Date().getTime())/1000);
+ String userName = "seba" + currentRandomCounter;
+ String email = "hans." + currentRandomCounter + "@openmeetings.apache.org";
+
+ super.testIsInstalledAndDoInstallation();
+
+ WebElement signUpButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
+ signUpButton.click();
+
+ // ##################################
+ // Test validation message for passwords to be identical
+ // ##################################
+ doSignUp("Hans","Muster", userName, "pw", "pw2", email);
+
+ //Find Error label-id 232 "Please enter two identical passwords"
+ SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("232") + "')]", true, true);
+
+ // ##################################
+ // Sign up with user and sign in
+ // ##################################
+ doSignUp("Hans","Muster", userName, pass, pass, email);
+
+ //Check for popup with success message and email to check
+ SeleniumUtils.findElement(driver, "//span[contains(text(), '" + getString("warn.notverified") + "')]", true, true);
+
+ //click button to close popup
+ WebElement signUpSucessPopUpOkButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), '" + DialogButtons.OK.toString() + "')]]", true, true);
+ signUpSucessPopUpOkButton.click();
+
+ //Login with user
+ SeleniumUtils.inputText(driver, "login", userName);
+ SeleniumUtils.inputText(driver, "pass", pass);
+
+ //click labelid 112 "Sign In"
+ WebElement signInButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), '" + getString("112") + "')]]", true, true);
+ signInButton.click();
+
+ // check for some text in dashbaord, labelid 281, "Help and support"
+ SeleniumUtils.elementExists(driver,
+ "//h3[contains(text(), '" + getString("281") + "')]", true);
+
+ //sign out
+ WebElement signOutLink = SeleniumUtils.findElement(driver,
+ "//a[contains(text(), '" + getString("310") + "')]", true, true);
+ signOutLink.click();
+
+ Alert alert = driver.switchTo().alert();
+ alert.accept();
+
+ // ##################################
+ // Sign up with same user and email and check duplicate messages
+ // ##################################
+
+ signUpButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
+ signUpButton.click();
+
+ doSignUp("Hans","Muster", userName, pass, pass, email);
+
+ SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.login.inuse") + "')]", true, true);
+
+ SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.email.inuse") + "')]", true, true);
+ } catch (Exception e) {
+ SeleniumUtils.makeScreenShot(this.getClass().getSimpleName(), e,
+ driver);
+ throw e;
+ }
+ }
+
+ private void doSignUp(String firstName, String lastName, String login, String password,
+ String confirmPassword, String email) throws Exception {
+
+ SeleniumUtils.inputText(driver, "firstName", firstName);
+ SeleniumUtils.inputText(driver, "lastName", lastName);
+ SeleniumUtils.inputText(driver, "//input[@name='login']", login);
+ SeleniumUtils.inputText(driver, "password", password);
+ SeleniumUtils.inputText(driver, "confirmPassword", confirmPassword);
+ SeleniumUtils.inputText(driver, "email", email);
+
+ WebElement submitButton = SeleniumUtils.findElement(driver,
+ "//button[span[contains(text(), 'Register')]]", true, true);
+ submitButton.click();
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/smoke/TestSmokeBasic.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/smoke/TestSmokeBasic.java b/openmeetings-web/src/test/java/org/apache/openmeetings/smoke/TestSmokeBasic.java
new file mode 100644
index 0000000..9a8b2cc
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/smoke/TestSmokeBasic.java
@@ -0,0 +1,36 @@
+/*
+ * 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.smoke;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestSmokeBasic extends AbstractJUnitDefaults {
+ @Autowired
+ private UserDao userDao;
+
+ @Test
+ public void createErrorValueAndTest() {
+ assertNotNull(userDao.get(1L));
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractJUnitDefaults.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractJUnitDefaults.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractJUnitDefaults.java
deleted file mode 100644
index 218b68a..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractJUnitDefaults.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getConfigKeyCryptClassName;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.setWicketApplicationName;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.db.entity.room.Room;
-import org.apache.openmeetings.db.entity.user.Address;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.installation.ImportInitvalues;
-import org.apache.openmeetings.installation.InstallationConfig;
-import org.junit.Before;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
- private static final Logger log = Red5LoggerFactory.getLogger(AbstractJUnitDefaults.class);
- public static final int ONE_HOUR = 60 * 60 * 1000;
-
- protected static final String username = "admin";
- protected static final String userpass = "12345";
- private static final String group = "smoketest";
- private static final String timeZone = "Europe/Berlin";
- private static final String email = "junit@openmeetings.apache.org";
-
- @Autowired
- private AppointmentDao appointmentDao;
- @Autowired
- private UserDao userDao;
- @Autowired
- private ImportInitvalues importInitvalues;
- @Autowired
- protected ConfigurationDao cfgDao;
-
- @Before
- public void setUp() throws Exception {
- setWicketApplicationName("openmeetings");
- cfgDao.getCryptKey();
- if (userDao.count() < 1) {
- makeDefaultScheme();
- log.info("Default scheme created successfully");
- } else {
- log.info("Default scheme already created");
- }
- if (getConfigKeyCryptClassName() == null) {
- assertNotNull("Crypt class name should not be null", cfgDao.getCryptKey());
- }
- }
-
- public Appointment getAppointment() {
- Date start = new Date();
- Date end = new Date();
- end.setTime(start.getTime() + ONE_HOUR);
- return getAppointment(start, end);
- }
-
- public Appointment getAppointment(Date start, Date end) {
- return getAppointment(userDao.get(1L), start, end);
- }
-
- public Appointment getAppointment(User owner, Date start, Date end) {
- return getAppointment(owner, null, start, end);
- }
-
- public Appointment getAppointment(User owner, Room r, Date start, Date end) {
- assertNotNull("Can't access to appointment dao implimentation", appointmentDao);
-
- // add new appointment
- Appointment ap = new Appointment();
-
- ap.setTitle("appointmentName");
- ap.setLocation("appointmentLocation");
-
- ap.setStart(start);
- ap.setEnd(end);
- ap.setDescription("appointmentDescription");
- ap.setInserted(new Date());
- ap.setDeleted(false);
- ap.setIsDaily(false);
- ap.setIsWeekly(false);
- ap.setIsMonthly(false);
- ap.setIsYearly(false);
- ap.setPasswordProtected(false);
-
- ap.setOwner(owner);
- ap.setConnectedEvent(false);
-
- if (ap.getReminder() == null) {
- ap.setReminder(Appointment.Reminder.none);
- }
-
- if (r == null) {
- r = new Room();
- r.setType(Room.Type.conference);
- r.setAppointment(true);
- }
- ap.setRoom(r);
- return ap;
- }
-
- public Appointment createAppointment(Appointment ap) {
- // add new appointment
- ap = appointmentDao.update(ap, null, false);
- assertNotNull("Cann't add appointment", ap.getId());
- return ap;
- }
-
- public User getUser() throws Exception {
- return getUser(UUID.randomUUID().toString());
- }
-
- protected String createPass() {
- return "pass1_!@#$%_A";
- }
-
- public User getUser(String uuid) throws Exception {
- User u = new User();
- // add user
- u.setFirstname("firstname" + uuid);
- u.setLastname("lastname" + uuid);
- u.setLogin("login" + uuid);
- u.setAddress(new Address());
- u.getAddress().setEmail(String.format("email%s@local", uuid));
- u.setRights(UserDao.getDefaultRights());
- u.setTimeZoneId("Asia/Bangkok");
- u.updatePassword(cfgDao, createPass());
- u.setLanguageId(1L);
- return u;
- }
-
- public User createUser() throws Exception {
- return createUser(UUID.randomUUID().toString());
- }
-
- public User createUser(String uuid) throws Exception {
- return createUser(getUser(uuid));
- }
-
- public User createUser(User u) {
- u = userDao.update(u, null);
- assertNotNull("Can't add user", u);
- return u;
- }
-
- private void makeDefaultScheme() throws Exception {
- InstallationConfig cfg = new InstallationConfig();
- cfg.setUsername(username);
- cfg.setPassword(userpass);
- cfg.setEmail(email);
- cfg.setGroup(group);
- cfg.setTimeZone(timeZone);
- importInitvalues.loadAll(cfg, false);
- }
-
- public User getContact(String uuid, Long ownerId) {
- return userDao.getContact("email" + uuid, "firstname" + uuid, "lastname" + uuid, ownerId);
- }
-
- public User createUserContact(Long ownerId) {
- return createUserContact(getContact(UUID.randomUUID().toString(), ownerId), ownerId);
- }
-
- public User createUserContact(User user, Long ownerId) {
- user = userDao.update(user, ownerId);
- assertNotNull("Cann't add user", user);
- return user;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractSpringTest.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractSpringTest.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractSpringTest.java
deleted file mode 100644
index c91eb34..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractSpringTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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;
-
-import static org.junit.Assert.fail;
-
-import org.apache.openmeetings.db.dao.label.LabelDao;
-import org.apache.openmeetings.util.OmFileHelper;
-import org.apache.tomcat.util.scan.Constants;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestExecutionListeners;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@TestExecutionListeners({})
-@ContextConfiguration(locations={"classpath:applicationContext.xml"}, inheritLocations = true)
-public abstract class AbstractSpringTest extends AbstractJUnit4SpringContextTests {
-
- @BeforeClass
- public static void init() {
- setOmHome();
- System.setProperty(Constants.SKIP_JARS_PROPERTY, "*");
- LabelDao.initLanguageMap();
- if (LabelDao.getLanguages().isEmpty()) {
- fail("Failed to set languages");
- }
- }
-
- protected static void setOmHome() {
- String webappsDir = System.getProperty("om.home", ".");
- OmFileHelper.setOmHome(webappsDir);
- if (!OmFileHelper.getOmHome().exists() || !OmFileHelper.getOmHome().isDirectory()) {
- fail("Invalid directory is specified as OM HOME: " + webappsDir);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractWicketTester.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractWicketTester.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractWicketTester.java
deleted file mode 100644
index 5d2ab66..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/AbstractWicketTester.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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;
-
-import static org.apache.openmeetings.db.util.ApplicationHelper.getWicketTester;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.apache.openmeetings.db.entity.user.User.Type;
-import org.apache.openmeetings.util.OmException;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.tester.WicketTester;
-
-import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog;
-import com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior;
-
-public class AbstractWicketTester extends AbstractJUnitDefaults {
- protected WicketTester tester;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- tester = getWicketTester();
- assertNotNull("Web session should not be null", WebSession.get());
- }
-
- public void login(String login, String password) {
- WebSession s = WebSession.get();
- try {
- if (login != null && password != null) {
- s.signIn(login, password, Type.user, null);
- } else {
- s.signIn(username, userpass, Type.user, null);
- }
- } catch (OmException e) {
- fail(e.getMessage());
- }
- assertTrue("Web session is not signed in for user: " + (login != null ? login : username), s.isSignedIn());
- }
-
- public <T extends Serializable> ButtonAjaxBehavior getButtonBehavior(String path, String name) {
- Args.notNull(path, "path");
- Args.notNull(name, "name");
- @SuppressWarnings("unchecked")
- AbstractDialog<T> dialog = (AbstractDialog<T>)tester.getComponentFromLastRenderedPage(path);
- List<ButtonAjaxBehavior> bl = dialog.getBehaviors(ButtonAjaxBehavior.class);
- for (ButtonAjaxBehavior bb : bl) {
- if (name.equals(bb.getButton().getName())) {
- return bb;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java
deleted file mode 100644
index f82ff95..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.backup;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_CRYPT;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-import org.apache.openmeetings.backup.BackupImport;
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
-import org.apache.openmeetings.db.dao.room.RoomDao;
-import org.apache.openmeetings.db.dao.room.RoomGroupDao;
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.basic.Configuration;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.After;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestOldBackups extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestOldBackups.class, getWebAppRootKey());
-
- @Autowired
- private BackupImport backupController;
- @Autowired
- private GroupDao groupDao;
- @Autowired
- private UserDao userDao;
- @Autowired
- private RoomDao roomDao;
- @Autowired
- private AppointmentDao appointmentDao;
- @Autowired
- private MeetingMemberDao meetingMemberDao;
- @Autowired
- private RoomGroupDao roomGroupDao;
- private String cryptClass = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- // Crypt class need to be preserved here to avoid overriding by backup import
- cryptClass = cfgDao.getCryptKey();
- }
-
- @After
- public void tearDown() {
- Configuration cfg = cfgDao.get(CONFIG_CRYPT);
- assertNotNull("Not null config should be returned", cfg);
- cfg.setValue(cryptClass);
- cfgDao.update(cfg, null);
- }
-
- @Test
- public void importOldVersions() {
- String backupsDir = System.getProperty("backups.dir", ".");
- File backupsHome = new File(backupsDir);
-
- if (!backupsHome.exists() || !backupsHome.isDirectory()) {
- fail("Invalid directory is specified for backup files: " + backupsDir);
- }
- long groupCount = 0;
- long userCount = 0;
- long roomCount = 0;
- long roomGroupCount = 0;
- long apptCount = 0;
- long meetingMembersCount = 0;
- for (File backup : backupsHome.listFiles()) {
- String name = backup.getName();
- log.debug("Import of backup file : '" + name + "' is started ...");
- try (InputStream is = new FileInputStream(backup)) {
- backupController.performImport(is);
- long newGroupCount = groupDao.count();
- long newUserCount = userDao.count();
- long newRoomCount = roomDao.count();
- long newRoomGroupCount = roomGroupDao.get().size();
- long newApptCount = appointmentDao.get().size();
- long newMeetingMembersCount = meetingMemberDao.getMeetingMembers().size();
- assertTrue("Zero groups were imported from " + name, newGroupCount > groupCount);
- assertTrue("Zero users were imported from " + name, newUserCount > userCount);
- assertTrue("Zero rooms were imported from " + name, newRoomCount > roomCount);
- assertTrue("Zero room groups were imported from " + name, newRoomGroupCount > roomGroupCount);
- assertTrue("Zero appointments were imported from " + name, newApptCount > apptCount);
- assertTrue("Zero meeting members were imported from " + name, newMeetingMembersCount > meetingMembersCount);
-
- groupCount = newGroupCount;
- userCount = newUserCount;
- roomCount = newRoomCount;
- roomGroupCount = newRoomGroupCount;
- apptCount = newApptCount;
- meetingMembersCount = newMeetingMembersCount;
- } catch (Exception e) {
- throw new RuntimeException("Unexpected exception while importing backup: " + name, e);
- }
- log.debug("... Done.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java
deleted file mode 100644
index b1cee5b..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.db.entity.calendar.Appointment.Reminder;
-import org.apache.openmeetings.db.entity.calendar.MeetingMember;
-import org.apache.openmeetings.db.entity.room.Room;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.service.calendar.AppointmentLogic;
-import org.apache.openmeetings.test.AbstractWicketTester;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.wicket.util.string.StringValue;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestAppointmentAddAppointment extends AbstractWicketTester {
- private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentAddAppointment.class, getWebAppRootKey());
-
- @Autowired
- private AppointmentLogic appointmentLogic;
- @Autowired
- private AppointmentDao appointmentDao;
- @Autowired
- private UserDao userDao;
-
- private static void setTime(Appointment a) {
- a.setStart(Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()));
- a.setEnd(Date.from(LocalDateTime.now().plusHours(1).atZone(ZoneId.systemDefault()).toInstant()));
- }
-
- @Test
- public void saveAppointment() throws Exception {
- log.debug("- saveAppointment");
-
- Calendar start = Calendar.getInstance();
- start.setTimeInMillis(start.getTimeInMillis() + 600000);
-
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis() + 600000);
-
- String appointmentName = "Test 01";
- String appointmentDescription = "Descr";
- Long userId = 1L;
- String appointmentLocation = "office";
- Boolean isMonthly = false;
- Boolean isDaily = false;
- Boolean isWeekly = false;
- String remind = Appointment.Reminder.ical.name();
- Boolean isYearly = false;
- String[] mmClient = new String[1];
- for (int i = 0; i < 1; i++) {
- mmClient[0] = createClientObj("firstname" + i, "lastname" + i,
- "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1");
- }
- Long languageId = 1L;
- Long roomType = 1L;
-
- Appointment a = appointmentLogic.getAppointment(appointmentName,
- appointmentLocation, appointmentDescription,
- start, end, isDaily, isWeekly,
- isMonthly, isYearly, remind, mmClient,
- roomType, languageId, false, "", -1, userId);
- a = appointmentDao.update(a, userId);
-
- Thread.sleep(3000);
-
- appointmentLogic.doScheduledMeetingReminder();
-
- Thread.sleep(3000);
-
- assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
- }
-
- @Test
- public void testCreate() {
- Appointment a = new Appointment();
- a.setTitle("Test title");
- setTime(a);
- a.setReminder(Reminder.ical);
- a.setMeetingMembers(new ArrayList<>());
- User owner = userDao.get(1L);
- a.setOwner(owner);
- a.setRoom(new Room());
- a.getRoom().setAppointment(true);
- a.getRoom().setType(Room.Type.conference);
- for (int i = 0; i < 3; ++i) {
- MeetingMember mm = new MeetingMember();
- mm.setUser(getContact(UUID.randomUUID().toString(), owner.getId()));
- a.getMeetingMembers().add(mm);
- }
- a = appointmentDao.update(a, owner.getId());
- assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
- assertEquals("Saved appointment should have corect count of guests: ", 3, a.getMeetingMembers().size());
- for (MeetingMember mm : a.getMeetingMembers()) {
- assertNotNull("Saved guest should have valid id: ", mm.getId());
- assertNotNull("Saved guest should have valid invitation: ", mm.getInvitation());
- assertNotNull("Saved guest should have invitation with ID: ", mm.getInvitation().getId());
- }
-
- WebSession ws = WebSession.get();
- Appointment a1 = appointmentDao.get(a.getId());
- ws.checkHashes(StringValue.valueOf(""), StringValue.valueOf(a1.getMeetingMembers().get(0).getInvitation().getHash()));
- assertTrue("Login via secure hash should be successful", ws.isSignedIn());
- }
-
- private static String createClientObj(String firstname, String lastname, String email, String jNameTimeZone) {
- StringBuilder sb = new StringBuilder();
- sb.append(",") //memberId
- .append(firstname).append(",")
- .append(lastname).append(",")
- .append(email).append(",")
- .append(",") //userId
- .append(jNameTimeZone);
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java
deleted file mode 100644
index 887ff90..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.openmeetings.service.calendar.AppointmentLogic;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestAppointmentSchedulerTask extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentSchedulerTask.class, getWebAppRootKey());
-
- @Autowired
- private AppointmentLogic appointmentLogic;
-
- @Test
- public void doIt() {
- log.debug("- 1 MeetingReminderJob.execute");
- log.warn("- 2 MeetingReminderJob.execute");
- try {
- appointmentLogic.doScheduledMeetingReminder();
-
- assertTrue(true);
- } catch (Exception err){
- log.error("execute",err);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java
deleted file mode 100644
index 84a2cf8..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestDatabaseStructureAppointment extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureAppointment.class, getWebAppRootKey());
-
- @Autowired
- private AppointmentDao appointmentDao;
-
- @Test
- public void testAddingGroup() {
- try {
- Calendar cal = Calendar.getInstance();
- cal.set(2008, 9, 2);
- cal.get(Calendar.DAY_OF_MONTH);
- cal.getTime();
-
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Date date = format.parse("2008-17-08");
- Date date2 = format.parse("2008-18-08");
-
- List<Appointment> listAppoints = appointmentDao.getInRange(1L, date, date2);
- // List<Appointment> listAppoints = appointmentDao.searchAppointmentsByName("%");
- // appointmentDao.getNextAppointmentById(1L);
- // appointmentDao.addAppointment("mezo", 1L, "Pforzheim", "zweiter", Calendar.getInstance().getTime(),
- // date, null, true, null, null, 1L,1L);
- // appointmentDao.addAppointment("testap", "erster Test",Calendar.getInstance().getTime(),
- // Calendar.getInstance().getTime(), true, false, false, false, new Long(1), 1L);
- log.debug("Anzahl: " + listAppoints.size());
-
- for (Appointment appoints : listAppoints) {
- log.debug("Termin: " + appoints.getTitle() + " startDate: " + appoints.getStart() + " endDate: " + appoints.getEnd());
- log.debug("MeetingMembers: " + appoints.getMeetingMembers().size());
- }
-
- for (Iterator<Appointment> iter = listAppoints.iterator(); iter.hasNext();) {
- log.debug("" + iter.next());
- }
- } catch (Exception err) {
- log.error("[testAddingGroup]", err);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java
deleted file mode 100644
index e20cd3f..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.db.entity.calendar.MeetingMember;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestDatabaseStructureGetAppointmentByRange extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetAppointmentByRange.class, getWebAppRootKey());
-
- @Autowired
- private AppointmentDao appointmentDao;
-
- @Test
- public void test() {
- log.debug("Test started");
- Long userId = 1L;
-
- Calendar now = Calendar.getInstance();
- Calendar rangeStart = Calendar.getInstance();
- rangeStart.setTime(now.getTime());
- rangeStart.add(Calendar.DATE, -1);
- Calendar rangeEnd = Calendar.getInstance();
- rangeEnd.add(Calendar.DATE, 1);
- rangeEnd.setTime(now.getTime());
-
- Calendar a1End = Calendar.getInstance();
- a1End.setTime(now.getTime());
- a1End.add(Calendar.HOUR_OF_DAY, 1);
- Appointment a1 = getAppointment(now.getTime(), a1End.getTime());
- a1.setTitle("AppointmentByRange_a1");
-
- Appointment a2 = getAppointment(now.getTime(), a1End.getTime());
- a2.setTitle("AppointmentByRange_a2");
- a2.setMeetingMembers(new ArrayList<MeetingMember>());
- MeetingMember mm1 = new MeetingMember();
- mm1.setUser(createUserContact(userId));
- mm1.setAppointment(a2);
- a2.getMeetingMembers().add(mm1);
-
- Appointment a3 = getAppointment(now.getTime(), a1End.getTime());
- a3.setTitle("AppointmentByRange_a3");
- a3.setMeetingMembers(new ArrayList<MeetingMember>());
- MeetingMember mm2 = new MeetingMember();
- mm2.setUser(createUserContact(userId));
- mm2.setAppointment(a3);
- a3.getMeetingMembers().add(mm2);
- MeetingMember mm3 = new MeetingMember();
- mm3.setUser(createUserContact(userId));
- mm3.setAppointment(a3);
- a3.getMeetingMembers().add(mm3);
-
- a1 = appointmentDao.update(a1, userId);
- a2 = appointmentDao.update(a2, userId);
- a3 = appointmentDao.update(a3, userId);
-
- int a1found = 0, a2found = 0, a3found = 0;
- for (Appointment a : appointmentDao.getInRange(userId, rangeStart.getTime(), rangeEnd.getTime())) {
- int mmCount = a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size();
- if (a.getId().equals(a1.getId())) {
- assertEquals("Inapropriate MeetingMembers count", 0, mmCount);
- a1found++;
- }
- if (a.getId().equals(a2.getId())) {
- assertEquals("Inapropriate MeetingMembers count", 1, mmCount);
- a2found++;
- }
- if (a.getId().equals(a3.getId())) {
- assertEquals("Inapropriate MeetingMembers count", 2, mmCount);
- a3found++;
- }
- }
- assertEquals("Inappropriate count of appointments without members found", 1, a1found);
- assertEquals("Inappropriate count of appointments with 1 member found", 1, a2found);
- assertEquals("Inappropriate count of appointments with 2 members found", 1, a3found);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java
deleted file mode 100644
index 8be42f2..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestDatabaseStructureGetUserStart extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetUserStart.class, getWebAppRootKey());
-
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testAddingGroup() {
- try {
- userDao.get(new Long(1));
- } catch (Exception err) {
- log.error("[testAddingGroup]", err);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureMeetingMember.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureMeetingMember.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureMeetingMember.java
deleted file mode 100644
index 08a0149..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureMeetingMember.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.calendar;
-
-
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-
-
-public class TestDatabaseStructureMeetingMember extends AbstractJUnitDefaults {
-
- @Test
- public void testUpdateMeetingMember(){
- //FIXME need to be refactored !!!!
-
- //MeetingMemberDaoImpl.getInstance().addMeetingMember("Adddd", "dir", "1", "2", 1L, 1L, "test");
- //MeetingMemberDaoImpl.getInstance().addMeetingMember(firstname, lastname, memberStatus, appointmentStatus, appointmentId, userid, email)
-
-
- //MeetingMemberDaoImpl.getInstance().getMeetingMemberById(1L);
- //MeetingMemberDaoImpl.getInstance().deleteMeetingMember(2L);
-
- //meetingMemberDao.updateMeetingMember(1l,"bbbbbb", "dir", "1", "2", 1L, 1L, "test", "");
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java
deleted file mode 100644
index c928ac1..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import java.util.List;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestDatabaseStructureUsersSearch extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureUsersSearch.class, getWebAppRootKey());
-
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testAddingGroup(){
- try {
- List<User> users = userDao.get("first", 0, 10, "lastname", false, 1L);
- log.debug("[result]" + users.size());
- log.debug("[records]"+ users);
- } catch (Exception err) {
- log.error("[testAddingGroup]",err);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java
deleted file mode 100644
index 2df1894..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Calendar;
-
-import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestGetAppointment extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestGetAppointment.class, getWebAppRootKey());
-
- @Autowired
- private AppointmentDao appointmentDao;
-
- @Test
- public void getAppoinment() {
- log.debug("getAppoinment enter");
- Long userId = 1L;
-
- Calendar now = Calendar.getInstance();
- Calendar a1End = Calendar.getInstance();
- a1End.setTime(now.getTime());
- a1End.add(Calendar.HOUR_OF_DAY, 1);
- Appointment a1 = getAppointment(now.getTime(), a1End.getTime());
- a1.setTitle("GetAppointment");
-
- a1 = appointmentDao.update(a1, userId);
-
- Appointment a = appointmentDao.get(a1.getId());
- assertNotNull("Failed to get Appointment By id", a);
- assertEquals("Inapropriate MeetingMembers count", 0, a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
deleted file mode 100644
index 5154bea..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.calendar.OmCalendar;
-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 TestOmCalendar extends AbstractJUnitDefaults {
- @Autowired
- private OmCalendarDao calendarDao;
- @Autowired
- private UserDao userDao;
-
- @Test
- public void saveCalendar() {
- OmCalendar calendar = new OmCalendar();
- Long userId = 1L;
- User owner = userDao.get(userId);
- String title = "Calendar Title", href = "http://caldav.example.com/principals/user";
-
- calendar.setOwner(owner);
- calendar.setTitle(title);
- calendar.setHref(href);
- calendar.setSyncType(OmCalendar.SyncType.ETAG);
-
- calendar = calendarDao.update(calendar);
-
- assertTrue("Saved calendar should have valid id: " + calendar.getId(),
- calendar.getId() != null && calendar.getId() > 0);
-
- OmCalendar c = calendarDao.get(calendar.getId());
- assertNotNull("Failed to find Calendar by id", c);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java
deleted file mode 100644
index 45cd2ce..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * 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.calendar;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.activation.DataHandler;
-import javax.mail.BodyPart;
-import javax.mail.Message;
-import javax.mail.Multipart;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-import org.apache.openmeetings.core.mail.MailHandler;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.mail.ByteArrayDataSource;
-import org.apache.openmeetings.util.mail.IcalHandler;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import net.fortuna.ical4j.data.CalendarOutputter;
-import net.fortuna.ical4j.model.DateTime;
-import net.fortuna.ical4j.model.TimeZone;
-import net.fortuna.ical4j.model.TimeZoneRegistry;
-import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
-import net.fortuna.ical4j.model.component.VEvent;
-import net.fortuna.ical4j.model.component.VTimeZone;
-import net.fortuna.ical4j.model.parameter.Cn;
-import net.fortuna.ical4j.model.parameter.Role;
-import net.fortuna.ical4j.model.property.Attendee;
-import net.fortuna.ical4j.model.property.CalScale;
-import net.fortuna.ical4j.model.property.Method;
-import net.fortuna.ical4j.model.property.Organizer;
-import net.fortuna.ical4j.model.property.ProdId;
-import net.fortuna.ical4j.model.property.Uid;
-import net.fortuna.ical4j.model.property.Version;
-
-public class TestSendIcalMessage extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestSendIcalMessage.class, getWebAppRootKey());
-
- @Autowired
- private MailHandler mailHandler;
-
- private byte[] iCalMimeBody;
-
- String subject = "test iCal";
- String recipients = "seba.wagner@gmail.com";
- String htmlBody = "test";
-
-
- public void simpleInvitionIcalLink() {
- // Create a TimeZone
- TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
- TimeZone timezone = registry.getTimeZone("America/Mexico_City");
- VTimeZone tz = timezone.getVTimeZone();
-
- // Start Date is on: April 1, 2008, 9:00 am
- java.util.Calendar startDate = new GregorianCalendar();
- startDate.setTimeZone(timezone);
- startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
- startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
- startDate.set(java.util.Calendar.YEAR, 2008);
- startDate.set(java.util.Calendar.HOUR_OF_DAY, 9);
- startDate.set(java.util.Calendar.MINUTE, 0);
- startDate.set(java.util.Calendar.SECOND, 0);
-
- // End Date is on: April 1, 2008, 13:00
- java.util.Calendar endDate = new GregorianCalendar();
- endDate.setTimeZone(timezone);
- endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
- endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
- endDate.set(java.util.Calendar.YEAR, 2008);
- endDate.set(java.util.Calendar.HOUR_OF_DAY, 13);
- endDate.set(java.util.Calendar.MINUTE, 0);
- endDate.set(java.util.Calendar.SECOND, 0);
-
- // Create the event
- String eventName = "Progress Meeting";
- DateTime start = new DateTime(startDate.getTime());
- DateTime end = new DateTime(endDate.getTime());
- VEvent meeting = new VEvent(start, end, eventName);
-
- // add timezone info..
- meeting.getProperties().add(tz.getTimeZoneId());
-
- // generate unique identifier..
- Uid uid = new Uid(UUID.randomUUID().toString());
- meeting.getProperties().add(uid);
-
- // add attendees..
- Attendee dev1 = new Attendee(URI.create("mailto:dev1@mycompany.com"));
- dev1.getParameters().add(Role.REQ_PARTICIPANT);
- dev1.getParameters().add(new Cn("Developer 1"));
- meeting.getProperties().add(dev1);
-
- Attendee dev2 = new Attendee(URI.create("mailto:dev2@mycompany.com"));
- dev2.getParameters().add(Role.OPT_PARTICIPANT);
- dev2.getParameters().add(new Cn("Developer 2"));
- meeting.getProperties().add(dev2);
-
- // Create a calendar
- net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
- icsCalendar.getProperties().add(
- new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
- icsCalendar.getProperties().add(CalScale.GREGORIAN);
- icsCalendar.getProperties().add(Version.VERSION_2_0);
-
- // Add the event and print
- icsCalendar.getComponents().add(meeting);
-
- Organizer orger = new Organizer(URI.create("seba.wagner@gmail.com"));
- orger.getParameters().add(new Cn("Sebastian Wagner"));
- meeting.getProperties().add(orger);
-
- icsCalendar.getProperties().add(Method.REQUEST);
-
- log.debug(icsCalendar.toString());
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- CalendarOutputter outputter = new CalendarOutputter();
- try {
- outputter.output(icsCalendar, bout);
- iCalMimeBody = bout.toByteArray();
-
- sendIcalMessage();
- } catch (Exception e) {
- log.error("Error", e);
- }
- }
-
- @Test
- public void sendInvitionIcalLink() {
- try {
- String email = "hans@webbase-design.de";
- String username = "shans";
- boolean invitor = false;
-
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- IcalHandler handler = new IcalHandler(IcalHandler.ICAL_METHOD_REQUEST);
-
- // Transforming Meeting Members
-
- Map<String, String> attendeeList = handler.getAttendeeData(email, username, invitor);
- Map<String, String> organizerAttendee = handler.getAttendeeData(recipients, "seba-test", true);
-
- List<Map<String, String>> atts = new ArrayList<>();
- atts.add(attendeeList);
-
- // Create ICal Message
- String meetingId = handler.addNewMeeting(start.getTime(), end.getTime(), "test event",
- atts, "localhost:5080/link_openmeetings",
- organizerAttendee, "", java.util.TimeZone.getDefault().getID());
-
- log.debug("meetingId " + meetingId);
-
- iCalMimeBody = handler.getIcalAsByteArray();
-
- sendIcalMessage();
-
- // return MailHandler.sendMail(email, subject, template);
-
- } catch (Exception err) {
- log.error("sendInvitionIcalLink", err);
- }
- }
-
- private void sendIcalMessage() throws Exception {
- log.debug("sendIcalMessage");
-
- // Building MimeMessage
- MimeMessage mimeMessage = mailHandler.getBasicMimeMessage();
- mimeMessage.setSubject(subject);
- mimeMessage.addRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
-
- // -- Create a new message --
- BodyPart msg = new MimeBodyPart();
- msg.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlBody,
- "text/html; charset=\"utf-8\"")));
-
- Multipart multipart = new MimeMultipart();
-
- BodyPart iCalAttachment = new MimeBodyPart();
- iCalAttachment.setDataHandler(new DataHandler(
- new javax.mail.util.ByteArrayDataSource(
- new ByteArrayInputStream(iCalMimeBody),
- "text/calendar;method=REQUEST;charset=\"UTF-8\"")));
- iCalAttachment.setFileName("invite.ics");
-
- multipart.addBodyPart(iCalAttachment);
- multipart.addBodyPart(msg);
-
- mimeMessage.setSentDate(new Date());
- mimeMessage.setContent(multipart);
-
- // -- Set some other header information --
- // mimeMessage.setHeader("X-Mailer", "XML-Mail");
- // mimeMessage.setSentDate(new Date());
-
- // Transport trans = session.getTransport("smtp");
- Transport.send(mimeMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/config/TestConfig.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/config/TestConfig.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/config/TestConfig.java
deleted file mode 100644
index 3b98927..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/config/TestConfig.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.config;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_SERVER;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.util.List;
-
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
-import org.apache.openmeetings.db.entity.basic.Configuration;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestConfig extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestConfig.class, getWebAppRootKey());
-
- @Autowired
- private ConfigurationDao configurationDao;
-
- @Test
- public void getConfigKey() {
- System.err.println("THIS");
-
- Configuration smtp_server = configurationDao.get(CONFIG_SMTP_SERVER);
-
- System.err.println("smtp_server " + smtp_server.getUser());
-
- assertNull(smtp_server.getUser());
- }
-
- @Test
- public void getConfigs() {
-
- try {
- List<Configuration> list = configurationDao.get(4, 6);
-
- for (Configuration conf : list) {
- log.error("conf.getKey() " + conf.getKey());
- log.error("conf.getUser() " + conf.getUser());
- if (conf.getUser() != null) {
- log.error("conf.getUsers() " + conf.getUser().getLogin());
- }
- }
-
- assertEquals(list.size(), 6);
-
- } catch (Exception err) {
- log.error("[startConversion]", err);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/core/file/TestFileProcessor.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/core/file/TestFileProcessor.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/core/file/TestFileProcessor.java
deleted file mode 100644
index 82ca41a..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/core/file/TestFileProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.core.file;
-
-import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.UUID;
-
-import org.apache.openmeetings.core.data.file.FileProcessor;
-import org.apache.openmeetings.db.dto.file.FileItemDTO;
-import org.apache.openmeetings.db.entity.file.BaseFileItem;
-import org.apache.openmeetings.db.entity.file.FileItem;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.process.ConverterProcessResultList;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestFileProcessor extends AbstractJUnitDefaults {
- private static final String FILE_NAME = "test_name";
-
- @Autowired
- protected FileProcessor processor;
-
- @Test
- public void testProcessJpeg() throws Exception {
- for (String ext : new String[] {null, "txt", "png"}) {
- FileItem f = new FileItemDTO()
- .setName(String.format("%s.%s", FILE_NAME, ext))
- .setHash(UUID.randomUUID().toString())
- .setType(BaseFileItem.Type.Recording).get();
- try (InputStream is = new FileInputStream(getDefaultProfilePicture())) {
- ConverterProcessResultList result = processor.processFile(f, is);
- assertFalse("Conversion should be successful", result.hasError());
- assertEquals("Type should be image", BaseFileItem.Type.Image, f.getType());
- }
- }
- }
-}
[2/4] openmeetings git commit: [OPENMEETINGS-1714] more issues are
fixed
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/derby/PrepareSystemFiles.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/derby/PrepareSystemFiles.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/derby/PrepareSystemFiles.java
deleted file mode 100644
index 6e02765..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/derby/PrepareSystemFiles.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.derby;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-
-import java.io.File;
-
-import org.apache.openmeetings.cli.ConnectionPropertiesPatcher;
-import org.apache.openmeetings.util.ConnectionProperties.DbType;
-import org.apache.openmeetings.util.OmFileHelper;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * This file is called from command line to patch the derby configuration
- * during the automated run of Selenium
- *
- * @author swagner
- *
- */
-public class PrepareSystemFiles {
- private static final Logger log = Red5LoggerFactory.getLogger(PrepareSystemFiles.class, getWebAppRootKey());
-
- public static void main(String... args) {
- try {
- OmFileHelper.setOmHome(args[0]);
-
- String databaseHomeDirectory = args[1];
-
- String persistanceFileToPatch = args[2];
-
- File conf = new File(persistanceFileToPatch);
-
- if (conf.exists()) {
- conf.delete();
- }
-
- ConnectionPropertiesPatcher.patch(DbType.derby.name()
- , "localhost"
- , "1527"
- , databaseHomeDirectory + "openmeetings"
- , "user"
- , "secret"
- );
- } catch (Exception err) {
- log.error("Error", err);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java
deleted file mode 100644
index fc90b9b..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.domain;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.Group;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestAddGroup extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestAddGroup.class, getWebAppRootKey());
-
- @Autowired
- private GroupDao groupDao;
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testAddingGroup() {
- Group o = new Group();
- o.setName("default");
- o = groupDao.update(o, null);
- assertNotNull("Id of group created should not be null", o.getId());
-
- User us = userDao.get(1L);
- assertNotNull("User should exist", us);
-
- assertNotNull("Group User list should exist", us.getGroupUsers());
- us.getGroupUsers().add(new GroupUser(o, us));
- us = userDao.update(us, null);
-
- log.error(us.getLastname());
- log.error(us.getAddress().getTown());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java
deleted file mode 100644
index 3152eba..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.domain;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestUserGroupAggregation extends AbstractJUnitDefaults {
- private static final Logger log = Red5LoggerFactory.getLogger(TestUserGroupAggregation.class, getWebAppRootKey());
-
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testitNow() {
- User u = userDao.get(1L);
-
- assertNotNull("Group list for default user must not be null", u.getGroupUsers());
- assertTrue("Default user must belong to at least one group", u.getGroupUsers().size() > 0);
-
- for (GroupUser orgUserObj : u.getGroupUsers()) {
- log.error("testitNow: group Id: '" + orgUserObj.getGroup().getId() + "'; name: '" + orgUserObj.getGroup().getName() + "'");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java
deleted file mode 100644
index 2c97de5..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.invitiation;
-
-import static org.apache.openmeetings.util.CalendarHelper.getDate;
-
-import java.time.LocalDateTime;
-
-import org.apache.openmeetings.db.dao.room.RoomDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.room.Invitation;
-import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
-import org.apache.openmeetings.db.entity.room.Invitation.Valid;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.service.room.InvitationManager;
-import org.apache.openmeetings.test.AbstractWicketTester;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestInvitation extends AbstractWicketTester {
- @Autowired
- private InvitationManager invitationManager;
- @Autowired
- private UserDao userDao;
- @Autowired
- private RoomDao roomDao;
-
- @Test
- public void testSendInvitationLink() throws Exception {
- User us = userDao.getByLogin(username, User.Type.user, null);
-
- LocalDateTime from = LocalDateTime.now().plusDays(1).withHour(12).withMinute(0).withSecond(0);
- User invitee = userDao.getContact("sebawagner@apache.org", "Testname", "Testlastname", us.getId());
- Invitation i = invitationManager.getInvitation(invitee, roomDao.get(1L),
- false, "", Valid.OneTime
- , us, us.getLanguageId(),
- getDate(from, "GMT"), getDate(from.plusHours(2), "GMT"), null);
-
- invitationManager.sendInvitationLink(i, MessageType.Create, "subject", "message", false);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/AbstractTestDefaults.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/AbstractTestDefaults.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/AbstractTestDefaults.java
deleted file mode 100644
index aadf93f..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/AbstractTestDefaults.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.selenium;
-
-import java.util.List;
-
-import org.apache.openmeetings.db.dao.label.LabelDao;
-import org.apache.openmeetings.test.AbstractSpringTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.experimental.categories.Category;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.firefox.FirefoxOptions;
-import org.openqa.selenium.firefox.FirefoxProfile;
-
-@Category(SeleniumTests.class)
-public abstract class AbstractTestDefaults extends AbstractSpringTest {
- public WebDriver driver = null;
-
- private String BASE_URL = "http://localhost:5080/openmeetings";
- private String username = "swagner";
- private String userpass = "qweqwe";
- private String groupName = "seleniumtest";
- private String email = "selenium@openmeetings.apache.org";
- private String locale = "en-us";
-
-
- public String getBASE_URL() {
- return BASE_URL;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getUserpass() {
- return userpass;
- }
-
- public String getGroupName() {
- return groupName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public Long getLanguageId() {
- return 1L;
- }
-
- public String getLocale() {
- return locale;
- }
-
- // setting this to false can be handy if you run the test from inside
- // Eclipse, the browser will not shut down after the test so you can start
- // to diagnose the test issue
- public boolean doTearDownAfterTest = false;
-
- public String getString(String key) {
- return LabelDao.getString(key, getLanguageId());
- }
-
- /**
- * Make method overwrite possible to have custom behavior in tests
- *
- * @return
- */
- public boolean getDoTearDownAfterTest() {
- return doTearDownAfterTest;
- }
-
- @Before
- public void setUp() {
- FirefoxProfile profile = new FirefoxProfile();
- profile.setPreference("intl.accept_languages", getLocale());
- driver = new FirefoxDriver(new FirefoxOptions().setProfile(profile));
- }
-
- /**
- * This test is a basic test to verify the default loader mechanism works
- * it is not intend to be a part of any sub test
- *
- * @throws Exception
- */
- //@Test
- public void smokeTest() throws Exception {
- try {
- driver.get(getBASE_URL());
-
- testIsInstalledAndDoInstallation();
-
- SeleniumUtils.inputText(driver, "login", getUsername());
- SeleniumUtils.inputText(driver, "pass", getUserpass());
-
- WebElement signInButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), 'Sign in')]]", true, true);
- signInButton.click();
-
- SeleniumUtils.elementExists(driver,
- "//h3[contains(text(), 'Help and support')]", true);
- } catch (Exception e) {
- SeleniumUtils.makeScreenShot(this.getClass().getSimpleName(), e,
- driver);
- throw e;
- }
- }
-
- /**
- * Throws exception in case that test fails, so it is important to not catch
- * that exception but really let the test fail!
- *
- * @throws Exception
- */
- protected void testIsInstalledAndDoInstallation() throws Exception {
-
- WebElement wicketExtensionsWizardHeaderTitle = SeleniumUtils
- .findElement(driver, "wicketExtensionsWizardHeaderTitle", false, true);
- if (wicketExtensionsWizardHeaderTitle == null) {
- return;
- }
- if (wicketExtensionsWizardHeaderTitle.getText()
- .contains("Installation")) {
- System.out.println("Do Installation");
- doInstallation();
- }
-
- }
-
- private void doInstallation() throws Exception {
- Thread.sleep(3000L);
-
- List<WebElement> buttons_next = SeleniumUtils.findElements(driver,
- "buttons:next", true);
-
- buttons_next.get(1).sendKeys(Keys.RETURN);
-
- Thread.sleep(1000L);
-
- SeleniumUtils.inputText(driver, "view:cfg.username", getUsername());
- SeleniumUtils.inputText(driver, "view:cfg.password", getUserpass());
- SeleniumUtils.inputText(driver, "view:cfg.email", getEmail());
- SeleniumUtils.inputText(driver, "view:cfg.group", getGroupName());
-
- buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
-
- buttons_next.get(1).sendKeys(Keys.RETURN);
-
- Thread.sleep(1000L);
-
- buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
-
- buttons_next.get(1).sendKeys(Keys.RETURN);
-
- Thread.sleep(1000L);
-
- buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
-
- buttons_next.get(1).sendKeys(Keys.RETURN);
-
- Thread.sleep(1000L);
-
- buttons_next = SeleniumUtils.findElements(driver, "buttons:next", true);
-
- buttons_next.get(1).sendKeys(Keys.RETURN);
-
- Thread.sleep(2000L);
-
- List<WebElement> elements = SeleniumUtils.findElements(driver,
- "buttons:finish", true);
-
- elements.get(1).sendKeys(Keys.RETURN);
-
- long maxMilliSecondsWait = 120000;
-
- while (maxMilliSecondsWait > 0) {
-
- // check if installation is complete by searching for the link on
- // the success page
- WebElement enterApplicationLink = SeleniumUtils.findElement(driver,
- "//a[contains(@href,'install')]", false, true);
-
- if (enterApplicationLink == null) {
- System.out
- .println("Installation running - wait 3 more seconds and check again");
-
- Thread.sleep(3000L);
- maxMilliSecondsWait -= 3000;
- } else {
- maxMilliSecondsWait = 0;
-
- enterApplicationLink.click();
-
- return;
- }
- }
-
- throw new Exception("Timeout during installation");
- }
-
- @After
- public void tearDown() {
- if (getDoTearDownAfterTest()) {
- driver.close();
- driver.quit();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/HeavyTests.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/HeavyTests.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/HeavyTests.java
deleted file mode 100644
index 2136ea8..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/HeavyTests.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.selenium;
-
-public @interface HeavyTests {
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumTests.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumTests.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumTests.java
deleted file mode 100644
index 5272d26..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumTests.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.selenium;
-
-public @interface SeleniumTests {
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
deleted file mode 100644
index 1344fa1..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.selenium;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.openqa.selenium.By;
-import org.openqa.selenium.OutputType;
-import org.openqa.selenium.TakesScreenshot;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-public class SeleniumUtils {
- private static final Logger log = Red5LoggerFactory.getLogger(SeleniumUtils.class, getWebAppRootKey());
- // we need to retry some actions because our web site is dynamic
- static int numberOfRetries = 10;
-
- // we need to sleep to make sure Ajax could complete whatever it does
- static long defaultSleepInterval = 1000;
-
- public static void inputText(WebDriver driver, String search,
- String inputText) throws Exception {
- WebElement element = SeleniumUtils.findElement(driver, search, true, true);
-
- //clear text before adding input
- element.clear();
-
- // Would make send to check if this element is really an input text
- element.sendKeys(inputText);
- }
-
- public static void click(WebDriver driver, String search) throws Exception {
- WebElement element = SeleniumUtils.findElement(driver, search, true, true);
- element.click();
- }
-
- /**
- *
- * @param driver
- * @param search
- * @param throwException
- * under some circumstance you do't want to exit the test here
- * @return
- * @throws Exception
- */
- public static List<WebElement> findElements(WebDriver driver, String search,
- boolean throwException) throws Exception {
- for (int i = 0; i < numberOfRetries; i++) {
- List<WebElement> elements = _findElement(driver, search);
- if (elements != null) {
- return elements;
- }
-
- Thread.sleep(defaultSleepInterval);
- }
-
- if (throwException) {
- throw new Exception("Could not find element with specified path "
- + search);
- }
-
- return null;
- }
-
- /**
- *
- * @param driver
- * @param search
- * @param throwException
- * under some circumstance you do't want to exit the test here
- * @param onlyReturnVisisbleElement TODO
- * @return
- * @throws Exception
- */
- public static WebElement findElement(WebDriver driver, String search,
- boolean throwException, boolean onlyReturnVisisbleElement) throws Exception {
- for (int i = 0; i < numberOfRetries; i++) {
- List<WebElement> elements = _findElement(driver, search);
- if (elements != null) {
-
- if (!onlyReturnVisisbleElement) {
- return elements.get(0);
- }
-
- for (WebElement element : elements) {
- if (element.isDisplayed()) {
- return element;
- }
- }
-
- }
-
- Thread.sleep(defaultSleepInterval);
- }
-
- if (throwException) {
- throw new Exception("Could not find element with specified path "
- + search);
- }
-
- return null;
- }
-
- private static By[] _getSearchArray(String search) {
- //If xpath we have to use it, if xpath is used with By.className(...) there will be an exception
- if (search.startsWith("//")) {
- return new By[] { By.xpath(search) };
- } else {
- return new By[] { By.id(search), By.name(search), By.className(search),
- By.tagName(search), By.xpath(search) };
- }
- }
-
- private static List<WebElement> _findElement(WebDriver driver, String search) {
- for (By by : _getSearchArray(search)) {
- try {
- List<WebElement> elements = driver.findElements(by);
- if (elements != null && elements.size() > 0) {
- return elements;
- }
- } catch (Exception e) {
- // Do not show any warnings
- }
- }
- return null;
- }
-
- public static void elementExists(WebDriver driver, String search,
- boolean shouldExist) throws Exception {
- Thread.sleep(defaultSleepInterval);
-
- boolean doesExist = !shouldExist;
-
- for (int i = 0; i < numberOfRetries; i++) {
- doesExist = checkExists(driver, search);
- if (doesExist == shouldExist) {
- break;
- }
-
- Thread.sleep(defaultSleepInterval);
- }
-
- if (doesExist != shouldExist) {
- if (shouldExist) {
- throw new Exception("Element could not be found: " + search);
- } else {
- throw new Exception("Unexpected Element was found: " + search);
- }
- }
- }
-
- private static boolean checkExists(WebDriver driver, String search) {
- for (By by : _getSearchArray(search)) {
- try {
- List<WebElement> element = driver.findElements(by);
- if (element.size() > 0) {
- return true;
- }
- } catch (Exception e) {
- // Do not show any warnings
- }
- }
- return false;
- }
-
- public static void makeScreenShot(String testName, Exception e,
- WebDriver driver) {
- try {
- DateFormat df = new SimpleDateFormat("MM-dd-yyyy_HH-mm-ss");
- String fileName = e.getMessage().replace(" ", "_");
- fileName = fileName.replaceAll("(\r\n|\n)", "");
- fileName = fileName.replaceAll("/", "");
-
- if (fileName.length() > 100) {
- fileName = fileName.substring(0, 100);
- }
-
- fileName = fileName + "_" + df.format(new Date()) + ".png";
- File screenShotFile = ((TakesScreenshot) driver)
- .getScreenshotAs(OutputType.FILE);
-
- String path = "." + File.separatorChar + "build"
- + File.separatorChar + "screenshots" + File.separatorChar
- + testName;
-
- File screenshotFolder = new File(path);
- if (!screenshotFolder.exists()) {
- screenshotFolder.mkdirs();
- }
-
- System.out.println("screenshot copy from: "
- + screenShotFile.getAbsolutePath());
- System.out.println("Length Filename: " + fileName.length()
- + " - Writing screenshot to: " + path + File.separatorChar
- + fileName);
-
- FileUtils.moveFile(screenShotFile, new File(path
- + File.separatorChar + fileName));
- } catch (Exception err) {
- log.error("Error", err);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
deleted file mode 100644
index 0716d81..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.selenium;
-
-import java.util.Date;
-
-import org.junit.Test;
-import org.openqa.selenium.Alert;
-import org.openqa.selenium.WebElement;
-
-import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButtons;
-
-public class TestSignUp extends AbstractTestDefaults {
- String pass = "pass";
-
- @Override
- public boolean getDoTearDownAfterTest() {
- return false;
- }
-
- @Test
- public void testSignUp() throws Exception {
- try {
- driver.get(getBASE_URL());
-
- String currentRandomCounter = "" + ((new Date().getTime())/1000);
- String userName = "seba" + currentRandomCounter;
- String email = "hans." + currentRandomCounter + "@openmeetings.apache.org";
-
- super.testIsInstalledAndDoInstallation();
-
- WebElement signUpButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
- signUpButton.click();
-
- // ##################################
- // Test validation message for passwords to be identical
- // ##################################
- doSignUp("Hans","Muster", userName, "pw", "pw2", email);
-
- //Find Error label-id 232 "Please enter two identical passwords"
- SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("232") + "')]", true, true);
-
- // ##################################
- // Sign up with user and sign in
- // ##################################
- doSignUp("Hans","Muster", userName, pass, pass, email);
-
- //Check for popup with success message and email to check
- SeleniumUtils.findElement(driver, "//span[contains(text(), '" + getString("warn.notverified") + "')]", true, true);
-
- //click button to close popup
- WebElement signUpSucessPopUpOkButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), '" + DialogButtons.OK.toString() + "')]]", true, true);
- signUpSucessPopUpOkButton.click();
-
- //Login with user
- SeleniumUtils.inputText(driver, "login", userName);
- SeleniumUtils.inputText(driver, "pass", pass);
-
- //click labelid 112 "Sign In"
- WebElement signInButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), '" + getString("112") + "')]]", true, true);
- signInButton.click();
-
- // check for some text in dashbaord, labelid 281, "Help and support"
- SeleniumUtils.elementExists(driver,
- "//h3[contains(text(), '" + getString("281") + "')]", true);
-
- //sign out
- WebElement signOutLink = SeleniumUtils.findElement(driver,
- "//a[contains(text(), '" + getString("310") + "')]", true, true);
- signOutLink.click();
-
- Alert alert = driver.switchTo().alert();
- alert.accept();
-
- // ##################################
- // Sign up with same user and email and check duplicate messages
- // ##################################
-
- signUpButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
- signUpButton.click();
-
- doSignUp("Hans","Muster", userName, pass, pass, email);
-
- SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.login.inuse") + "')]", true, true);
-
- SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.email.inuse") + "')]", true, true);
- } catch (Exception e) {
- SeleniumUtils.makeScreenShot(this.getClass().getSimpleName(), e,
- driver);
- throw e;
- }
- }
-
- private void doSignUp(String firstName, String lastName, String login, String password,
- String confirmPassword, String email) throws Exception {
-
- SeleniumUtils.inputText(driver, "firstName", firstName);
- SeleniumUtils.inputText(driver, "lastName", lastName);
- SeleniumUtils.inputText(driver, "//input[@name='login']", login);
- SeleniumUtils.inputText(driver, "password", password);
- SeleniumUtils.inputText(driver, "confirmPassword", confirmPassword);
- SeleniumUtils.inputText(driver, "email", email);
-
- WebElement submitButton = SeleniumUtils.findElement(driver,
- "//button[span[contains(text(), 'Register')]]", true, true);
- submitButton.click();
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/smoke/TestSmokeBasic.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/smoke/TestSmokeBasic.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/smoke/TestSmokeBasic.java
deleted file mode 100644
index 341154f..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/smoke/TestSmokeBasic.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.smoke;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestSmokeBasic extends AbstractJUnitDefaults {
- @Autowired
- private UserDao userDao;
-
- @Test
- public void createErrorValueAndTest() {
- assertNotNull(userDao.get(1L));
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java
deleted file mode 100644
index a313612..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.user;
-
-import static org.apache.openmeetings.web.app.WebSession.getUserId;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractWicketTester;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestUserContact extends AbstractWicketTester {
- @Autowired
- private UserDao userDao;
- @Autowired
- private GroupDao groupDao;
-
- @Test
- public void testGetUser() {
- assertNull("Null should be returned in case User does not exist", userDao.get(Long.MAX_VALUE));
- }
-
- @Test
- public void createUserWithGroup() throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
- u = userDao.update(u, null);
- assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), createPass()));
-
- User u1 = userDao.get(u.getId());
- assertNotNull("Just created user should not be null", u1);
- assertNotNull("Just created user should have non null org-users", u1.getGroupUsers());
- assertFalse("Just created user should have not empty org-users", u1.getGroupUsers().isEmpty());
- }
-
- @Test
- public void testCreateUser() throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = createUser(uuid);
- assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), createPass()));
- }
-
- @Test
- public void addContactByOwner() throws Exception {
- login(null, null);
-
- List<User> users = userDao.getAllUsers();
- assertNotNull("User list should not be null ", users);
- assertFalse("User list should not be empty ", users.isEmpty());
-
- User contact = createUserContact(getUserId());
- String email = contact.getAddress().getEmail();
- List<User> l = userDao.get(email, false, 0, 9999);
- // check that contact is visible for admin
- assertNotNull("Contact list should not be null for admin ", l);
- assertFalse("Contact list should not be empty for admin ", l.isEmpty());
-
- // check that contact is visible for owner
- l = userDao.get(email, 0, 9999, null, true, getUserId());
- assertTrue("Contact list should not be empty for owner ", !l.isEmpty());
- //delete contact
- userDao.delete(contact, getUserId());
- l = userDao.get(email, false, 0, 9999);
- assertTrue("Contact list should be empty after deletion", l.isEmpty());
-
- User u = createUser();
- User u1 = createUser();
- contact = createUserContact(u.getId());
- email = contact.getAddress().getEmail();
- // check that contact is not visible for user that is not owner of this contact
- l = userDao.get(email, 0, 9999, null, true, u1.getId());
- assertTrue("Contact list should be empty for another user", l.isEmpty());
- //delete contact
- userDao.delete(contact, u.getId());
- l = userDao.get(email, false, 0, 9999);
- assertTrue("Contact list should be empty after deletion", l.isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java
deleted file mode 100644
index 530dae7..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.user;
-
-import static org.apache.openmeetings.web.app.WebSession.getUserId;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractWicketTester;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestUserCount extends AbstractWicketTester {
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testCountSearchUsers() throws Exception {
- User u = createUser();
- assertTrue("Account of search users should be one", userDao.count(u.getFirstname()) == 1);
- }
-
- @Test
- public void testCountFilteredUsers() throws Exception {
- User u = createUser();
- User contact = createUserContact(u.getId());
- assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getId()) == 1);
- }
-
- @Test
- public void testCountUnfilteredUsers() throws Exception {
- User u = createUser();
- createUserContact(u.getId());
- assertTrue("Account of unfiltered should be more then one", userDao.count("firstname", false, getUserId()) > 1);
- }
-
- @Test
- public void testCountAllUsers() {
- assertTrue("Account of users should be positive", userDao.count() > 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserGroup.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserGroup.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserGroup.java
deleted file mode 100644
index 9a46d95..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserGroup.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.user;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.GroupUserDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.Group;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.test.selenium.HeavyTests;
-import org.apache.openmeetings.util.OmException;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestUserGroup extends AbstractJUnitDefaults {
- @Autowired
- private GroupUserDao groupUserDao;
- @Autowired
- private GroupDao groupDao;
- @Autowired
- private UserDao userDao;
- public static final String GROUP_NAME = "Test Group";
-
- private User getValidUser() {
- for (User u : userDao.getAllBackupUsers()) {
- if (!u.isDeleted() && u.getGroupUsers().size() > 0) {
- return u;
- }
- }
- fail("Unable to find valid user");
- return null; //unreachable
- }
-
- @Test
- public void getUsersByGroupId() {
- User u = getValidUser();
- Long groupId = u.getGroupUsers().get(0).getGroup().getId();
- List<GroupUser> ul = groupUserDao.get(groupId, 0, 9999);
- assertTrue("Default Group should contain at least 1 user: " + ul.size(), ul.size() > 0);
-
- GroupUser ou = groupUserDao.getByGroupAndUser(groupId, u.getId());
- assertNotNull("Unable to find [group, user] pair - [" + groupId + "," + u.getId() + "]", ou);
- }
-
- @Test
- public void addGroup() {
- Group g = new Group();
- g.setName(GROUP_NAME);
- Long groupId = groupDao.update(g, null).getId(); //inserted by not checked
- assertNotNull("New Group have valid id", groupId);
-
- List<GroupUser> ul = groupUserDao.get(groupId, 0, 9999);
- assertTrue("New Group should contain NO users: " + ul.size(), ul.size() == 0);
- }
-
- @Test
- public void addUserWithoutGroup() throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u = userDao.update(u, null);
- assertNotNull("User successfully created", u.getId());
- checkEmptyGroup("dao.get()", userDao.get(u.getId()));
- try {
- checkEmptyGroup("dao.login()", userDao.login(u.getAddress().getEmail(), createPass()));
- fail("User with no Group is unable to login");
- } catch (OmException e) {
- assertTrue("Expected Om Exception", "error.nogroup".equals(e.getKey()));
- }
- checkEmptyGroup("dao.getByLogin(user)", userDao.getByLogin(u.getLogin(), u.getType(), u.getDomainId()));
- }
-
-
- @Test
- public void addLdapUserWithoutGroup() throws Exception {
- User u1 = getUser();
- u1.setType(User.Type.ldap);
- u1.setDomainId(1L);
- u1 = userDao.update(u1, null);
- checkEmptyGroup("dao.getByLogin(ldap)", userDao.getByLogin(u1.getLogin(), u1.getType(), u1.getDomainId()));
- }
-
- private static void checkEmptyGroup(String prefix, User u) {
- assertNotNull(prefix + ":: Created user should be available", u);
- assertNotNull(prefix + ":: List<GroupUser> for newly created user should not be null", u.getGroupUsers());
- assertTrue(prefix + ":: List<GroupUser> for newly created user should be empty", u.getGroupUsers().isEmpty());
- }
-
- @Test
- @Category(HeavyTests.class)
- public void add10kUsers() throws Exception {
- List<Group> groups = groupDao.get(GROUP_NAME, 0, 1, null);
- Group g = null;
- if (groups == null || groups.isEmpty()) {
- g = new Group();
- g.setName(GROUP_NAME);
- g = groupDao.update(g, null);
- } else {
- g = groups.get(0);
- }
- for (int i = 0; i < 10000; ++i) {
- User u = createUser();
- u.getGroupUsers().add(new GroupUser(g, u));
- userDao.update(u, null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java
deleted file mode 100644
index 5513b07..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.userdata;
-
-import org.apache.openmeetings.db.dao.server.SessiondataDao;
-import org.apache.openmeetings.db.entity.server.Sessiondata;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.crypt.CryptProvider;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestAuth extends AbstractJUnitDefaults {
- @Autowired
- private SessiondataDao sessionDao;
-
- @Test
- public void testTestAuth() {
- Sessiondata sessionData = sessionDao.create(1L, 1L);
-
- System.out.println("sessionData: " + sessionData.getSessionId());
-
- String tTemp = CryptProvider.get().hash("test");
-
- System.out.println("tTemp: " + tTemp);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestLogin.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestLogin.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestLogin.java
deleted file mode 100644
index 0774a43..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestLogin.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.userdata;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.OmException;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestLogin extends AbstractJUnitDefaults {
-
- @Autowired
- private UserDao userDao;
-
- @Test
- public void testTestLogin() throws OmException {
- User us = userDao.login(username, userpass);
-
- assertNotNull("User is unable to login", us);
-
- //mService.getLanguageById(1);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/util/TestStoredFile.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/util/TestStoredFile.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/util/TestStoredFile.java
deleted file mode 100644
index 43b6a48..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/util/TestStoredFile.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.util;
-
-import static org.apache.openmeetings.util.OmFileHelper.getDefaultProfilePicture;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.StoredFile;
-import org.junit.Test;
-
-public class TestStoredFile extends AbstractJUnitDefaults {
- @Test
- public void testJpeg() throws FileNotFoundException, IOException {
- File f = getDefaultProfilePicture();
- for (String ext : new String[] {null, "txt", "png"}) {
- StoredFile sf = new StoredFile("test image", ext, f);
- assertTrue("Type should be detected as image", sf.isImage());
- assertTrue("Type should be detected as image", sf.isAsIs());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/web/LoginUI.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/web/LoginUI.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/web/LoginUI.java
deleted file mode 100644
index 3abf7c9..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/web/LoginUI.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.web;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.openmeetings.test.AbstractWicketTester;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.openmeetings.web.pages.MainPage;
-import org.apache.openmeetings.web.pages.auth.SignInPage;
-import org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter;
-import org.apache.wicket.feedback.FeedbackMessage;
-import org.apache.wicket.util.tester.FormTester;
-import org.junit.Test;
-
-import com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior;
-
-public class LoginUI extends AbstractWicketTester {
- @Test
- public void testValidLogin() {
- tester.startPage(MainPage.class);
- tester.assertRenderedPage(SignInPage.class);
-
- FormTester formTester = tester.newFormTester("signin:signin");
- formTester.setValue("login", username);
- formTester.setValue("pass", userpass);
- formTester.submit("submit");
-
- tester.assertNoErrorMessage();
- tester.assertRenderedPage(MainPage.class);
- WebSession ws = (WebSession)tester.getSession();
- assertTrue("Login should be successful", ws.isSignedIn());
- }
-
- @Test
- public void testEmptyLogin() {
- tester.startPage(SignInPage.class);
- tester.assertRenderedPage(SignInPage.class);
-
- FormTester formTester = tester.newFormTester("signin:signin");
- formTester.submit("submit");
-
- assertEquals("There should be exactly 2 errors", 2,
- tester.getFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)).size());
- }
-
-
- @Test
- public void testEmptyRegister() {
- tester.startPage(SignInPage.class);
- tester.assertRenderedPage(SignInPage.class);
-
- ButtonAjaxBehavior b = getButtonBehavior("signin", "register");
- tester.executeBehavior(b);
- FormTester formTester = tester.newFormTester("register:form");
- formTester.submit("submit");
- assertEquals("There should be exactly 7 errors", 7,
- tester.getFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)).size());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
deleted file mode 100644
index ff08b7f..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * 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 javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
-import static org.apache.openmeetings.db.util.ApplicationHelper.getWicketTester;
-import static org.apache.openmeetings.util.OmFileHelper.getOmHome;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.catalina.LifecycleState;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
-import org.apache.openmeetings.db.dto.file.FileItemDTO;
-import org.apache.openmeetings.db.dto.user.UserDTO;
-import org.apache.openmeetings.db.entity.file.BaseFileItem;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.openmeetings.webservice.util.AppointmentMessageBodyReader;
-import org.apache.wicket.util.tester.WicketTester;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-
-public class AbstractWebServiceTest extends AbstractJUnitDefaults {
- private static Tomcat tomcat;
- public static final String CONTEXT = "/openmeetings";
- public static final String BASE_SERVICES_URL = "http://localhost:8080" + CONTEXT + "/services";
- public static final String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
- public static final String INFO_SERVICE_URL = BASE_SERVICES_URL + "/info";
- public static final String FILE_SERVICE_URL = BASE_SERVICES_URL + "/file";
- public static final String UNIT_TEST_EXT_TYPE = "om_unit_tests";
- public static final long TIMEOUT = 5 * 60 * 1000;
- protected WicketTester tester;
-
- public static WebClient getClient(String url) {
- WebClient c = WebClient.create(url, Arrays.asList(new AppointmentMessageBodyReader()))
- .accept("application/json").type("application/json");
- HTTPClientPolicy p = WebClient.getConfig(c).getHttpConduit().getClient();
- p.setConnectionTimeout(TIMEOUT);
- p.setReceiveTimeout(TIMEOUT);
- return c;
- }
-
- public static ServiceResult login() {
- return login(username, userpass);
- }
-
- public static ServiceResult loginNoCheck(String user, String pass) {
- ServiceResult sr = getClient(USER_SERVICE_URL).path("/login").query("user", user).query("pass", pass)
- .get(ServiceResult.class);
- return sr;
- }
-
- public static ServiceResult login(String user, String pass) {
- ServiceResult sr = loginNoCheck(user, pass);
- assertEquals("Login should be successful", Type.SUCCESS.name(), sr.getType());
- return sr;
- }
-
- @BeforeClass
- public static void initialize() throws Exception {
- tomcat = new Tomcat();
- tomcat.setPort(8080);
- File wd = Files.createTempDirectory("om" + UUID.randomUUID().toString()).toFile();
- tomcat.setBaseDir(wd.getCanonicalPath());
- tomcat.getHost().setAppBase(wd.getCanonicalPath());
- tomcat.getHost().setAutoDeploy(true);
- tomcat.getHost().setDeployOnStartup(true);
- tomcat.addWebapp(CONTEXT, getOmHome().getAbsolutePath());
- tomcat.start();
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- tester = getWicketTester();
- assertNotNull("Web session should not be null", WebSession.get());
- }
-
- @After
- public void tearDown() {
- if (tester != null) {
- //can be null in case exception on initialization
- tester.destroy();
- }
- }
-
- @AfterClass
- public static void destroy() throws Exception {
- if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
- if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
- tomcat.stop();
- }
- tomcat.destroy();
- }
- }
-
- public void webCreateUser(User u) {
- ServiceResult r = login();
- UserDTO dto = new UserDTO(u);
- dto.setPassword(createPass());
- UserDTO user = getClient(USER_SERVICE_URL)
- .path("/")
- .query("sid", r.getMessage())
- .type(APPLICATION_FORM_URLENCODED)
- .post(new Form().param("user", dto.toString()).param("confirm", "" + false), UserDTO.class);
- Assert.assertNotNull(user.getId());
- u.setId(user.getId());
- }
-
- public CallResult<FileItemDTO> createVerifiedFile(File fsFile, String name, BaseFileItem.Type type) throws IOException {
- ServiceResult r = login();
-
- FileItemDTO f1 = null;
- try (InputStream is = new FileInputStream(fsFile)) {
- FileItemDTO file = new FileItemDTO()
- .setName(name)
- .setHash(UUID.randomUUID().toString())
- .setType(type);
- List<Attachment> atts = new ArrayList<>();
- atts.add(new Attachment("file", MediaType.APPLICATION_JSON, file));
- atts.add(new Attachment("stream", MediaType.APPLICATION_OCTET_STREAM, is));
- f1 = getClient(FILE_SERVICE_URL)
- .path("/")
- .query("sid", r.getMessage())
- .type(MediaType.MULTIPART_FORM_DATA_TYPE).postCollection(atts, Attachment.class, FileItemDTO.class);
- assertNotNull("Valid FileItem should be returned", f1);
- assertNotNull("Valid FileItem should be returned", f1.getId());
- }
- return new CallResult<>(r.getMessage(), f1);
- }
-
- public static class CallResult<T> {
- private final String sid;
- private final T obj;
-
- public CallResult(String sid, T obj) {
- this.sid = sid;
- this.obj = obj;
- }
-
- public String getSid() {
- return sid;
- }
-
- public T getObj() {
- return obj;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
deleted file mode 100644
index 55d5abe..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * 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.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.Response;
-
-import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
-import org.apache.openmeetings.db.dao.room.InvitationDao;
-import org.apache.openmeetings.db.dao.room.RoomDao;
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.calendar.AppointmentDTO;
-import org.apache.openmeetings.db.dto.calendar.MeetingMemberDTO;
-import org.apache.openmeetings.db.entity.calendar.Appointment;
-import org.apache.openmeetings.db.entity.calendar.MeetingMember;
-import org.apache.openmeetings.db.entity.room.Room;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.webservice.util.AppointmentParamConverter;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.github.openjson.JSONArray;
-import com.github.openjson.JSONObject;
-
-public class TestCalendarService extends AbstractWebServiceTest {
- public static final String CALENDAR_SERVICE_URL = BASE_SERVICES_URL + "/calendar";
- @Autowired
- private GroupDao groupDao;
- @Autowired
- private RoomDao roomDao;
- @Autowired
- private MeetingMemberDao mmDao;
- @Autowired
- private InvitationDao invitationDao;
- @Autowired
- private UserDao userDao;
-
- private void actualTest(Room r) throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
- webCreateUser(u);
- ServiceResult sr = login(u.getLogin(), createPass());
-
- Date start = new Date();
- Appointment a = createAppointment(getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
-
- AppointmentDTO app = getClient(CALENDAR_SERVICE_URL).path("/room/" + a.getRoom().getId()).query("sid", sr.getMessage())
- .get(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", app);
- }
-
- @Test
- public void testGetByAppRoom() throws Exception {
- actualTest(null);
- }
-
- @Test
- public void testGetByPublicRoom() throws Exception {
- actualTest(roomDao.get(5L)); //default public presentation room
- }
-
- private static JSONObject createAppointment(String title) {
- return new JSONObject()
- .put("title", title)
- .put("start", "2025-01-20T20:30:03+0300")
- .put("end", "2025-01-20T21:30:03+0300")
- .put("description", "Русский Тест")
- .put("reminder", "email")
- .put("room", new JSONObject()
- .put("name", "test24")
- .put("comment", "appointment test room")
- .put("type", "conference")
- .put("capacity", 15)
- .put("appointment", true)
- .put("isPublic", false)
- .put("demo", false)
- .put("closed", false)
- .put("externalId", 10)
- .put("externalType", "HuntingLabCMS")
- .put("redirectUrl", "")
- .put("moderated", true)
- .put("allowUserQuestions", true)
- .put("allowRecording", false)
- .put("waitForRecording", false)
- .put("audioOnly", true)
- .put("topBarHidden", false)
- .put("chatHidden", false)
- .put("activitiesHidden", false)
- .put("filesExplorerHidden", false)
- .put("actionsMenuHidden", false)
- .put("screenSharingHidden", false)
- .put("whiteboardHidden", false))
- .put("languageId", 9)
- .put("passwordProtected", false)
- .put("connectedEvent", false)
- .put("reminderEmailSend", false);
- }
-
- private String loginNewUser() throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
- webCreateUser(u);
- ServiceResult sr = login(u.getLogin(), createPass());
- return sr.getMessage();
- }
-
- private String createApp(String title) throws Exception {
- JSONObject o = createAppointment(title);
-
- String sid = loginNewUser();
-
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/")
- .query("sid", sid)
- .form(new Form().param("appointment", o.toString()));
-
- assertNotNull("Valid AppointmentDTO should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", dto);
- assertNotNull("DTO id should be valid", dto.getId());
-
- return sid;
- }
-
- @Test
- public void testCreate() throws Exception {
- createApp("test");
- }
-
- @Test
- public void testDelete() {
- ServiceResult sr = login();
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/" + Long.MAX_VALUE) //non-existent ID
- .query("sid", sr.getMessage())
- .delete();
-
- assertNotEquals("Call should NOT be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- }
-
- @Test
- public void testCreateWithOmMm() throws Exception {
- JSONObject o = createAppointment("test")
- .put("meetingMembers", new JSONArray()
- .put(new JSONObject().put("user", new JSONObject()
- .put("id", 1))));
-
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
- u = createUser(u);
- ServiceResult sr = login(u.getLogin(), createPass());
-
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/")
- .query("sid", sr.getMessage())
- .form(new Form().param("appointment", o.toString()));
-
- assertNotNull("Valid AppointmentDTO should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", dto);
- assertNotNull("DTO id should be valid", dto.getId());
- }
-
- private static AppointmentDTO createEventWithGuests(String sid) throws Exception {
- JSONObject o = createAppointment("test")
- .put("meetingMembers", new JSONArray()
- .put(new JSONObject().put("user", new JSONObject()
- .put("firstname", "John 1")
- .put("lastname", "Doe")
- .put("address", new JSONObject().put("email", "john1@doe.email"))
- ))
- .put(new JSONObject().put("user", new JSONObject()
- .put("firstname", "John 2")
- .put("lastname", "Doe")
- .put("address", new JSONObject().put("email", "john2@doe.email"))
- ))
- );
-
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/")
- .query("sid", sid)
- .form(new Form().param("appointment", o.toString()));
-
- assertNotNull("Valid AppointmentDTO should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", dto);
- assertNotNull("DTO id should be valid", dto.getId());
- assertEquals("DTO should have 2 attendees", 2, dto.getMeetingMembers().size());
- for (MeetingMemberDTO mm : dto.getMeetingMembers()) {
- assertNotNull("Email should be valid", mm.getUser().getAddress().getEmail());
- }
-
- return dto;
- }
-
- @Test
- public void testCreateWithGuests() throws Exception {
- String sid = loginNewUser();
- AppointmentDTO dto = createEventWithGuests(sid);
-
- //try to change MM list
- JSONObject o1 = AppointmentParamConverter.json(dto)
- .put("meetingMembers", new JSONArray()
- .put(new JSONObject().put("user", new JSONObject()
- .put("id", 1))));
-
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/")
- .query("sid", sid)
- .form(new Form().param("appointment", o1.toString()));
-
- assertNotNull("Valid AppointmentDTO should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- dto = resp.readEntity(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", dto);
- assertNotNull("DTO id should be valid", dto.getId());
- assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
- }
-
- @Test
- public void testCreateWithGuestsCleanOne() throws Exception {
- String sid = loginNewUser();
- AppointmentDTO dto = createEventWithGuests(sid);
- List<MeetingMemberDTO> initialList = new ArrayList<>(dto.getMeetingMembers());
- MeetingMember mm = mmDao.get(initialList.get(initialList.size() - 1).getId());
- Long mmId = mm.getId(), mmUserId = mm.getUser().getId();
- String hash = mm.getInvitation().getHash();
- dto.getMeetingMembers().remove(initialList.size() - 1);
-
- //try to change MM list
- JSONObject o = AppointmentParamConverter.json(dto);
- Response resp = getClient(CALENDAR_SERVICE_URL)
- .path("/")
- .query("sid", sid)
- .form(new Form().param("appointment", o.toString()));
-
- assertNotNull("Valid AppointmentDTO should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- dto = resp.readEntity(AppointmentDTO.class);
- assertNotNull("Valid DTO should be returned", dto);
- assertNotNull("DTO id should be valid", dto.getId());
- assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
-
- assertNull("Meeting member should deleted", mmDao.get(mmId));
- assertNull("Invitation should deleted", invitationDao.getByHash(hash, true, false));
- User uc = userDao.get(mmUserId);
- assertNotNull("Meeting member user should not be deleted", uc);
- assertFalse("Meeting member user should not be deleted", uc.isDeleted());
- }
-
- @Test
- public void testGetByTitle() throws Exception {
- String title = "title" + UUID.randomUUID().toString();
- String sid = createApp(title);
- @SuppressWarnings("unchecked")
- List<AppointmentDTO> list = (List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
- .path(String.format("/title/%s", title))
- .query("sid", sid)
- .getCollection(AppointmentDTO.class);
-
- assertEquals("List of one item should be returned", 1, list.size());
- assertEquals("Title should match", title, list.get(0).getTitle());
-
- title = UUID.randomUUID().toString();
- @SuppressWarnings("unchecked")
- List<AppointmentDTO> list1 = (List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
- .path(String.format("/title/%s", title))
- .query("sid", sid)
- .getCollection(AppointmentDTO.class);
- assertEquals("None items should be returned", 0, list1.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestFileService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestFileService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestFileService.java
deleted file mode 100644
index f742430..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestFileService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.awt.Graphics;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-
-import javax.imageio.ImageIO;
-
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.file.FileExplorerObject;
-import org.apache.openmeetings.db.dto.file.FileItemDTO;
-import org.apache.openmeetings.db.entity.file.BaseFileItem;
-import org.apache.openmeetings.util.NonJenkinsTests;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-public class TestFileService extends AbstractWebServiceTest {
-
- @Test
- @Category(NonJenkinsTests.class)
- public void addFileTest() throws IOException {
- File img = null;
- try {
- img = File.createTempFile("omtest", ".jpg");
- final Integer width = 150;
- final Integer height = 100;
- BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- Graphics g = image.getGraphics();
- g.drawString("Hello World!!!", 10, 20);
- ImageIO.write(image, "jpg", img);
- CallResult<FileItemDTO> cr = createVerifiedFile(img, "test.txt", BaseFileItem.Type.Presentation);
- assertEquals("Type should be Image", BaseFileItem.Type.Image, cr.getObj().getType());
- assertEquals("Width should be determined", width, cr.getObj().getWidth());
- assertEquals("Height should be Image", height, cr.getObj().getHeight());
- } finally {
- if (img != null && img.exists()) {
- img.delete();
- }
- }
- }
-
- @Test
- public void testGetRoom() {
- ServiceResult r = login();
- FileExplorerObject fo = getClient(FILE_SERVICE_URL)
- .path("/room/5")
- .query("sid", r.getMessage())
- .get(FileExplorerObject.class);
- assertNotNull(fo);
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java
deleted file mode 100644
index 773ede6..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.openmeetings.db.dto.basic.ServiceResult;
-import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
-import org.junit.Test;
-
-public class TestGroupService extends AbstractWebServiceTest {
- public static final String GROUP_SERVICE_URL = BASE_SERVICES_URL + "/group";
-
- @Test
- public void putTest() {
- ServiceResult r = login();
- Response resp = getClient(GROUP_SERVICE_URL)
- .path("/")
- .query("sid", r.getMessage()).put("");
- assertEquals("Call should NOT be successful", Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), resp.getStatus());
- }
-
- @Test
- public void addRemoveTest() {
- ServiceResult r = login();
- Long groupId = -1L;
- {
- Response resp = getClient(GROUP_SERVICE_URL)
- .path("/")
- .query("sid", r.getMessage()).query("name", "Test Group").post("");
- assertNotNull("Valid ServiceResult should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- ServiceResult r1 = resp.readEntity(ServiceResult.class);
- assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
- groupId = Long.valueOf(r1.getMessage());
- }
- //delete group created
- {
- Response resp = getClient(GROUP_SERVICE_URL)
- .path("/" + groupId)
- .query("sid", r.getMessage()).delete();
- assertNotNull("Valid ServiceResult should be returned", resp);
- assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
- ServiceResult r1 = resp.readEntity(ServiceResult.class);
- assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3dac8e2f/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRecordingService.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRecordingService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRecordingService.java
deleted file mode 100644
index b553ab6..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestRecordingService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.UUID;
-
-import org.apache.openmeetings.db.dao.record.RecordingDao;
-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.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestRecordingService extends AbstractWebServiceTest {
- public static final String RECORD_SERVICE_URL = BASE_SERVICES_URL + "/record";
- @Autowired
- private RecordingDao recordingDao;
-
- private User getExternalUser() throws Exception {
- String uuid = UUID.randomUUID().toString();
- User u = getUser(uuid);
- u.setExternalType(UNIT_TEST_EXT_TYPE);
- u.setExternalId(uuid);
- webCreateUser(u);
- return u;
- }
-
- @Test
- public void testExternal() throws Exception {
- User u = getExternalUser();
- Recording r = new Recording();
- r.setInsertedBy(u.getId());
- r.setComment("Created by Unit Tests");
- r.setRoomId(5L);
- r = recordingDao.update(r);
- ServiceResult sr = login();
- Collection<? extends RecordingDTO> recs = getClient(RECORD_SERVICE_URL).path("/" + UNIT_TEST_EXT_TYPE).query("sid", sr.getMessage())
- .getCollection(RecordingDTO.class);
- assertNotNull("Valid collection should be returned", recs);
- assertFalse("Collection of the recordings should not be empty", recs.isEmpty());
- boolean found = false;
- for (RecordingDTO rdo : recs) {
- if (r.getId().equals(rdo.getId())) {
- //TODO check room, user
- found = true;
- break;
- }
- }
- assertTrue("Just created recording was not found by the service", found);
- }
-}