diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-11-21 12:36:26 +0100 |
---|---|---|
committer | caalador <mikael.grankvist@gmail.com> | 2017-11-21 13:36:26 +0200 |
commit | afe8b8a3873a202230f2c176e6552b5d64d1b758 (patch) | |
tree | 98af669ad8e3c999bfc1ffdb45f5bfe5cdea727d /server/src/test | |
parent | 94409e2221f14d2b592cfd41b17b000aed091600 (diff) | |
download | vaadin-framework-afe8b8a3873a202230f2c176e6552b5d64d1b758.tar.gz vaadin-framework-afe8b8a3873a202230f2c176e6552b5d64d1b758.zip |
FileResource to use bufferSize, and StreamResource to use getCacheTime() (#10247)
Diffstat (limited to 'server/src/test')
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/FileResourceTest.java | 24 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java | 23 |
2 files changed, 47 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/tests/server/FileResourceTest.java b/server/src/test/java/com/vaadin/tests/server/FileResourceTest.java index 130e87431c..5a21c749c8 100644 --- a/server/src/test/java/com/vaadin/tests/server/FileResourceTest.java +++ b/server/src/test/java/com/vaadin/tests/server/FileResourceTest.java @@ -15,10 +15,14 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertEquals; + import java.io.File; +import java.net.URISyntaxException; import org.junit.Test; +import com.vaadin.server.DownloadStream; import com.vaadin.server.FileResource; public class FileResourceTest { @@ -33,4 +37,24 @@ public class FileResourceTest { new FileResource(new File("nonexisting")).getStream(); } + @Test + public void bufferSize() throws URISyntaxException { + File file = new File(getClass().getResource("../styles.scss").toURI()); + FileResource resource = new FileResource(file) { + @Override + public long getCacheTime() { + return 5; + } + }; + resource.setBufferSize(100); + resource.setCacheTime(200); + + DownloadStream downloadStream = resource.getStream(); + assertEquals( + "DownloadStream buffer size must be same as resource buffer size", + resource.getBufferSize(), downloadStream.getBufferSize()); + assertEquals( + "DownloadStream cache time must be same as resource cache time", + resource.getCacheTime(), downloadStream.getCacheTime()); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java b/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java index 438bf31925..b2d14802b0 100644 --- a/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java +++ b/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java @@ -18,9 +18,12 @@ package com.vaadin.tests.server; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import java.net.URISyntaxException; + import org.easymock.EasyMock; import org.junit.Test; +import com.vaadin.server.DownloadStream; import com.vaadin.server.StreamResource; import com.vaadin.server.StreamResource.StreamSource; @@ -54,4 +57,24 @@ public class StreamResourceTest { resource.hashCode(); } + @Test + public void cacheTime() throws URISyntaxException { + StreamResource resource = new StreamResource( + EasyMock.createMock(StreamSource.class), "") { + @Override + public long getCacheTime() { + return 5; + } + }; + resource.setBufferSize(100); + resource.setCacheTime(200); + + DownloadStream downloadStream = resource.getStream(); + assertEquals( + "DownloadStream buffer size must be same as resource buffer size", + resource.getBufferSize(), downloadStream.getBufferSize()); + assertEquals( + "DownloadStream cache time must be same as resource cache time", + resource.getCacheTime(), downloadStream.getCacheTime()); + } } |