diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-30 11:30:39 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-30 12:47:35 +0300 |
commit | fd3826abf42f69db546eff18d269e462843feb49 (patch) | |
tree | 2852b77e657e90061842bc2d99dad09b36cd4150 /tests/testbench/com/vaadin | |
parent | e71794ee177e309a4cba15ebd6b65d5950721dd7 (diff) | |
download | vaadin-framework-fd3826abf42f69db546eff18d269e462843feb49.tar.gz vaadin-framework-fd3826abf42f69db546eff18d269e462843feb49.zip |
Replace ApplicationResource with ConnectorResource (#9419)
Diffstat (limited to 'tests/testbench/com/vaadin')
31 files changed, 153 insertions, 85 deletions
diff --git a/tests/testbench/com/vaadin/tests/LayoutDemo.java b/tests/testbench/com/vaadin/tests/LayoutDemo.java index 3348eda7a4..a5331b94af 100644 --- a/tests/testbench/com/vaadin/tests/LayoutDemo.java +++ b/tests/testbench/com/vaadin/tests/LayoutDemo.java @@ -25,8 +25,8 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; /** @@ -121,7 +121,7 @@ public class LayoutDemo extends com.vaadin.Application.LegacyApplication { private Component getExamplePicture(String caption) { // loads image from package com.vaadin.demo - final ClassResource cr = new ClassResource("m-bullet-blue.gif", this); + final ClassResource cr = new ClassResource("m-bullet-blue.gif"); final Embedded em = new Embedded("Embedded " + caption, cr); em.setWidth("170px"); return em; diff --git a/tests/testbench/com/vaadin/tests/TestCaptionWrapper.java b/tests/testbench/com/vaadin/tests/TestCaptionWrapper.java index 57a98f787f..b2e09a2a6f 100644 --- a/tests/testbench/com/vaadin/tests/TestCaptionWrapper.java +++ b/tests/testbench/com/vaadin/tests/TestCaptionWrapper.java @@ -92,10 +92,8 @@ public class TestCaptionWrapper extends CustomComponent implements Listener { final VerticalLayout tab2 = new VerticalLayout(); test(tab2); populateLayout(tab2); - tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif", - getApplication())); - tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif", - getApplication())); + tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif")); + tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif")); final VerticalLayout expandLayout = new VerticalLayout(); test(expandLayout); @@ -186,7 +184,7 @@ public class TestCaptionWrapper extends CustomComponent implements Listener { * @param c */ void test(AbstractComponent c) { - final ClassResource res = new ClassResource("m.gif", getApplication()); + final ClassResource res = new ClassResource("m.gif"); final ErrorMessage errorMsg = new UserError("User error " + c); if ((c.getCaption() == null) || (c.getCaption().length() <= 0)) { diff --git a/tests/testbench/com/vaadin/tests/TestDateField.java b/tests/testbench/com/vaadin/tests/TestDateField.java index 67b2f2cc69..5854b52b73 100644 --- a/tests/testbench/com/vaadin/tests/TestDateField.java +++ b/tests/testbench/com/vaadin/tests/TestDateField.java @@ -77,8 +77,7 @@ public class TestDateField extends CustomComponent { @Override public void attach() { - final ClassResource res = new ClassResource("m.gif", - super.getApplication()); + final ClassResource res = new ClassResource("m.gif"); df.setIcon(res); super.attach(); } diff --git a/tests/testbench/com/vaadin/tests/TestForStyledUpload.java b/tests/testbench/com/vaadin/tests/TestForStyledUpload.java index a6fdaf5643..14fe7902aa 100644 --- a/tests/testbench/com/vaadin/tests/TestForStyledUpload.java +++ b/tests/testbench/com/vaadin/tests/TestForStyledUpload.java @@ -189,7 +189,7 @@ public class TestForStyledUpload extends Application.LegacyApplication + " bytes.", ContentMode.XHTML)); status.addComponent(new Link("Download " + buffer.getFileName(), - new StreamResource(buffer, buffer.getFileName(), this))); + new StreamResource(buffer, buffer.getFileName()))); status.setVisible(true); } diff --git a/tests/testbench/com/vaadin/tests/TestForUpload.java b/tests/testbench/com/vaadin/tests/TestForUpload.java index eb59ed9f1f..b0697d337d 100644 --- a/tests/testbench/com/vaadin/tests/TestForUpload.java +++ b/tests/testbench/com/vaadin/tests/TestForUpload.java @@ -160,7 +160,7 @@ public class TestForUpload extends CustomComponent implements status.addComponent(new Link("Download " + buffer.getFileName(), new StreamResource(buffer, - buffer.getFileName(), getApplication()))); + buffer.getFileName()))); status.setVisible(true); } diff --git a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java index 26bf90948b..a7d2b03415 100644 --- a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java +++ b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java @@ -12,8 +12,8 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; +import com.vaadin.ui.UI.LegacyWindow; public class GAESyncTest extends Application.LegacyApplication { @@ -116,7 +116,7 @@ public class GAESyncTest extends Application.LegacyApplication { } private void addImage() { - ClassResource res = new ClassResource("img1.png", app) { + ClassResource res = new ClassResource("img1.png") { private static final long serialVersionUID = 1L; diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java index f31ea76728..0e7dd1b242 100644 --- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java @@ -2,7 +2,6 @@ package com.vaadin.tests.application; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.server.ApplicationResource; import com.vaadin.server.DownloadStream; import com.vaadin.server.PaintException; import com.vaadin.server.WrappedRequest; @@ -47,7 +46,7 @@ public class ThreadLocalInstances extends AbstractTestApplication { } }; - private final ApplicationResource resource = new FlagSeResource(this) { + private final FlagSeResource resource = new FlagSeResource() { @Override public DownloadStream getStream() { reportCurrentStatus("resource handler"); diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java index 254d27c1dd..52454e115e 100644 --- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java @@ -38,7 +38,7 @@ public class EmbeddedImageRefresh extends TestBase { // Attach it to a resource. final MyImageSource imageSource = new MyImageSource(); final StreamResource imageResource = new StreamResource(imageSource, - "testimage.png", this); + "testimage.png"); imageResource.setCacheTime(0); embedded.setSource(imageResource); diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java index ae98a55348..025245ab64 100644 --- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java @@ -25,7 +25,7 @@ public class EmbeddedPdf extends TestBase { player.setType(Embedded.TYPE_BROWSER); player.setWidth("400px"); player.setHeight("300px"); - player.setSource(new ClassResource(getClass(), "test.pdf", this)); + player.setSource(new ClassResource(getClass(), "test.pdf")); addComponent(player); addComponent(new Button("Remove pdf", new Button.ClickListener() { diff --git a/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java index b15f33f633..2eaf712676 100644 --- a/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java +++ b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java @@ -35,17 +35,18 @@ public class EmbeddedBrowserIsVisible extends TestBase { browser.setAlternateText("Browser alternative text"); final TextSource textSource = new TextSource("initial"); final StreamResource textResource = new StreamResource(textSource, - "initial.txt", this); + "initial.txt"); textResource.setMIMEType("text/plain"); browser.setSource(textResource); addComponent(browser); page1.addListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { TextSource helloSource = new TextSource("Hello World"); StreamResource helloResource = new StreamResource(helloSource, - "helloworld.txt", EmbeddedBrowserIsVisible.this); + "helloworld.txt"); helloResource.setMIMEType("text/plain"); browser.setSource(helloResource); } @@ -53,10 +54,11 @@ public class EmbeddedBrowserIsVisible extends TestBase { page2.addListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { TextSource helloSource = new TextSource("Lorem Ipsum"); StreamResource helloResource = new StreamResource(helloSource, - "loremipsum.txt", EmbeddedBrowserIsVisible.this); + "loremipsum.txt"); helloResource.setMIMEType("text/plain"); browser.setSource(helloResource); } @@ -64,6 +66,7 @@ public class EmbeddedBrowserIsVisible extends TestBase { page3.addListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { browser.setSource(null); } @@ -87,6 +90,7 @@ public class EmbeddedBrowserIsVisible extends TestBase { this.text = text; } + @Override public InputStream getStream() { StringBuilder sb = new StringBuilder(); diff --git a/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java index f1a3a09952..e2d983b7ce 100644 --- a/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java +++ b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java @@ -30,10 +30,11 @@ public class ImageClicks extends TestBase { Image image = new Image(); final MyImageSource imageSource = new MyImageSource(); final StreamResource imageResource = new StreamResource(imageSource, - "testimage.png", this); + "testimage.png"); image.setSource(imageResource); image.addListener(new ClickListener() { + @Override public void click(ClickEvent event) { ++clickCounter; label.setValue(labelText()); @@ -70,6 +71,7 @@ public class ImageClicks extends TestBase { return (int) Math.round(pos * resolution / (cells * 1.0)); } + @Override public InputStream getStream() { // Create an image and draw some background on it. BufferedImage image = new BufferedImage(300, 300, diff --git a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.html b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.html index 16e74aa485..8d0bb44cb5 100644 --- a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.html +++ b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.html @@ -39,7 +39,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[0]</td> - <td>4. Url: /run/com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent/APP/1/test</td> + <td>4. Url: /run/com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent/APP/connector/1/12/test</td> </tr> <tr> <td>assertText</td> diff --git a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java index a0189354f9..38beca3bf1 100644 --- a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java +++ b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java @@ -22,7 +22,8 @@ import java.util.List; import com.vaadin.annotations.JavaScript; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; -import com.vaadin.server.ClassResource; +import com.vaadin.server.DynamicConnectorResource; +import com.vaadin.server.Resource; import com.vaadin.server.ResourceReference; import com.vaadin.server.WrappedRequest; import com.vaadin.shared.communication.ClientRpc; @@ -107,9 +108,8 @@ public class BasicJavaScriptComponent extends AbstractTestUI { .setMessages( Arrays.asList("First state message", "Second state message")); - ClassResource resource = new ClassResource("test", - BasicJavaScriptComponent.this.getApplication()); - getState().setUrl(new ResourceReference(resource)); + Resource resource = new DynamicConnectorResource(this, "test"); + getState().setUrl(new ResourceReference(resource, null, null)); } @Override diff --git a/tests/testbench/com/vaadin/tests/components/link/LinkToPercentage.java b/tests/testbench/com/vaadin/tests/components/link/LinkToPercentage.java index 70ddc74616..770ff9895a 100644 --- a/tests/testbench/com/vaadin/tests/components/link/LinkToPercentage.java +++ b/tests/testbench/com/vaadin/tests/components/link/LinkToPercentage.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.link; import java.io.IOException; import java.io.InputStream; -import com.vaadin.server.ApplicationResource; +import com.vaadin.server.Resource; import com.vaadin.server.StreamResource; import com.vaadin.server.StreamResource.StreamSource; import com.vaadin.tests.components.TestBase; @@ -14,7 +14,7 @@ public class LinkToPercentage extends TestBase { @Override protected void setup() { String filename = "110% Vaadin"; - ApplicationResource resource = new StreamResource(new StreamSource() { + Resource resource = new StreamResource(new StreamSource() { @Override public InputStream getStream() { return new InputStream() { @@ -31,8 +31,7 @@ public class LinkToPercentage extends TestBase { } }; } - }, filename, this); - addResource(resource); + }, filename); Link link = new Link("The link", resource); diff --git a/tests/testbench/com/vaadin/tests/components/table/TableItemIcon.java b/tests/testbench/com/vaadin/tests/components/table/TableItemIcon.java index 8b502268b1..1faa9667c2 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableItemIcon.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableItemIcon.java @@ -27,11 +27,9 @@ public class TableItemIcon extends TestBase { getLayout().addComponent(table); Item item = table.addItem("FI"); - item.getItemProperty("icon").setValue( - new ClassResource("fi.gif", TableItemIcon.this)); + item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); item = table.addItem("SE"); - item.getItemProperty("icon").setValue( - new ClassResource("se.gif", TableItemIcon.this)); + item.getItemProperty("icon").setValue(new ClassResource("se.gif")); } diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest6.java b/tests/testbench/com/vaadin/tests/dd/DDTest6.java index 05be14eb76..a4c566d75a 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest6.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest6.java @@ -229,7 +229,7 @@ public class DDTest6 extends TestBase { return null; } }; - return new StreamResource(streamSource, getName(), DDTest6.get()); + return new StreamResource(streamSource, getName()); } } diff --git a/tests/testbench/com/vaadin/tests/dd/StartHtml5Drag.java b/tests/testbench/com/vaadin/tests/dd/StartHtml5Drag.java index 592ea92f80..609b2fe4fc 100644 --- a/tests/testbench/com/vaadin/tests/dd/StartHtml5Drag.java +++ b/tests/testbench/com/vaadin/tests/dd/StartHtml5Drag.java @@ -44,8 +44,7 @@ public class StartHtml5Drag extends TestBase { }); addComponent(dropTarget); - Embedded iframe = new Embedded("", new ClassResource("html5drop.htm", - this)); + Embedded iframe = new Embedded("", new ClassResource("html5drop.htm")); iframe.setType(Embedded.TYPE_BROWSER); iframe.setWidth(400, Sizeable.UNITS_PIXELS); iframe.setHeight(400, Sizeable.UNITS_PIXELS); diff --git a/tests/testbench/com/vaadin/tests/integration/FlagSeResource.java b/tests/testbench/com/vaadin/tests/integration/FlagSeResource.java index 76adecb7d8..6c2fcdc2d4 100644 --- a/tests/testbench/com/vaadin/tests/integration/FlagSeResource.java +++ b/tests/testbench/com/vaadin/tests/integration/FlagSeResource.java @@ -1,17 +1,16 @@ package com.vaadin.tests.integration; -import com.vaadin.Application; import com.vaadin.server.ClassResource; public class FlagSeResource extends ClassResource { - public FlagSeResource(Application application) { + public FlagSeResource() { super("/" + FlagSeResource.class .getName() .replace('.', '/') .replaceAll(FlagSeResource.class.getSimpleName() + "$", - "") + "se.gif", application); + "") + "se.gif"); } } diff --git a/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java b/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java index b089515b0e..9c7225b510 100644 --- a/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java +++ b/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java @@ -7,8 +7,8 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.server.ClassResource; import com.vaadin.server.Resource; import com.vaadin.ui.Label; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; +import com.vaadin.ui.UI.LegacyWindow; public class IntegrationTestApplication extends Application.LegacyApplication { @@ -28,11 +28,10 @@ public class IntegrationTestApplication extends Application.LegacyApplication { window.addComponent(table); Item item = table.addItem("FI"); - item.getItemProperty("icon") - .setValue(new ClassResource("fi.gif", this)); + item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); item.getItemProperty("country").setValue("Finland"); item = table.addItem("SE"); - item.getItemProperty("icon").setValue(new FlagSeResource(this)); + item.getItemProperty("icon").setValue(new FlagSeResource()); item.getItemProperty("country").setValue("Sweden"); final Label selectedLabel = new Label(); diff --git a/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java index d2c15053ef..2243adf336 100644 --- a/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java +++ b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java @@ -28,9 +28,9 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; import com.vaadin.ui.Link; import com.vaadin.ui.Notification; +import com.vaadin.ui.TextField; import com.vaadin.ui.UI; import com.vaadin.ui.UI.LegacyWindow; -import com.vaadin.ui.TextField; import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.Receiver; @@ -57,11 +57,11 @@ public class JSR286PortletApplication extends Application.LegacyApplication { Embedded appResourceTest = new Embedded( "Test of ApplicationResources with full path", - new FlagSeResource(this)); + new FlagSeResource()); main.addComponent(appResourceTest); Embedded specialNameResourceTest = new Embedded( "Test ApplicationResources with special names", - new SpecialNameResource(this)); + new SpecialNameResource()); specialNameResourceTest.addStyleName("hugeBorder"); main.addComponent(specialNameResourceTest); diff --git a/tests/testbench/com/vaadin/tests/integration/SpecialNameResource.java b/tests/testbench/com/vaadin/tests/integration/SpecialNameResource.java index 3a0bf7cdd5..3806e61c36 100644 --- a/tests/testbench/com/vaadin/tests/integration/SpecialNameResource.java +++ b/tests/testbench/com/vaadin/tests/integration/SpecialNameResource.java @@ -1,10 +1,9 @@ package com.vaadin.tests.integration; -import com.vaadin.Application; import com.vaadin.server.ClassResource; public class SpecialNameResource extends ClassResource { - public SpecialNameResource(Application application) { - super("spe=cial%res&ource.gif", application); + public SpecialNameResource() { + super("spe=cial%res&ource.gif"); } } diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java index 3ec8dd3664..cf0c5a3e2b 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java @@ -17,7 +17,6 @@ package com.vaadin.tests.minitutorials.v7a2; import com.vaadin.server.Resource; -import com.vaadin.server.ResourceReference; import com.vaadin.tests.widgetset.client.minitutorials.v7a2.ResourceInStateState; import com.vaadin.ui.AbstractComponent; @@ -28,10 +27,10 @@ public class ResourceInStateComponent extends AbstractComponent { } public void setMyIcon(Resource icon) { - getState().setMyIcon(new ResourceReference(icon)); + setResource(ResourceInStateState.MY_ICON_RESOURCE, icon); } public Resource getMyIcon() { - return ResourceReference.getResource(getState().getMyIcon()); + return getResource(ResourceInStateState.MY_ICON_RESOURCE); } } diff --git a/tests/testbench/com/vaadin/tests/requesthandlers/AppResource404.java b/tests/testbench/com/vaadin/tests/requesthandlers/AppResource404.java index 6c3dcafc74..ebccba74fb 100644 --- a/tests/testbench/com/vaadin/tests/requesthandlers/AppResource404.java +++ b/tests/testbench/com/vaadin/tests/requesthandlers/AppResource404.java @@ -3,8 +3,6 @@ package com.vaadin.tests.requesthandlers; import com.vaadin.server.ExternalResource; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.integration.FlagSeResource; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Link; public class AppResource404 extends TestBase { @@ -12,21 +10,12 @@ public class AppResource404 extends TestBase { @Override protected void setup() { // Add one existing resource - final FlagSeResource resource = new FlagSeResource(this); + final FlagSeResource resource = new FlagSeResource(); resource.setCacheTime(0); - addResource(resource); addComponent(new Link("Existing resource", resource)); addComponent(new Link("Non-existing resource", new ExternalResource( getURL().toString() + "APP/12341234/"))); - - addComponent(new Button("Remove existing resrouce", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - removeResource(resource); - } - })); } @Override diff --git a/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.html b/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.html new file mode 100644 index 0000000000..f400bacffa --- /dev/null +++ b/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.resources.ConnectorResourceTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.java b/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.java new file mode 100644 index 0000000000..c8d711f0b2 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/resources/ConnectorResourceTest.java @@ -0,0 +1,71 @@ +package com.vaadin.tests.resources; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.HashMap; + +import javax.imageio.ImageIO; + +import com.vaadin.server.DynamicConnectorResource; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedResponse; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Embedded; + +public class ConnectorResourceTest extends AbstractTestUI { + + private static final String DYNAMIC_IMAGE_NAME = "requestImage.png"; + + @Override + protected void setup(WrappedRequest request) { + addComponent(new Embedded(DYNAMIC_IMAGE_NAME, + new DynamicConnectorResource(this, DYNAMIC_IMAGE_NAME))); + addComponent(new Embedded("Dynamic text", new DynamicConnectorResource( + this, DYNAMIC_IMAGE_NAME, new HashMap<String, String>() { + { + put("text", "Dynamic%20text"); + } + }))); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean handleConnectorRequest(WrappedRequest request, + WrappedResponse response, String path) throws IOException { + if (DYNAMIC_IMAGE_NAME.equals(path)) { + // Create an image, draw the "text" parameter to it and output it to + // the browser. + String text = request.getParameter("text"); + if (text == null) { + text = DYNAMIC_IMAGE_NAME; + } + BufferedImage bi = getImage(text); + response.setContentType("image/png"); + ImageIO.write(bi, "png", response.getOutputStream()); + + return true; + } else { + return super.handleConnectorRequest(request, response, path); + } + } + + private BufferedImage getImage(String text) { + BufferedImage bi = new BufferedImage(150, 30, + BufferedImage.TYPE_3BYTE_BGR); + bi.getGraphics() + .drawChars(text.toCharArray(), 0, text.length(), 10, 20); + return bi; + } + +} diff --git a/tests/testbench/com/vaadin/tests/resources/DownloadLargeFileResource.java b/tests/testbench/com/vaadin/tests/resources/DownloadLargeFileResource.java index 00f1e4d2d6..d799e1a8d4 100644 --- a/tests/testbench/com/vaadin/tests/resources/DownloadLargeFileResource.java +++ b/tests/testbench/com/vaadin/tests/resources/DownloadLargeFileResource.java @@ -51,7 +51,7 @@ public class DownloadLargeFileResource extends TestBase { os.write(b); } os.close(); - hugeFileResource = new FileResource(hugeFile, this); + hugeFileResource = new FileResource(hugeFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java b/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java index e0c7b16318..eb8559f746 100644 --- a/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java +++ b/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java @@ -25,8 +25,7 @@ public class NonExistingFileResource extends TestBase { @Override public void buttonClick(ClickEvent event) { FileResource res = new FileResource(new File(getContext() - .getBaseDirectory() + "/" + filename), - NonExistingFileResource.this); + .getBaseDirectory() + "/" + filename)); getMainWindow().open(res); } diff --git a/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java b/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java index 3b4e4b9ff3..e323f5285b 100644 --- a/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java +++ b/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java @@ -74,7 +74,7 @@ public class ResourceDownload extends TestBase { return null; } } - }, filename + ".xls", this); + }, filename + ".xls"); streamResource.setCacheTime(5000); // no cache (<=0) does not work with // IE8 streamResource.setMIMEType("application/x-msexcel"); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java index 44d4109203..caf44865f9 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java @@ -12,8 +12,7 @@ import com.vaadin.ui.VerticalLayout; public class Ticket1737 extends Application.LegacyApplication { - Resource slowRes = new ClassResource(Ticket1737.class, "m-bullet-blue.gif", - this) { + Resource slowRes = new ClassResource(Ticket1737.class, "m-bullet-blue.gif") { @Override public DownloadStream getStream() { try { diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java index fa31267fd4..93b12dbc68 100644 --- a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java +++ b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java @@ -19,7 +19,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a2; import com.google.gwt.user.client.ui.Image; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; -import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.ui.Connect; import com.vaadin.tests.minitutorials.v7a2.ResourceInStateComponent; @@ -28,10 +27,10 @@ public class ResourceInStateConnector extends AbstractComponentConnector { @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); + String icon = getResourceUrl(ResourceInStateState.MY_ICON_RESOURCE); - URLReference icon = getState().getMyIcon(); if (icon != null) { - getWidget().setUrl(icon.getURL()); + getWidget().setUrl(icon); } else { getWidget().setUrl(""); } diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java index 69b415625c..728f0ba5e1 100644 --- a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java +++ b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java @@ -1,17 +1,7 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a2; import com.vaadin.shared.ComponentState; -import com.vaadin.shared.communication.URLReference; public class ResourceInStateState extends ComponentState { - - private URLReference myIcon; - - public URLReference getMyIcon() { - return myIcon; - } - - public void setMyIcon(URLReference icon) { - myIcon = icon; - } + public static final String MY_ICON_RESOURCE = "myIcon"; }
\ No newline at end of file |