diff options
author | Artur Signell <artur@vaadin.com> | 2013-09-17 14:16:35 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-09-17 14:16:36 +0300 |
commit | 0f7bcffdb9f753148d1027ff380c9520bb78bfd8 (patch) | |
tree | a91e21f0060cd097bfa70b8eef91723047d49692 /server/tests/src | |
parent | 70649ac21a40a2b819856da39ebcfb5394ae3280 (diff) | |
parent | 3a4351f9b777009d8e226d26125f758861ddcbb3 (diff) | |
download | vaadin-framework-0f7bcffdb9f753148d1027ff380c9520bb78bfd8.tar.gz vaadin-framework-0f7bcffdb9f753148d1027ff380c9520bb78bfd8.zip |
Merge changes from origin/7.1
de53191 Fix for #12279 (caret jumps when formatting in RTA).
fca0f7a Add <br> as empty representation for webkit (#12490)
6dcece8 Allow creating TextBox or SuggestionPopup when extending VFilterSelect (#12491)
22fcb44 Include unobfuscated file used by test in the war (#12468)
bc90a58 Unified xml files to end with new line
3d01d74 Reduce Ivy resolver spam to a minimum (#12510)
1e73ca8 Fix keystore path to correspond to the Vaadin 7 directory structure (#12520)
dcf9c61 Protect CurrentInstance instances from garbage collection (#12509)
24ffbc2 Allow storing and restoring null instances in CurrentInstance #12509
0d79a84 Added a comment that hopefully explains the NULL_OBJECT #12509
e4d99b3 Use non-obfuscated version of vaadinPush.js when not in production (#12527)
3a31dfe NullPointerException in TableQuery.fetchMetadata() (#11403)
4659797 fixed incorrect name for close-pressed.png for windows in black theme (#12563)
9b05257 Test for push with streaming based on Table
3cafce3 NullPointerException in DateToSqlDateConverter (#12284)
3a4351f Ensure PushConnection is properly cleaned up on disconnect (#12226, #12522)
Change-Id: I44f3d5f003e62e7ab86a22188b22933491226868
Diffstat (limited to 'server/tests/src')
-rw-r--r-- | server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java | 25 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/util/TestCurrentInstance.java | 53 |
2 files changed, 76 insertions, 2 deletions
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java new file mode 100644 index 0000000000..685404ded6 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.data.converter; + +import java.util.Date; +import java.util.Locale; + +import junit.framework.TestCase; + +import com.vaadin.data.util.converter.DateToSqlDateConverter; + +public class TestDateToSqlDateConverter extends TestCase { + + DateToSqlDateConverter converter = new DateToSqlDateConverter(); + + public void testNullConversion() { + assertEquals(null, + converter.convertToModel(null, java.sql.Date.class, null)); + } + + public void testValueConversion() { + Date testDate = new Date(100, 0, 1); + long time = testDate.getTime(); + assertEquals(testDate, converter.convertToModel(new java.sql.Date(time), + java.sql.Date.class, Locale.ENGLISH)); + } +} diff --git a/server/tests/src/com/vaadin/util/TestCurrentInstance.java b/server/tests/src/com/vaadin/util/TestCurrentInstance.java index da986abe31..1910172aa8 100644 --- a/server/tests/src/com/vaadin/util/TestCurrentInstance.java +++ b/server/tests/src/com/vaadin/util/TestCurrentInstance.java @@ -15,14 +15,21 @@ */ package com.vaadin.util; +import static org.junit.Assert.assertNull; + import java.lang.reflect.Field; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import junit.framework.Assert; - +import org.easymock.EasyMock; +import org.junit.Assert; import org.junit.Test; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinSession; +import com.vaadin.ui.UI; + public class TestCurrentInstance { @Test @@ -142,4 +149,46 @@ public class TestCurrentInstance { public void testInheritedClearedAfterRemove() { } + + private static class UIStoredInCurrentInstance extends UI { + @Override + protected void init(VaadinRequest request) { + } + } + + private static class SessionStoredInCurrentInstance extends VaadinSession { + public SessionStoredInCurrentInstance(VaadinService service) { + super(service); + } + } + + @Test + public void testRestoringNullUIWorks() throws Exception { + // First make sure current instance is empty + CurrentInstance.clearAll(); + + // Then store a new UI in there + Map<Class<?>, CurrentInstance> old = CurrentInstance + .setCurrent(new UIStoredInCurrentInstance()); + + // Restore the old values and assert that the UI is null again + CurrentInstance.restoreInstances(old); + assertNull(CurrentInstance.get(UI.class)); + } + + @Test + public void testRestoringNullSessionWorks() throws Exception { + // First make sure current instance is empty + CurrentInstance.clearAll(); + + // Then store a new session in there + Map<Class<?>, CurrentInstance> old = CurrentInstance + .setCurrent(new SessionStoredInCurrentInstance(EasyMock + .createNiceMock(VaadinService.class))); + + // Restore the old values and assert that the session is null again + CurrentInstance.restoreInstances(old); + assertNull(CurrentInstance.get(VaadinSession.class)); + assertNull(CurrentInstance.get(VaadinService.class)); + } } |