diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2017-07-31 14:25:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-31 14:25:55 +0300 |
commit | 456f14f5e557cd1f5be3c3161df8e4e26a99f36f (patch) | |
tree | 79db926255e2af4f584a4920d59576cb6a0b2d86 /test/servlet-containers | |
parent | a280b0fa5989c21166ee3d50787bb5c92ee1d1b5 (diff) | |
download | vaadin-framework-456f14f5e557cd1f5be3c3161df8e4e26a99f36f.tar.gz vaadin-framework-456f14f5e557cd1f5be3c3161df8e4e26a99f36f.zip |
Automatic test for OSGi/karaf
Diffstat (limited to 'test/servlet-containers')
15 files changed, 740 insertions, 0 deletions
diff --git a/test/servlet-containers/karaf/README.md b/test/servlet-containers/karaf/README.md new file mode 100644 index 0000000000..0ee2cb1ad0 --- /dev/null +++ b/test/servlet-containers/karaf/README.md @@ -0,0 +1,31 @@ +Automatic test for Karaf deployment +=== + +What is tested +--- +* Multiple applications are deployed and work properly +* Default widgetset works +* Custom widgetset works +* Custom theme works + +Tips and Tricks +--- +* Karaf is downloaded and deployed by maven karaf plugin +* Karaf is run as a background process using maven `exec:exec` goal +* Karaf is shut down using maven `karaf:client` goal during `post-integration-test` phase +* All required karaf features and project bundles are deployed using maven karaf plugin with `client` goal + +Running and stopping karaf manually +--- +* To start karaf as a foreground process and deploy both vaadin bundles and two existing applications, run `mvn -f karaf-run-pom.xml clean karaf:run` +in `karaf-run` module +* To start karaf as a background process and deploy both vaadin bundles and two existing applications, run `mvn clean pre-integration-test` +in `karaf-run` module +* Karaf console is available via ssh at `127.0.0.0:8101` port, username/password is `karaf/karaf` +* To stop background karaf process, run `mvn karaf:client@karaf-client-shutdown` +in `karaf-run` module + +Potential problems +--- +* Maven executable should be in `PATH` +* Background karaf process may be left running for 10 minutes if the build fails prior `integration-test` phase. diff --git a/test/servlet-containers/karaf/karaf-run/karaf-run-pom.xml b/test/servlet-containers/karaf/karaf-run/karaf-run-pom.xml new file mode 100644 index 0000000000..9e222565de --- /dev/null +++ b/test/servlet-containers/karaf/karaf-run/karaf-run-pom.xml @@ -0,0 +1,21 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <artifactId>karaf-runner</artifactId> + <groupId>com.vaadin</groupId> + <version>8.1-SNAPSHOT</version> + <modelVersion>4.0.0</modelVersion> + <build> + <plugins> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <version>4.0.8</version> + <configuration> + <deployProjectArtifact>false</deployProjectArtifact> + <startSsh>true</startSsh> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/test/servlet-containers/karaf/karaf-run/pom.xml b/test/servlet-containers/karaf/karaf-run/pom.xml new file mode 100644 index 0000000000..40d3043f37 --- /dev/null +++ b/test/servlet-containers/karaf/karaf-run/pom.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>vaadin-test-karaf</artifactId> + <groupId>com.vaadin</groupId> + <relativePath>..</relativePath> + <version>8.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>karaf-run</artifactId> + <name>Vaadin Karaf Test Runner</name> + + <dependencies> + <!--Vaadin dependencies should not be in a classpath--> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + <version>${vaadin.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + <version>${vaadin.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.6.0</version> + <executions> + <execution> + <phase>pre-integration-test</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>mvn</executable> + <async>true</async> + <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown> + <commandlineArgs>-f karaf-run-pom.xml karaf:run</commandlineArgs> + </configuration> + </execution> + </executions> + + </plugin> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <version>4.0.8</version> + <executions> + <execution> + <id>karaf-client-ctrl</id> + <phase>pre-integration-test</phase> + <goals> + <goal>client</goal> + </goals> + <configuration> + <delay>5</delay> + <attempts>150</attempts> + <commands> + <!--Scheduled shutdown in 15 minutes--> + <command>shutdown -f +10</command> + <command>feature:install http</command> + <command>feature:install http-whiteboard</command> + <command>bundle:install -s mvn:org.jsoup/jsoup/1.8.3</command> + <command>bundle:install -s mvn:com.vaadin.external/gentyref/1.2.0.vaadin1</command> + <command>bundle:install -s mvn:com.vaadin/vaadin-shared/${vaadin.version}</command> + <command>bundle:install -s mvn:com.vaadin/vaadin-server/${vaadin.version}</command> + <command>bundle:install -s mvn:com.vaadin/vaadin-osgi-integration/${vaadin.version}</command> + <command>bundle:install -s mvn:com.vaadin/vaadin-client-compiled/${vaadin.version}</command> + <command>bundle:install -s mvn:com.vaadin/vaadin-themes/${vaadin.version}</command> + <command> + <![CDATA[bundle:install -s file:./../vaadin-karaf-bundle1/target/vaadin-karaf-bundle1-${project.version}.jar]]></command> + <command> + <![CDATA[bundle:install -s file:./../vaadin-karaf-bundle2/target/vaadin-karaf-bundle2-${project.version}.jar]]></command> + </commands> + </configuration> + </execution> + <execution> + <id>karaf-client-shutdown</id> + <phase>post-integration-test</phase> + <goals> + <goal>client</goal> + </goals> + <configuration> + <delay>5</delay> + <attempts>10</attempts> + <commands> + <command>system:shutdown -f</command> + </commands> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.19.1</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <environmentVariables> + <vaadin.version>${vaadin.version}</vaadin.version> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/test/servlet-containers/karaf/karaf-run/src/test/java/com/vaadin/test/osgi/KarafIntegrationIT.java b/test/servlet-containers/karaf/karaf-run/src/test/java/com/vaadin/test/osgi/KarafIntegrationIT.java new file mode 100644 index 0000000000..d2d8e54a9c --- /dev/null +++ b/test/servlet-containers/karaf/karaf-run/src/test/java/com/vaadin/test/osgi/KarafIntegrationIT.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed 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 com.vaadin.test.osgi; + +import com.vaadin.testbench.TestBenchTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.phantomjs.PhantomJSDriver; + +import static org.junit.Assert.assertEquals; + +public class KarafIntegrationIT extends TestBenchTestCase { + + private static final String URL_PREFIX = "http://localhost:8181/"; + private static final String APP1_URL = URL_PREFIX + "myapp1"; + private static final String APP2_URL = URL_PREFIX + "myapp2"; + + + @Test + public void testApp1() { + runBasicTest(APP1_URL, "bar"); + //App theme should make a button pink + WebElement element = getDriver().findElement(By.className("v-button")); + String buttonColor = element.getCssValue("color"); + assertEquals("rgba(255, 128, 128, 1)", buttonColor); + } + + @Test + public void testApp2() { + runBasicTest(APP2_URL, "foo"); + } + + private void runBasicTest(String app1Url, String text) { + getDriver().navigate().to(app1Url); + getDriver().findElement(By.className("v-textfield")).sendKeys(text); + getDriver().findElement(By.className("v-button")).click(); + String foundText = getDriver().findElement(By.className("v-label")).getText(); + assertEquals("Thanks " + text + ", it works!", foundText); + } + + + @Before + public void setup() { + setDriver(new PhantomJSDriver()); + } + + @After + public void teardown() { + getDriver().quit(); + } +} diff --git a/test/servlet-containers/karaf/pom.xml b/test/servlet-containers/karaf/pom.xml new file mode 100644 index 0000000000..eb15f7147b --- /dev/null +++ b/test/servlet-containers/karaf/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-test</artifactId> + <version>8.1-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + <artifactId>vaadin-test-karaf</artifactId> + <packaging>pom</packaging> + <name>Vaadin Karaf TestRoot</name> + + <modules> + <module>vaadin-karaf-bundle1</module> + <module>vaadin-karaf-bundle2</module> + <module>karaf-run</module> + </modules> + + <properties> + <karaf.plugin.version>4.0.8</karaf.plugin.version> + <vaadin.widgetset.mode>local</vaadin.widgetset.mode> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + + </build> +</project> diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/bnd.bnd b/test/servlet-containers/karaf/vaadin-karaf-bundle1/bnd.bnd new file mode 100644 index 0000000000..d9ac46fb69 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/bnd.bnd @@ -0,0 +1,6 @@ +Bundle-Name: ${project.name} +Bundle-Version: ${project.version} +Bundle-SymbolicName: ${project.groupId}.${project.artifactId} +Export-Package: com.vaadin.test.osgi.myapplication1 +Import-Package: * +Web-ContentPath: /myapp1 diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/pom.xml b/test/servlet-containers/karaf/vaadin-karaf-bundle1/pom.xml new file mode 100644 index 0000000000..f30a1877dd --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/pom.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-test-karaf</artifactId> + <version>8.1-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + <artifactId>vaadin-karaf-bundle1</artifactId> + <packaging>jar</packaging> + <name>Vaadin Karaf test bundle 1</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-bom</artifactId> + <version>${vaadin.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client-compiled</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-osgi-integration</artifactId> + <version>8.1.0.beta1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.core</artifactId> + <version>6.0.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.annotation</artifactId> + <version>6.0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.cmpn</artifactId> + <version>6.0.0</version> + <scope>provided</scope> + </dependency> + <!-- For compiling WidgetSet --> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client</artifactId> + <version>${vaadin.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <goals> + <goal>bnd-process</goal> + </goals> + <configuration> + + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-maven-plugin</artifactId> + <version>${vaadin.plugin.version}</version> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>compile-theme</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + <configuration> + <archive> + <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <!-- Vaadin pre-release repositories --> + <id>vaadin-prerelease</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + + <repositories> + <repository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </repository> + <repository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </pluginRepository> + <pluginRepository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + </profiles> + +</project> diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/CustomWidgetSet.java b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/CustomWidgetSet.java new file mode 100644 index 0000000000..7a34f343f6 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/CustomWidgetSet.java @@ -0,0 +1,14 @@ +package com.vaadin.test.osgi.myapplication1; + +import com.vaadin.osgi.resources.OsgiVaadinTheme; +import com.vaadin.osgi.resources.OsgiVaadinWidgetset; +import com.vaadin.ui.themes.ValoTheme; +import org.osgi.service.component.annotations.Component; + +@Component +public class CustomWidgetSet implements OsgiVaadinWidgetset { + @Override + public String getName() { + return "com.vaadin.test.osgi.widgetset.CustomWidgetSet"; + } +} diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/KarafTestTheme.java b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/KarafTestTheme.java new file mode 100644 index 0000000000..0b300b8680 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/KarafTestTheme.java @@ -0,0 +1,13 @@ +package com.vaadin.test.osgi.myapplication1; + +import com.vaadin.osgi.resources.OsgiVaadinTheme; +import com.vaadin.ui.themes.ValoTheme; +import org.osgi.service.component.annotations.Component; + +@Component +public class KarafTestTheme extends ValoTheme implements OsgiVaadinTheme { + @Override + public String getName() { + return "karaftesttheme"; + } +} diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/MyUI.java b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/MyUI.java new file mode 100644 index 0000000000..1da8cc51ff --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/java/com/vaadin/test/osgi/myapplication1/MyUI.java @@ -0,0 +1,45 @@ +package com.vaadin.test.osgi.myapplication1; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.Widgetset; +import org.osgi.service.component.annotations.Component; + +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +@Theme("karaftesttheme") +@Widgetset("com.vaadin.test.osgi.widgetset.CustomWidgetSet") +public class MyUI extends UI { + + @Override + protected void init(VaadinRequest vaadinRequest) { + final VerticalLayout layout = new VerticalLayout(); + + final TextField name = new TextField(); + name.setCaption("Type your name here:"); + + Button button = new Button("Click Me"); + button.addClickListener(e -> { + layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!")); + }); + + layout.addComponents(name, button); + + setContent(layout); + } + + @Component(service = VaadinServlet.class) + @WebServlet(urlPatterns = "/myapp1/*", name = "MyUIServlet", asyncSupported = true) + @VaadinServletConfiguration(ui = MyUI.class, productionMode = false) + public static class MyUIServlet extends VaadinServlet { + } + +} diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/VAADIN/themes/karaftesttheme/styles.scss b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/VAADIN/themes/karaftesttheme/styles.scss new file mode 100644 index 0000000000..2346cfd785 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/VAADIN/themes/karaftesttheme/styles.scss @@ -0,0 +1,12 @@ +@import "../valo/valo.scss"; + +@mixin karaftesttheme { + @include valo; + .v-button { + color: rgba(255, 128, 128, 1) + } +} + +.karaftesttheme { + @include karaftesttheme; +} diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/com/vaadin/test/osgi/widgetset/CustomWidgetSet.gwt.xml b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/com/vaadin/test/osgi/widgetset/CustomWidgetSet.gwt.xml new file mode 100644 index 0000000000..4cadd95714 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/com/vaadin/test/osgi/widgetset/CustomWidgetSet.gwt.xml @@ -0,0 +1,7 @@ +<module> + <!-- Hint for WidgetSetBuilder not to automatically update the file --> + <!-- WS Compiler: manually edited --> + + <inherits name="com.vaadin.DefaultWidgetSet" /> + +</module> diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle2/bnd.bnd b/test/servlet-containers/karaf/vaadin-karaf-bundle2/bnd.bnd new file mode 100644 index 0000000000..33013281da --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle2/bnd.bnd @@ -0,0 +1,5 @@ +Bundle-Name: ${project.name} +Bundle-Version: ${project.version} +Bundle-SymbolicName: ${project.groupId}.${project.artifactId} +Import-Package: * +Web-ContentPath: /myapp2 diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle2/pom.xml b/test/servlet-containers/karaf/vaadin-karaf-bundle2/pom.xml new file mode 100644 index 0000000000..d2183d0dc3 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle2/pom.xml @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>vaadin-test-karaf</artifactId> + <groupId>com.vaadin</groupId> + <relativePath>..</relativePath> + <version>8.1-SNAPSHOT</version> + </parent> + <artifactId>vaadin-karaf-bundle2</artifactId> + <packaging>jar</packaging> + <name>Vaadin Karaf test bundle 2</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-bom</artifactId> + <version>${vaadin.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client-compiled</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-osgi-integration</artifactId> + <version>8.1.0.beta1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.core</artifactId> + <version>6.0.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.annotation</artifactId> + <version>6.0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.cmpn</artifactId> + <version>6.0.0</version> + <scope>provided</scope> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <goals> + <goal>bnd-process</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-maven-plugin</artifactId> + <version>${vaadin.plugin.version}</version> + <executions> + <execution> + <phase>process-resources</phase> + <goals> + <goal>compile-theme</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + <configuration> + <archive> + <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <!-- Vaadin pre-release repositories --> + <id>vaadin-prerelease</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + + <repositories> + <repository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </repository> + <repository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </pluginRepository> + <pluginRepository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + </profiles> + +</project> diff --git a/test/servlet-containers/karaf/vaadin-karaf-bundle2/src/main/java/com/vaadin/test/osgi/myapplication/MyUI.java b/test/servlet-containers/karaf/vaadin-karaf-bundle2/src/main/java/com/vaadin/test/osgi/myapplication/MyUI.java new file mode 100644 index 0000000000..eb52336eb5 --- /dev/null +++ b/test/servlet-containers/karaf/vaadin-karaf-bundle2/src/main/java/com/vaadin/test/osgi/myapplication/MyUI.java @@ -0,0 +1,42 @@ +package com.vaadin.test.osgi.myapplication; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Theme; +import org.osgi.service.component.annotations.Component; + +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +public class MyUI extends UI { + + @Override + protected void init(VaadinRequest vaadinRequest) { + final VerticalLayout layout = new VerticalLayout(); + + final TextField name = new TextField(); + name.setCaption("Type your name here:"); + + Button button = new Button("Click Me"); + button.addClickListener(e -> { + layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!")); + }); + + layout.addComponents(name, button); + + setContent(layout); + } + + @Component(service = VaadinServlet.class) + @WebServlet(urlPatterns = "/myapp2/*", name = "MyUIServlet", asyncSupported = true) + @VaadinServletConfiguration(ui = MyUI.class, productionMode = false) + public static class MyUIServlet extends VaadinServlet { + } + +} |