aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-03-26 10:51:50 +0200
committerVaadin Code Review <review@vaadin.com>2013-04-02 10:25:58 +0000
commitcbd3badb929e0253a44ae19464b6dd0caebca968 (patch)
treeec37cf18c901e36b106a3159e3266de7328cedac /server
parent6323e6e3f15c039d51f084436461e0be52b2acb9 (diff)
downloadvaadin-framework-cbd3badb929e0253a44ae19464b6dd0caebca968.tar.gz
vaadin-framework-cbd3badb929e0253a44ae19464b6dd0caebca968.zip
Fixed locking issue in tests
Change-Id: I3706cfa46f82615b8cc677bcaaa207d5ab05bf40
Diffstat (limited to 'server')
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java9
-rw-r--r--server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java23
-rw-r--r--server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java11
-rw-r--r--server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java4
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java9
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java5
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java3
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java1
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java3
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java3
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java3
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java3
-rw-r--r--server/tests/src/com/vaadin/ui/LabelDataSource.java3
-rw-r--r--server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java2
14 files changed, 61 insertions, 21 deletions
diff --git a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
index 5067da8861..bf4412fbce 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
@@ -22,6 +22,7 @@ import junit.framework.TestCase;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.DefaultConverterFactory;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.TextField;
public class ConverterFactory extends TestCase {
@@ -66,7 +67,7 @@ public class ConverterFactory extends TestCase {
public void testApplicationConverterFactoryInBackgroundThread() {
VaadinSession.setCurrent(null);
- final VaadinSession appWithCustomIntegerConverter = new VaadinSession(
+ final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession(
null);
appWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
@@ -84,7 +85,7 @@ public class ConverterFactory extends TestCase {
}
public void testApplicationConverterFactoryForDetachedComponent() {
- final VaadinSession appWithCustomIntegerConverter = new VaadinSession(
+ final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession(
null);
appWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
@@ -98,11 +99,11 @@ public class ConverterFactory extends TestCase {
}
public void testApplicationConverterFactoryForDifferentThanCurrentApplication() {
- final VaadinSession fieldAppWithCustomIntegerConverter = new VaadinSession(
+ final VaadinSession fieldAppWithCustomIntegerConverter = new AlwaysLockedVaadinSession(
null);
fieldAppWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
TextField tf = new TextField("", "123") {
@Override
diff --git a/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java b/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java
new file mode 100644
index 0000000000..49e761f8b1
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java
@@ -0,0 +1,23 @@
+package com.vaadin.tests.server;
+
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.vaadin.server.VaadinService;
+import com.vaadin.server.VaadinSession;
+
+public class AlwaysLockedVaadinSession extends VaadinSession {
+
+ private ReentrantLock lock;
+
+ public AlwaysLockedVaadinSession(VaadinService service) {
+ super(service);
+ lock = new ReentrantLock();
+ lock.lock();
+ }
+
+ @Override
+ public Lock getLockInstance() {
+ return lock;
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java
index 68fbdb8d0d..da0bf9ebc8 100644
--- a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java
+++ b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java
@@ -4,9 +4,12 @@ import junit.framework.TestCase;
import org.easymock.EasyMock;
+import com.vaadin.server.DeploymentConfiguration;
import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.StreamVariable;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.server.VaadinServletService;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.ConnectorTracker;
import com.vaadin.ui.UI;
@@ -22,7 +25,7 @@ public class TestStreamVariableMapping extends TestCase {
@Override
protected void setUp() throws Exception {
- final VaadinSession application = new VaadinSession(null);
+ final VaadinSession application = new AlwaysLockedVaadinSession(null);
final UI uI = new UI() {
@Override
protected void init(VaadinRequest request) {
@@ -73,7 +76,11 @@ public class TestStreamVariableMapping extends TestCase {
}
private LegacyCommunicationManager createCommunicationManager() {
- return new LegacyCommunicationManager(new VaadinSession(null));
+ VaadinServletService vss = new VaadinServletService(
+ EasyMock.createMock(VaadinServlet.class),
+ EasyMock.createMock(DeploymentConfiguration.class));
+ return new LegacyCommunicationManager(
+ new AlwaysLockedVaadinSession(vss));
}
}
diff --git a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java
index 8a61ec6352..f8dbaccdad 100644
--- a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java
+++ b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java
@@ -18,6 +18,7 @@ import com.vaadin.server.ClientConnector.DetachListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
@@ -40,7 +41,8 @@ public class AttachDetachListeners {
public void setUp() {
control = EasyMock.createStrictControl();
- session = new VaadinSession(control.createMock(VaadinService.class));
+ session = new AlwaysLockedVaadinSession(
+ control.createMock(VaadinService.class));
ui = new UI() {
@Override
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
index cd77101ac3..144ca0fe24 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
@@ -17,6 +17,7 @@ import com.vaadin.tests.data.bean.Address;
import com.vaadin.tests.data.bean.Country;
import com.vaadin.tests.data.bean.Person;
import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.TextField;
@@ -45,7 +46,7 @@ public class AbstractFieldValueConversions extends TestCase {
}
public void testNonmodifiedBufferedFieldConversion() {
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
TextField tf = new TextField("salary");
tf.setBuffered(true);
tf.setLocale(new Locale("en", "US"));
@@ -61,7 +62,7 @@ public class AbstractFieldValueConversions extends TestCase {
}
public void testModifiedBufferedFieldConversion() {
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
TextField tf = new TextField("salary");
tf.setBuffered(true);
tf.setLocale(new Locale("en", "US"));
@@ -129,7 +130,7 @@ public class AbstractFieldValueConversions extends TestCase {
}
public void testChangeReadOnlyFieldLocale() {
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
TextField tf = new TextField("salary");
tf.setLocale(new Locale("en", "US"));
@@ -214,7 +215,7 @@ public class AbstractFieldValueConversions extends TestCase {
}
public void testNumberDoubleConverterChange() {
- final VaadinSession a = new VaadinSession(null);
+ final VaadinSession a = new AlwaysLockedVaadinSession(null);
VaadinSession.setCurrent(a);
TextField tf = new TextField() {
@Override
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
index 698e9bcee4..5455da18f8 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
@@ -11,6 +11,7 @@ import com.vaadin.tests.data.bean.Address;
import com.vaadin.tests.data.bean.Country;
import com.vaadin.tests.data.bean.Person;
import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.TextField;
public class DefaultConverterFactory extends TestCase {
@@ -53,7 +54,7 @@ public class DefaultConverterFactory extends TestCase {
}
public void testFloatConversion() {
- VaadinSession sess = new VaadinSession(null);
+ VaadinSession sess = new AlwaysLockedVaadinSession(null);
VaadinSession.setCurrent(sess);
TextField tf = new TextField();
@@ -68,7 +69,7 @@ public class DefaultConverterFactory extends TestCase {
}
public void testDefaultNumberConversion() {
- VaadinSession app = new VaadinSession(null);
+ VaadinSession app = new AlwaysLockedVaadinSession(null);
VaadinSession.setCurrent(app);
TextField tf = new TextField();
tf.setLocale(new Locale("en", "US"));
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
index cd9b6c6631..6dfd50c44c 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
@@ -9,6 +9,7 @@ import com.vaadin.data.util.AbstractProperty;
import com.vaadin.data.util.converter.Converter.ConversionException;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.UI;
@@ -18,7 +19,7 @@ public class RemoveListenersOnDetach {
int numReadOnlyChanges = 0;
AbstractField field = new AbstractField() {
- final private VaadinSession application = new VaadinSession(null);
+ final private VaadinSession application = new AlwaysLockedVaadinSession(null);
private UI uI = new UI() {
@Override
diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java
index 68c1133dc0..44b77e88e2 100644
--- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java
@@ -3,6 +3,7 @@ package com.vaadin.tests.server.component.fieldgroup;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
+
import com.vaadin.data.fieldgroup.BeanFieldGroup;
public class BeanFieldGroupTest {
diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java
index 7fd2930865..13da46cd60 100644
--- a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java
+++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java
@@ -21,6 +21,7 @@ import com.vaadin.data.Property;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.server.VaadinSession;
import com.vaadin.tests.data.bean.Person;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.Label;
public class LabelConverters extends TestCase {
@@ -37,7 +38,7 @@ public class LabelConverters extends TestCase {
}
public void testIntegerDataSource() {
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
Label l = new Label("Foo");
Property ds = new MethodProperty<Integer>(Person.createTestPerson1(),
"age");
diff --git a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java
index 8884c0c27c..186f563569 100644
--- a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java
+++ b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java
@@ -15,6 +15,7 @@ import com.vaadin.server.UIClassSelectionEvent;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.UI;
public class CustomUIClassLoader extends TestCase {
@@ -113,7 +114,7 @@ public class CustomUIClassLoader extends TestCase {
}
private VaadinSession createStubApplication() {
- return new VaadinSession(null) {
+ return new AlwaysLockedVaadinSession(null) {
@Override
public DeploymentConfiguration getConfiguration() {
return createConfigurationMock();
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
index bf6d127a83..15d3707f28 100644
--- a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
+++ b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
@@ -8,6 +8,7 @@ import org.junit.Test;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
@@ -25,7 +26,7 @@ public class AddRemoveSubWindow {
@Test
public void addSubWindow() {
- VaadinSession.setCurrent(new VaadinSession(null));
+ VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
TestApp app = new TestApp();
app.init();
Window subWindow = new Window("Sub window");
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java
index 63a58bcab3..4dfadc23a1 100644
--- a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java
+++ b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java
@@ -8,6 +8,7 @@ import org.junit.Test;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@@ -15,7 +16,7 @@ import com.vaadin.ui.Window;
public class AttachDetachWindow {
- private VaadinSession testApp = new VaadinSession(null);
+ private VaadinSession testApp = new AlwaysLockedVaadinSession(null);
private interface TestContainer {
public boolean attachCalled();
diff --git a/server/tests/src/com/vaadin/ui/LabelDataSource.java b/server/tests/src/com/vaadin/ui/LabelDataSource.java
index 7dcb382124..87ca4e372c 100644
--- a/server/tests/src/com/vaadin/ui/LabelDataSource.java
+++ b/server/tests/src/com/vaadin/ui/LabelDataSource.java
@@ -24,6 +24,7 @@ import org.junit.Test;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.server.AlwaysLockedVaadinSession;
public class LabelDataSource {
@@ -39,7 +40,7 @@ public class LabelDataSource {
@Before
public void setup() {
- vaadinSession = new VaadinSession(null);
+ vaadinSession = new AlwaysLockedVaadinSession(null);
VaadinSession.setCurrent(vaadinSession);
label = new Label();
diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
index 78be9b04fb..718a76804f 100644
--- a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
+++ b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
@@ -3,8 +3,6 @@ package com.vaadin.util;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.lang.reflect.InvocationTargetException;
-
import org.junit.Test;
public class ReflectToolsGetFieldValueByType {