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("[email protected]", "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 = "[email protected]"; - 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", "[email protected]")) - )) - .put(new JSONObject().put("user", new JSONObject() - .put("firstname", "John 2") - .put("lastname", "Doe") - .put("address", new JSONObject().put("email", "[email protected]")) - )) - ); - - 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); - } -}
