Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic deployment of root-context test UIs to Jetty server container inside Felix OSGi #4416

Merged
merged 14 commits into from
Jul 25, 2018
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import org.junit.Test;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.data.validator.BeanValidator;
import com.vaadin.flow.tests.data.bean.Address;
import com.vaadin.flow.tests.data.bean.BeanToValidate;

public class BeanValidatorTest extends ValidatorTestBase {

@Test
public void testFirstNameNullFails() {
assertFails(null, "must not be null", validator("firstname"));
assertFails(null, "may not be null", validator("firstname"));
}

@Test
Expand Down Expand Up @@ -45,7 +44,7 @@ public void testDateOfBirthNullPasses() {
public void testDateOfBirthInTheFutureFails() {
Calendar year3k = Calendar.getInstance();
year3k.set(3000, 0, 1);
assertFails(year3k, "must be a past date", validator("dateOfBirth"));
assertFails(year3k, "must be in the past", validator("dateOfBirth"));
}

@Test
Expand All @@ -57,15 +56,16 @@ public void testAddressesEmptyArrayPasses() {

@Test
public void testAddressesNullFails() {
assertFails(null, "must not be null", validator("addresses"));
assertFails(null, "may not be null", validator("addresses"));
}

@Test
public void testInvalidDecimalsFailsInFrench() {
setLocale(Locale.FRENCH);
BeanValidator v = validator("decimals");
assertFails("1234.567", "valeur numérique hors limite "
+ "(<3 chiffres>.<2 chiffres> attendu)", v);
assertFails("1234.567",
"Valeur numérique hors limite (<3 chiffres>.<2 chiffres> attendus)",
v);
}

@Test
Expand Down
5 changes: 1 addition & 4 deletions flow-server/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Import-Package: org.atmosphere*;resolution:=optional;version='${atmosphere.runtime.version}',\
*
Export-Package: !com.vaadin.flow.dom.impl*,\
!com.vaadin.flow.internal*,\
!com.vaadin.flow.router.internal*,\
con.vaadin.flow.client,\
Export-Package: com.vaadin.flow.client,\
com.vaadin.flow*;-noimport:=true
20 changes: 17 additions & 3 deletions flow-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@
<!-- Library dependencies -->

<dependency>
<groupId>com.google.gwt</groupId>
<groupId>com.vaadin.external.gwt</groupId>
<artifactId>gwt-elemental</artifactId>
<version>2.8.2.vaadin1</version>
<exclusions>
<exclusion>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>

</dependency>

<dependency>
Expand Down Expand Up @@ -84,6 +86,18 @@
<groupId>com.helger</groupId>
<artifactId>ph-css</artifactId>
<version>6.1.1</version>
<exclusions>
<exclusion>
<groupId>com.helger</groupId>
<artifactId>ph-commons</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-commons</artifactId>
<version>9.1.2</version>
</dependency>

<!-- Byte code generation -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.uitest.servlet;
package com.vaadin.flow.testcategory;

import javax.servlet.annotation.WebServlet;

import com.vaadin.flow.server.VaadinServletConfiguration;

@WebServlet(asyncSupported = true, urlPatterns = { "/view-production/*" })
@VaadinServletConfiguration(productionMode = true)
public class ProductionModeViewTestServlet extends ViewTestServlet {
/**
* Tests that should not be run inside OSGi container should be annotated with @
* {@code Category(IgnoreOSGi.class)} so they can be optionally excluded from
* the build.
*
* @author Vaadin Ltd
* @since 1.0
*
*/
public interface IgnoreOSGi extends TestCategory {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

<!-- =========================================================== -->
<!-- Configure the deployment manager -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref refid="Contexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
</Call>
</New>
</Arg>
</Call>

</Configure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<!-- ============================================================= -->
<!-- Configure the Jetty Server instance with an ID "Server" -->
<!-- by adding a HTTP connector. -->
<!-- This configuration must be used in conjunction with jetty.xml -->
<!-- ============================================================= -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">

<!-- =========================================================== -->
<!-- Add a HTTP Connector. -->
<!-- Configure an o.e.j.server.ServerConnector with a single -->
<!-- HttpConnectionFactory instance using the common httpConfig -->
<!-- instance defined in jetty.xml -->
<!-- -->
<!-- Consult the javadoc of o.e.j.server.ServerConnector and -->
<!-- o.e.j.server.HttpConnectionFactory for all configuration -->
<!-- that may be set here. -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="httpConfig" /></Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host"><Property name="jetty.http.host" /></Set>
<Set name="port"><Property name="jetty.http.port" default="8888" /></Set>
<Set name="idleTimeout"><Property name="jetty.http.idleTimeout" default="30000"/></Set>
</New>
</Arg>
</Call>

</Configure>
95 changes: 95 additions & 0 deletions flow-tests/servlet-containers/felix-jetty/jettyhome/etc/jetty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">


<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- https://www.eclipse.org/jetty/documentation/current/ -->
<!-- =============================================================== -->

<Configure id="Server" class="org.eclipse.jetty.server.Server">

<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Get name="ThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</Get>


<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>

<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme">https</Set>
<Set name="securePort"><Property name="jetty.httpConfig.securePort" default="8443" /></Set>
<Set name="outputBufferSize">32768</Set>
<Set name="requestHeaderSize">8192</Set>
<Set name="responseHeaderSize">8192</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">false</Set>
<Set name="headerCacheSize">512</Set>
</New>


<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="stopTimeout">1000</Set>
<Set name="dumpAfterStart">false</Set>
<Set name="dumpBeforeStop">false</Set>


<!-- =========================================================== -->
<!-- Set up the list of default configuration classes -->
<!-- =========================================================== -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.configuration</Arg>
<Arg>
<New class="org.eclipse.jetty.webapp.Configuration$ClassList">
<Arg>
<Array type="String">
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>
</Arg>
</New>
</Arg>
</Call>


<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>
<Arg><Property name="java.naming.factory.initial" default="org.eclipse.jetty.jndi.InitialContextFactory"/></Arg>
</Call>
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.url.pkgs</Arg>
<Arg><Property name="java.naming.factory.url.pkgs" default="org.eclipse.jetty.jndi"/></Arg>
</Call>

</Configure>
Loading