summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-20 19:19:47 +0300
committerLeif Åstrand <leif@vaadin.com>2012-08-20 19:20:09 +0300
commit72d9cc9ec098952dfdb03708f808da555307e78d (patch)
treed2e97757e8a1ecdcf25cfec3b066c87a2db6c791 /tests
parent0dfdb151913a13e929a65c4dd8b5987c9edd06d5 (diff)
downloadvaadin-framework-72d9cc9ec098952dfdb03708f808da555307e78d.tar.gz
vaadin-framework-72d9cc9ec098952dfdb03708f808da555307e78d.zip
Add RootProvider for Root selection without custom Application (#8159)
Diffstat (limited to 'tests')
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java18
-rw-r--r--tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java33
-rw-r--r--tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java16
-rw-r--r--tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java15
4 files changed, 50 insertions, 32 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
index fa730515a2..74770f8652 100644
--- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
+++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
@@ -6,15 +6,16 @@ import java.util.Properties;
import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
import com.vaadin.Application;
import com.vaadin.Application.ApplicationStartEvent;
import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.DefaultRootProvider;
import com.vaadin.terminal.DeploymentConfiguration;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.ui.Root;
-import org.easymock.EasyMock;
-
public class CustomRootClassLoader extends TestCase {
/**
@@ -111,10 +112,17 @@ public class CustomRootClassLoader extends TestCase {
private Application createStubApplication() {
return new Application() {
+ {
+ addRootProvider(new DefaultRootProvider());
+ }
+
@Override
- protected String getRootClassName(WrappedRequest request) {
- // Always use the same root class
- return MyRoot.class.getName();
+ public String getProperty(String name) {
+ if (name.equals(ROOT_PARAMETER)) {
+ return MyRoot.class.getName();
+ } else {
+ return super.getProperty(name);
+ }
}
@Override
diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
index 6b7b36c3f3..bb37082d30 100644
--- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
+++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
@@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
import com.vaadin.terminal.gwt.server.WrappedHttpServletRequest;
@@ -40,23 +42,6 @@ import com.vaadin.ui.Root;
public class ApplicationRunnerServlet extends AbstractApplicationServlet {
/**
- * Internal implementation of an application with a dynamically selected
- * Root implementation;
- */
- private static class RootRunnerApplication extends Application {
- private final Class<?> runnableClass;
-
- private RootRunnerApplication(Class<?> runnableClass) {
- this.runnableClass = runnableClass;
- }
-
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return runnableClass.getCanonicalName();
- }
- }
-
- /**
* The name of the application class currently used. Only valid within one
* request.
*/
@@ -126,7 +111,17 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet {
try {
final Class<?> classToRun = getClassToRun();
if (Root.class.isAssignableFrom(classToRun)) {
- return new RootRunnerApplication(classToRun);
+ Application application = new Application();
+ application.addRootProvider(new AbstractRootProvider() {
+
+ @Override
+ public Class<? extends Root> getRootClass(
+ Application application, WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return (Class<? extends Root>) classToRun;
+ }
+ });
+ return application;
} else if (Application.class.isAssignableFrom(classToRun)) {
return (Application) classToRun.newInstance();
} else {
@@ -221,7 +216,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet {
throws ClassNotFoundException {
Class<?> classToRun = getClassToRun();
if (Root.class.isAssignableFrom(classToRun)) {
- return RootRunnerApplication.class;
+ return Application.class;
} else if (Application.class.isAssignableFrom(classToRun)) {
return classToRun.asSubclass(Application.class);
} else {
diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
index 36a793bd6d..bd2aea3756 100644
--- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
+++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
@@ -1,5 +1,8 @@
package com.vaadin.tests.application;
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
@@ -20,11 +23,14 @@ public class RefreshStatePreserve extends AbstractTestApplication {
public void init() {
super.init();
setRootPreserved(true);
- }
-
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return RefreshStateRoot.class.getName();
+ addRootProvider(new AbstractRootProvider() {
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return RefreshStateRoot.class;
+ }
+ });
}
@Override
diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
index c3b20c5e7c..ae3182401d 100644
--- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
+++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
@@ -1,5 +1,8 @@
package com.vaadin.tests.components.root;
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
@@ -19,9 +22,15 @@ public class RootsInMultipleTabs extends AbstractTestApplication {
}
}
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return TabRoot.class.getName();
+ public RootsInMultipleTabs() {
+ addRootProvider(new AbstractRootProvider() {
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return TabRoot.class;
+ }
+ });
}
@Override