summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-19 12:19:30 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-19 12:19:43 +0300
commitc1e82529b1191d9c41de0dc8a4cde8caf9754329 (patch)
tree47724ea23cd2e4126275b5d82379d29a77578569 /uitest
parent56a5f6853318acbd743346e0f14faa0ed7325fa4 (diff)
downloadvaadin-framework-c1e82529b1191d9c41de0dc8a4cde8caf9754329.tar.gz
vaadin-framework-c1e82529b1191d9c41de0dc8a4cde8caf9754329.zip
Add some getCurrent() methods (#9505)
This change also clears the current instances in the beginning of each request in case something has accidentally been left uncleared in a previous request on the same thread.
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java4
-rw-r--r--uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java9
-rw-r--r--uitest/src/com/vaadin/tests/tickets/Ticket1975.java7
-rw-r--r--uitest/src/com/vaadin/tests/util/SampleDirectory.java6
4 files changed, 10 insertions, 16 deletions
diff --git a/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
index 6f21346b7d..4d0dea4f91 100644
--- a/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
+++ b/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
@@ -1,6 +1,7 @@
package com.vaadin.tests.components.window;
import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.server.VaadinService;
import com.vaadin.server.WrappedRequest;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.tests.util.Log;
@@ -11,7 +12,6 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
-import com.vaadin.util.CurrentInstance;
public class AttachShouldBeCalledForSubWindows extends AbstractTestCase {
private static final long serialVersionUID = 1L;
@@ -23,7 +23,7 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase {
@Override
public void init() {
- WrappedRequest request = CurrentInstance.get(WrappedRequest.class);
+ WrappedRequest request = VaadinService.getCurrentRequest();
if (request.getParameter("attachMainFirst") != null) {
addSubWindowBeforeMainWindow = false;
} else {
diff --git a/uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java b/uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java
index c102291b50..f55c1f1f1d 100644
--- a/uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java
+++ b/uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java
@@ -3,11 +3,10 @@ package com.vaadin.tests.resources;
import java.io.File;
import com.vaadin.server.FileResource;
-import com.vaadin.server.WrappedRequest;
+import com.vaadin.server.VaadinService;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.util.CurrentInstance;
public class NonExistingFileResource extends TestBase {
@@ -26,10 +25,8 @@ public class NonExistingFileResource extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
- FileResource res = new FileResource(new File(CurrentInstance
- .get(WrappedRequest.class).getVaadinService()
- .getBaseDirectory()
- + "/" + filename));
+ FileResource res = new FileResource(new File(VaadinService
+ .getCurrent().getBaseDirectory() + "/" + filename));
getMainWindow().open(res);
}
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1975.java b/uitest/src/com/vaadin/tests/tickets/Ticket1975.java
index a688fd9908..f41585ff5d 100644
--- a/uitest/src/com/vaadin/tests/tickets/Ticket1975.java
+++ b/uitest/src/com/vaadin/tests/tickets/Ticket1975.java
@@ -5,14 +5,13 @@ import java.io.File;
import java.io.FileInputStream;
import com.vaadin.LegacyApplication;
-import com.vaadin.server.WrappedRequest;
+import com.vaadin.server.VaadinService;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.UI.LegacyWindow;
-import com.vaadin.util.CurrentInstance;
public class Ticket1975 extends LegacyApplication {
@@ -47,8 +46,8 @@ public class Ticket1975 extends LegacyApplication {
}
}));
- File baseDir = CurrentInstance.get(WrappedRequest.class)
- .getVaadinService().getBaseDirectory().getAbsoluteFile();
+ File baseDir = VaadinService.getCurrent().getBaseDirectory()
+ .getAbsoluteFile();
File f = new File(baseDir + "/VAADIN/themes/" + getTheme()
+ "/layouts/Ticket1975.html");
diff --git a/uitest/src/com/vaadin/tests/util/SampleDirectory.java b/uitest/src/com/vaadin/tests/util/SampleDirectory.java
index 140f778551..5c45e0d64e 100644
--- a/uitest/src/com/vaadin/tests/util/SampleDirectory.java
+++ b/uitest/src/com/vaadin/tests/util/SampleDirectory.java
@@ -19,13 +19,12 @@ package com.vaadin.tests.util;
import java.io.File;
import com.vaadin.server.SystemError;
+import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
-import com.vaadin.server.WrappedRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
-import com.vaadin.util.CurrentInstance;
/**
* Provides sample directory based on application directory. If this fails then
@@ -48,8 +47,7 @@ public class SampleDirectory {
+ "context base directory failed, "
+ "possible security constraint with Application "
+ "Server or Servlet Container.<br />";
- File file = CurrentInstance.get(WrappedRequest.class)
- .getVaadinService().getBaseDirectory();
+ File file = VaadinService.getCurrent().getBaseDirectory();
if ((file == null) || (!file.canRead())
|| (file.getAbsolutePath() == null)) {
// cannot access example directory, possible security issue with