summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/ClassInDefaultPackage.java2
-rw-r--r--server/tests/src/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java2
-rw-r--r--server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java2
-rw-r--r--server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java185
-rw-r--r--server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java2
-rw-r--r--server/tests/src/com/vaadin/data/util/TestIndexedContainer.java113
-rw-r--r--server/tests/src/com/vaadin/data/util/TransactionalPropertyWrapperTest.java116
-rw-r--r--server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java2
-rwxr-xr-xserver/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java4
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java2
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/ConnectorResourceHandlerTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/DefaultDeploymentConfigurationTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/JSONSerializerTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/MockServletConfig.java2
-rw-r--r--server/tests/src/com/vaadin/server/MockServletContext.java2
-rw-r--r--server/tests/src/com/vaadin/server/MockVaadinSession.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java4
-rw-r--r--server/tests/src/com/vaadin/server/VaadinPortletServiceTests.java33
-rw-r--r--server/tests/src/com/vaadin/server/VaadinPortletTests.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServiceTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServletTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinSessionTest.java2
-rw-r--r--server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java4
-rw-r--r--server/tests/src/com/vaadin/server/communication/MetadataWriterTest.java95
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java2
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java2
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java2
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java2
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java2
-rw-r--r--server/tests/src/com/vaadin/tests/event/EventRouterTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/TestSerialization.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/ComponentSizeParseTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java85
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java34
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java57
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java380
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/WindowTest.java53
-rw-r--r--server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/util/UniqueSerializableTest.java2
-rw-r--r--server/tests/src/com/vaadin/ui/LabelDataSource.java2
-rw-r--r--server/tests/src/com/vaadin/ui/UIInitRefreshTest.java (renamed from server/tests/src/com/vaadin/ui/UIInitReinitTest.java)16
-rw-r--r--server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java2
-rw-r--r--server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java2
-rw-r--r--server/tests/src/com/vaadin/util/TestCurrentInstance.java2
62 files changed, 913 insertions, 362 deletions
diff --git a/server/tests/src/ClassInDefaultPackage.java b/server/tests/src/ClassInDefaultPackage.java
index 1eb8bc4df5..52dc87e0e2 100644
--- a/server/tests/src/ClassInDefaultPackage.java
+++ b/server/tests/src/ClassInDefaultPackage.java
@@ -1,7 +1,7 @@
import org.junit.Ignore;
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java b/server/tests/src/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java
index b319c13e4e..cc1de6560f 100644
--- a/server/tests/src/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java
+++ b/server/tests/src/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java
index e11b6e50f8..951fc20c42 100644
--- a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java
+++ b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
index b9633753b4..c7d992dbeb 100644
--- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
@@ -10,15 +10,8 @@ import java.util.Map;
import junit.framework.Assert;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-
import com.vaadin.data.Container;
-import com.vaadin.data.Container.Indexed.ItemAddEvent;
-import com.vaadin.data.Container.Indexed.ItemRemoveEvent;
-import com.vaadin.data.Container.ItemSetChangeListener;
import com.vaadin.data.Item;
-import com.vaadin.data.util.filter.Compare;
/**
* Test basic functionality of BeanItemContainer.
@@ -734,182 +727,4 @@ public class BeanItemContainerTest extends AbstractBeanContainerTest {
assertNull(container.getContainerProperty(john, "address.street")
.getValue());
}
-
- public void testItemAddedEvent() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- ItemSetChangeListener addListener = createListenerMockFor(container);
- addListener.containerItemSetChange(EasyMock.isA(ItemAddEvent.class));
- EasyMock.replay(addListener);
-
- container.addItem(bean);
-
- EasyMock.verify(addListener);
- }
-
- public void testItemAddedEvent_AddedItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
-
- container.addItem(bean);
-
- assertEquals(bean, capturedEvent.getValue().getFirstItemId());
- }
-
- public void testItemAddedEvent_addItemAt_IndexOfAddedItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- container.addItem(bean);
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
-
- container.addItemAt(1, new Person(""));
-
- assertEquals(1, capturedEvent.getValue().getFirstIndex());
- }
-
- public void testItemAddedEvent_addItemAfter_IndexOfAddedItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- container.addItem(bean);
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
-
- container.addItemAfter(bean, new Person(""));
-
- assertEquals(1, capturedEvent.getValue().getFirstIndex());
- }
-
- public void testItemAddedEvent_amountOfAddedItems() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
- List<Person> beans = Arrays.asList(new Person("Jack"), new Person(
- "John"));
-
- container.addAll(beans);
-
- assertEquals(2, capturedEvent.getValue().getAddedItemsCount());
- }
-
- public void testItemAddedEvent_someItemsAreFiltered_amountOfAddedItemsIsReducedByAmountOfFilteredItems() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
- List<Person> beans = Arrays.asList(new Person("Jack"), new Person(
- "John"));
- container.addFilter(new Compare.Equal("name", "John"));
-
- container.addAll(beans);
-
- assertEquals(1, capturedEvent.getValue().getAddedItemsCount());
- }
-
- public void testItemAddedEvent_someItemsAreFiltered_addedItemIsTheFirstVisibleItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
- List<Person> beans = Arrays.asList(new Person("Jack"), bean);
- container.addFilter(new Compare.Equal("name", "John"));
-
- container.addAll(beans);
-
- assertEquals(bean, capturedEvent.getValue().getFirstItemId());
- }
-
- public void testItemRemovedEvent() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- container.addItem(bean);
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- removeListener.containerItemSetChange(EasyMock
- .isA(ItemRemoveEvent.class));
- EasyMock.replay(removeListener);
-
- container.removeItem(bean);
-
- EasyMock.verify(removeListener);
- }
-
- public void testItemRemovedEvent_RemovedItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- Person bean = new Person("John");
- container.addItem(bean);
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeItem(bean);
-
- assertEquals(bean, capturedEvent.getValue().getFirstItemId());
- }
-
- public void testItemRemovedEvent_indexOfRemovedItem() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- container.addItem(new Person("Jack"));
- Person secondBean = new Person("John");
- container.addItem(secondBean);
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeItem(secondBean);
-
- assertEquals(1, capturedEvent.getValue().getFirstIndex());
- }
-
- public void testItemRemovedEvent_amountOfRemovedItems() {
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class);
- container.addItem(new Person("Jack"));
- container.addItem(new Person("John"));
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeAllItems();
-
- assertEquals(2, capturedEvent.getValue().getRemovedItemsCount());
- }
-
- private Capture<ItemAddEvent> captureAddEvent(
- ItemSetChangeListener addListener) {
- Capture<ItemAddEvent> capturedEvent = new Capture<ItemAddEvent>();
- addListener.containerItemSetChange(EasyMock.capture(capturedEvent));
- return capturedEvent;
- }
-
- private Capture<ItemRemoveEvent> captureRemoveEvent(
- ItemSetChangeListener removeListener) {
- Capture<ItemRemoveEvent> capturedEvent = new Capture<ItemRemoveEvent>();
- removeListener.containerItemSetChange(EasyMock.capture(capturedEvent));
- return capturedEvent;
- }
-
- private ItemSetChangeListener createListenerMockFor(
- BeanItemContainer<Person> container) {
- ItemSetChangeListener listener = EasyMock
- .createNiceMock(ItemSetChangeListener.class);
- container.addItemSetChangeListener(listener);
- return listener;
- }
}
diff --git a/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java b/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java
index caff33cf50..ce0711a29e 100644
--- a/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java
+++ b/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java b/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java
index 5da0bdc8a2..09e5a26c15 100644
--- a/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java
+++ b/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java
@@ -4,12 +4,6 @@ import java.util.List;
import junit.framework.Assert;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-
-import com.vaadin.data.Container.Indexed.ItemAddEvent;
-import com.vaadin.data.Container.Indexed.ItemRemoveEvent;
-import com.vaadin.data.Container.ItemSetChangeListener;
import com.vaadin.data.Item;
public class TestIndexedContainer extends AbstractInMemoryContainerTest {
@@ -277,113 +271,6 @@ public class TestIndexedContainer extends AbstractInMemoryContainerTest {
counter.assertNone();
}
- public void testItemAddedEvent() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeListener addListener = createListenerMockFor(container);
- addListener.containerItemSetChange(EasyMock.isA(ItemAddEvent.class));
- EasyMock.replay(addListener);
-
- container.addItem();
-
- EasyMock.verify(addListener);
- }
-
- public void testItemAddedEvent_AddedItem() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeListener addListener = createListenerMockFor(container);
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
-
- Object itemId = container.addItem();
-
- assertEquals(itemId, capturedEvent.getValue().getFirstItemId());
- }
-
- public void testItemAddedEvent_IndexOfAddedItem() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeListener addListener = createListenerMockFor(container);
- container.addItem();
- Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener);
- EasyMock.replay(addListener);
-
- container.addItemAt(1);
-
- assertEquals(1, capturedEvent.getValue().getFirstIndex());
- }
-
- public void testItemRemovedEvent() {
- IndexedContainer container = new IndexedContainer();
- Object itemId = container.addItem();
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- removeListener.containerItemSetChange(EasyMock
- .isA(ItemRemoveEvent.class));
- EasyMock.replay(removeListener);
-
- container.removeItem(itemId);
-
- EasyMock.verify(removeListener);
- }
-
- public void testItemRemovedEvent_RemovedItem() {
- IndexedContainer container = new IndexedContainer();
- Object itemId = container.addItem();
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeItem(itemId);
-
- assertEquals(itemId, capturedEvent.getValue().getFirstItemId());
- }
-
- public void testItemRemovedEvent_indexOfRemovedItem() {
- IndexedContainer container = new IndexedContainer();
- container.addItem();
- Object secondItemId = container.addItem();
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeItem(secondItemId);
-
- assertEquals(1, capturedEvent.getValue().getFirstIndex());
- }
-
- public void testItemRemovedEvent_amountOfRemovedItems() {
- IndexedContainer container = new IndexedContainer();
- container.addItem();
- container.addItem();
- ItemSetChangeListener removeListener = createListenerMockFor(container);
- Capture<ItemRemoveEvent> capturedEvent = captureRemoveEvent(removeListener);
- EasyMock.replay(removeListener);
-
- container.removeAllItems();
-
- assertEquals(2, capturedEvent.getValue().getRemovedItemsCount());
- }
-
- private Capture<ItemAddEvent> captureAddEvent(
- ItemSetChangeListener addListener) {
- Capture<ItemAddEvent> capturedEvent = new Capture<ItemAddEvent>();
- addListener.containerItemSetChange(EasyMock.capture(capturedEvent));
- return capturedEvent;
- }
-
- private Capture<ItemRemoveEvent> captureRemoveEvent(
- ItemSetChangeListener removeListener) {
- Capture<ItemRemoveEvent> capturedEvent = new Capture<ItemRemoveEvent>();
- removeListener.containerItemSetChange(EasyMock.capture(capturedEvent));
- return capturedEvent;
- }
-
- private ItemSetChangeListener createListenerMockFor(
- IndexedContainer container) {
- ItemSetChangeListener listener = EasyMock
- .createNiceMock(ItemSetChangeListener.class);
- container.addItemSetChangeListener(listener);
- return listener;
- }
-
// Ticket 8028
public void testGetItemIdsRangeIndexOutOfBounds() {
IndexedContainer ic = new IndexedContainer();
diff --git a/server/tests/src/com/vaadin/data/util/TransactionalPropertyWrapperTest.java b/server/tests/src/com/vaadin/data/util/TransactionalPropertyWrapperTest.java
new file mode 100644
index 0000000000..5297cd807c
--- /dev/null
+++ b/server/tests/src/com/vaadin/data/util/TransactionalPropertyWrapperTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.ui.TextField;
+
+/**
+ * Test verifying that TransactionalPropertyWrapper removes it's listener from
+ * wrapped Property
+ *
+ * @since 7.1.15
+ * @author Vaadin Ltd
+ */
+public class TransactionalPropertyWrapperTest {
+
+ @SuppressWarnings("serial")
+ public class TestingProperty<T extends Object> extends
+ ObjectProperty<Object> {
+
+ private List<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
+
+ public TestingProperty(Object value) {
+ super(value);
+ }
+
+ @Override
+ public void addValueChangeListener(ValueChangeListener listener) {
+ super.addValueChangeListener(listener);
+ listeners.add(listener);
+ }
+
+ @Override
+ public void removeValueChangeListener(ValueChangeListener listener) {
+ super.removeValueChangeListener(listener);
+ if (listeners.contains(listener)) {
+ listeners.remove(listener);
+ }
+ }
+
+ public boolean hasListeners() {
+ return !listeners.isEmpty();
+ }
+ }
+
+ private final TextField nameField = new TextField("Name");
+ private final TextField ageField = new TextField("Age");
+ private final TextField unboundField = new TextField("No FieldGroup");
+ private final TestingProperty<String> unboundProp = new TestingProperty<String>(
+ "Hello World");
+ private final PropertysetItem item = new PropertysetItem();
+
+ @Test
+ public void fieldGroupBindAndUnbind() {
+ item.addItemProperty("name", new TestingProperty<String>(
+ "Just some text"));
+ item.addItemProperty("age", new TestingProperty<String>("42"));
+
+ final FieldGroup binder = new FieldGroup(item);
+ binder.setBuffered(false);
+
+ for (int i = 0; i < 2; ++i) {
+ binder.bind(nameField, "name");
+ binder.bind(ageField, "age");
+ unboundField.setPropertyDataSource(unboundProp);
+
+ assertTrue("No listeners in Properties", fieldsHaveListeners(true));
+
+ binder.unbind(nameField);
+ binder.unbind(ageField);
+ unboundField.setPropertyDataSource(null);
+
+ assertTrue("Listeners in Properties after unbinding",
+ fieldsHaveListeners(false));
+ }
+ }
+
+ /**
+ * Check that all listeners have same hasListeners() response
+ *
+ * @param expected
+ * expected response
+ * @return true if all are the same as expected. false if not
+ */
+ private boolean fieldsHaveListeners(boolean expected) {
+ for (Object id : item.getItemPropertyIds()) {
+ TestingProperty<?> itemProperty = (TestingProperty<?>) item
+ .getItemProperty(id);
+
+ if (itemProperty.hasListeners() != expected) {
+ return false;
+ }
+ }
+ return unboundProp.hasListeners() == expected;
+ }
+}
diff --git a/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java
index 15ad85e10d..b0c96b6f9c 100644
--- a/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java
+++ b/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java
index 1e96d59ed5..e03e970048 100755
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -151,4 +151,4 @@ public class SQLTestsConstants {
}
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java
index c8faa71e66..252acd81fc 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
index c275cd4363..f009fc505e 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
@@ -734,4 +734,4 @@ public class TableQueryTest {
statement.execute(SQLTestsConstants.dropSchema);
}
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/server/ConnectorResourceHandlerTest.java b/server/tests/src/com/vaadin/server/ConnectorResourceHandlerTest.java
index 828c35ced3..a5746065d6 100644
--- a/server/tests/src/com/vaadin/server/ConnectorResourceHandlerTest.java
+++ b/server/tests/src/com/vaadin/server/ConnectorResourceHandlerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/DefaultDeploymentConfigurationTest.java b/server/tests/src/com/vaadin/server/DefaultDeploymentConfigurationTest.java
index 45d9853537..7cbb73af17 100644
--- a/server/tests/src/com/vaadin/server/DefaultDeploymentConfigurationTest.java
+++ b/server/tests/src/com/vaadin/server/DefaultDeploymentConfigurationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/JSONSerializerTest.java b/server/tests/src/com/vaadin/server/JSONSerializerTest.java
index 81fd997c4a..8c1967acb3 100644
--- a/server/tests/src/com/vaadin/server/JSONSerializerTest.java
+++ b/server/tests/src/com/vaadin/server/JSONSerializerTest.java
@@ -1,7 +1,7 @@
package com.vaadin.server;
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/MockServletConfig.java b/server/tests/src/com/vaadin/server/MockServletConfig.java
index cd1201c249..d9d0e4d773 100644
--- a/server/tests/src/com/vaadin/server/MockServletConfig.java
+++ b/server/tests/src/com/vaadin/server/MockServletConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/MockServletContext.java b/server/tests/src/com/vaadin/server/MockServletContext.java
index 40d79190f6..031c83ae90 100644
--- a/server/tests/src/com/vaadin/server/MockServletContext.java
+++ b/server/tests/src/com/vaadin/server/MockServletContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/MockVaadinSession.java b/server/tests/src/com/vaadin/server/MockVaadinSession.java
index 1fb53cd368..660767e0d4 100644
--- a/server/tests/src/com/vaadin/server/MockVaadinSession.java
+++ b/server/tests/src/com/vaadin/server/MockVaadinSession.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java b/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java
index 017613661e..4478b4cf39 100644
--- a/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java b/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java
index 01d501c4fb..a87eb1870e 100644
--- a/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java b/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java
index 074941a556..8ccd649ea4 100644
--- a/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -36,4 +36,4 @@ public class VaadinLiferayRequestTests extends
return spy;
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/server/VaadinPortletServiceTests.java b/server/tests/src/com/vaadin/server/VaadinPortletServiceTests.java
index 62befdc516..f7a69c2edb 100644
--- a/server/tests/src/com/vaadin/server/VaadinPortletServiceTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinPortletServiceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -20,8 +20,15 @@ import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.vaadin.shared.ui.ui.UIConstants;
+import com.vaadin.ui.UI;
public class VaadinPortletServiceTests {
@@ -188,4 +195,28 @@ public class VaadinPortletServiceTests {
assertThat(widgetset,
is("com.vaadin.portal.gwt.PortalDefaultWidgetSet"));
}
+
+ @Test
+ public void findUIDoesntThrowNPE() {
+ try {
+ ReentrantLock mockLock = Mockito.mock(ReentrantLock.class);
+ when(mockLock.isHeldByCurrentThread()).thenReturn(true);
+
+ WrappedSession emptyWrappedSession = Mockito
+ .mock(WrappedSession.class);
+ when(emptyWrappedSession.getAttribute("null.lock")).thenReturn(
+ mockLock);
+ VaadinRequest requestWithUIIDSet = Mockito
+ .mock(VaadinRequest.class);
+ when(requestWithUIIDSet.getParameter(UIConstants.UI_ID_PARAMETER))
+ .thenReturn("1");
+ when(requestWithUIIDSet.getWrappedSession()).thenReturn(
+ emptyWrappedSession);
+
+ UI ui = sut.findUI(requestWithUIIDSet);
+ Assert.assertNull("Unset session did not return null", ui);
+ } catch (NullPointerException e) {
+ Assert.fail("findUI threw a NullPointerException");
+ }
+ }
}
diff --git a/server/tests/src/com/vaadin/server/VaadinPortletTests.java b/server/tests/src/com/vaadin/server/VaadinPortletTests.java
index 93f8fd0778..f92aa0dcaa 100644
--- a/server/tests/src/com/vaadin/server/VaadinPortletTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinPortletTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinServiceTest.java b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
index 77eb155378..51325067d2 100644
--- a/server/tests/src/com/vaadin/server/VaadinServiceTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java b/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
index 58b44dc3db..a5c683a119 100644
--- a/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinServletTest.java b/server/tests/src/com/vaadin/server/VaadinServletTest.java
index be21586be4..566c4ce70a 100644
--- a/server/tests/src/com/vaadin/server/VaadinServletTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServletTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinSessionTest.java b/server/tests/src/com/vaadin/server/VaadinSessionTest.java
index edc78ba8d7..d39da211f4 100644
--- a/server/tests/src/com/vaadin/server/VaadinSessionTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinSessionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java b/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java
index 0da85c7111..a1abfbd280 100644
--- a/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java
+++ b/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -36,4 +36,4 @@ public class VaadinWebSpherePortalRequestTests extends
return spy;
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/server/communication/MetadataWriterTest.java b/server/tests/src/com/vaadin/server/communication/MetadataWriterTest.java
new file mode 100644
index 0000000000..dee37ddc7f
--- /dev/null
+++ b/server/tests/src/com/vaadin/server/communication/MetadataWriterTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.server.communication;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.StringWriter;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.vaadin.server.SystemMessages;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.server.WrappedSession;
+import com.vaadin.ui.UI;
+
+public class MetadataWriterTest {
+
+ private UI ui;
+ private VaadinSession session;
+ private StringWriter writer;
+ private SystemMessages messages;
+
+ @Before
+ public void setup() {
+ ui = Mockito.mock(UI.class);
+ session = Mockito.mock(VaadinSession.class);
+ Mockito.when(ui.getSession()).thenReturn(session);
+ writer = new StringWriter();
+ messages = Mockito.mock(SystemMessages.class);
+ }
+
+ private void disableSessionExpirationMessages(SystemMessages messages) {
+ when(messages.isSessionExpiredNotificationEnabled()).thenReturn(true);
+ when(messages.getSessionExpiredMessage()).thenReturn(null);
+ when(messages.getSessionExpiredCaption()).thenReturn(null);
+ }
+
+ @Test
+ public void writeAsyncTag() throws Exception {
+ new MetadataWriter().write(ui, writer, false, true, messages);
+ Assert.assertEquals("{\"async\":true}", writer.getBuffer().toString());
+ }
+
+ @Test
+ public void writeRepaintTag() throws Exception {
+ new MetadataWriter().write(ui, writer, true, false, messages);
+ Assert.assertEquals("{\"repaintAll\":true}", writer.getBuffer()
+ .toString());
+ }
+
+ @Test
+ public void writeRepaintAndAsyncTag() throws Exception {
+ new MetadataWriter().write(ui, writer, true, true, messages);
+ Assert.assertEquals("{\"repaintAll\":true, \"async\":true}", writer
+ .getBuffer().toString());
+ }
+
+ @Test
+ public void writeRedirectWithExpiredSession() throws Exception {
+ disableSessionExpirationMessages(messages);
+
+ new MetadataWriter().write(ui, writer, false, false, messages);
+ Assert.assertEquals("{}", writer.getBuffer().toString());
+ }
+
+ @Test
+ public void writeRedirectWithActiveSession() throws Exception {
+ WrappedSession wrappedSession = mock(WrappedSession.class);
+ when(session.getSession()).thenReturn(wrappedSession);
+
+ disableSessionExpirationMessages(messages);
+
+ new MetadataWriter().write(ui, writer, false, false, messages);
+ Assert.assertEquals(
+ "{\"timedRedirect\":{\"interval\":15,\"url\":\"\"}}", writer
+ .getBuffer().toString());
+ }
+}
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 306e2f0405..32c9dc6604 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java
index e21382069f..64b06f651e 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java
index 8ce7b8eab8..75c742775f 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
index 5db33691b6..b8e74c7572 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java
index 18e2ed06c0..3210703445 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java
@@ -51,7 +51,7 @@ public class TestStringToLongConverter extends TestCase {
String.class, Locale.ENGLISH);
Assert.assertEquals("9,223,372,036,854,775,807", str);
str = reverseConverter.convertToModel(Long.MIN_VALUE, String.class,
- null);
+ Locale.ENGLISH);
Assert.assertEquals("-9,223,372,036,854,775,808", str);
}
diff --git a/server/tests/src/com/vaadin/tests/event/EventRouterTest.java b/server/tests/src/com/vaadin/tests/event/EventRouterTest.java
index dbbeaf778e..aeb460c49e 100644
--- a/server/tests/src/com/vaadin/tests/event/EventRouterTest.java
+++ b/server/tests/src/com/vaadin/tests/event/EventRouterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java b/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java
index f94cff391f..7e120cb9dd 100644
--- a/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java
+++ b/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java b/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java
index 1e0210dc63..41b71a37fa 100644
--- a/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java
+++ b/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/TestSerialization.java b/server/tests/src/com/vaadin/tests/server/TestSerialization.java
index a52821a919..3c18035dab 100644
--- a/server/tests/src/com/vaadin/tests/server/TestSerialization.java
+++ b/server/tests/src/com/vaadin/tests/server/TestSerialization.java
@@ -136,4 +136,4 @@ public class TestSerialization extends TestCase {
return dummyGetter;
}
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/ComponentSizeParseTest.java b/server/tests/src/com/vaadin/tests/server/component/ComponentSizeParseTest.java
index 11c0d10998..2083d1f473 100644
--- a/server/tests/src/com/vaadin/tests/server/component/ComponentSizeParseTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/ComponentSizeParseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java
new file mode 100644
index 0000000000..fd951f1692
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.abstractorderedlayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+
+/**
+ * Tests for abstract layout settings which should be preserved on replace
+ * component
+ *
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class LayoutSettingsOnReplace {
+
+ @Test
+ public void testExpandRatio() {
+ AbstractOrderedLayout layout = new AbstractOrderedLayout() {
+ };
+
+ AbstractComponent first = new AbstractComponent() {
+ };
+ AbstractComponent second = new AbstractComponent() {
+ };
+
+ layout.addComponent(first);
+ layout.addComponent(second);
+
+ int ratio = 2;
+ layout.setExpandRatio(first, ratio);
+ layout.setExpandRatio(second, 1);
+
+ AbstractComponent replace = new AbstractComponent() {
+ };
+ layout.replaceComponent(first, replace);
+
+ Assert.assertEquals("Expand ratio for replaced component is not "
+ + "the same as for previous one", ratio,
+ layout.getExpandRatio(replace), 0.0001);
+ }
+
+ @Test
+ public void testAlignment() {
+ AbstractOrderedLayout layout = new AbstractOrderedLayout() {
+ };
+
+ AbstractComponent first = new AbstractComponent() {
+ };
+ AbstractComponent second = new AbstractComponent() {
+ };
+
+ layout.addComponent(first);
+ layout.addComponent(second);
+
+ Alignment alignment = Alignment.BOTTOM_RIGHT;
+ layout.setComponentAlignment(first, alignment);
+ layout.setComponentAlignment(second, Alignment.MIDDLE_CENTER);
+
+ AbstractComponent replace = new AbstractComponent() {
+ };
+ layout.replaceComponent(first, replace);
+
+ Assert.assertEquals("Alignment for replaced component is not "
+ + "the same as for previous one", alignment,
+ layout.getComponentAlignment(replace));
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java
index 26443ead2b..fd4a1df766 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java
index 5926cfa1ca..ab2bc7c8c0 100644
--- a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java
+++ b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java
index 2bc95e371c..030abc0eb2 100644
--- a/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java
+++ b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -25,6 +25,7 @@ import org.junit.Test;
import com.vaadin.data.Container.Indexed;
import com.vaadin.data.Container.Sortable;
import com.vaadin.data.Item;
+import com.vaadin.data.Property;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.Calendar;
@@ -327,6 +328,37 @@ public class ContainerDataSource extends TestCase {
assertEquals(0, calendar.getEvents(start, end).size());
}
+ @Test
+ public void testStyleNamePropertyRetrieved() {
+ IndexedContainer ic = (IndexedContainer) createTestIndexedContainer();
+ ic.addContainerProperty("testStyleName", String.class, "");
+ for (int i = 0; i < 10; i++) {
+ Item item = ic.getItem(ic.getIdByIndex(i));
+ @SuppressWarnings("unchecked")
+ Property<String> itemProperty = item
+ .getItemProperty("testStyleName");
+ itemProperty.setValue("testStyle");
+ }
+
+ ContainerEventProvider provider = new ContainerEventProvider(ic);
+ provider.setCaptionProperty("testCaption");
+ provider.setDescriptionProperty("testDescription");
+ provider.setStartDateProperty("testStartDate");
+ provider.setEndDateProperty("testEndDate");
+ provider.setStyleNameProperty("testStyleName");
+
+ calendar.setEventProvider(provider);
+ java.util.Calendar cal = java.util.Calendar.getInstance();
+ Date now = cal.getTime();
+ cal.add(java.util.Calendar.DAY_OF_MONTH, 20);
+ Date then = cal.getTime();
+ List<CalendarEvent> events = calendar.getEventProvider().getEvents(now,
+ then);
+ for (CalendarEvent ce : events) {
+ assertEquals("testStyle", ce.getStyleName());
+ }
+ }
+
private static Indexed createTestBeanItemContainer() {
BeanItemContainer<CalendarEvent> eventContainer = new BeanItemContainer<CalendarEvent>(
CalendarEvent.class);
diff --git a/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java b/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java
new file mode 100644
index 0000000000..46d72a6ae6
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.colorpicker;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.shared.ui.colorpicker.Color;
+
+public class ColorConversions {
+
+ @Test
+ public void convertHSL2RGB() {
+
+ int rgb = Color.HSLtoRGB(100, 50, 50);
+ Color c = new Color(rgb);
+ assertEquals(106, c.getRed());
+ assertEquals(191, c.getGreen());
+ assertEquals(64, c.getBlue());
+ assertEquals("#6abf40", c.getCSS());
+
+ rgb = Color.HSLtoRGB(0, 50, 50);
+ c = new Color(rgb);
+ assertEquals(191, c.getRed());
+ assertEquals(64, c.getGreen());
+ assertEquals(64, c.getBlue());
+ assertEquals("#bf4040", c.getCSS());
+
+ rgb = Color.HSLtoRGB(50, 0, 50);
+ c = new Color(rgb);
+ assertEquals(128, c.getRed());
+ assertEquals(128, c.getGreen());
+ assertEquals(128, c.getBlue());
+ assertEquals("#808080", c.getCSS());
+
+ rgb = Color.HSLtoRGB(50, 100, 0);
+ c = new Color(rgb);
+ assertEquals(0, c.getRed(), 0);
+ assertEquals(0, c.getGreen(), 0);
+ assertEquals(0, c.getBlue(), 0);
+ assertEquals("#000000", c.getCSS());
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
index 21a48888d6..ee75d6ed59 100644
--- a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
+++ b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
@@ -10,4 +10,4 @@ public class CssLayoutListeners extends AbstractListenerMethodsTest {
testListenerAddGetRemove(CssLayout.class, LayoutClickEvent.class,
LayoutClickListener.class);
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java
index 25ee0a38a9..f5467b2d18 100644
--- a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java
index e571576990..ea34d8b04e 100644
--- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java
+++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java
@@ -82,4 +82,4 @@ public class CaseInsensitiveBinding {
assertTrue("This".equals(form.firstName.getValue()));
}
-} \ No newline at end of file
+}
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 9d71db89a6..e6cecee1bf 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java b/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java
index c7703303d3..2a1cc0deb0 100644
--- a/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java
+++ b/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java
@@ -17,4 +17,4 @@ public class SelectListeners extends AbstractListenerMethodsTest {
testListenerAddGetRemove(Select.class, BlurEvent.class,
BlurListener.class);
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java b/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java
index 6cc522f8c7..fbe5bb3146 100644
--- a/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java
+++ b/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java
@@ -38,4 +38,4 @@ public class TableListeners extends AbstractListenerMethodsTest {
testListenerAddGetRemove(Table.class, ColumnReorderEvent.class,
ColumnReorderListener.class);
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java b/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java
new file mode 100644
index 0000000000..418ca333bc
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java
@@ -0,0 +1,380 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.table;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.ui.Table;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TablePropertyValueConverter extends TestCase {
+ protected TestableTable table;
+ protected Collection<?> initialProperties;
+
+ @Test
+ public void testRemovePropertyId() {
+ Collection<Object> converters = table.getCurrentConverters();
+ assertTrue("Set of converters was empty at the start.",
+ converters.size() > 0);
+
+ Object firstId = converters.iterator().next();
+
+ table.removeContainerProperty(firstId);
+
+ Collection<Object> converters2 = table.getCurrentConverters();
+ assertTrue("FirstId was not removed", !converters2.contains(firstId));
+
+ assertTrue("The number of removed converters was not one.",
+ converters.size() - converters2.size() == 1);
+
+ for (Object originalId : converters) {
+ if (!originalId.equals(firstId)) {
+ assertTrue("The wrong converter was removed.",
+ converters2.contains(originalId));
+ }
+ }
+
+ }
+
+ @Test
+ public void testSetContainer() {
+ table.setContainerDataSource(createContainer(new String[] { "col1",
+ "col3", "col4", "col5" }));
+ Collection<Object> converters = table.getCurrentConverters();
+ assertTrue("There should only have been one converter left.",
+ converters.size() == 1);
+ Object onlyKey = converters.iterator().next();
+ assertTrue("The incorrect key was left.", onlyKey.equals("col1"));
+
+ }
+
+ @Test
+ public void testSetContainerWithInexactButCompatibleTypes() {
+ TestableTable customTable = new TestableTable("Test table",
+ createContainer(new String[] { "col1", "col2", "col3" },
+ new Class[] { String.class, BaseClass.class,
+ DerivedClass.class }));
+ customTable.setConverter("col1", new Converter<String, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String convertToModel(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "model";
+ }
+
+ @Override
+ public String convertToPresentation(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "presentation";
+ }
+
+ @Override
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ });
+ customTable.setConverter("col2", new Converter<String, BaseClass>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public BaseClass convertToModel(String value,
+ Class<? extends BaseClass> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return new BaseClass("model");
+ }
+
+ @Override
+ public Class<BaseClass> getModelType() {
+ return BaseClass.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ @Override
+ public String convertToPresentation(BaseClass value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return null;
+ }
+ });
+ customTable.setConverter("col3", new Converter<String, DerivedClass>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public DerivedClass convertToModel(String value,
+ Class<? extends DerivedClass> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return new DerivedClass("derived" + 1001);
+ }
+
+ @Override
+ public Class<DerivedClass> getModelType() {
+ return DerivedClass.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ @Override
+ public String convertToPresentation(DerivedClass value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return null;
+ }
+ });
+ customTable.setContainerDataSource(createContainer(new String[] {
+ "col1", "col2", "col3" }, new Class[] { DerivedClass.class,
+ DerivedClass.class, BaseClass.class }));
+ Set<Object> converters = customTable.getCurrentConverters();
+ // TODO Test temporarily disabled as this feature
+ // is not yet implemented in Table
+ /*
+ * assertTrue("Incompatible types were not removed.", converters.size()
+ * <= 1); assertTrue("Even compatible types were removed",
+ * converters.size() == 1); assertTrue("Compatible type was missing.",
+ * converters.contains("col2"));
+ */
+ }
+
+ @Test
+ public void testPrimitiveTypeConverters() {
+ TestableTable customTable = new TestableTable("Test table",
+ createContainer(new String[] { "col1", "col2", "col3" },
+ new Class[] { int.class, BaseClass.class,
+ DerivedClass.class }));
+ customTable.setConverter("col1", new Converter<String, Integer>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Integer convertToModel(String value,
+ Class<? extends Integer> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return 11;
+ }
+
+ @Override
+ public String convertToPresentation(Integer value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "presentation";
+ }
+
+ @Override
+ public Class<Integer> getModelType() {
+ return Integer.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+ });
+ Set<Object> converters = customTable.getCurrentConverters();
+ assertTrue("Converter was not set.", converters.size() > 0);
+ }
+
+ @Test
+ public void testInheritance() {
+ assertTrue("BaseClass isn't assignable from DerivedClass",
+ BaseClass.class.isAssignableFrom(DerivedClass.class));
+ assertFalse("DerivedClass is assignable from BaseClass",
+ DerivedClass.class.isAssignableFrom(BaseClass.class));
+ }
+
+ @Override
+ public void setUp() {
+ table = new TestableTable("Test table", createContainer(new String[] {
+ "col1", "col2", "col3" }));
+ table.setConverter("col1", new Converter<String, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String convertToModel(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "model";
+ }
+
+ @Override
+ public String convertToPresentation(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "presentation";
+ }
+
+ @Override
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ });
+
+ table.setConverter("col2", new Converter<String, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String convertToModel(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "model2";
+ }
+
+ @Override
+ public String convertToPresentation(String value,
+ Class<? extends String> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "presentation2";
+ }
+
+ @Override
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ @Override
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ });
+
+ initialProperties = table.getContainerPropertyIds();
+ }
+
+ private static Container createContainer(Object[] ids) {
+ Class[] types = new Class[ids.length];
+ for (int i = 0; i < types.length; ++i) {
+ types[i] = String.class;
+ }
+ return createContainer(ids, types);
+ }
+
+ private static Container createContainer(Object[] ids, Class[] types) {
+ IndexedContainer container = new IndexedContainer();
+ if (ids.length > types.length) {
+ throw new IllegalArgumentException("Too few defined types");
+ }
+ for (int i = 0; i < ids.length; ++i) {
+ container.addContainerProperty(ids[i], types[i], "");
+ }
+
+ for (int i = 0; i < 100; i++) {
+ Item item = container.addItem("item " + i);
+ for (int j = 0; j < ids.length; ++j) {
+ Property itemProperty = item.getItemProperty(ids[j]);
+ if (types[j] == String.class) {
+ itemProperty.setValue(ids[j].toString() + i);
+ } else if (types[j] == BaseClass.class) {
+ itemProperty.setValue(new BaseClass("base" + i));
+ } else if (types[j] == DerivedClass.class) {
+ itemProperty.setValue(new DerivedClass("derived" + i));
+ } else if (types[j] == int.class) {
+ // FIXME can't set values because the int is autoboxed into
+ // an Integer and not unboxed prior to set
+
+ // itemProperty.setValue(i);
+ } else {
+ throw new IllegalArgumentException(
+ "Unhandled type in createContainer: " + types[j]);
+ }
+ }
+ }
+
+ return container;
+ }
+
+ private class TestableTable extends Table {
+ /**
+ * @param string
+ * @param createContainer
+ */
+ public TestableTable(String string, Container container) {
+ super(string, container);
+ }
+
+ Set<Object> getCurrentConverters() {
+ try {
+ Field f = Table.class
+ .getDeclaredField("propertyValueConverters");
+ f.setAccessible(true);
+ HashMap<Object, Converter<String, Object>> pvc = (HashMap<Object, Converter<String, Object>>) f
+ .get(this);
+ Set<Object> currentConverters = new HashSet<Object>();
+ for (Entry<Object, Converter<String, Object>> entry : pvc
+ .entrySet()) {
+ currentConverters.add(entry.getKey());
+ }
+ return currentConverters;
+
+ } catch (Exception e) {
+ fail("Unable to retrieve propertyValueConverters");
+ return null;
+ }
+ }
+ }
+
+ private static class BaseClass {
+ private String title;
+
+ public BaseClass(String title) {
+ this.title = title;
+ }
+ }
+
+ private static class DerivedClass extends BaseClass {
+ public DerivedClass(String title) {
+ super(title);
+ }
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java
index e14ebe739d..8d5b499264 100644
--- a/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java
+++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java
@@ -24,4 +24,4 @@ public class TreeListeners extends AbstractListenerMethodsTest {
testListenerAddGetRemove(Tree.class, CollapseEvent.class,
CollapseListener.class);
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java
index f9c93d307b..586300f650 100644
--- a/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java
+++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowTest.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowTest.java
new file mode 100644
index 0000000000..b74896b7a1
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.window;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class WindowTest {
+
+ public Window window;
+
+ @Before
+ public void setup() {
+ window = new Window();
+ }
+
+ @Test
+ public void testAssistiveDescription() {
+ Label l1 = new Label("label 1");
+ Button b2 = new Button("button 2");
+ window.setAssistiveDescription(l1, b2);
+
+ Assert.assertEquals(2, window.getAssistiveDescription().length);
+ Assert.assertEquals(l1, window.getAssistiveDescription()[0]);
+ Assert.assertEquals(b2, window.getAssistiveDescription()[1]);
+
+ // Modifying return value must not change actual value
+ window.getAssistiveDescription()[0] = null;
+
+ Assert.assertEquals(2, window.getAssistiveDescription().length);
+ Assert.assertEquals(l1, window.getAssistiveDescription()[0]);
+ Assert.assertEquals(b2, window.getAssistiveDescription()[1]);
+
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java b/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java
index 89cb352b6f..bc067ddb88 100644
--- a/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java
+++ b/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
index 5dc28757a7..ff6028648e 100644
--- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
+++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
index 4be34707e4..85de106e23 100644
--- a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
+++ b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/tests/util/UniqueSerializableTest.java b/server/tests/src/com/vaadin/tests/util/UniqueSerializableTest.java
index db9b5c02fa..abdc6c1a5c 100644
--- a/server/tests/src/com/vaadin/tests/util/UniqueSerializableTest.java
+++ b/server/tests/src/com/vaadin/tests/util/UniqueSerializableTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/ui/LabelDataSource.java b/server/tests/src/com/vaadin/ui/LabelDataSource.java
index 21d3e56d57..b57e83df8e 100644
--- a/server/tests/src/com/vaadin/ui/LabelDataSource.java
+++ b/server/tests/src/com/vaadin/ui/LabelDataSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/tests/src/com/vaadin/ui/UIInitReinitTest.java b/server/tests/src/com/vaadin/ui/UIInitRefreshTest.java
index f8ec0e68c2..e4b31ca487 100644
--- a/server/tests/src/com/vaadin/ui/UIInitReinitTest.java
+++ b/server/tests/src/com/vaadin/ui/UIInitRefreshTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -27,10 +27,10 @@ import com.vaadin.server.Page.UriFragmentChangedEvent;
import com.vaadin.server.Page.UriFragmentChangedListener;
import com.vaadin.server.VaadinRequest;
-public class UIInitReinitTest {
+public class UIInitRefreshTest {
private boolean initCalled;
- private boolean reinitCalled;
+ private boolean refreshCalled;
private boolean fragmentChangeCalled;
private boolean browserWindowResizeCalled;
@@ -52,8 +52,8 @@ public class UIInitReinitTest {
}
@Override
- protected void reinit(VaadinRequest request) {
- reinitCalled = true;
+ protected void refresh(VaadinRequest request) {
+ refreshCalled = true;
Assert.assertEquals("bar", getPage().getUriFragment());
Assert.assertEquals(200, getPage().getBrowserWindowWidth());
@@ -79,7 +79,7 @@ public class UIInitReinitTest {
@Before
public void setUp() {
- initCalled = reinitCalled = fragmentChangeCalled = browserWindowResizeCalled = false;
+ initCalled = refreshCalled = fragmentChangeCalled = browserWindowResizeCalled = false;
}
@Test
@@ -107,9 +107,9 @@ public class UIInitReinitTest {
Assert.assertFalse(fragmentChangeCalled);
Assert.assertFalse(browserWindowResizeCalled);
- ui.doReinit(reinitRequest);
+ ui.doRefresh(reinitRequest);
- Assert.assertTrue(reinitCalled);
+ Assert.assertTrue(refreshCalled);
Assert.assertTrue(fragmentChangeCalled);
Assert.assertTrue(browserWindowResizeCalled);
}
diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
index 540ffb852d..25f8ba7796 100644
--- a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
+++ b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java
@@ -60,4 +60,4 @@ public class ReflectToolsGetFieldValueByType {
} catch (Exception e) {
}
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java
index 1e1fafe31c..690f77d9a5 100644
--- a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java
+++ b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java
@@ -23,4 +23,4 @@ public class ReflectToolsGetPrimitiveFieldValue {
}
assertFalse(fieldValue instanceof Boolean);
}
-} \ No newline at end of file
+}
diff --git a/server/tests/src/com/vaadin/util/TestCurrentInstance.java b/server/tests/src/com/vaadin/util/TestCurrentInstance.java
index 09ef9514e5..666a0ef019 100644
--- a/server/tests/src/com/vaadin/util/TestCurrentInstance.java
+++ b/server/tests/src/com/vaadin/util/TestCurrentInstance.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of