From 0c9625d05c829a66b2b42fb5c3f14384d8c0f4a8 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Fri, 2 Jan 2015 16:10:52 +0200 Subject: Unify test class naming. Unit tests are now run for *Test.java and *Tests.java. Change-Id: Iffff1d9a79c7c9b9317ffd19b5a46715b1442909 --- .../vaadin/ui/AbsFieldDataSourceLocaleChange.java | 62 --------- .../ui/AbsFieldDataSourceLocaleChangeTest.java | 62 +++++++++ server/tests/src/com/vaadin/ui/AbsSelectTest.java | 147 +++++++++++++++++++++ .../src/com/vaadin/ui/AbstractSelectTest.java | 147 --------------------- .../tests/src/com/vaadin/ui/LabelDataSource.java | 129 ------------------ .../src/com/vaadin/ui/LabelDataSourceTest.java | 129 ++++++++++++++++++ .../tests/src/com/vaadin/ui/UIThemeEscaping.java | 89 ------------- .../src/com/vaadin/ui/UIThemeEscapingTest.java | 89 +++++++++++++ 8 files changed, 427 insertions(+), 427 deletions(-) delete mode 100644 server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java create mode 100644 server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java create mode 100644 server/tests/src/com/vaadin/ui/AbsSelectTest.java delete mode 100644 server/tests/src/com/vaadin/ui/AbstractSelectTest.java delete mode 100644 server/tests/src/com/vaadin/ui/LabelDataSource.java create mode 100644 server/tests/src/com/vaadin/ui/LabelDataSourceTest.java delete mode 100644 server/tests/src/com/vaadin/ui/UIThemeEscaping.java create mode 100644 server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java (limited to 'server/tests/src/com/vaadin/ui') diff --git a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java deleted file mode 100644 index fa69fc46da..0000000000 --- a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.vaadin.ui; - -import java.text.NumberFormat; -import java.util.Locale; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.vaadin.data.util.converter.StringToIntegerConverter; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinSession; -import com.vaadin.tests.util.AlwaysLockedVaadinSession; - -public class AbsFieldDataSourceLocaleChange { - - private VaadinSession vaadinSession; - private UI ui; - - @Before - public void setup() { - vaadinSession = new AlwaysLockedVaadinSession(null); - VaadinSession.setCurrent(vaadinSession); - ui = new UI() { - - @Override - protected void init(VaadinRequest request) { - - } - }; - ui.setSession(vaadinSession); - UI.setCurrent(ui); - } - - @Test - public void localeChangesOnAttach() { - TextField tf = new TextField(); - - tf.setConverter(new StringToIntegerConverter() { - @Override - protected NumberFormat getFormat(Locale locale) { - if (locale == null) { - NumberFormat format = super.getFormat(locale); - format.setGroupingUsed(false); - format.setMinimumIntegerDigits(10); - return format; - } - return super.getFormat(locale); - } - }); - tf.setImmediate(true); - tf.setConvertedValue(10000); - Assert.assertEquals("0000010000", tf.getValue()); - - VerticalLayout vl = new VerticalLayout(); - ui.setContent(vl); - ui.setLocale(new Locale("en", "US")); - - vl.addComponent(tf); - Assert.assertEquals("10,000", tf.getValue()); - } -} diff --git a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java new file mode 100644 index 0000000000..bb5babf360 --- /dev/null +++ b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java @@ -0,0 +1,62 @@ +package com.vaadin.ui; + +import java.text.NumberFormat; +import java.util.Locale; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.data.util.converter.StringToIntegerConverter; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; +import com.vaadin.tests.util.AlwaysLockedVaadinSession; + +public class AbsFieldDataSourceLocaleChangeTest { + + private VaadinSession vaadinSession; + private UI ui; + + @Before + public void setup() { + vaadinSession = new AlwaysLockedVaadinSession(null); + VaadinSession.setCurrent(vaadinSession); + ui = new UI() { + + @Override + protected void init(VaadinRequest request) { + + } + }; + ui.setSession(vaadinSession); + UI.setCurrent(ui); + } + + @Test + public void localeChangesOnAttach() { + TextField tf = new TextField(); + + tf.setConverter(new StringToIntegerConverter() { + @Override + protected NumberFormat getFormat(Locale locale) { + if (locale == null) { + NumberFormat format = super.getFormat(locale); + format.setGroupingUsed(false); + format.setMinimumIntegerDigits(10); + return format; + } + return super.getFormat(locale); + } + }); + tf.setImmediate(true); + tf.setConvertedValue(10000); + Assert.assertEquals("0000010000", tf.getValue()); + + VerticalLayout vl = new VerticalLayout(); + ui.setContent(vl); + ui.setLocale(new Locale("en", "US")); + + vl.addComponent(tf); + Assert.assertEquals("10,000", tf.getValue()); + } +} diff --git a/server/tests/src/com/vaadin/ui/AbsSelectTest.java b/server/tests/src/com/vaadin/ui/AbsSelectTest.java new file mode 100644 index 0000000000..0b807c5f21 --- /dev/null +++ b/server/tests/src/com/vaadin/ui/AbsSelectTest.java @@ -0,0 +1,147 @@ +/* + * 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.ui; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.util.ObjectProperty; + +public class AbsSelectTest { + + @Test + public void addItemsStrings() { + NativeSelect ns = new NativeSelect(); + ns.addItems("Foo", "bar", "baz"); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, ns + .getItemIds().toArray()); + } + + @Test + public void addItemsObjects() { + Object o1 = new Object(); + Object o2 = new Object(); + Object o3 = new Object(); + + NativeSelect ns = new NativeSelect(); + ns.addItems(o1, o2, o3); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds() + .toArray()); + } + + @Test + public void addItemsStringList() { + ArrayList itemIds = new ArrayList(); + itemIds.add("foo"); + itemIds.add("bar"); + itemIds.add("baz"); + NativeSelect ns = new NativeSelect(); + ns.addItems(itemIds); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, ns + .getItemIds().toArray()); + } + + @Test + public void addItemsObjectList() { + Object o1 = new Object(); + Object o2 = new Object(); + Object o3 = new Object(); + ArrayList itemIds = new ArrayList(); + itemIds.add(o1); + itemIds.add(o2); + itemIds.add(o3); + NativeSelect ns = new NativeSelect(); + ns.addItems(itemIds); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds() + .toArray()); + + } + + @Test + public void singleSelectInitiallyEmpty() { + AbstractSelect s = new ListSelect(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void singleSelectEmptyAfterClearUsingPDS() { + AbstractSelect s = new ListSelect(); + s.addItem("foo"); + s.addItem("bar"); + s.setPropertyDataSource(new ObjectProperty("foo")); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void singleSelectEmptyAfterClear() { + AbstractSelect s = new ListSelect(); + s.addItem("foo"); + s.addItem("bar"); + s.setValue("bar"); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectInitiallyEmpty() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectEmptyAfterClearUsingPDS() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + s.addItem("foo"); + s.addItem("bar"); + HashSet sel = new HashSet(); + sel.add("foo"); + sel.add("bar"); + s.setPropertyDataSource(new ObjectProperty(sel)); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectEmptyAfterClear() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + s.addItem("foo"); + s.addItem("bar"); + s.select("foo"); + s.select("bar"); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + +} diff --git a/server/tests/src/com/vaadin/ui/AbstractSelectTest.java b/server/tests/src/com/vaadin/ui/AbstractSelectTest.java deleted file mode 100644 index bd399f088c..0000000000 --- a/server/tests/src/com/vaadin/ui/AbstractSelectTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.ui; - -import java.util.ArrayList; -import java.util.HashSet; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.data.util.ObjectProperty; - -public class AbstractSelectTest { - - @Test - public void addItemsStrings() { - NativeSelect ns = new NativeSelect(); - ns.addItems("Foo", "bar", "baz"); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, ns - .getItemIds().toArray()); - } - - @Test - public void addItemsObjects() { - Object o1 = new Object(); - Object o2 = new Object(); - Object o3 = new Object(); - - NativeSelect ns = new NativeSelect(); - ns.addItems(o1, o2, o3); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds() - .toArray()); - } - - @Test - public void addItemsStringList() { - ArrayList itemIds = new ArrayList(); - itemIds.add("foo"); - itemIds.add("bar"); - itemIds.add("baz"); - NativeSelect ns = new NativeSelect(); - ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, ns - .getItemIds().toArray()); - } - - @Test - public void addItemsObjectList() { - Object o1 = new Object(); - Object o2 = new Object(); - Object o3 = new Object(); - ArrayList itemIds = new ArrayList(); - itemIds.add(o1); - itemIds.add(o2); - itemIds.add(o3); - NativeSelect ns = new NativeSelect(); - ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds() - .toArray()); - - } - - @Test - public void singleSelectInitiallyEmpty() { - AbstractSelect s = new ListSelect(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void singleSelectEmptyAfterClearUsingPDS() { - AbstractSelect s = new ListSelect(); - s.addItem("foo"); - s.addItem("bar"); - s.setPropertyDataSource(new ObjectProperty("foo")); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void singleSelectEmptyAfterClear() { - AbstractSelect s = new ListSelect(); - s.addItem("foo"); - s.addItem("bar"); - s.setValue("bar"); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectInitiallyEmpty() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectEmptyAfterClearUsingPDS() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - s.addItem("foo"); - s.addItem("bar"); - HashSet sel = new HashSet(); - sel.add("foo"); - sel.add("bar"); - s.setPropertyDataSource(new ObjectProperty(sel)); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectEmptyAfterClear() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - s.addItem("foo"); - s.addItem("bar"); - s.select("foo"); - s.select("bar"); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - -} diff --git a/server/tests/src/com/vaadin/ui/LabelDataSource.java b/server/tests/src/com/vaadin/ui/LabelDataSource.java deleted file mode 100644 index b57e83df8e..0000000000 --- a/server/tests/src/com/vaadin/ui/LabelDataSource.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.ui; - -import java.util.Locale; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.vaadin.data.util.ObjectProperty; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinSession; -import com.vaadin.tests.util.AlwaysLockedVaadinSession; - -public class LabelDataSource { - - Label label; - private static final String STRING_DS_VALUE = "String DatA source"; - private static final int INTEGER_DS_VALUE = 1587; - private static final String INTEGER_STRING_VALUE_FI = "1 587"; - private static final String INTEGER_STRING_VALUE_EN_US = "1,587"; - private static final Object INTEGER_STRING_VALUE_DE = "1.587"; - ObjectProperty stringDataSource; - private ObjectProperty integerDataSource; - VaadinSession vaadinSession; - - @Before - public void setup() { - vaadinSession = new AlwaysLockedVaadinSession(null); - VaadinSession.setCurrent(vaadinSession); - - label = new Label(); - stringDataSource = new ObjectProperty(STRING_DS_VALUE); - integerDataSource = new ObjectProperty(INTEGER_DS_VALUE); - } - - @Test - public void stringDataSource() { - label.setPropertyDataSource(stringDataSource); - Assert.assertEquals(STRING_DS_VALUE, label.getState().text); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - Assert.assertEquals(stringDataSource, label.getPropertyDataSource()); - label.setPropertyDataSource(null); - Assert.assertEquals(STRING_DS_VALUE, label.getState().text); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - Assert.assertEquals(null, label.getPropertyDataSource()); - label.setValue("foo"); - Assert.assertEquals("foo", label.getState().text); - Assert.assertEquals("foo", label.getValue()); - Assert.assertNull(label.getPropertyDataSource()); - - } - - @Test - public void integerDataSourceFi() { - label.setLocale(new Locale("fi", "FI")); - label.setPropertyDataSource(integerDataSource); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); - } - - @Test - public void integerDataSourceEn() { - label.setLocale(new Locale("en", "US")); - label.setPropertyDataSource(integerDataSource); - Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); - } - - @Test - public void changeLocaleAfterDataSource() { - label.setLocale(new Locale("en", "US")); - label.setPropertyDataSource(integerDataSource); - label.setLocale(new Locale("fi", "FI")); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); - } - - @Test - public void setRemoveDataSource() { - label.setValue("before"); - label.setPropertyDataSource(stringDataSource); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - label.setPropertyDataSource(null); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - label.setValue("after"); - Assert.assertEquals("after", label.getValue()); - } - - public class MockUI extends UI { - - public MockUI() { - setSession(vaadinSession); - } - - @Override - protected void init(VaadinRequest request) { - } - - } - - @Test - public void attachToSessionWithDifferentLocale() { - label.setValue("before"); - // label.setLocale(Locale.GERMANY); - label.setPropertyDataSource(integerDataSource); - UI ui = new MockUI(); - ui.setLocale(Locale.GERMANY); - ui.setContent(label); - Assert.assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); - } -} diff --git a/server/tests/src/com/vaadin/ui/LabelDataSourceTest.java b/server/tests/src/com/vaadin/ui/LabelDataSourceTest.java new file mode 100644 index 0000000000..8ec3ca1245 --- /dev/null +++ b/server/tests/src/com/vaadin/ui/LabelDataSourceTest.java @@ -0,0 +1,129 @@ +/* + * 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.ui; + +import java.util.Locale; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; +import com.vaadin.tests.util.AlwaysLockedVaadinSession; + +public class LabelDataSourceTest { + + Label label; + private static final String STRING_DS_VALUE = "String DatA source"; + private static final int INTEGER_DS_VALUE = 1587; + private static final String INTEGER_STRING_VALUE_FI = "1 587"; + private static final String INTEGER_STRING_VALUE_EN_US = "1,587"; + private static final Object INTEGER_STRING_VALUE_DE = "1.587"; + ObjectProperty stringDataSource; + private ObjectProperty integerDataSource; + VaadinSession vaadinSession; + + @Before + public void setup() { + vaadinSession = new AlwaysLockedVaadinSession(null); + VaadinSession.setCurrent(vaadinSession); + + label = new Label(); + stringDataSource = new ObjectProperty(STRING_DS_VALUE); + integerDataSource = new ObjectProperty(INTEGER_DS_VALUE); + } + + @Test + public void stringDataSource() { + label.setPropertyDataSource(stringDataSource); + Assert.assertEquals(STRING_DS_VALUE, label.getState().text); + Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + Assert.assertEquals(stringDataSource, label.getPropertyDataSource()); + label.setPropertyDataSource(null); + Assert.assertEquals(STRING_DS_VALUE, label.getState().text); + Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + Assert.assertEquals(null, label.getPropertyDataSource()); + label.setValue("foo"); + Assert.assertEquals("foo", label.getState().text); + Assert.assertEquals("foo", label.getValue()); + Assert.assertNull(label.getPropertyDataSource()); + + } + + @Test + public void integerDataSourceFi() { + label.setLocale(new Locale("fi", "FI")); + label.setPropertyDataSource(integerDataSource); + Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + } + + @Test + public void integerDataSourceEn() { + label.setLocale(new Locale("en", "US")); + label.setPropertyDataSource(integerDataSource); + Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getState().text); + Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getValue()); + Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + } + + @Test + public void changeLocaleAfterDataSource() { + label.setLocale(new Locale("en", "US")); + label.setPropertyDataSource(integerDataSource); + label.setLocale(new Locale("fi", "FI")); + Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + } + + @Test + public void setRemoveDataSource() { + label.setValue("before"); + label.setPropertyDataSource(stringDataSource); + Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + label.setPropertyDataSource(null); + Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + label.setValue("after"); + Assert.assertEquals("after", label.getValue()); + } + + public class MockUI extends UI { + + public MockUI() { + setSession(vaadinSession); + } + + @Override + protected void init(VaadinRequest request) { + } + + } + + @Test + public void attachToSessionWithDifferentLocale() { + label.setValue("before"); + // label.setLocale(Locale.GERMANY); + label.setPropertyDataSource(integerDataSource); + UI ui = new MockUI(); + ui.setLocale(Locale.GERMANY); + ui.setContent(label); + Assert.assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); + } +} diff --git a/server/tests/src/com/vaadin/ui/UIThemeEscaping.java b/server/tests/src/com/vaadin/ui/UIThemeEscaping.java deleted file mode 100644 index 236f283823..0000000000 --- a/server/tests/src/com/vaadin/ui/UIThemeEscaping.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.ui; - -import com.vaadin.server.VaadinRequest; -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class UIThemeEscaping { - - private UI ui; - - private void initUiWithTheme(String theme) { - VaadinRequest request = getRequestWithTheme(theme); - - ui.doInit(request, 1234, "foobar"); - } - - private VaadinRequest getRequestWithTheme(String theme) { - VaadinRequest request = mock(VaadinRequest.class); - - when(request.getParameter("theme")).thenReturn(theme); - - return request; - } - - @Before - public void setup() { - ui = new UI() { - @Override - protected void init(VaadinRequest request) { - // Nothing to do - } - }; - } - - @Test - public void dangerousCharactersAreRemoved() { - ui.setTheme("a<å(_\"$"); - - assertThat(ui.getTheme(), is("aå_$")); - } - - @Test - public void nullThemeIsSet() { - ui.setTheme("foobar"); - - ui.setTheme(null); - - assertThat(ui.getTheme(), is(nullValue())); - } - - @Test - public void themeIsSetOnInit() { - ui.setTheme("foobar"); - - initUiWithTheme("bar"); - - assertThat(ui.getTheme(), is("bar")); - } - - @Test - public void nullThemeIsSetOnInit() { - ui.setTheme("foobar"); - - initUiWithTheme(null); - - assertThat(ui.getTheme(), is(nullValue())); - } -} diff --git a/server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java b/server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java new file mode 100644 index 0000000000..7a0a5551e3 --- /dev/null +++ b/server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java @@ -0,0 +1,89 @@ +/* + * 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.ui; + +import com.vaadin.server.VaadinRequest; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class UIThemeEscapingTest { + + private UI ui; + + private void initUiWithTheme(String theme) { + VaadinRequest request = getRequestWithTheme(theme); + + ui.doInit(request, 1234, "foobar"); + } + + private VaadinRequest getRequestWithTheme(String theme) { + VaadinRequest request = mock(VaadinRequest.class); + + when(request.getParameter("theme")).thenReturn(theme); + + return request; + } + + @Before + public void setup() { + ui = new UI() { + @Override + protected void init(VaadinRequest request) { + // Nothing to do + } + }; + } + + @Test + public void dangerousCharactersAreRemoved() { + ui.setTheme("a<å(_\"$"); + + assertThat(ui.getTheme(), is("aå_$")); + } + + @Test + public void nullThemeIsSet() { + ui.setTheme("foobar"); + + ui.setTheme(null); + + assertThat(ui.getTheme(), is(nullValue())); + } + + @Test + public void themeIsSetOnInit() { + ui.setTheme("foobar"); + + initUiWithTheme("bar"); + + assertThat(ui.getTheme(), is("bar")); + } + + @Test + public void nullThemeIsSetOnInit() { + ui.setTheme("foobar"); + + initUiWithTheme(null); + + assertThat(ui.getTheme(), is(nullValue())); + } +} -- cgit v1.2.3