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 2018/03/14 10:15:59 UTC
[openmeetings] branch master updated: [OPENMEETINGS-1850] some
tests are fixed
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 3013951 [OPENMEETINGS-1850] some tests are fixed
3013951 is described below
commit 3013951a43f78e73df282450d3a31965af51a0f8
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Wed Mar 14 17:15:50 2018 +0700
[OPENMEETINGS-1850] some tests are fixed
---
.../apache/openmeetings/db/dao/label/LabelDao.java | 15 +--
.../openmeetings/db/util/ApplicationHelper.java | 71 +++++++++-----
.../installation/ImportInitvalues.java | 8 ++
.../src/main/resources/logback.xml | 26 +++--
.../src/main/resources/logback.xsd | 109 ---------------------
openmeetings-service/pom.xml | 5 +
.../mail/template/AbstractTemplatePanel.java | 14 +--
.../mail/template/RequestContactTemplate.java | 4 +-
.../subject/AppointmentReminderTemplate.java | 2 +-
.../subject/CanceledAppointmentTemplate.java | 2 +-
.../subject/CreatedAppointmentTemplate.java | 2 +-
.../subject/RecordingExpiringTemplate.java | 6 +-
.../subject/UpdatedAppointmentTemplate.java | 2 +-
.../openmeetings/util/OpenmeetingsVariables.java | 9 ++
openmeetings-web/pom.xml | 5 -
.../apache/openmeetings/web/app/Application.java | 5 +-
.../main/webapp/WEB-INF/classes/logback-config.xml | 1 -
.../apache/openmeetings/AbstractJUnitDefaults.java | 70 +++++++------
.../apache/openmeetings/AbstractWicketTester.java | 26 +----
.../apache/openmeetings/db/dao/TestRoomDao.java | 5 +
.../webservice/AbstractWebServiceTest.java | 22 ++++-
.../webservice/TestCalendarService.java | 35 ++++---
.../openmeetings/webservice/TestErrorService.java | 1 +
.../webservice/TestRecordingService.java | 6 +-
.../openmeetings/webservice/TestUserService.java | 6 ++
.../src/test/resources/logback-test.xml | 1 -
26 files changed, 196 insertions(+), 262 deletions(-)
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java
index a3412b4..e310489 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java
@@ -18,8 +18,9 @@
*/
package org.apache.openmeetings.db.dao.label;
-import static org.apache.openmeetings.db.util.ApplicationHelper._ensureApplication;
+import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
import static org.apache.openmeetings.util.DaoHelper.UNSUPPORTED;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getAppClass;
import java.io.File;
import java.io.IOException;
@@ -90,25 +91,17 @@ public class LabelDao implements IDataProviderDao<StringLabel>{
}
public static String getString(String key, long langId) {
- return _ensureApplication().getOmString(key, langId);
+ return ensureApplication().getOmString(key, langId);
}
private static File getLangFile() {
return new File(OmFileHelper.getLanguagesDir(), OmFileHelper.LANG_FILE_NAME);
}
- public static synchronized Class<?> getAppClass() throws ClassNotFoundException {
- if (appClass == null) {
- //HACK to resolve package dependencies
- appClass = Class.forName("org.apache.openmeetings.web.app.Application");
- }
- return appClass;
- }
-
public static void initLanguageMap() {
SAXReader reader = new SAXReader();
try {
- getAppClass();
+ appClass = getAppClass();
Document document = reader.read(getLangFile());
Element root = document.getRootElement();
languages.clear();
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/util/ApplicationHelper.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/util/ApplicationHelper.java
index 854c4f4..0320712 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/util/ApplicationHelper.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/util/ApplicationHelper.java
@@ -18,7 +18,9 @@
*/
package org.apache.openmeetings.db.util;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_CONTEXT_NAME;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getWicketApplicationName;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.isInitComplete;
import static org.springframework.web.context.WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
import static org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext;
@@ -29,6 +31,7 @@ import org.apache.openmeetings.IApplication;
import org.apache.openmeetings.IWebSession;
import org.apache.openmeetings.db.dao.label.LabelDao;
import org.apache.openmeetings.util.OMContextListener;
+import org.apache.openmeetings.util.OpenmeetingsVariables;
import org.apache.wicket.Application;
import org.apache.wicket.RuntimeConfigurationType;
import org.apache.wicket.ThreadContext;
@@ -52,11 +55,46 @@ public class ApplicationHelper {
private ApplicationHelper() {}
- public static IApplication ensureApplication() {
- return ensureApplication(-1L);
+ private static WebApplication createApp(WebApplication _app) {
+ WebApplication app = _app;
+ if (app == null) {
+ // This is the case for non-web-app applications (command line admin)
+ try {
+ app = (WebApplication)OpenmeetingsVariables.getAppClass().newInstance();
+ ServletContext sc = new MockServletContext(app, null);
+ XmlWebApplicationContext xmlContext = new XmlWebApplicationContext();
+ xmlContext.setConfigLocation("classpath:applicationContext.xml");
+ xmlContext.setServletContext(sc);
+ xmlContext.refresh();
+ sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext);
+ app.setServletContext(sc);
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ log.error("Failed to create Application");
+ }
+ }
+ return app;
+ }
+
+ private static WebApplication initApp(WebApplication app) {
+ if (app != null) {
+ if (app.getName() == null && getWicketApplicationName() == null) {
+ app.setName(DEFAULT_CONTEXT_NAME);
+ }
+ try {
+ app.getServletContext();
+ } catch(IllegalStateException e) {
+ app.setServletContext(new MockServletContext(app, null));
+ }
+ app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
+ OMContextListener omcl = new OMContextListener();
+ omcl.contextInitialized(new ServletContextEvent(app.getServletContext()));
+ ThreadContext.setApplication(app);
+ app.initApplication();
+ }
+ return app;
}
- public static IApplication _ensureApplication() {
+ public static IApplication ensureApplication() {
if (Application.exists()) {
return (IApplication)Application.get();
}
@@ -64,29 +102,12 @@ public class ApplicationHelper {
if (Application.exists()) {
return (IApplication)Application.get();
}
- WebApplication app = (WebApplication)Application.get(getWicketApplicationName());
+ WebApplication app = createApp((WebApplication)Application.get(getWicketApplicationName()));
LabelDao.initLanguageMap();
- if (app == null) {
- try {
- app = (WebApplication)LabelDao.getAppClass().newInstance();
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- log.error("Failed to create Application");
- return null;
+ if (app != null) {
+ if (!isInitComplete()) {
+ initApp(app);
}
- app.setServletContext(new MockServletContext(app, null));
- app.setName(getWicketApplicationName());
- ServletContext sc = app.getServletContext();
- OMContextListener omcl = new OMContextListener();
- omcl.contextInitialized(new ServletContextEvent(sc));
- XmlWebApplicationContext xmlContext = new XmlWebApplicationContext();
- xmlContext.setConfigLocation("classpath:applicationContext.xml");
- xmlContext.setServletContext(sc);
- xmlContext.refresh();
- sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext);
- app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
- ThreadContext.setApplication(app);
- app.initApplication();
- } else {
ThreadContext.setApplication(app);
}
return (IApplication)Application.get(getWicketApplicationName());
@@ -94,7 +115,7 @@ public class ApplicationHelper {
}
public static IApplication ensureApplication(Long langId) {
- IApplication a = _ensureApplication();
+ IApplication a = ensureApplication();
if (ThreadContext.getRequestCycle() == null) {
ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application)a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
diff --git a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
index be0d15b..de8a481 100644
--- a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
+++ b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
@@ -435,6 +435,14 @@ public class ImportInitvalues {
}
}
+ public User createSystemUser(User u, String group, String login, String pass, boolean groupAdmin) throws Exception {
+ GroupUser gu = new GroupUser(groupDao.get(group), u);
+ gu.setModerator(groupAdmin);
+ u.getGroupUsers().add(gu);
+ u.setLogin(login);
+ return userDao.update(u, pass, null);
+ }
+
public void loadInitialOAuthServers() {
// Yandex
OAuthServer yaServer = new OAuthServer();
diff --git a/openmeetings-screenshare/src/main/resources/logback.xml b/openmeetings-screenshare/src/main/resources/logback.xml
index 8b6c297..1325dc6 100644
--- a/openmeetings-screenshare/src/main/resources/logback.xml
+++ b/openmeetings-screenshare/src/main/resources/logback.xml
@@ -18,27 +18,25 @@
under the License.
-->
-
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="logback.xsd">
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<contextName>${current_openmeetings_context_name}</contextName>
<jmxConfigurator contextName="${current_openmeetings_context_name}" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <File>screensharing.log</File>
- <Append>false</Append>
- <Encoding>UTF-8</Encoding>
- <BufferedIO>false</BufferedIO>
- <ImmediateFlush>true</ImmediateFlush>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%5p %d{MM-dd HH:mm:ss.SSS } %L %c{10} [%t] - %m%n</pattern>
- </layout>
+ <file>screensharing.log</file>
+ <append>false</append>
+ <immediateFlush>true</immediateFlush>
+ <encoder>
+ <charset>UTF-8</charset>
+ <pattern>%5p %d{MM-dd HH:mm:ss.SSS } %c{15}:%L [%.15thread] - %m%n</pattern>
+ </encoder>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%5p %d{MM-dd HH:mm:ss.SSS } %L %c{10} [%t] - %m%n</pattern>
- </layout>
+ <encoder>
+ <charset>UTF-8</charset>
+ <pattern>%highlight(%-5level) %d{MM-dd HH:mm:ss.SSS } %cyan(%c{15}:%L [%.15thread]) - %m%n</pattern>
+ </encoder>
</appender>
<logger name="org.apache.openmeetings" level="DEBUG"/>
<logger name="org.red5.server.net.rtmp.codec.RTMPProtocolDecoder" level="OFF"/>
diff --git a/openmeetings-screenshare/src/main/resources/logback.xsd b/openmeetings-screenshare/src/main/resources/logback.xsd
deleted file mode 100644
index cc5ad1c..0000000
--- a/openmeetings-screenshare/src/main/resources/logback.xsd
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
-
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
- <xs:element name="configuration">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="contextName"/>
- <xs:element ref="jmxConfigurator"/>
- <xs:element maxOccurs="unbounded" ref="appender"/>
- <xs:element maxOccurs="unbounded" ref="logger"/>
- <xs:element ref="root"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="contextName" type="xs:string"/>
- <xs:element name="jmxConfigurator">
- <xs:complexType>
- <xs:attribute name="contextName" use="required"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="appender">
- <xs:complexType>
- <xs:sequence>
- <xs:sequence minOccurs="0">
- <xs:element ref="File"/>
- <xs:element ref="Append"/>
- <xs:element ref="Encoding"/>
- <xs:element ref="BufferedIO"/>
- <xs:element ref="ImmediateFlush"/>
- </xs:sequence>
- <xs:element ref="layout"/>
- </xs:sequence>
- <xs:attribute name="class" use="required"/>
- <xs:attribute name="name" use="required" type="xs:NCName"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="File" type="xs:string"/>
- <xs:element name="Append" type="xs:boolean"/>
- <xs:element name="Encoding" type="xs:NCName"/>
- <xs:element name="BufferedIO" type="xs:boolean"/>
- <xs:element name="ImmediateFlush" type="xs:boolean"/>
- <xs:element name="layout">
- <xs:complexType>
- <xs:choice>
- <xs:element ref="Pattern"/>
- <xs:element ref="pattern"/>
- </xs:choice>
- <xs:attribute name="class" use="required"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="Pattern" type="xs:string"/>
- <xs:element name="pattern" type="xs:string"/>
- <xs:element name="logger">
- <xs:complexType>
- <xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" ref="appender-ref"/>
- <xs:element maxOccurs="1" minOccurs="0" ref="level"/>
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:NCName"/>
- <xs:attribute name="level" type="LoggerLevels" use="optional"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="root">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" ref="appender-ref"/>
- </xs:sequence>
- <xs:attribute name="level" type="LoggerLevels" use="optional"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="appender-ref">
- <xs:complexType>
- <xs:attribute name="ref" use="required" type="xs:NCName"/>
- </xs:complexType>
- </xs:element>
- <xs:complexType name="level">
- <xs:sequence>
- <xs:element ref="level"/>
- </xs:sequence>
- </xs:complexType>
- <xs:element name="level">
- <xs:complexType>
- <xs:attribute name="value" use="required" type="xs:NCName"/>
- </xs:complexType>
- </xs:element>
- <xs:simpleType name="LoggerLevels">
- <xs:restriction base="xs:string">
- <xs:pattern value="off|OFF|all|ALL|inherited|INHERITED|null|NULL|error|ERROR|warn|WARN|info|INFO|debug|DEBUG|trace|TRACE"/>
- </xs:restriction>
- </xs:simpleType>
-</xs:schema>
diff --git a/openmeetings-service/pom.xml b/openmeetings-service/pom.xml
index 75ef9e4..fc3389f 100644
--- a/openmeetings-service/pom.xml
+++ b/openmeetings-service/pom.xml
@@ -43,6 +43,11 @@
<version>${wicket.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-spring</artifactId>
+ <version>${wicket.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java
index bfbec3d..b556835 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java
@@ -18,11 +18,11 @@
*/
package org.apache.openmeetings.service.mail.template;
-import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultLang;
import java.util.Locale;
+import org.apache.openmeetings.IApplication;
import org.apache.openmeetings.IWebSession;
import org.apache.openmeetings.db.dao.label.LabelDao;
import org.apache.openmeetings.db.util.FormatHelper;
@@ -30,22 +30,22 @@ import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.spring.injection.annot.SpringBean;
public abstract class AbstractTemplatePanel extends Panel {
private static final long serialVersionUID = 1L;
public static final String COMP_ID = "template";
protected final Locale locale;
+ @SpringBean
+ protected IApplication app;
+
protected AbstractTemplatePanel(Locale locale) {
super(COMP_ID);
this.locale = locale == null ? getDefault() : locale;
add(new TransparentWebMarkupContainer("container").add(AttributeModifier.append("dir", FormatHelper.isRtlLanguage(this.locale.toLanguageTag()) ? "rtl" : "ltr")));
}
- public static <T> T getBean(Class<T> clazz) {
- return ensureApplication().getOmBean(clazz);
- }
-
public static IWebSession getOmSession() {
return (IWebSession)WebSession.get();
}
@@ -54,7 +54,7 @@ public abstract class AbstractTemplatePanel extends Panel {
return LabelDao.getLocale(getDefaultLang());
}
- public static String getString(String id, Locale locale, String... params) {
- return ensureApplication().getOmString(id, locale, params);
+ public String getString(String id, Locale locale, String... params) {
+ return app.getOmString(id, locale, params);
}
}
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java
index 9d4ddd5..1781f53 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java
@@ -18,8 +18,6 @@
*/
package org.apache.openmeetings.service.mail.template;
-import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
-
import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.util.LocaleHelper;
import org.apache.wicket.core.util.string.ComponentRenderer;
@@ -38,7 +36,7 @@ public class RequestContactTemplate extends AbstractTemplatePanel {
add(new Label("lastName", user.getLastname()));
add(new Label("likeToAdd", getString("1193", locale)));
add(new Label("check", getString("1194", locale)));
- add(new ExternalLink("link", ensureApplication().getOmContactsLink()).add(new Label("contactList", getString("1196", locale))));
+ add(new ExternalLink("link", app.getOmContactsLink()).add(new Label("contactList", getString("1196", locale))));
}
public static String getEmail(User userToAdd, User user) {
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java
index 744cd1c..08149d8 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java
@@ -48,6 +48,6 @@ public class AppointmentReminderTemplate extends AppointmentTemplate {
@Override
String getPrefix() {
- return ensureApplication().getOmString("1158", locale);
+ return app.getOmString("1158", locale);
}
}
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java
index fff5902..ebf807b 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java
@@ -48,6 +48,6 @@ public class CanceledAppointmentTemplate extends InvitedAppointmentTemplate {
@Override
String getPrefix() {
- return ensureApplication().getOmString("1157", locale);
+ return app.getOmString("1157", locale);
}
}
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java
index 99a0e8c..161d10f 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java
@@ -48,6 +48,6 @@ public class CreatedAppointmentTemplate extends InvitedAppointmentTemplate {
@Override
String getPrefix() {
- return ensureApplication().getOmString("1151", locale);
+ return app.getOmString("1151", locale);
}
}
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/RecordingExpiringTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/RecordingExpiringTemplate.java
index ce756dc..db696b7 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/RecordingExpiringTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/RecordingExpiringTemplate.java
@@ -29,6 +29,7 @@ import org.apache.openmeetings.db.util.LocaleHelper;
import org.apache.openmeetings.service.mail.template.OmTextLabel;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.spring.injection.annot.SpringBean;
public class RecordingExpiringTemplate extends SubjectEmailTemplate {
private static final long serialVersionUID = 1L;
@@ -36,6 +37,9 @@ public class RecordingExpiringTemplate extends SubjectEmailTemplate {
private long remainingDays;
private final User u;
+ @SpringBean
+ protected RoomDao roomDao;
+
private RecordingExpiringTemplate(User u, final Recording rec, long remainingDays) {
super(LocaleHelper.getLocale(u));
this.u = u;
@@ -60,7 +64,7 @@ public class RecordingExpiringTemplate extends SubjectEmailTemplate {
@Override
Fragment getSubjectFragment() {
Fragment f = new Fragment(COMP_ID, "subject", this);
- Room room = getBean(RoomDao.class).get(rec.getRoomId());
+ Room room = roomDao.get(rec.getRoomId());
f.add(new OmTextLabel("prefix", getString("template.recording.expiring.subj.prefix", locale))
, new OmTextLabel("room", room == null ? null : getString("template.recording.expiring.subj.room", locale, room.getName())).setVisible(room != null)
);
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java
index c1dcec1..cb9b315 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java
@@ -48,6 +48,6 @@ public class UpdatedAppointmentTemplate extends InvitedAppointmentTemplate {
@Override
String getPrefix() {
- return ensureApplication().getOmString("1155", locale);
+ return app.getOmString("1155", locale);
}
}
diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index 5e58994..fb59d97 100644
--- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -132,6 +132,7 @@ public class OpenmeetingsVariables {
private static String audioBitrate = "32k";
private static String defaultTimezone = "Europe/Berlin";
private static String restAllowOrigin = null;
+ private static Class<?> appClass = null;
private OpenmeetingsVariables() {}
@@ -258,4 +259,12 @@ public class OpenmeetingsVariables {
public static void setRestAllowOrigin(String allowOrigin) {
restAllowOrigin = allowOrigin;
}
+
+ public static synchronized Class<?> getAppClass() throws ClassNotFoundException {
+ if (appClass == null) {
+ //HACK to resolve package dependencies
+ appClass = Class.forName("org.apache.openmeetings.web.app.Application");
+ }
+ return appClass;
+ }
}
diff --git a/openmeetings-web/pom.xml b/openmeetings-web/pom.xml
index 7ce4b2c..38b9d62 100644
--- a/openmeetings-web/pom.xml
+++ b/openmeetings-web/pom.xml
@@ -567,11 +567,6 @@
<version>${wicket.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-spring</artifactId>
- <version>${wicket.version}</version>
- </dependency>
- <dependency>
<groupId>com.googlecode.wicket-jquery-ui</groupId>
<artifactId>wicket-jquery-ui-core</artifactId>
<version>${wicketju.version}</version>
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
index cb917c2..ad822a0 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
@@ -277,7 +277,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica
mountResource("/group/${id}", new GroupLogoResourceReference());
getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx, true));
- log.debug("InitComponent::PostConstruct");
+ log.debug("Application::init");
try {
if (OmFileHelper.getOmHome() == null) {
OmFileHelper.setOmHome(new File(getServletContext().getRealPath("/")));
@@ -289,7 +289,6 @@ public class Application extends AuthenticatedWebApplication implements IApplica
// Init all global config properties
cfgDao.reinit();
- setInitComplete(true);
// Init properties
setXFrameOptions(cfgDao.getString(CONFIG_HEADER_XFRAME, HEADER_XFRAME_SAMEORIGIN));
setContentSecurityPolicy(cfgDao.getString(CONFIG_HEADER_CSP, HEADER_CSP_SELF));
@@ -297,6 +296,8 @@ public class Application extends AuthenticatedWebApplication implements IApplica
setExtProcessTtl(cfgDao.getInt(CONFIG_EXT_PROCESS_TTL, getExtProcessTtl()));
Version.logOMStarted();
recordingDao.resetProcessingStatus(); //we are starting so all processing recordings are now errors
+
+ setInitComplete(true);
} catch (Exception err) {
log.error("[appStart]", err);
}
diff --git a/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml b/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
index 17a0a42..d18ff74 100644
--- a/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
+++ b/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
@@ -25,7 +25,6 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${current_openmeetings_log_dir}/${current_openmeetings_context_name}.log</file>
- <append>false</append>
<immediateFlush>true</immediateFlush>
<encoder>
<charset>UTF-8</charset>
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
index 8906829..2a6654e 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
@@ -18,8 +18,10 @@
*/
package org.apache.openmeetings;
+import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
import static org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_CONTEXT_NAME;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getCryptClassName;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWicketApplicationName;
import static org.apache.openmeetings.util.OpenmeetingsVariables.setWicketApplicationName;
import static org.junit.Assert.assertNotNull;
@@ -34,10 +36,10 @@ 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.GroupUser;
import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.installation.ImportInitvalues;
import org.apache.openmeetings.installation.InstallationConfig;
+import org.apache.openmeetings.web.app.Application;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,22 +67,24 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
private ImportInitvalues importInitvalues;
@Autowired
protected ConfigurationDao cfgDao;
+ @Autowired
+ protected Application app;
@Before
public void setUp() throws Exception {
- setWicketApplicationName(DEFAULT_CONTEXT_NAME);
- try {
- cfgDao.reinit();
- } catch (Exception e) {
- log.warn("DB seems not to be inited", e);
+ if (app.getName() == null) {
+ app.setName(DEFAULT_CONTEXT_NAME);
}
- if (userDao.count() < 1) {
- makeDefaultScheme();
- // regular user
- createSystemUser(regularUsername, false);
+ if (getWicketApplicationName() == null) {
+ setWicketApplicationName(app.getName());
+ }
+ ensureApplication();
+ ensureSchema(userDao, importInitvalues);
+ }
- // group admin
- createSystemUser(groupAdminUsername, true);
+ public static void ensureSchema(UserDao userDao, ImportInitvalues importInitvalues) throws Exception {
+ if (userDao.count() < 1) {
+ makeDefaultScheme(importInitvalues);
log.info("Default scheme created successfully");
} else {
log.info("Default scheme already created");
@@ -105,9 +109,7 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
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);
-
+ public static Appointment getAppointment(User owner, Room r, Date start, Date end) {
// add new appointment
Appointment ap = new Appointment();
@@ -141,13 +143,18 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
return ap;
}
- public Appointment createAppointment(Appointment ap) {
+ public static Appointment createAppointment(AppointmentDao appointmentDao, Appointment ap) {
+ assertNotNull("Can't access to appointment dao implimentation", appointmentDao);
// add new appointment
ap = appointmentDao.update(ap, null, false);
- assertNotNull("Cann't add appointment", ap.getId());
+ assertNotNull("Can't add appointment", ap.getId());
return ap;
}
+ public Appointment createAppointment(Appointment ap) {
+ return createAppointment(appointmentDao, ap);
+ }
+
public User getUser() throws Exception {
return getUser(UUID.randomUUID().toString());
}
@@ -160,11 +167,11 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
return String.format("email%s@local", uid);
}
- protected String createPass() {
+ public static String createPass() {
return "pass1_!@#$%_A";
}
- public User getUser(String uuid) throws Exception {
+ public static User getUser(String uuid) throws Exception {
User u = new User();
// add user
u.setFirstname("firstname" + uuid);
@@ -174,21 +181,11 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
u.getAddress().setEmail(getEmail(uuid));
u.setRights(UserDao.getDefaultRights());
u.setTimeZoneId("Asia/Bangkok");
- u.updatePassword(cfgDao, createPass());
+ u.updatePassword(null, createPass()); // NO SIP
u.setLanguageId(1L);
return u;
}
- public User createSystemUser(String login, boolean groupAdmin) throws Exception {
- User u = getUser();
- GroupUser gu = new GroupUser(groupDao.get(group), u);
- gu.setModerator(groupAdmin);
- u.getGroupUsers().add(gu);
- u.setLogin(login);
- u.updatePassword(cfgDao, userpass);
- return createUser(u);
- }
-
public User createUser() throws Exception {
return createUser(UUID.randomUUID().toString());
}
@@ -197,13 +194,17 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
return createUser(getUser(uuid));
}
- public User createUser(User u) {
+ public static User createUser(UserDao userDao, User u) {
u = userDao.update(u, null);
assertNotNull("Can't add user", u);
return u;
}
- private void makeDefaultScheme() throws Exception {
+ public User createUser(User u) {
+ return createUser(userDao, u);
+ }
+
+ private static void makeDefaultScheme(ImportInitvalues importInitvalues) throws Exception {
InstallationConfig cfg = new InstallationConfig();
cfg.setUsername(adminUsername);
cfg.setPassword(userpass);
@@ -211,6 +212,11 @@ public abstract class AbstractJUnitDefaults extends AbstractSpringTest {
cfg.setGroup(group);
cfg.setTimeZone(timeZone);
importInitvalues.loadAll(cfg, false);
+ // regular user
+ importInitvalues.createSystemUser(getUser(UUID.randomUUID().toString()), group, regularUsername, userpass, false);
+
+ // group admin
+ importInitvalues.createSystemUser(getUser(UUID.randomUUID().toString()), group, groupAdminUsername, userpass, true);
}
public User getContact(String uuid, Long ownerId) {
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
index 325bcbd..77be8b4 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractWicketTester.java
@@ -19,8 +19,6 @@
package org.apache.openmeetings;
import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.getWicketApplicationName;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.setInitComplete;
import static org.apache.wicket.util.string.Strings.escapeMarkup;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -32,28 +30,21 @@ import java.util.List;
import java.util.Locale;
import java.util.function.Consumer;
-import javax.servlet.ServletContextEvent;
-
import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.entity.user.User.Type;
-import org.apache.openmeetings.util.OMContextListener;
import org.apache.openmeetings.util.OmException;
import org.apache.openmeetings.web.app.Application;
import org.apache.openmeetings.web.app.WebSession;
import org.apache.openmeetings.web.pages.MainPage;
-import org.apache.wicket.RuntimeConfigurationType;
-import org.apache.wicket.ThreadContext;
import org.apache.wicket.behavior.AbstractAjaxBehavior;
import org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter;
import org.apache.wicket.feedback.FeedbackMessage;
-import org.apache.wicket.protocol.http.mock.MockServletContext;
import org.apache.wicket.protocol.ws.util.tester.WebSocketTester;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog;
import com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior;
@@ -64,29 +55,14 @@ public class AbstractWicketTester extends AbstractJUnitDefaults {
public static final String PATH_MENU = "main-container:main:topControls:menu:menu";
protected WicketTester tester;
- @Autowired
- private Application app;
-
public static WicketTester getWicketTester(Application app) {
return getWicketTester(app, -1);
}
public static WicketTester getWicketTester(Application app, long langId) {
- boolean testerNeedInit = app.getName() != null;
- if (!testerNeedInit) {
- //FIXME TODO re-use this for templates
- app.setName(getWicketApplicationName());
- app.setServletContext(new MockServletContext(app, null));
- app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
- OMContextListener omcl = new OMContextListener();
- omcl.contextInitialized(new ServletContextEvent(app.getServletContext()));
- ThreadContext.setApplication(app);
- app.initApplication();
- }
ensureApplication(langId); // to ensure WebSession is attached
- WicketTester tester = new WicketTester(app, app.getServletContext(), testerNeedInit);
- setInitComplete(true);
+ WicketTester tester = new WicketTester(app, app.getServletContext(), false);
return tester;
}
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java b/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
index 6a81ad8..92ab136 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
@@ -19,6 +19,7 @@
package org.apache.openmeetings.db.dao;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.apache.openmeetings.AbstractJUnitDefaults;
@@ -40,14 +41,18 @@ public class TestRoomDao extends AbstractJUnitDefaults {
@Test
public void testMicStatusHidden() throws Exception {
Room r = roomDao.get(1);
+ assertNotNull("Room must exist", r);
assertTrue("Default interview room should have mic status hidden", r.isHidden(RoomElement.MicrophoneStatus));
r = roomDao.get(5);
+ assertNotNull("Room must exist", r);
assertTrue("Default presentation room should have mic status hidden", r.isHidden(RoomElement.MicrophoneStatus));
r = roomDao.get(6);
+ assertNotNull("Room must exist", r);
assertFalse("Default Mic room should have mic status visible", r.isHidden(RoomElement.MicrophoneStatus));
User u = createUser(); //creating new User here
r = roomDao.getUserRoom(u.getId(), Room.Type.presentation, "bla");
+ assertNotNull("Room must exist", r);
boolean hidden = r.isHidden(RoomElement.MicrophoneStatus);
if (!hidden && log.isDebugEnabled()) {
log.debug("Invalid personal room found -> User: {}, Room: {} ... deleted ? {}", u, r, r.isDeleted());
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
index 562d132..367668e 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/AbstractWebServiceTest.java
@@ -19,6 +19,11 @@
package org.apache.openmeetings.webservice;
import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static org.apache.openmeetings.AbstractJUnitDefaults.adminUsername;
+import static org.apache.openmeetings.AbstractJUnitDefaults.createPass;
+import static org.apache.openmeetings.AbstractJUnitDefaults.ensureSchema;
+import static org.apache.openmeetings.AbstractJUnitDefaults.userpass;
+import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
import static org.apache.openmeetings.util.OmFileHelper.getOmHome;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -43,7 +48,8 @@ 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.AbstractSpringTest;
+import org.apache.openmeetings.db.dao.user.UserDao;
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;
@@ -51,12 +57,14 @@ import org.apache.openmeetings.db.dto.room.RoomDTO;
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.installation.ImportInitvalues;
import org.apache.openmeetings.webservice.util.AppointmentMessageBodyReader;
import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.BeforeClass;
-public class AbstractWebServiceTest extends AbstractJUnitDefaults {
+public class AbstractWebServiceTest {
private static Tomcat tomcat;
private static final String HOST = "localhost";
private static final String CONTEXT = "/openmeetings";
@@ -67,6 +75,10 @@ public class AbstractWebServiceTest extends AbstractJUnitDefaults {
public static final String UNIT_TEST_EXT_TYPE = "om_unit_tests";
public static final long TIMEOUT = 5 * 60 * 1000;
+ protected static <T> T getBean(Class<T> clazz) {
+ return ensureApplication()._getOmBean(clazz);
+ }
+
public static WebClient getClient(String url) {
WebClient c = WebClient.create(url, Arrays.asList(new AppointmentMessageBodyReader()))
.accept("application/json").type("application/json");
@@ -94,6 +106,7 @@ public class AbstractWebServiceTest extends AbstractJUnitDefaults {
@BeforeClass
public static void initialize() throws Exception {
+ AbstractSpringTest.init();
tomcat = new Tomcat();
Connector connector = new Connector("HTTP/1.1");
connector.setAttribute("address", InetAddress.getByName(HOST).getHostAddress());
@@ -111,6 +124,11 @@ public class AbstractWebServiceTest extends AbstractJUnitDefaults {
port = tomcat.getConnector().getLocalPort();
}
+ @Before
+ public void setUp() throws Exception {
+ ensureSchema(getBean(UserDao.class), getBean(ImportInitvalues.class));
+ }
+
@AfterClass
public static void destroy() throws Exception {
if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
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
index 1ff6684..2526911 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestCalendarService.java
@@ -18,6 +18,11 @@
*/
package org.apache.openmeetings.webservice;
+import static org.apache.openmeetings.AbstractJUnitDefaults.ONE_HOUR;
+import static org.apache.openmeetings.AbstractJUnitDefaults.createPass;
+import static org.apache.openmeetings.AbstractJUnitDefaults.createUser;
+import static org.apache.openmeetings.AbstractJUnitDefaults.getAppointment;
+import static org.apache.openmeetings.AbstractJUnitDefaults.getUser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -32,9 +37,13 @@ import java.util.UUID;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
+import org.apache.openmeetings.AbstractJUnitDefaults;
+import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
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;
@@ -45,30 +54,23 @@ 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_MOUNT = "calendar";
- @Autowired
- private RoomDao roomDao;
- @Autowired
- private MeetingMemberDao mmDao;
- @Autowired
- private InvitationDao invitationDao;
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));
+ u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
webCreateUser(u);
ServiceResult sr = login(u.getLogin(), createPass());
- u = userDao.get(u.getId());
+ u = getBean(UserDao.class).get(u.getId());
Date start = new Date();
- Appointment a = createAppointment(getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
+ Appointment a = AbstractJUnitDefaults.createAppointment(getBean(AppointmentDao.class), getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
AppointmentDTO app = getClient(getCalendarUrl()).path("/room/" + a.getRoom().getId()).query("sid", sr.getMessage())
.get(AppointmentDTO.class);
@@ -82,7 +84,7 @@ public class TestCalendarService extends AbstractWebServiceTest {
@Test
public void testGetByPublicRoom() throws Exception {
- actualTest(roomDao.get(5L)); //default public presentation room
+ actualTest(getBean(RoomDao.class).get(5L)); //default public presentation room
}
private static JSONObject createAppointment(String title) {
@@ -125,7 +127,7 @@ public class TestCalendarService extends AbstractWebServiceTest {
private String loginNewUser() throws Exception {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
+ u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
webCreateUser(u);
ServiceResult sr = login(u.getLogin(), createPass());
return sr.getMessage();
@@ -175,8 +177,8 @@ public class TestCalendarService extends AbstractWebServiceTest {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
- u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u));
- u = createUser(u);
+ u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
+ u = createUser(getBean(UserDao.class), u);
ServiceResult sr = login(u.getLogin(), createPass());
Response resp = getClient(getCalendarUrl())
@@ -253,6 +255,7 @@ public class TestCalendarService extends AbstractWebServiceTest {
String sid = loginNewUser();
AppointmentDTO dto = createEventWithGuests(sid);
List<MeetingMemberDTO> initialList = new ArrayList<>(dto.getMeetingMembers());
+ MeetingMemberDao mmDao = getBean(MeetingMemberDao.class);
MeetingMember mm = mmDao.get(initialList.get(initialList.size() - 1).getId());
Long mmId = mm.getId(), mmUserId = mm.getUser().getId();
String hash = mm.getInvitation().getHash();
@@ -273,8 +276,8 @@ public class TestCalendarService extends AbstractWebServiceTest {
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);
+ assertNull("Invitation should deleted", getBean(InvitationDao.class).getByHash(hash, true, false));
+ User uc = getBean(UserDao.class).get(mmUserId);
assertNotNull("Meeting member user should not be deleted", uc);
assertFalse("Meeting member user should not be deleted", uc.isDeleted());
}
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestErrorService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestErrorService.java
index 4dc1ca0..281788f 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestErrorService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestErrorService.java
@@ -18,6 +18,7 @@
*/
package org.apache.openmeetings.webservice;
+import static org.apache.openmeetings.AbstractJUnitDefaults.rnd;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
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
index b2d3230..05ac4e7 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestRecordingService.java
@@ -18,6 +18,7 @@
*/
package org.apache.openmeetings.webservice;
+import static org.apache.openmeetings.AbstractJUnitDefaults.getUser;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -31,12 +32,9 @@ 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_MOUNT = "record";
- @Autowired
- private RecordingDao recordingDao;
private User getExternalUser() throws Exception {
String uuid = UUID.randomUUID().toString();
@@ -54,7 +52,7 @@ public class TestRecordingService extends AbstractWebServiceTest {
r.setInsertedBy(u.getId());
r.setComment("Created by Unit Tests");
r.setRoomId(5L);
- r = recordingDao.update(r);
+ r = getBean(RecordingDao.class).update(r);
ServiceResult sr = login();
Collection<? extends RecordingDTO> recs = getClient(getRecordUrl()).path("/" + UNIT_TEST_EXT_TYPE).query("sid", sr.getMessage())
.getCollection(RecordingDTO.class);
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
index 2921b46..49ec310 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
@@ -19,6 +19,11 @@
package org.apache.openmeetings.webservice;
import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static org.apache.openmeetings.AbstractJUnitDefaults.adminUsername;
+import static org.apache.openmeetings.AbstractJUnitDefaults.createPass;
+import static org.apache.openmeetings.AbstractJUnitDefaults.rnd;
+import static org.apache.openmeetings.AbstractJUnitDefaults.userpass;
+import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -97,6 +102,7 @@ public class TestUserService extends AbstractWebServiceTest {
ServiceResult r1 = getHash(r.getMessage(), false);
assertEquals("OM Call should be successful", Type.SUCCESS.name(), r1.getType());
+ ensureApplication(-1L); // to ensure WebSession is attached
WebSession ws = WebSession.get();
assertTrue(ws.signIn(adminUsername, userpass, User.Type.user, null));
Long userId0 = WebSession.getUserId();
diff --git a/openmeetings-web/src/test/resources/logback-test.xml b/openmeetings-web/src/test/resources/logback-test.xml
index 17a0a42..d18ff74 100644
--- a/openmeetings-web/src/test/resources/logback-test.xml
+++ b/openmeetings-web/src/test/resources/logback-test.xml
@@ -25,7 +25,6 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${current_openmeetings_log_dir}/${current_openmeetings_context_name}.log</file>
- <append>false</append>
<immediateFlush>true</immediateFlush>
<encoder>
<charset>UTF-8</charset>
--
To stop receiving notification emails like this one, please contact
solomax@apache.org.