aboutsummaryrefslogtreecommitdiffstats
path: root/test/dependency-rewrite/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'test/dependency-rewrite/src/main')
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/ApplicationDependencyFilter.java26
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyDynamicUI.java34
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyInitialUI.java21
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyService.java27
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIProvider.java22
-rw-r--r--test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIServlet.java22
-rw-r--r--test/dependency-rewrite/src/main/webapp/VAADIN/sub/jquery.js5
7 files changed, 157 insertions, 0 deletions
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/ApplicationDependencyFilter.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/ApplicationDependencyFilter.java
new file mode 100644
index 0000000000..63e1db0377
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/ApplicationDependencyFilter.java
@@ -0,0 +1,26 @@
+package com.vaadin.test.dependencyrewrite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.server.DependencyFilter;
+import com.vaadin.ui.Dependency;
+
+public class ApplicationDependencyFilter implements DependencyFilter {
+
+ @Override
+ public List<Dependency> filter(List<Dependency> dependencies,
+ FilterContext filterContext) {
+ List<Dependency> filtered = new ArrayList<>();
+ for (Dependency dependency : dependencies) {
+ if (dependency.getUrl().startsWith("vaadin://")) {
+ filtered.add(new Dependency(dependency.getType(), dependency
+ .getUrl().replace("vaadin://", "vaadin://sub/")));
+ } else {
+ filtered.add(dependency);
+ }
+ }
+ return filtered;
+ }
+
+}
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyDynamicUI.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyDynamicUI.java
new file mode 100644
index 0000000000..ec696713f1
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyDynamicUI.java
@@ -0,0 +1,34 @@
+package com.vaadin.test.dependencyrewrite;
+
+import com.vaadin.annotations.JavaScript;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class DependencyDynamicUI extends UI {
+
+ @JavaScript("http://jquery.com/jquery-1.2.3.js")
+ public static class MyJqueryLabel extends Label {
+ public MyJqueryLabel() {
+ super("MyJqueryLabel");
+ }
+ }
+
+ @JavaScript("vaadin://jquery-33.3.3.js")
+ public static class MyJqueryLabel2 extends Label {
+ public MyJqueryLabel2() {
+ super("MyJqueryLabel2");
+ }
+ }
+
+ @Override
+ protected void init(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponent(new MyJqueryLabel());
+ layout.addComponent(new MyJqueryLabel2());
+
+ setContent(layout);
+ }
+
+}
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyInitialUI.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyInitialUI.java
new file mode 100644
index 0000000000..3e600c2aaa
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/DependencyInitialUI.java
@@ -0,0 +1,21 @@
+package com.vaadin.test.dependencyrewrite;
+
+import com.vaadin.annotations.JavaScript;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.test.dependencyrewrite.DependencyDynamicUI.MyJqueryLabel;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+@JavaScript("http://jquery.com/jquery-12.2.3.js")
+@JavaScript("vaadin://jquery-323.3.3.js")
+public class DependencyInitialUI extends UI {
+
+ @Override
+ protected void init(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponent(new MyJqueryLabel());
+
+ setContent(layout);
+ }
+
+}
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyService.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyService.java
new file mode 100644
index 0000000000..5723a93885
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyService.java
@@ -0,0 +1,27 @@
+package com.vaadin.test.dependencyrewrite;
+
+import java.util.List;
+
+import com.vaadin.server.DependencyFilter;
+import com.vaadin.server.DeploymentConfiguration;
+import com.vaadin.server.ServiceException;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.server.VaadinServletService;
+
+public class MyService extends VaadinServletService {
+
+ public MyService(VaadinServlet servlet,
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
+ super(servlet, deploymentConfiguration);
+ }
+
+ @Override
+ protected List<DependencyFilter> createDependencyFilters()
+ throws ServiceException {
+ List<DependencyFilter> list = super.createDependencyFilters();
+ list.add(new ApplicationDependencyFilter());
+ return list;
+ }
+
+}
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIProvider.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIProvider.java
new file mode 100644
index 0000000000..dd4675888a
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIProvider.java
@@ -0,0 +1,22 @@
+package com.vaadin.test.dependencyrewrite;
+
+import com.vaadin.server.UIClassSelectionEvent;
+import com.vaadin.server.UIProvider;
+import com.vaadin.ui.UI;
+
+public class MyUIProvider extends UIProvider {
+
+ @Override
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ String url = event.getRequest().getPathInfo();
+ if (url.contains("/dynamic/")) {
+ return DependencyDynamicUI.class;
+ } else if (url.contains("/initial/")) {
+ return DependencyInitialUI.class;
+ } else {
+ return null;
+ }
+
+ }
+
+}
diff --git a/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIServlet.java b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIServlet.java
new file mode 100644
index 0000000000..dbddf3d970
--- /dev/null
+++ b/test/dependency-rewrite/src/main/java/com/vaadin/test/dependencyrewrite/MyUIServlet.java
@@ -0,0 +1,22 @@
+package com.vaadin.test.dependencyrewrite;
+
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+
+import com.vaadin.server.DeploymentConfiguration;
+import com.vaadin.server.ServiceException;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.server.VaadinServletService;;
+
+@WebServlet(urlPatterns = {
+ "/*" }, name = "MyUIServlet", asyncSupported = true, initParams = @WebInitParam(name = "UIProvider", value = "com.vaadin.test.dependencyrewrite.MyUIProvider"))
+public class MyUIServlet extends VaadinServlet {
+ @Override
+ protected VaadinServletService createServletService(
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
+ MyService service = new MyService(this, deploymentConfiguration);
+ service.init();
+ return service;
+ }
+}
diff --git a/test/dependency-rewrite/src/main/webapp/VAADIN/sub/jquery.js b/test/dependency-rewrite/src/main/webapp/VAADIN/sub/jquery.js
new file mode 100644
index 0000000000..b6aa9b8a0f
--- /dev/null
+++ b/test/dependency-rewrite/src/main/webapp/VAADIN/sub/jquery.js
@@ -0,0 +1,5 @@
+if (!window.jqueryLoaded) {
+ window.jqueryLoaded = 1;
+} else {
+ window.jqueryLoaded++;
+}