diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-03 12:56:25 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-03 13:56:25 +0300 |
commit | ccad305464af83826de4a4bd25a383360fb356d0 (patch) | |
tree | d399448d2910c4cf373e64c690b053740dff43ba /compatibility-server | |
parent | 28b52d687dade66154a4fcd545415bf0d01b0a53 (diff) | |
download | vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.tar.gz vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.zip |
Use static import of Assert in tests (#10126)
Also removes dependency on junit.framework.TestCase .
Diffstat (limited to 'compatibility-server')
119 files changed, 2122 insertions, 2020 deletions
diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java b/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java index 00022ba44c..cea9f7a135 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.lang.reflect.Modifier; import java.net.URISyntaxException; @@ -11,7 +13,6 @@ import java.util.stream.Collectors; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Test; import com.vaadin.navigator.Navigator; @@ -47,23 +48,23 @@ public class ComponentDesignWriterUtility { WHITE_LIST_FQNS.add(ColorPickerSelect.class.getName()); WHITE_LIST_FQNS.add(ColorPickerHistory.class.getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerGradient.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerGradient.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerPopup.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerPopup.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerPreview.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerPreview.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerGrid.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerGrid.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerSelect.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerSelect.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerHistory.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerHistory.class .getName()); // ================================================================== @@ -113,7 +114,7 @@ public class ComponentDesignWriterUtility { @Test public void vaadin8ComponentsElementStartsWithVaadinPrefix() throws URISyntaxException { - Assert.assertTrue(getVaadin8Components().stream() + assertTrue(getVaadin8Components().stream() .map(ComponentDesignWriterUtility::getDeclarativeSyntax) .allMatch(element -> element.startsWith("<vaadin-"))); } @@ -121,7 +122,7 @@ public class ComponentDesignWriterUtility { @Test public void vaadin7ComponentsElementStartsWithVaadinPrefix() throws URISyntaxException { - Assert.assertTrue(getVaadin7Components().stream() + assertTrue(getVaadin7Components().stream() .map(ComponentDesignWriterUtility::getDeclarativeSyntax) .allMatch(element -> element.startsWith("<vaadin7-"))); } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java index f00592af6d..38380483a6 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + import java.io.File; import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; import org.junit.Test; /** @@ -40,13 +42,11 @@ public class DeprecatedTest { && !testRoot.equals(new File(entry))) .forEach(cls -> { count.incrementAndGet(); - Assert.assertNotNull( - "Class " + cls - + " is in compatability package and it's not deprecated", + assertNotNull("Class " + cls + + " is in compatability package and it's not deprecated", cls.getAnnotation(Deprecated.class)); }); - Assert.assertNotEquals("Total number of checked classes", 0, - count.get()); + assertNotEquals("Total number of checked classes", 0, count.get()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 7924b36f7e..0252da62ac 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -1,5 +1,8 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; @@ -7,7 +10,6 @@ import java.util.HashSet; import java.util.Set; import org.easymock.EasyMock; -import org.junit.Assert; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Component; @@ -54,13 +56,11 @@ public abstract class AbstractListenerMethodsTestBase { .getName() + ";"); System.out.println("import " + c.getName() + ";"); - System.out - .println( - "public class " + c.getSimpleName() - + "Listeners extends " - + AbstractListenerMethodsTestBase.class - .getSimpleName() - + " {"); + System.out.println("public class " + c.getSimpleName() + + "Listeners extends " + + AbstractListenerMethodsTestBase.class + .getSimpleName() + + " {"); } String listenerClassName = m.getParameterTypes()[0] @@ -174,11 +174,10 @@ public abstract class AbstractListenerMethodsTestBase { SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Collection<?> registeredListeners = getListeners(c, eventClass); - Assert.assertEquals("Number of listeners", expectedListeners.length, + assertEquals("Number of listeners", expectedListeners.length, registeredListeners.size()); - Assert.assertArrayEquals(expectedListeners, - registeredListeners.toArray()); + assertArrayEquals(expectedListeners, registeredListeners.toArray()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java index 1f7783dda5..a2d40836b6 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java @@ -3,8 +3,8 @@ package com.vaadin.tests.server.component.slider; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.fail; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Slider; @@ -61,7 +61,7 @@ public class SliderTest { try { s.setValue(20.0); - Assert.fail("Should throw out of bounds exception"); + fail("Should throw out of bounds exception"); } catch (Slider.ValueOutOfBoundsException e) { // TODO: handle exception } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java index fdb0ae2bf3..9e213fbb1d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.data.fieldgroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class BeanFieldGroupTest { @@ -63,8 +64,8 @@ public class BeanFieldGroupTest { public void propertyTypeWithoutItem() { BeanFieldGroup<Sub2> s = new BeanFieldGroup<BeanFieldGroupTest.Sub2>( Sub2.class); - Assert.assertEquals(boolean.class, s.getPropertyType("sub2field")); - Assert.assertEquals(Integer.class, s.getPropertyType("sub1Field")); - Assert.assertEquals(String.class, s.getPropertyType("mainField")); + assertEquals(boolean.class, s.getPropertyType("sub2field")); + assertEquals(Integer.class, s.getPropertyType("sub1Field")); + assertEquals(String.class, s.getPropertyType("mainField")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java index 38ac1a8f9c..e502da734c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java @@ -15,10 +15,13 @@ */ package com.vaadin.v7.data.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.util.Date; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -44,7 +47,7 @@ public class DefaultFieldGroupFieldFactoryTest { public void noPublicConstructor() { Class<DefaultFieldGroupFieldFactory> clazz = DefaultFieldGroupFieldFactory.class; Constructor<?>[] constructors = clazz.getConstructors(); - Assert.assertEquals( + assertEquals( "DefaultFieldGroupFieldFactory contains public constructors", 0, constructors.length); } @@ -55,40 +58,39 @@ public class DefaultFieldGroupFieldFactoryTest { .get(); DefaultFieldGroupFieldFactory factory2 = DefaultFieldGroupFieldFactory .get(); - Assert.assertTrue( + assertTrue( "DefaultFieldGroupFieldFactory.get() method returns different instances", factory1 == factory2); - Assert.assertNotNull( - "DefaultFieldGroupFieldFactory.get() method returns null", + assertNotNull("DefaultFieldGroupFieldFactory.get() method returns null", factory1); } @Test public void testDateGenerationForPopupDateField() { Field f = fieldFactory.createField(Date.class, DateField.class); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test public void testDateGenerationForInlineDateField() { Field f = fieldFactory.createField(Date.class, InlineDateField.class); - Assert.assertNotNull(f); - Assert.assertEquals(InlineDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(InlineDateField.class, f.getClass()); } @Test public void testDateGenerationForTextField() { Field f = fieldFactory.createField(Date.class, TextField.class); - Assert.assertNotNull(f); - Assert.assertEquals(TextField.class, f.getClass()); + assertNotNull(f); + assertEquals(TextField.class, f.getClass()); } @Test public void testDateGenerationForField() { Field f = fieldFactory.createField(Date.class, Field.class); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } public enum SomeEnum { @@ -98,22 +100,22 @@ public class DefaultFieldGroupFieldFactoryTest { @Test public void testEnumComboBox() { Field f = fieldFactory.createField(SomeEnum.class, ComboBox.class); - Assert.assertNotNull(f); - Assert.assertEquals(ComboBox.class, f.getClass()); + assertNotNull(f); + assertEquals(ComboBox.class, f.getClass()); } @Test public void testEnumAnySelect() { Field f = fieldFactory.createField(SomeEnum.class, AbstractSelect.class); - Assert.assertNotNull(f); - Assert.assertEquals(ListSelect.class, f.getClass()); + assertNotNull(f); + assertEquals(ListSelect.class, f.getClass()); } @Test public void testEnumAnyField() { Field f = fieldFactory.createField(SomeEnum.class, Field.class); - Assert.assertNotNull(f); - Assert.assertEquals(ListSelect.class, f.getClass()); + assertNotNull(f); + assertEquals(ListSelect.class, f.getClass()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java index d354729bea..728860dcf3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.data.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.Date; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,15 +69,15 @@ public class FieldGroupDateTest { @Test public void testBuildAndBindDate() { Field f = fieldGroup.buildAndBind("javaDate"); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test public void testBuildAndBindSqlDate() { Field f = fieldGroup.buildAndBind("sqlDate"); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test @@ -85,12 +87,12 @@ public class FieldGroupDateTest { fieldGroup.bind(sqlDate, "sqlDate"); fieldGroup.bind(javaDate, "javaDate"); - Assert.assertEquals(new Date(2010, 5, 7), javaDate.getValue()); - Assert.assertEquals(new Date(2011, 6, 8), sqlDate.getValue()); + assertEquals(new Date(2010, 5, 7), javaDate.getValue()); + assertEquals(new Date(2011, 6, 8), sqlDate.getValue()); fieldGroup.clear(); - Assert.assertEquals(null, javaDate.getValue()); - Assert.assertEquals(null, sqlDate.getValue()); + assertEquals(null, javaDate.getValue()); + assertEquals(null, sqlDate.getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java index c8d98c14b5..219bd07815 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java @@ -3,9 +3,9 @@ package com.vaadin.v7.data.fieldgroup; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,7 +67,7 @@ public class FieldGroupTest { group.bind(field, "name"); Property propertyDataSource = field.getPropertyDataSource(); - Assert.assertTrue( + assertTrue( "Custom implementation of transactional property " + "has not been used", propertyDataSource instanceof TransactionalPropertyImpl); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java index 7ff24f76ae..bfbf6d4eb2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java @@ -42,7 +42,7 @@ public abstract class AbstractContainerTestBase { * Check that no one event has occurred since the previous assert call. */ public void assertNone() { - Assert.assertEquals(lastAssertedEventCount, eventCount); + assertEquals(lastAssertedEventCount, eventCount); } /** @@ -50,7 +50,7 @@ public abstract class AbstractContainerTestBase { * call. */ public void assertOnce() { - Assert.assertEquals(++lastAssertedEventCount, eventCount); + assertEquals(++lastAssertedEventCount, eventCount); } /** @@ -154,7 +154,7 @@ public abstract class AbstractContainerTestBase { } // getItemProperty - Assert.assertNull( + assertNull( container.getItem(itemIdInSet).getItemProperty("notinset")); } @@ -208,20 +208,20 @@ public abstract class AbstractContainerTestBase { container.removeAllItems(); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); - Assert.assertNotNull(container.getItem(id)); + assertTrue(container.containsId(id)); + assertNotNull(container.getItem(id)); Item item = container.addItem("foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); // Add again Item item2 = container.addItem("foo"); - Assert.assertNull(item2); + assertNull(item2); // Null is not a valid itemId - Assert.assertNull(container.addItem(null)); + assertNull(container.addItem(null)); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -232,25 +232,25 @@ public abstract class AbstractContainerTestBase { container.removeAllItems(); Object id = container.addItemAt(0); - Assert.assertTrue(container.containsId(id)); - Assert.assertEquals(id, container.getIdByIndex(0)); - Assert.assertNotNull(container.getItem(id)); + assertTrue(container.containsId(id)); + assertEquals(id, container.getIdByIndex(0)); + assertNotNull(container.getItem(id)); Item item = container.addItemAt(0, "foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); - Assert.assertEquals("foo", container.getIdByIndex(0)); + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); + assertEquals("foo", container.getIdByIndex(0)); Item itemAtEnd = container.addItemAt(2, "atend"); - Assert.assertNotNull(itemAtEnd); - Assert.assertTrue(container.containsId("atend")); - Assert.assertEquals(itemAtEnd, container.getItem("atend")); - Assert.assertEquals("atend", container.getIdByIndex(2)); + assertNotNull(itemAtEnd); + assertTrue(container.containsId("atend")); + assertEquals(itemAtEnd, container.getItem("atend")); + assertEquals("atend", container.getIdByIndex(2)); // Add again Item item2 = container.addItemAt(0, "foo"); - Assert.assertNull(item2); + assertNull(item2); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -265,28 +265,28 @@ public abstract class AbstractContainerTestBase { try { container.removeAllItems(); - Assert.assertNotNull(container.addItem(0)); + assertNotNull(container.addItem(0)); Item item = container.addItemAfter(null, "foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); - Assert.assertEquals("foo", + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); + assertEquals("foo", container.getItemIds().iterator().next()); Item itemAtEnd = container.addItemAfter(0, "atend"); - Assert.assertNotNull(itemAtEnd); - Assert.assertTrue(container.containsId("atend")); - Assert.assertEquals(itemAtEnd, container.getItem("atend")); + assertNotNull(itemAtEnd); + assertTrue(container.containsId("atend")); + assertEquals(itemAtEnd, container.getItem("atend")); Iterator<?> i = container.getItemIds().iterator(); i.next(); i.next(); - Assert.assertEquals("atend", i.next()); + assertEquals("atend", i.next()); // Add again - Assert.assertNull(container.addItemAfter(null, "foo")); - Assert.assertNull(container.addItemAfter("atend", "foo")); - Assert.assertNull(container.addItemAfter("nonexistant", "123123")); + assertNull(container.addItemAfter(null, "foo")); + assertNull(container.addItemAfter("atend", "foo")); + assertNull(container.addItemAfter("nonexistant", "123123")); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -421,43 +421,43 @@ public abstract class AbstractContainerTestBase { initializeContainer(container); // indexOfId - Assert.assertEquals(itemPosition, container.indexOfId(itemId)); + assertEquals(itemPosition, container.indexOfId(itemId)); // getIdByIndex - Assert.assertEquals(itemId, container.getIdByIndex(itemPosition)); + assertEquals(itemId, container.getIdByIndex(itemPosition)); // addItemAt if (testAddEmptyItemAt) { Object addedId = container.addItemAt(itemPosition); - Assert.assertEquals(itemPosition, container.indexOfId(addedId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(addedId, container.getIdByIndex(itemPosition)); - Assert.assertEquals(itemId, + assertEquals(itemPosition, container.indexOfId(addedId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(addedId, container.getIdByIndex(itemPosition)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); Object newFirstId = container.addItemAt(0); - Assert.assertEquals(0, container.indexOfId(newFirstId)); - Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId)); - Assert.assertEquals(newFirstId, container.firstItemId()); - Assert.assertEquals(newFirstId, container.getIdByIndex(0)); - Assert.assertEquals(itemId, + assertEquals(0, container.indexOfId(newFirstId)); + assertEquals(itemPosition + 2, container.indexOfId(itemId)); + assertEquals(newFirstId, container.firstItemId()); + assertEquals(newFirstId, container.getIdByIndex(0)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 2)); Object newLastId = container.addItemAt(container.size()); - Assert.assertEquals(container.size() - 1, + assertEquals(container.size() - 1, container.indexOfId(newLastId)); - Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId)); - Assert.assertEquals(newLastId, container.lastItemId()); - Assert.assertEquals(newLastId, + assertEquals(itemPosition + 2, container.indexOfId(itemId)); + assertEquals(newLastId, container.lastItemId()); + assertEquals(newLastId, container.getIdByIndex(container.size() - 1)); - Assert.assertEquals(itemId, + assertEquals(itemId, container.getIdByIndex(itemPosition + 2)); - Assert.assertTrue(container.removeItem(addedId)); - Assert.assertTrue(container.removeItem(newFirstId)); - Assert.assertTrue(container.removeItem(newLastId)); + assertTrue(container.removeItem(addedId)); + assertTrue(container.removeItem(newFirstId)); + assertTrue(container.removeItem(newLastId)); - Assert.assertFalse( + assertFalse( "Removing non-existing item should indicate failure", container.removeItem(addedId)); } @@ -465,35 +465,35 @@ public abstract class AbstractContainerTestBase { // addItemAt if (testAddItemAtWithId) { container.addItemAt(itemPosition, newItemId); - Assert.assertEquals(itemPosition, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, + assertEquals(itemPosition, container.indexOfId(newItemId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(newItemId, container.getIdByIndex(itemPosition)); - Assert.assertEquals(itemId, + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); container.addItemAt(0, newItemId); - Assert.assertEquals(0, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, container.firstItemId()); - Assert.assertEquals(newItemId, container.getIdByIndex(0)); - Assert.assertEquals(itemId, + assertEquals(0, container.indexOfId(newItemId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(newItemId, container.firstItemId()); + assertEquals(newItemId, container.getIdByIndex(0)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); container.addItemAt(container.size(), newItemId); - Assert.assertEquals(container.size() - 1, + assertEquals(container.size() - 1, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, container.lastItemId()); - Assert.assertEquals(newItemId, + assertEquals(itemPosition, container.indexOfId(itemId)); + assertEquals(newItemId, container.lastItemId()); + assertEquals(newItemId, container.getIdByIndex(container.size() - 1)); - Assert.assertEquals(itemId, container.getIdByIndex(itemPosition)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertEquals(itemId, container.getIdByIndex(itemPosition)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); } } @@ -597,7 +597,7 @@ public abstract class AbstractContainerTestBase { } protected void initializeContainer(Container container) { - Assert.assertTrue(container.removeAllItems()); + assertTrue(container.removeAllItems()); Object[] propertyIds = container.getContainerPropertyIds().toArray(); for (Object propertyId : propertyIds) { container.removeContainerProperty(propertyId); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java index f536fb489e..a7cf440279 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java @@ -79,7 +79,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_existingProperty_typeReturned() { BeanContainer<String, ClassName> container = getContainer(); - Assert.assertEquals( + assertEquals( "Unexpected type is returned for property 'simpleName'", String.class, container.getType("simpleName")); } @@ -87,7 +87,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_notExistingProperty_nullReturned() { BeanContainer<String, ClassName> container = getContainer(); - Assert.assertNull("Not null type is returned for property ''", + assertNull("Not null type is returned for property ''", container.getType("")); } @@ -222,49 +222,49 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addItem(); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItem(null); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(null, null); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0, new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addContainerProperty("lastName", String.class, ""); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } @@ -279,14 +279,14 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { container.setBeanIdResolver(new PersonNameResolver()); container.addBean(new Person("John")); - Assert.assertEquals("John", + assertEquals("John", container.getContainerProperty("John", "name").getValue()); - Assert.assertTrue(container.removeContainerProperty("name")); - Assert.assertNull(container.getContainerProperty("John", "name")); + assertTrue(container.removeContainerProperty("name")); + assertNull(container.getContainerProperty("John", "name")); - Assert.assertNotNull(container.getItem("John")); + assertNotNull(container.getItem("John")); // property removed also from item - Assert.assertNull(container.getItem("John").getItemProperty("name")); + assertNull(container.getItem("John").getItemProperty("name")); } @Test @@ -335,26 +335,26 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addBean(new Person("John")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container.addBeanAfter(null, new Person("Jane")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container.addBeanAt(0, new Person("Jack")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container .addAll(Arrays.asList(new Person[] { new Person("Jack") })); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } @@ -404,19 +404,19 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addBean(new Person("John")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } try { container.addBeanAfter(null, new Person("Jane")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } try { container.addBeanAt(0, new Person("Jack")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java index 9ad0c65f1a..4c228c59f3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -7,7 +10,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; import org.junit.Test; public class BeanItemContainerSortTest { @@ -45,11 +47,10 @@ public class BeanItemContainerSortTest { } } - String[] names = { "Antti", "Ville", "Sirkka", "Jaakko", - "Pekka", "John" }; + String[] names = { "Antti", "Ville", "Sirkka", "Jaakko", "Pekka", "John" }; int[] ages = { 10, 20, 50, 12, 64, 67 }; - String[] sortedByAge = { names[0], names[3], names[1], - names[2], names[4], names[5] }; + String[] sortedByAge = { names[0], names[3], names[1], names[2], names[4], + names[5] }; public BeanItemContainer<Person> getContainer() { BeanItemContainer<Person> bc = new BeanItemContainer<Person>( @@ -94,8 +95,8 @@ public class BeanItemContainerSortTest { int i = 0; for (String string : asList) { Person idByIndex = container.getIdByIndex(i++); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -112,8 +113,8 @@ public class BeanItemContainerSortTest { int i = 0; for (String string : sortedByAge) { Person idByIndex = container.getIdByIndex(i++); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -134,8 +135,8 @@ public class BeanItemContainerSortTest { int i = container.size() - 1; for (String string : sortedByAge) { Person idByIndex = container.getIdByIndex(i--); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -145,22 +146,22 @@ public class BeanItemContainerSortTest { Collection<?> sortablePropertyIds = container .getSortableContainerPropertyIds(); - Assert.assertEquals(2, sortablePropertyIds.size()); - Assert.assertTrue(sortablePropertyIds.contains("name")); - Assert.assertTrue(sortablePropertyIds.contains("age")); + assertEquals(2, sortablePropertyIds.size()); + assertTrue(sortablePropertyIds.contains("name")); + assertTrue(sortablePropertyIds.contains("age")); } @Test public void testGetNonSortableProperties() { BeanItemContainer<Parent> container = getParentContainer(); - Assert.assertEquals(3, container.getContainerPropertyIds().size()); + assertEquals(3, container.getContainerPropertyIds().size()); Collection<?> sortablePropertyIds = container .getSortableContainerPropertyIds(); - Assert.assertEquals(2, sortablePropertyIds.size()); - Assert.assertTrue(sortablePropertyIds.contains("name")); - Assert.assertTrue(sortablePropertyIds.contains("age")); + assertEquals(2, sortablePropertyIds.size()); + assertTrue(sortablePropertyIds.contains("name")); + assertTrue(sortablePropertyIds.contains("age")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java index dee7c3fee3..c6ef1f4ab0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Arrays; @@ -15,7 +16,6 @@ import java.util.Map; import org.easymock.Capture; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -86,15 +86,14 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_existingProperty_typeReturned() { BeanItemContainer<ClassName> container = getContainer(); - Assert.assertEquals( - "Unexpected type is returned for property 'simpleName'", + assertEquals("Unexpected type is returned for property 'simpleName'", String.class, container.getType("simpleName")); } @Test public void testGetType_notExistingProperty_nullReturned() { BeanItemContainer<ClassName> container = getContainer(); - Assert.assertNull("Not null type is returned for property ''", + assertNull("Not null type is returned for property ''", container.getType("")); } @@ -213,18 +212,18 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { BeanItemContainer<ClassName> container = new BeanItemContainer<ClassName>( classNames); - Assert.assertEquals(3, container.size()); - Assert.assertEquals(classNames.get(0), container.firstItemId()); - Assert.assertEquals(classNames.get(1), container.getIdByIndex(1)); - Assert.assertEquals(classNames.get(2), container.lastItemId()); + assertEquals(3, container.size()); + assertEquals(classNames.get(0), container.firstItemId()); + assertEquals(classNames.get(1), container.getIdByIndex(1)); + assertEquals(classNames.get(2), container.lastItemId()); BeanItemContainer<ClassName> container2 = new BeanItemContainer<ClassName>( ClassName.class, classNames); - Assert.assertEquals(3, container2.size()); - Assert.assertEquals(classNames.get(0), container2.firstItemId()); - Assert.assertEquals(classNames.get(1), container2.getIdByIndex(1)); - Assert.assertEquals(classNames.get(2), container2.lastItemId()); + assertEquals(3, container2.size()); + assertEquals(classNames.get(0), container2.firstItemId()); + assertEquals(classNames.get(1), container2.getIdByIndex(1)); + assertEquals(classNames.get(2), container2.lastItemId()); } // this only applies to the collection constructor with no type parameter @@ -233,15 +232,13 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { public void testEmptyCollectionConstructor() { try { new BeanItemContainer<ClassName>((Collection<ClassName>) null); - Assert.fail( - "Initializing BeanItemContainer from a null collection should not work!"); + fail("Initializing BeanItemContainer from a null collection should not work!"); } catch (IllegalArgumentException e) { // success } try { new BeanItemContainer<ClassName>(new ArrayList<ClassName>()); - Assert.fail( - "Initializing BeanItemContainer from an empty collection should not work!"); + fail("Initializing BeanItemContainer from an empty collection should not work!"); } catch (IllegalArgumentException e) { // success } @@ -275,7 +272,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(null, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -283,7 +280,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.firstItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -291,7 +288,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.lastItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -299,7 +296,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(0, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -307,7 +304,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(1, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -315,7 +312,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(container.size(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -401,7 +398,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(null, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -409,7 +406,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.firstItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -417,7 +414,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.lastItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -425,7 +422,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(0, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -433,7 +430,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(1, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -441,7 +438,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(container.size(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -655,28 +652,28 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { try { container.addItem(); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addContainerProperty("lastName", String.class, ""); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } @@ -691,14 +688,14 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { Person john = new Person("John"); container.addBean(john); - Assert.assertEquals("John", + assertEquals("John", container.getContainerProperty(john, "name").getValue()); - Assert.assertTrue(container.removeContainerProperty("name")); - Assert.assertNull(container.getContainerProperty(john, "name")); + assertTrue(container.removeContainerProperty("name")); + assertNull(container.getContainerProperty(john, "name")); - Assert.assertNotNull(container.getItem(john)); + assertNotNull(container.getItem(john)); // property removed also from item - Assert.assertNull(container.getItem(john).getItemProperty("name")); + assertNull(container.getItem(john).getItemProperty("name")); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java index 8232f9d532..76d25d1db5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java @@ -1,5 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -9,7 +13,6 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property; @@ -166,10 +169,10 @@ public class BeanItemTest { new MySuperClass()); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(3, itemPropertyIds.size()); - Assert.assertTrue(itemPropertyIds.contains("superPrivate")); - Assert.assertTrue(itemPropertyIds.contains("superProtected")); - Assert.assertTrue(itemPropertyIds.contains("superPublic")); + assertEquals(3, itemPropertyIds.size()); + assertTrue(itemPropertyIds.contains("superPrivate")); + assertTrue(itemPropertyIds.contains("superProtected")); + assertTrue(itemPropertyIds.contains("superPublic")); } @Test @@ -177,13 +180,13 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); - Assert.assertTrue(itemPropertyIds.contains("superPrivate")); - Assert.assertTrue(itemPropertyIds.contains("superProtected")); - Assert.assertTrue(itemPropertyIds.contains("superPublic")); - Assert.assertTrue(itemPropertyIds.contains("name")); - Assert.assertTrue(itemPropertyIds.contains("noField")); - Assert.assertTrue(itemPropertyIds.contains("name2")); + assertEquals(6, itemPropertyIds.size()); + assertTrue(itemPropertyIds.contains("superPrivate")); + assertTrue(itemPropertyIds.contains("superProtected")); + assertTrue(itemPropertyIds.contains("superPublic")); + assertTrue(itemPropertyIds.contains("name")); + assertTrue(itemPropertyIds.contains("noField")); + assertTrue(itemPropertyIds.contains("name2")); } @Test @@ -191,12 +194,12 @@ public class BeanItemTest { BeanItem<MyClass2> item = new BeanItem<MyClass2>(new MyClass2("bean2")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); - Assert.assertTrue(MyClass2.class.equals(item.getBean().getClass())); + assertTrue(MyClass2.class.equals(item.getBean().getClass())); // check that name2 accessed via MyClass2, not MyClass - Assert.assertFalse(item.getItemProperty("name2").isReadOnly()); + assertFalse(item.getItemProperty("name2").isReadOnly()); } @Test @@ -209,13 +212,13 @@ public class BeanItemTest { LinkedHashMap<String, VaadinPropertyDescriptor<Class>> propertyDescriptors = (LinkedHashMap<String, VaadinPropertyDescriptor<Class>>) method .invoke(null, MySuperInterface.class); - Assert.assertEquals(2, propertyDescriptors.size()); - Assert.assertTrue(propertyDescriptors.containsKey("super1")); - Assert.assertTrue(propertyDescriptors.containsKey("override")); + assertEquals(2, propertyDescriptors.size()); + assertTrue(propertyDescriptors.containsKey("super1")); + assertTrue(propertyDescriptors.containsKey("override")); MethodProperty<?> property = (MethodProperty<?>) propertyDescriptors .get("override").createProperty(getClass()); - Assert.assertTrue(property.isReadOnly()); + assertTrue(property.isReadOnly()); } @Test @@ -228,15 +231,15 @@ public class BeanItemTest { LinkedHashMap<String, VaadinPropertyDescriptor<Class>> propertyDescriptors = (LinkedHashMap<String, VaadinPropertyDescriptor<Class>>) method .invoke(null, MySubInterface.class); - Assert.assertEquals(4, propertyDescriptors.size()); - Assert.assertTrue(propertyDescriptors.containsKey("sub")); - Assert.assertTrue(propertyDescriptors.containsKey("super1")); - Assert.assertTrue(propertyDescriptors.containsKey("super2")); - Assert.assertTrue(propertyDescriptors.containsKey("override")); + assertEquals(4, propertyDescriptors.size()); + assertTrue(propertyDescriptors.containsKey("sub")); + assertTrue(propertyDescriptors.containsKey("super1")); + assertTrue(propertyDescriptors.containsKey("super2")); + assertTrue(propertyDescriptors.containsKey("override")); MethodProperty<?> property = (MethodProperty<?>) propertyDescriptors .get("override").createProperty(getClass()); - Assert.assertFalse(property.isReadOnly()); + assertFalse(property.isReadOnly()); } @Test @@ -251,11 +254,11 @@ public class BeanItemTest { ids); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertEquals("superPublic", it.next()); - Assert.assertEquals("name2", it.next()); - Assert.assertEquals("noField", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertEquals("superPublic", it.next()); + assertEquals("name2", it.next()); + assertEquals("noField", it.next()); + assertFalse(it.hasNext()); } @Test @@ -264,11 +267,11 @@ public class BeanItemTest { new String[] { "name", "superPublic", "name2", "noField" }); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertEquals("superPublic", it.next()); - Assert.assertEquals("name2", it.next()); - Assert.assertEquals("noField", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertEquals("superPublic", it.next()); + assertEquals("name2", it.next()); + assertEquals("noField", it.next()); + assertFalse(it.hasNext()); } @Test @@ -282,8 +285,8 @@ public class BeanItemTest { ids); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertFalse(it.hasNext()); } @Test @@ -291,11 +294,11 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); item.removeItemProperty("name2"); - Assert.assertEquals(5, itemPropertyIds.size()); - Assert.assertFalse(itemPropertyIds.contains("name2")); + assertEquals(5, itemPropertyIds.size()); + assertFalse(itemPropertyIds.contains("name2")); } @Test @@ -303,33 +306,32 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); item.removeItemProperty("superPrivate"); - Assert.assertEquals(5, itemPropertyIds.size()); - Assert.assertFalse(itemPropertyIds.contains("superPrivate")); + assertEquals(5, itemPropertyIds.size()); + assertFalse(itemPropertyIds.contains("superPrivate")); } @Test public void testPropertyTypes() { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertTrue(Integer.class + assertTrue(Integer.class .equals(item.getItemProperty("superPrivate").getType())); - Assert.assertTrue(Double.class + assertTrue(Double.class .equals(item.getItemProperty("superProtected").getType())); - Assert.assertTrue(Boolean.class + assertTrue(Boolean.class .equals(item.getItemProperty("superPublic").getType())); - Assert.assertTrue( - String.class.equals(item.getItemProperty("name").getType())); + assertTrue(String.class.equals(item.getItemProperty("name").getType())); } @Test public void testPropertyReadOnly() { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertFalse(item.getItemProperty("name").isReadOnly()); - Assert.assertTrue(item.getItemProperty("name2").isReadOnly()); + assertFalse(item.getItemProperty("name").isReadOnly()); + assertTrue(item.getItemProperty("name2").isReadOnly()); } @Test @@ -348,8 +350,8 @@ public class BeanItemTest { BeanItem<MyClass> item = constructor.newInstance(instance, propertyDescriptors); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals("bean1", item.getItemProperty("myname").getValue()); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals("bean1", item.getItemProperty("myname").getValue()); } @Test @@ -361,15 +363,15 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertEquals(6, item.getItemPropertyIds().size()); - Assert.assertEquals(null, item.getItemProperty("myname")); + assertEquals(6, item.getItemPropertyIds().size()); + assertEquals(null, item.getItemProperty("myname")); item.addItemProperty("myname", pd.createProperty(item.getBean())); - Assert.assertEquals(7, item.getItemPropertyIds().size()); - Assert.assertEquals("bean1", item.getItemProperty("myname").getValue()); + assertEquals(7, item.getItemPropertyIds().size()); + assertEquals("bean1", item.getItemProperty("myname").getValue()); item.removeItemProperty("myname"); - Assert.assertEquals(6, item.getItemPropertyIds().size()); - Assert.assertEquals(null, item.getItemProperty("myname")); + assertEquals(6, item.getItemPropertyIds().size()); + assertEquals(null, item.getItemProperty("myname")); } @Test @@ -377,11 +379,10 @@ public class BeanItemTest { BeanItem<SubClass> item = new BeanItem<SubClass>(new SubClass()); Property<?> property = item.getItemProperty("property"); - Assert.assertEquals("Unexpected class for property type", String.class, + assertEquals("Unexpected class for property type", String.class, property.getType()); - Assert.assertEquals("Unexpected property value", "", - property.getValue()); + assertEquals("Unexpected property value", "", property.getValue()); // Should not be exception property.setValue(null); @@ -392,7 +393,7 @@ public class BeanItemTest { BeanItem<MyClass> beanItem = new BeanItem<BeanItemTest.MyClass>( new MyClass("Foo")); beanItem.setBean(new MyClass("Bar")); - Assert.assertEquals("Bar", beanItem.getItemProperty("name").getValue()); + assertEquals("Bar", beanItem.getItemProperty("name").getValue()); } @Test @@ -400,7 +401,7 @@ public class BeanItemTest { BeanItem<MyClass> beanItem = new BeanItem<BeanItemTest.MyClass>( new MyClass("Foo")); beanItem.setBean(new MyClass("Bar")); - Assert.assertEquals("Bar", beanItem.getItemProperty("name").getValue()); + assertEquals("Bar", beanItem.getItemProperty("name").getValue()); } @Test(expected = IllegalArgumentException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java index c421750f87..f6444ce459 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertTrue; + import java.io.File; -import org.junit.Assert; import org.junit.Test; public class FileSystemContainerTest { @@ -11,6 +12,6 @@ public class FileSystemContainerTest { public void nonExistingDirectory() { FilesystemContainer fsc = new FilesystemContainer( new File("/non/existing")); - Assert.assertTrue(fsc.getItemIds().isEmpty()); + assertTrue(fsc.getItemIds().isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java index fb7cb06727..dfa537a98a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java @@ -532,7 +532,7 @@ public class GeneratedPropertyContainerBasicTest public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); - Assert.assertEquals( + assertEquals( "Container returned too many items when the range was >> container size", 1, ic.getItemIds(0, 10).size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java index 712a9b7047..79adeb8218 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java @@ -485,7 +485,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); - Assert.assertEquals( + assertEquals( "Container returned too many items when the range was >> container size", 1, ic.getItemIds(0, 10).size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java index 64a7c19b8f..d208dffa95 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java @@ -15,6 +15,9 @@ */ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,7 +26,6 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Field; -import org.junit.Assert; import org.junit.Test; /** @@ -52,12 +54,12 @@ public class MethodPropertyMemoryConsumptionTest { .getDeclaredField("setArgs"); setArgsField.setAccessible(true); - Assert.assertSame( + assertSame( "setArguments method sets non-default instance" + " of empty Object array for getArgs", getArgsField.get(property), getArgs); - Assert.assertSame( + assertSame( "setArguments method sets non-default instance" + " of empty Object array for setArgs", setArgsField.get(property), setArgs); @@ -75,11 +77,11 @@ public class MethodPropertyMemoryConsumptionTest { TestBean otherBean = new TestBean(); TestMethodProperty<String> otherProperty = new TestMethodProperty<String>( otherBean, "name"); - Assert.assertSame( + assertSame( "setArguments method uses different instance" + " of empty Object array for getArgs", getArgs, otherProperty.getGetArgs()); - Assert.assertSame( + assertSame( "setArguments method uses different instance" + " of empty Object array for setArgs", setArgs, otherProperty.getSetArgs()); @@ -101,9 +103,9 @@ public class MethodPropertyMemoryConsumptionTest { Object red = inputStream.readObject(); TestMethodProperty<?> deserialized = (TestMethodProperty<?>) red; - Assert.assertNotNull("Deseriliation doesn't call setArguments method", + assertNotNull("Deseriliation doesn't call setArguments method", deserialized.getGetArgs()); - Assert.assertNotNull("Deseriliation doesn't call setArguments method", + assertNotNull("Deseriliation doesn't call setArguments method", deserialized.getSetArgs()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java index 61c66b9167..5ef3d03a2e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.data.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -34,7 +35,7 @@ public class MethodPropertyTest { public void getValue() { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); - Assert.assertEquals("some street", mp.getValue()); + assertEquals("some street", mp.getValue()); } @Test @@ -42,7 +43,7 @@ public class MethodPropertyTest { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); testObject.setStreet("Foo street"); - Assert.assertEquals("Foo street", mp.getValue()); + assertEquals("Foo street", mp.getValue()); } @Test @@ -50,7 +51,7 @@ public class MethodPropertyTest { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); mp.setValue("Foo street"); - Assert.assertEquals("Foo street", testObject.getStreet()); + assertEquals("Foo street", testObject.getStreet()); } @Test @@ -59,8 +60,8 @@ public class MethodPropertyTest { "street"); Address newStreet = new Address("new street", 999); mp.setInstance(newStreet); - Assert.assertEquals("new street", mp.getValue()); - Assert.assertEquals("some street", testObject.getStreet()); + assertEquals("new street", mp.getValue()); + assertEquals("some street", testObject.getStreet()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java index 9a47e395e2..96065ae199 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; @@ -10,7 +13,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -140,8 +142,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> nameProperty = new NestedMethodProperty<String>( vaadin, "name"); - Assert.assertEquals(String.class, nameProperty.getType()); - Assert.assertEquals("Vaadin", nameProperty.getValue()); + assertEquals(String.class, nameProperty.getType()); + assertEquals("Vaadin", nameProperty.getValue()); } @Test @@ -149,8 +151,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Person> managerProperty = new NestedMethodProperty<Person>( vaadin, "manager"); - Assert.assertEquals(Person.class, managerProperty.getType()); - Assert.assertEquals(joonas, managerProperty.getValue()); + assertEquals(Person.class, managerProperty.getType()); + assertEquals(joonas, managerProperty.getValue()); } @Test @@ -168,26 +170,25 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>( vaadin, "manager.address.boolean"); - Assert.assertEquals(String.class, managerNameProperty.getType()); - Assert.assertEquals("Joonas", managerNameProperty.getValue()); + assertEquals(String.class, managerNameProperty.getType()); + assertEquals("Joonas", managerNameProperty.getValue()); - Assert.assertEquals(Address.class, addressProperty.getType()); - Assert.assertEquals(oldMill, addressProperty.getValue()); + assertEquals(Address.class, addressProperty.getType()); + assertEquals(oldMill, addressProperty.getValue()); - Assert.assertEquals(String.class, streetProperty.getType()); - Assert.assertEquals("Ruukinkatu 2-4", streetProperty.getValue()); + assertEquals(String.class, streetProperty.getType()); + assertEquals("Ruukinkatu 2-4", streetProperty.getValue()); - Assert.assertEquals(Integer.class, - postalCodePrimitiveProperty.getType()); - Assert.assertEquals(Integer.valueOf(20540), + assertEquals(Integer.class, postalCodePrimitiveProperty.getType()); + assertEquals(Integer.valueOf(20540), postalCodePrimitiveProperty.getValue()); - Assert.assertEquals(Integer.class, postalCodeObjectProperty.getType()); - Assert.assertEquals(Integer.valueOf(20540), + assertEquals(Integer.class, postalCodeObjectProperty.getType()); + assertEquals(Integer.valueOf(20540), postalCodeObjectProperty.getValue()); - Assert.assertEquals(Boolean.class, booleanProperty.getType()); - Assert.assertEquals(Boolean.TRUE, booleanProperty.getValue()); + assertEquals(Boolean.class, booleanProperty.getType()); + assertEquals(Boolean.TRUE, booleanProperty.getValue()); } @Test @@ -274,8 +275,8 @@ public class NestedMethodPropertyTest { assertNull(streetProperty.getValue()); vaadin.setManager(joonas); - Assert.assertEquals("Joonas", managerNameProperty.getValue()); - Assert.assertNull(streetProperty.getValue()); + assertEquals("Joonas", managerNameProperty.getValue()); + assertNull(streetProperty.getValue()); } @@ -293,20 +294,20 @@ public class NestedMethodPropertyTest { vaadin, "manager.address.postalCodeObject"); managerNameProperty.setValue("Joonas L"); - Assert.assertEquals("Joonas L", joonas.getName()); + assertEquals("Joonas L", joonas.getName()); streetProperty.setValue("Ruukinkatu"); - Assert.assertEquals("Ruukinkatu", oldMill.getStreet()); + assertEquals("Ruukinkatu", oldMill.getStreet()); postalCodePrimitiveProperty.setValue(0); postalCodeObjectProperty.setValue(1); - Assert.assertEquals(0, oldMill.getPostalCodePrimitive()); - Assert.assertEquals(Integer.valueOf(1), oldMill.getPostalCodeObject()); + assertEquals(0, oldMill.getPostalCodePrimitive()); + assertEquals(Integer.valueOf(1), oldMill.getPostalCodeObject()); postalCodeObjectProperty.setValue(null); - Assert.assertNull(oldMill.getPostalCodeObject()); + assertNull(oldMill.getPostalCodeObject()); Address address2 = new Address("Other street", 12345); addressProperty.setValue(address2); - Assert.assertEquals("Other street", streetProperty.getValue()); + assertEquals("Other street", streetProperty.getValue()); } @Test @@ -319,7 +320,7 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> property2 = (NestedMethodProperty<String>) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); - Assert.assertEquals("Ruukinkatu 2-4", property2.getValue()); + assertEquals("Ruukinkatu 2-4", property2.getValue()); } @Test @@ -334,7 +335,7 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> property2 = (NestedMethodProperty<String>) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); - Assert.assertNull(property2.getValue()); + assertNull(property2.getValue()); } @Test @@ -344,8 +345,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>( vaadin, "manager.address.boolean"); - Assert.assertFalse(streetProperty.isReadOnly()); - Assert.assertTrue(booleanProperty.isReadOnly()); + assertFalse(streetProperty.isReadOnly()); + assertTrue(booleanProperty.isReadOnly()); } @Test @@ -358,9 +359,9 @@ public class NestedMethodPropertyTest { Team someteam = new Team("The team", someone); streetProperty.setInstance(someteam); - Assert.assertEquals("The street", streetProperty.getValue()); - Assert.assertEquals("Ruukinkatu 2-4", vaadin.getManager().getAddress() - .getStreet()); + assertEquals("The street", streetProperty.getValue()); + assertEquals("Ruukinkatu 2-4", + vaadin.getManager().getAddress().getStreet()); } @Test(expected = IllegalArgumentException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java index 3e2cb5cc91..4484a2a584 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.data.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class ObjectPropertyTest { @@ -35,68 +36,68 @@ public class ObjectPropertyTest { public void testSimple() { ObjectProperty<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop1.getValue().getName()); + assertEquals("super1", prop1.getValue().getName()); prop1 = new ObjectProperty<TestSuperClass>(super1); - Assert.assertEquals("super1", prop1.getValue().getName()); + assertEquals("super1", prop1.getValue().getName()); ObjectProperty<TestSubClass> prop2 = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop2.getValue().getName()); + assertEquals("Subclass: sub1", prop2.getValue().getName()); prop2 = new ObjectProperty<TestSubClass>(sub1); - Assert.assertEquals("Subclass: sub1", prop2.getValue().getName()); + assertEquals("Subclass: sub1", prop2.getValue().getName()); } @Test public void testSetValueObjectSuper() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop.getValue().getName()); + assertEquals("super1", prop.getValue().getName()); prop.setValue(new TestSuperClass("super2")); - Assert.assertEquals("super1", super1.getName()); - Assert.assertEquals("super2", prop.getValue().getName()); + assertEquals("super1", super1.getName()); + assertEquals("super2", prop.getValue().getName()); } @Test public void testSetValueObjectSub() { ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals("Subclass: sub1", prop.getValue().getName()); prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub1", sub1.getName()); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub1", sub1.getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } @Test public void testSetValueStringSuper() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop.getValue().getName()); + assertEquals("super1", prop.getValue().getName()); prop.setValue(new TestSuperClass("super2")); - Assert.assertEquals("super1", super1.getName()); - Assert.assertEquals("super2", prop.getValue().getName()); + assertEquals("super1", super1.getName()); + assertEquals("super2", prop.getValue().getName()); } @Test public void testSetValueStringSub() { ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals("Subclass: sub1", prop.getValue().getName()); prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub1", sub1.getName()); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub1", sub1.getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } @Test public void testMixedGenerics() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( sub1); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); - Assert.assertEquals(prop.getType(), TestSubClass.class); + assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals(prop.getType(), TestSubClass.class); // create correct subclass based on the runtime type of the instance // given to ObjectProperty constructor, which is a subclass of the type // parameter prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java index 78ff4e9b9f..6491b9cc99 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java @@ -1,5 +1,7 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -7,7 +9,6 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; -import org.junit.Assert; import org.junit.Test; public class PerformanceTestIndexedContainerTest { @@ -109,8 +110,8 @@ public class PerformanceTestIndexedContainerTest { long median = median(times); System.out.println( methodName + " timings (ms) for " + items + " items: " + times); - Assert.assertTrue(methodName + " too slow, median time " + median - + "ms for " + items + " items", median <= threshold); + assertTrue(methodName + " too slow, median time " + median + "ms for " + + items + " items", median <= threshold); } private Long median(Collection<Long> times) { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java index 1dd603c328..19147fdef4 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.ByteArrayInputStream; @@ -7,7 +10,6 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property; @@ -38,7 +40,7 @@ public class PropertyDescriptorTest { Property<?> property = descriptor2 .createProperty(new Person("John", null)); - Assert.assertEquals("John", property.getValue()); + assertEquals("John", property.getValue()); } @Test @@ -54,7 +56,7 @@ public class PropertyDescriptorTest { new ByteArrayInputStream(baos.toByteArray())).readObject(); Property<?> property = pd2.createProperty(new Person("John", null)); - Assert.assertEquals("John", property.getValue()); + assertEquals("John", property.getValue()); } @Test @@ -69,7 +71,7 @@ public class PropertyDescriptorTest { new ByteArrayInputStream(baos.toByteArray())).readObject(); Property<?> property = pd2.createProperty(new Person("John", null)); - Assert.assertNull(property.getValue()); + assertNull(property.getValue()); } @Test @@ -79,6 +81,6 @@ public class PropertyDescriptorTest { "age", int.class, Person.class.getMethod("getAge"), Person.class.getMethod("setAge", int.class)); - Assert.assertEquals(Integer.class, pd.getPropertyType()); + assertEquals(Integer.class, pd.getPropertyType()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java index 0516c8ae9f..8f9adb3e0d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java @@ -1,10 +1,15 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,20 +62,20 @@ public class PropertySetItemTest { @Test public void testEmptyItem() { PropertysetItem item = createPropertySetItem(); - Assert.assertNotNull(item.getItemPropertyIds()); - Assert.assertEquals(0, item.getItemPropertyIds().size()); + assertNotNull(item.getItemPropertyIds()); + assertEquals(0, item.getItemPropertyIds().size()); } @Test public void testGetProperty() { PropertysetItem item = createPropertySetItem(); - Assert.assertNull(item.getItemProperty(ID1)); + assertNull(item.getItemProperty(ID1)); item.addItemProperty(ID1, prop1); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertNull(item.getItemProperty(ID2)); + assertEquals(prop1, item.getItemProperty(ID1)); + assertNull(item.getItemProperty(ID2)); } @Test @@ -78,10 +83,10 @@ public class PropertySetItemTest { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); - Assert.assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(1, item.getItemPropertyIds().size()); Object firstValue = item.getItemPropertyIds().iterator().next(); - Assert.assertEquals(ID1, firstValue); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(ID1, firstValue); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test @@ -89,16 +94,16 @@ public class PropertySetItemTest { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); item.addItemProperty(ID2, prop2); - Assert.assertEquals(2, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertEquals(prop2, item.getItemProperty(ID2)); + assertEquals(2, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(prop2, item.getItemProperty(ID2)); item.addItemProperty(ID3, prop3); - Assert.assertEquals(3, item.getItemPropertyIds().size()); + assertEquals(3, item.getItemPropertyIds().size()); } @Test @@ -109,32 +114,32 @@ public class PropertySetItemTest { item.addItemProperty(ID3, prop3); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals(ID1, it.next()); - Assert.assertEquals(ID2, it.next()); - Assert.assertEquals(ID3, it.next()); + assertEquals(ID1, it.next()); + assertEquals(ID2, it.next()); + assertEquals(ID3, it.next()); } @Test public void testAddPropertyTwice() { PropertysetItem item = createPropertySetItem(); - Assert.assertTrue(item.addItemProperty(ID1, prop1)); - Assert.assertFalse(item.addItemProperty(ID1, prop1)); + assertTrue(item.addItemProperty(ID1, prop1)); + assertFalse(item.addItemProperty(ID1, prop1)); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test public void testCannotChangeProperty() { PropertysetItem item = createPropertySetItem(); - Assert.assertTrue(item.addItemProperty(ID1, prop1)); + assertTrue(item.addItemProperty(ID1, prop1)); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertFalse(item.addItemProperty(ID1, prop2)); + assertFalse(item.addItemProperty(ID1, prop2)); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test @@ -143,8 +148,8 @@ public class PropertySetItemTest { item.addItemProperty(ID1, prop1); item.removeItemProperty(ID1); - Assert.assertEquals(0, item.getItemPropertyIds().size()); - Assert.assertNull(item.getItemProperty(ID1)); + assertEquals(0, item.getItemPropertyIds().size()); + assertNull(item.getItemProperty(ID1)); } @Test @@ -157,8 +162,8 @@ public class PropertySetItemTest { item.removeItemProperty(ID2); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals(ID1, it.next()); - Assert.assertEquals(ID3, it.next()); + assertEquals(ID1, it.next()); + assertEquals(ID3, it.next()); } @Test @@ -232,7 +237,7 @@ public class PropertySetItemTest { public void testItemEqualsNull() { PropertysetItem item = createPropertySetItem(); - Assert.assertFalse(item.equals(null)); + assertFalse(item.equals(null)); } @Test @@ -240,7 +245,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertTrue(item1.equals(item2)); + assertTrue(item1.equals(item2)); } @Test @@ -255,21 +260,21 @@ public class PropertySetItemTest { PropertysetItem item5 = createPropertySetItem(); item5.addItemProperty(ID2, prop2); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item1.equals(item3)); - Assert.assertFalse(item1.equals(item4)); - Assert.assertFalse(item1.equals(item5)); + assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item3)); + assertFalse(item1.equals(item4)); + assertFalse(item1.equals(item5)); - Assert.assertTrue(item2.equals(item3)); - Assert.assertFalse(item2.equals(item4)); - Assert.assertFalse(item2.equals(item5)); + assertTrue(item2.equals(item3)); + assertFalse(item2.equals(item4)); + assertFalse(item2.equals(item5)); - Assert.assertFalse(item3.equals(item4)); - Assert.assertFalse(item3.equals(item5)); + assertFalse(item3.equals(item4)); + assertFalse(item3.equals(item5)); - Assert.assertFalse(item4.equals(item5)); + assertFalse(item4.equals(item5)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item2.equals(item1)); } @Test @@ -285,9 +290,9 @@ public class PropertySetItemTest { item3.addItemProperty(ID1, prop1); item3.addItemProperty(ID2, prop2); - Assert.assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item2)); - Assert.assertTrue(item2.equals(item3)); + assertTrue(item2.equals(item3)); } @Test @@ -300,7 +305,7 @@ public class PropertySetItemTest { item2.addItemProperty(ID2, prop2); item2.addItemProperty(ID1, prop1); - Assert.assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item2)); } @Test @@ -310,13 +315,13 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item1.equals(item2)); + assertFalse(item2.equals(item1)); item2.addListener(propertySetListenerMock); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -329,13 +334,13 @@ public class PropertySetItemTest { item2.addListener(propertySetListenerMock); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item1.equals(item2)); + assertFalse(item2.equals(item1)); item2.addListener(propertySetListenerMock2); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -346,8 +351,8 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); item1.removeListener(propertySetListenerMock); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -355,7 +360,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -363,7 +368,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); item1.addItemProperty(ID1, prop1); item1.addItemProperty(ID2, prop2); @@ -372,7 +377,7 @@ public class PropertySetItemTest { item2.addItemProperty(ID1, prop1); item2.addItemProperty(ID2, prop2); // but here hashCodes must be equal - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -380,14 +385,14 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); item1.addListener(propertySetListenerMock); // hashCodes can be equal even if items are different item2.addListener(propertySetListenerMock); // but here hashCodes must be equal - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -398,7 +403,7 @@ public class PropertySetItemTest { item1.addItemProperty(ID1, prop1); item1.removeItemProperty(ID1); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -409,7 +414,7 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); item1.removeListener(propertySetListenerMock); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -417,15 +422,15 @@ public class PropertySetItemTest { // toString() behavior is specified in the class javadoc PropertysetItem item = createPropertySetItem(); - Assert.assertEquals("", item.toString()); + assertEquals("", item.toString()); item.addItemProperty(ID1, prop1); - Assert.assertEquals(String.valueOf(prop1.getValue()), item.toString()); + assertEquals(String.valueOf(prop1.getValue()), item.toString()); item.addItemProperty(ID2, prop2); - Assert.assertEquals(String.valueOf(prop1.getValue()) + " " + assertEquals(String.valueOf(prop1.getValue()) + " " + String.valueOf(prop2.getValue()), item.toString()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java index 7120a429fc..432b264e84 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java @@ -6,10 +6,7 @@ import com.vaadin.v7.data.Property; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.data.util.PropertysetItem; -import junit.framework.TestCase; - -public abstract class AbstractFilterTestBase<FILTERTYPE extends Filter> - extends TestCase { +public abstract class AbstractFilterTestBase<FILTERTYPE extends Filter> { protected static final String PROPERTY1 = "property1"; protected static final String PROPERTY2 = "property2"; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java index 827da03790..ecdbcfaa40 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -17,15 +20,15 @@ public class AndOrFilterTest public void testNoFilterAnd() { Filter filter = new And(); - Assert.assertTrue(filter.passesFilter(null, item1)); + assertTrue(filter.passesFilter(null, item1)); } @Test public void testSingleFilterAnd() { Filter filter = new And(new SameItemFilter(item1)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); } @Test @@ -35,11 +38,11 @@ public class AndOrFilterTest Filter filter2 = new And(new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertFalse(filter2.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertFalse(filter2.passesFilter(null, item2)); } @Test @@ -49,26 +52,26 @@ public class AndOrFilterTest Filter filter2 = new And(new SameItemFilter(item1), new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertFalse(filter2.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertFalse(filter2.passesFilter(null, item2)); } @Test public void testNoFilterOr() { Filter filter = new Or(); - Assert.assertFalse(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item1)); } @Test public void testSingleFilterOr() { Filter filter = new Or(new SameItemFilter(item1)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); } @Test @@ -78,11 +81,11 @@ public class AndOrFilterTest Filter filter2 = new Or(new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertTrue(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -92,11 +95,11 @@ public class AndOrFilterTest Filter filter2 = new Or(new SameItemFilter(item1), new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertTrue(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -115,28 +118,28 @@ public class AndOrFilterTest Filter other0 = new Or(); Filter other1 = new Or(new SameItemFilter(item1)); - Assert.assertEquals(filter0, filter0); - Assert.assertEquals(filter0, filter0b); - Assert.assertFalse(filter0.equals(filter1a)); - Assert.assertFalse(filter0.equals(other0)); - Assert.assertFalse(filter0.equals(other1)); + assertEquals(filter0, filter0); + assertEquals(filter0, filter0b); + assertFalse(filter0.equals(filter1a)); + assertFalse(filter0.equals(other0)); + assertFalse(filter0.equals(other1)); - Assert.assertFalse(filter1a.equals(filter1b)); - Assert.assertFalse(filter1a.equals(other1)); + assertFalse(filter1a.equals(filter1b)); + assertFalse(filter1a.equals(other1)); - Assert.assertFalse(filter1a.equals(filter2a)); - Assert.assertFalse(filter2a.equals(filter1a)); + assertFalse(filter1a.equals(filter2a)); + assertFalse(filter2a.equals(filter1a)); - Assert.assertFalse(filter2a.equals(filter2b)); - Assert.assertEquals(filter2b, filter2b2); + assertFalse(filter2a.equals(filter2b)); + assertEquals(filter2b, filter2b2); // hashCode() - Assert.assertEquals(filter0.hashCode(), filter0.hashCode()); - Assert.assertEquals(filter0.hashCode(), filter0b.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a2.hashCode()); - Assert.assertEquals(filter2a.hashCode(), filter2a.hashCode()); - Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); + assertEquals(filter0.hashCode(), filter0.hashCode()); + assertEquals(filter0.hashCode(), filter0b.hashCode()); + assertEquals(filter1a.hashCode(), filter1a.hashCode()); + assertEquals(filter1a.hashCode(), filter1a2.hashCode()); + assertEquals(filter2a.hashCode(), filter2a.hashCode()); + assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } @Test @@ -155,28 +158,28 @@ public class AndOrFilterTest Filter other0 = new And(); Filter other1 = new And(new SameItemFilter(item1)); - Assert.assertEquals(filter0, filter0); - Assert.assertEquals(filter0, filter0b); - Assert.assertFalse(filter0.equals(filter1a)); - Assert.assertFalse(filter0.equals(other0)); - Assert.assertFalse(filter0.equals(other1)); + assertEquals(filter0, filter0); + assertEquals(filter0, filter0b); + assertFalse(filter0.equals(filter1a)); + assertFalse(filter0.equals(other0)); + assertFalse(filter0.equals(other1)); - Assert.assertFalse(filter1a.equals(filter1b)); - Assert.assertFalse(filter1a.equals(other1)); + assertFalse(filter1a.equals(filter1b)); + assertFalse(filter1a.equals(other1)); - Assert.assertFalse(filter1a.equals(filter2a)); - Assert.assertFalse(filter2a.equals(filter1a)); + assertFalse(filter1a.equals(filter2a)); + assertFalse(filter2a.equals(filter1a)); - Assert.assertFalse(filter2a.equals(filter2b)); - Assert.assertEquals(filter2b, filter2b2); + assertFalse(filter2a.equals(filter2b)); + assertEquals(filter2b, filter2b2); // hashCode() - Assert.assertEquals(filter0.hashCode(), filter0.hashCode()); - Assert.assertEquals(filter0.hashCode(), filter0b.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a2.hashCode()); - Assert.assertEquals(filter2a.hashCode(), filter2a.hashCode()); - Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); + assertEquals(filter0.hashCode(), filter0.hashCode()); + assertEquals(filter0.hashCode(), filter0b.hashCode()); + assertEquals(filter1a.hashCode(), filter1a.hashCode()); + assertEquals(filter1a.hashCode(), filter1a2.hashCode()); + assertEquals(filter2a.hashCode(), filter2a.hashCode()); + assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } @Test @@ -192,23 +195,23 @@ public class AndOrFilterTest new SameItemFilter(item1, "b"), new SameItemFilter(item1, "c")); // empty And does not filter out anything - Assert.assertFalse(filter0.appliesToProperty("a")); - Assert.assertFalse(filter0.appliesToProperty("d")); - - Assert.assertTrue(filter1a.appliesToProperty("a")); - Assert.assertFalse(filter1a.appliesToProperty("b")); - Assert.assertFalse(filter1b.appliesToProperty("a")); - Assert.assertTrue(filter1b.appliesToProperty("b")); - - Assert.assertTrue(filter2aa.appliesToProperty("a")); - Assert.assertFalse(filter2aa.appliesToProperty("b")); - Assert.assertTrue(filter2ab.appliesToProperty("a")); - Assert.assertTrue(filter2ab.appliesToProperty("b")); - - Assert.assertTrue(filter3abc.appliesToProperty("a")); - Assert.assertTrue(filter3abc.appliesToProperty("b")); - Assert.assertTrue(filter3abc.appliesToProperty("c")); - Assert.assertFalse(filter3abc.appliesToProperty("d")); + assertFalse(filter0.appliesToProperty("a")); + assertFalse(filter0.appliesToProperty("d")); + + assertTrue(filter1a.appliesToProperty("a")); + assertFalse(filter1a.appliesToProperty("b")); + assertFalse(filter1b.appliesToProperty("a")); + assertTrue(filter1b.appliesToProperty("b")); + + assertTrue(filter2aa.appliesToProperty("a")); + assertFalse(filter2aa.appliesToProperty("b")); + assertTrue(filter2ab.appliesToProperty("a")); + assertTrue(filter2ab.appliesToProperty("b")); + + assertTrue(filter3abc.appliesToProperty("a")); + assertTrue(filter3abc.appliesToProperty("b")); + assertTrue(filter3abc.appliesToProperty("c")); + assertFalse(filter3abc.appliesToProperty("d")); } @Test @@ -224,23 +227,23 @@ public class AndOrFilterTest new SameItemFilter(item1, "b"), new SameItemFilter(item1, "c")); // empty Or filters out everything - Assert.assertTrue(filter0.appliesToProperty("a")); - Assert.assertTrue(filter0.appliesToProperty("d")); - - Assert.assertTrue(filter1a.appliesToProperty("a")); - Assert.assertFalse(filter1a.appliesToProperty("b")); - Assert.assertFalse(filter1b.appliesToProperty("a")); - Assert.assertTrue(filter1b.appliesToProperty("b")); - - Assert.assertTrue(filter2aa.appliesToProperty("a")); - Assert.assertFalse(filter2aa.appliesToProperty("b")); - Assert.assertTrue(filter2ab.appliesToProperty("a")); - Assert.assertTrue(filter2ab.appliesToProperty("b")); - - Assert.assertTrue(filter3abc.appliesToProperty("a")); - Assert.assertTrue(filter3abc.appliesToProperty("b")); - Assert.assertTrue(filter3abc.appliesToProperty("c")); - Assert.assertFalse(filter3abc.appliesToProperty("d")); + assertTrue(filter0.appliesToProperty("a")); + assertTrue(filter0.appliesToProperty("d")); + + assertTrue(filter1a.appliesToProperty("a")); + assertFalse(filter1a.appliesToProperty("b")); + assertFalse(filter1b.appliesToProperty("a")); + assertTrue(filter1b.appliesToProperty("b")); + + assertTrue(filter2aa.appliesToProperty("a")); + assertFalse(filter2aa.appliesToProperty("b")); + assertTrue(filter2ab.appliesToProperty("a")); + assertTrue(filter2ab.appliesToProperty("b")); + + assertTrue(filter3abc.appliesToProperty("a")); + assertTrue(filter3abc.appliesToProperty("b")); + assertTrue(filter3abc.appliesToProperty("c")); + assertFalse(filter3abc.appliesToProperty("d")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java index 89e9d08cda..8e0e88ad58 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java @@ -1,9 +1,13 @@ package com.vaadin.v7.data.util.filter; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Assert; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -37,10 +41,8 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { protected Filter greaterEqualCompSqlDate; protected Filter lessEqualCompSqlDate; - @Override - protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() throws Exception { equalCompUtilDate = new Equal(PROPERTY1, formatter.parse("26072016")); greaterCompUtilDate = new Greater(PROPERTY1, formatter.parse("26072016")); @@ -78,9 +80,8 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { java.sql.Date.class)); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { itemNullUtilDate = null; itemNullSqlDate = null; itemUtilDate = null; @@ -89,54 +90,42 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { @Test public void testCompareUtilDatesAndUtilDates() { - Assert.assertFalse( - equalCompUtilDate.passesFilter(null, itemNullUtilDate)); - Assert.assertFalse(equalCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue(lessCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterEqualCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue( - lessEqualCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemNullUtilDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterCompUtilDate.passesFilter(null, itemUtilDate)); + assertTrue(lessCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterEqualCompUtilDate.passesFilter(null, itemUtilDate)); + assertTrue(lessEqualCompUtilDate.passesFilter(null, itemUtilDate)); } @Test public void testCompareUtilDatesAndSqlDates() { - Assert.assertFalse( - equalCompUtilDate.passesFilter(null, itemNullSqlDate)); - Assert.assertFalse(equalCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse(greaterCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse( - greaterEqualCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue( - lessEqualCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemNullSqlDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterCompUtilDate.passesFilter(null, itemSqlDate)); + assertTrue(lessCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterEqualCompUtilDate.passesFilter(null, itemSqlDate)); + assertTrue(lessEqualCompUtilDate.passesFilter(null, itemSqlDate)); } @Test public void testCompareSqlDatesAndSqlDates() { - Assert.assertFalse( - equalCompSqlDate.passesFilter(null, itemNullSqlDate)); - Assert.assertFalse(equalCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse(greaterCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse( - greaterEqualCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessEqualCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemNullSqlDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterCompSqlDate.passesFilter(null, itemSqlDate)); + assertTrue(lessCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterEqualCompSqlDate.passesFilter(null, itemSqlDate)); + assertTrue(lessEqualCompSqlDate.passesFilter(null, itemSqlDate)); } @Test public void testCompareSqlDatesAndUtilDates() { - Assert.assertFalse( - equalCompSqlDate.passesFilter(null, itemNullUtilDate)); - Assert.assertFalse(equalCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse(greaterCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue(lessCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterEqualCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue( - lessEqualCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemNullUtilDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterCompSqlDate.passesFilter(null, itemUtilDate)); + assertTrue(lessCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterEqualCompSqlDate.passesFilter(null, itemUtilDate)); + assertTrue(lessEqualCompSqlDate.passesFilter(null, itemUtilDate)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java index b93c72e37e..be0eeebb33 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java @@ -1,9 +1,14 @@ package com.vaadin.v7.data.util.filter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; import java.util.Date; -import org.junit.Assert; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -37,9 +42,8 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { null); protected final Filter lessEqualNull = new LessOrEqual(PROPERTY1, null); - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { itemNull = new PropertysetItem(); itemNull.addItemProperty(PROPERTY1, new ObjectProperty<String>(null, String.class)); @@ -57,9 +61,8 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<String>("c", String.class)); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { itemNull = null; itemEmpty = null; itemA = null; @@ -68,52 +71,52 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { @Test public void testCompareString() { - Assert.assertFalse(equalB.passesFilter(null, itemEmpty)); - Assert.assertFalse(equalB.passesFilter(null, itemA)); - Assert.assertTrue(equalB.passesFilter(null, itemB)); - Assert.assertFalse(equalB.passesFilter(null, itemC)); - - Assert.assertFalse(greaterB.passesFilter(null, itemEmpty)); - Assert.assertFalse(greaterB.passesFilter(null, itemA)); - Assert.assertFalse(greaterB.passesFilter(null, itemB)); - Assert.assertTrue(greaterB.passesFilter(null, itemC)); - - Assert.assertTrue(lessB.passesFilter(null, itemEmpty)); - Assert.assertTrue(lessB.passesFilter(null, itemA)); - Assert.assertFalse(lessB.passesFilter(null, itemB)); - Assert.assertFalse(lessB.passesFilter(null, itemC)); - - Assert.assertFalse(greaterEqualB.passesFilter(null, itemEmpty)); - Assert.assertFalse(greaterEqualB.passesFilter(null, itemA)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemB)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemC)); - - Assert.assertTrue(lessEqualB.passesFilter(null, itemEmpty)); - Assert.assertTrue(lessEqualB.passesFilter(null, itemA)); - Assert.assertTrue(lessEqualB.passesFilter(null, itemB)); - Assert.assertFalse(lessEqualB.passesFilter(null, itemC)); + assertFalse(equalB.passesFilter(null, itemEmpty)); + assertFalse(equalB.passesFilter(null, itemA)); + assertTrue(equalB.passesFilter(null, itemB)); + assertFalse(equalB.passesFilter(null, itemC)); + + assertFalse(greaterB.passesFilter(null, itemEmpty)); + assertFalse(greaterB.passesFilter(null, itemA)); + assertFalse(greaterB.passesFilter(null, itemB)); + assertTrue(greaterB.passesFilter(null, itemC)); + + assertTrue(lessB.passesFilter(null, itemEmpty)); + assertTrue(lessB.passesFilter(null, itemA)); + assertFalse(lessB.passesFilter(null, itemB)); + assertFalse(lessB.passesFilter(null, itemC)); + + assertFalse(greaterEqualB.passesFilter(null, itemEmpty)); + assertFalse(greaterEqualB.passesFilter(null, itemA)); + assertTrue(greaterEqualB.passesFilter(null, itemB)); + assertTrue(greaterEqualB.passesFilter(null, itemC)); + + assertTrue(lessEqualB.passesFilter(null, itemEmpty)); + assertTrue(lessEqualB.passesFilter(null, itemA)); + assertTrue(lessEqualB.passesFilter(null, itemB)); + assertFalse(lessEqualB.passesFilter(null, itemC)); } @Test public void testCompareWithNull() { // null comparisons: null is less than any other value - Assert.assertFalse(equalB.passesFilter(null, itemNull)); - Assert.assertTrue(greaterB.passesFilter(null, itemNull)); - Assert.assertFalse(lessB.passesFilter(null, itemNull)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemNull)); - Assert.assertFalse(lessEqualB.passesFilter(null, itemNull)); - - Assert.assertTrue(equalNull.passesFilter(null, itemNull)); - Assert.assertFalse(greaterNull.passesFilter(null, itemNull)); - Assert.assertFalse(lessNull.passesFilter(null, itemNull)); - Assert.assertTrue(greaterEqualNull.passesFilter(null, itemNull)); - Assert.assertTrue(lessEqualNull.passesFilter(null, itemNull)); - - Assert.assertFalse(equalNull.passesFilter(null, itemA)); - Assert.assertFalse(greaterNull.passesFilter(null, itemA)); - Assert.assertTrue(lessNull.passesFilter(null, itemA)); - Assert.assertFalse(greaterEqualNull.passesFilter(null, itemA)); - Assert.assertTrue(lessEqualNull.passesFilter(null, itemA)); + assertFalse(equalB.passesFilter(null, itemNull)); + assertTrue(greaterB.passesFilter(null, itemNull)); + assertFalse(lessB.passesFilter(null, itemNull)); + assertTrue(greaterEqualB.passesFilter(null, itemNull)); + assertFalse(lessEqualB.passesFilter(null, itemNull)); + + assertTrue(equalNull.passesFilter(null, itemNull)); + assertFalse(greaterNull.passesFilter(null, itemNull)); + assertFalse(lessNull.passesFilter(null, itemNull)); + assertTrue(greaterEqualNull.passesFilter(null, itemNull)); + assertTrue(lessEqualNull.passesFilter(null, itemNull)); + + assertFalse(equalNull.passesFilter(null, itemA)); + assertFalse(greaterNull.passesFilter(null, itemA)); + assertTrue(lessNull.passesFilter(null, itemA)); + assertFalse(greaterEqualNull.passesFilter(null, itemA)); + assertTrue(lessEqualNull.passesFilter(null, itemA)); } @Test @@ -133,29 +136,29 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<Integer>(positive, Integer.class)); Filter equalZero = new Equal(PROPERTY1, zero); - Assert.assertFalse(equalZero.passesFilter(null, itemNegative)); - Assert.assertTrue(equalZero.passesFilter(null, itemZero)); - Assert.assertFalse(equalZero.passesFilter(null, itemPositive)); + assertFalse(equalZero.passesFilter(null, itemNegative)); + assertTrue(equalZero.passesFilter(null, itemZero)); + assertFalse(equalZero.passesFilter(null, itemPositive)); Filter isPositive = new Greater(PROPERTY1, zero); - Assert.assertFalse(isPositive.passesFilter(null, itemNegative)); - Assert.assertFalse(isPositive.passesFilter(null, itemZero)); - Assert.assertTrue(isPositive.passesFilter(null, itemPositive)); + assertFalse(isPositive.passesFilter(null, itemNegative)); + assertFalse(isPositive.passesFilter(null, itemZero)); + assertTrue(isPositive.passesFilter(null, itemPositive)); Filter isNegative = new Less(PROPERTY1, zero); - Assert.assertTrue(isNegative.passesFilter(null, itemNegative)); - Assert.assertFalse(isNegative.passesFilter(null, itemZero)); - Assert.assertFalse(isNegative.passesFilter(null, itemPositive)); + assertTrue(isNegative.passesFilter(null, itemNegative)); + assertFalse(isNegative.passesFilter(null, itemZero)); + assertFalse(isNegative.passesFilter(null, itemPositive)); Filter isNonNegative = new GreaterOrEqual(PROPERTY1, zero); - Assert.assertFalse(isNonNegative.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemZero)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemPositive)); + assertFalse(isNonNegative.passesFilter(null, itemNegative)); + assertTrue(isNonNegative.passesFilter(null, itemZero)); + assertTrue(isNonNegative.passesFilter(null, itemPositive)); Filter isNonPositive = new LessOrEqual(PROPERTY1, zero); - Assert.assertTrue(isNonPositive.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonPositive.passesFilter(null, itemZero)); - Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive)); + assertTrue(isNonPositive.passesFilter(null, itemNegative)); + assertTrue(isNonPositive.passesFilter(null, itemZero)); + assertFalse(isNonPositive.passesFilter(null, itemPositive)); } @Test @@ -181,35 +184,33 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { BigDecimal.class)); Filter equalZero = new Equal(PROPERTY1, zero); - Assert.assertFalse(equalZero.passesFilter(null, itemNegative)); - Assert.assertTrue(equalZero.passesFilter(null, itemZero)); - Assert.assertFalse(equalZero.passesFilter(null, itemPositive)); + assertFalse(equalZero.passesFilter(null, itemNegative)); + assertTrue(equalZero.passesFilter(null, itemZero)); + assertFalse(equalZero.passesFilter(null, itemPositive)); Filter isPositive = new Greater(PROPERTY1, zero); - Assert.assertFalse(isPositive.passesFilter(null, itemNegative)); - Assert.assertFalse(isPositive.passesFilter(null, itemZero)); - Assert.assertTrue(isPositive.passesFilter(null, itemPositive)); + assertFalse(isPositive.passesFilter(null, itemNegative)); + assertFalse(isPositive.passesFilter(null, itemZero)); + assertTrue(isPositive.passesFilter(null, itemPositive)); Filter isNegative = new Less(PROPERTY1, zero); - Assert.assertTrue(isNegative.passesFilter(null, itemNegative)); - Assert.assertFalse(isNegative.passesFilter(null, itemZero)); - Assert.assertFalse(isNegative.passesFilter(null, itemPositive)); + assertTrue(isNegative.passesFilter(null, itemNegative)); + assertFalse(isNegative.passesFilter(null, itemZero)); + assertFalse(isNegative.passesFilter(null, itemPositive)); Filter isNonNegative = new GreaterOrEqual(PROPERTY1, zero); - Assert.assertFalse(isNonNegative.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemZero)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemPositive)); + assertFalse(isNonNegative.passesFilter(null, itemNegative)); + assertTrue(isNonNegative.passesFilter(null, itemZero)); + assertTrue(isNonNegative.passesFilter(null, itemPositive)); Filter isNonPositive = new LessOrEqual(PROPERTY1, zero); - Assert.assertTrue(isNonPositive.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonPositive.passesFilter(null, itemZero)); - Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive)); + assertTrue(isNonPositive.passesFilter(null, itemNegative)); + assertTrue(isNonPositive.passesFilter(null, itemZero)); + assertFalse(isNonPositive.passesFilter(null, itemPositive)); Filter isPositiveScaleTwo = new Equal(PROPERTY1, positiveScaleTwo); - Assert.assertTrue( - isPositiveScaleTwo.passesFilter(null, itemPositiveScaleTwo)); - Assert.assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositive)); - + assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositiveScaleTwo)); + assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositive)); } @Test @@ -231,29 +232,29 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<Date>(later, Date.class)); Filter equalNow = new Equal(PROPERTY1, now); - Assert.assertFalse(equalNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(equalNow.passesFilter(null, itemNow)); - Assert.assertFalse(equalNow.passesFilter(null, itemLater)); + assertFalse(equalNow.passesFilter(null, itemEarlier)); + assertTrue(equalNow.passesFilter(null, itemNow)); + assertFalse(equalNow.passesFilter(null, itemLater)); Filter after = new Greater(PROPERTY1, now); - Assert.assertFalse(after.passesFilter(null, itemEarlier)); - Assert.assertFalse(after.passesFilter(null, itemNow)); - Assert.assertTrue(after.passesFilter(null, itemLater)); + assertFalse(after.passesFilter(null, itemEarlier)); + assertFalse(after.passesFilter(null, itemNow)); + assertTrue(after.passesFilter(null, itemLater)); Filter before = new Less(PROPERTY1, now); - Assert.assertTrue(before.passesFilter(null, itemEarlier)); - Assert.assertFalse(before.passesFilter(null, itemNow)); - Assert.assertFalse(before.passesFilter(null, itemLater)); + assertTrue(before.passesFilter(null, itemEarlier)); + assertFalse(before.passesFilter(null, itemNow)); + assertFalse(before.passesFilter(null, itemLater)); Filter afterOrNow = new GreaterOrEqual(PROPERTY1, now); - Assert.assertFalse(afterOrNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(afterOrNow.passesFilter(null, itemNow)); - Assert.assertTrue(afterOrNow.passesFilter(null, itemLater)); + assertFalse(afterOrNow.passesFilter(null, itemEarlier)); + assertTrue(afterOrNow.passesFilter(null, itemNow)); + assertTrue(afterOrNow.passesFilter(null, itemLater)); Filter beforeOrNow = new LessOrEqual(PROPERTY1, now); - Assert.assertTrue(beforeOrNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(beforeOrNow.passesFilter(null, itemNow)); - Assert.assertFalse(beforeOrNow.passesFilter(null, itemLater)); + assertTrue(beforeOrNow.passesFilter(null, itemEarlier)); + assertTrue(beforeOrNow.passesFilter(null, itemNow)); + assertFalse(beforeOrNow.passesFilter(null, itemLater)); } @Test @@ -261,10 +262,10 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { Filter filterA = new Equal("a", 1); Filter filterB = new Equal("b", 1); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -282,41 +283,41 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { Filter greaterEmpty = new Greater(PROPERTY1, ""); // equals() - Assert.assertEquals(equalNull, equalNull); - Assert.assertEquals(equalNull, equalNull2); - Assert.assertFalse(equalNull.equals(equalNullProperty2)); - Assert.assertFalse(equalNull.equals(equalEmpty)); - Assert.assertFalse(equalNull.equals(equalB)); - - Assert.assertEquals(equalEmpty, equalEmpty); - Assert.assertFalse(equalEmpty.equals(equalNull)); - Assert.assertEquals(equalEmpty, equalEmpty2); - Assert.assertFalse(equalEmpty.equals(equalEmptyProperty2)); - Assert.assertFalse(equalEmpty.equals(equalB)); - - Assert.assertEquals(equalB, equalB); - Assert.assertFalse(equalB.equals(equalNull)); - Assert.assertFalse(equalB.equals(equalEmpty)); - Assert.assertEquals(equalB, equalB2); - Assert.assertFalse(equalB.equals(equalBProperty2)); - Assert.assertFalse(equalB.equals(equalA)); - - Assert.assertEquals(greaterB, greaterB); - Assert.assertFalse(greaterB.equals(lessB)); - Assert.assertFalse(greaterB.equals(greaterEqualB)); - Assert.assertFalse(greaterB.equals(lessEqualB)); - - Assert.assertFalse(greaterNull.equals(greaterEmpty)); - Assert.assertFalse(greaterNull.equals(greaterB)); - Assert.assertFalse(greaterEmpty.equals(greaterNull)); - Assert.assertFalse(greaterEmpty.equals(greaterB)); - Assert.assertFalse(greaterB.equals(greaterNull)); - Assert.assertFalse(greaterB.equals(greaterEmpty)); + assertEquals(equalNull, equalNull); + assertEquals(equalNull, equalNull2); + assertFalse(equalNull.equals(equalNullProperty2)); + assertFalse(equalNull.equals(equalEmpty)); + assertFalse(equalNull.equals(equalB)); + + assertEquals(equalEmpty, equalEmpty); + assertFalse(equalEmpty.equals(equalNull)); + assertEquals(equalEmpty, equalEmpty2); + assertFalse(equalEmpty.equals(equalEmptyProperty2)); + assertFalse(equalEmpty.equals(equalB)); + + assertEquals(equalB, equalB); + assertFalse(equalB.equals(equalNull)); + assertFalse(equalB.equals(equalEmpty)); + assertEquals(equalB, equalB2); + assertFalse(equalB.equals(equalBProperty2)); + assertFalse(equalB.equals(equalA)); + + assertEquals(greaterB, greaterB); + assertFalse(greaterB.equals(lessB)); + assertFalse(greaterB.equals(greaterEqualB)); + assertFalse(greaterB.equals(lessEqualB)); + + assertFalse(greaterNull.equals(greaterEmpty)); + assertFalse(greaterNull.equals(greaterB)); + assertFalse(greaterEmpty.equals(greaterNull)); + assertFalse(greaterEmpty.equals(greaterB)); + assertFalse(greaterB.equals(greaterNull)); + assertFalse(greaterB.equals(greaterEmpty)); // hashCode() - Assert.assertEquals(equalNull.hashCode(), equalNull2.hashCode()); - Assert.assertEquals(equalEmpty.hashCode(), equalEmpty2.hashCode()); - Assert.assertEquals(equalB.hashCode(), equalB2.hashCode()); + assertEquals(equalNull.hashCode(), equalNull2.hashCode()); + assertEquals(equalEmpty.hashCode(), equalEmpty2.hashCode()); + assertEquals(equalB.hashCode(), equalB2.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java index 1b5705ea45..68e164fbb5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -26,10 +29,10 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filter1 = new IsNull("a"); Filter filter2 = new IsNull("b"); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -37,10 +40,10 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filterA = new IsNull("a"); Filter filterB = new IsNull("b"); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -50,12 +53,12 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filter2 = new IsNull("b"); // equals() - Assert.assertEquals(filter1, filter1b); - Assert.assertFalse(filter1.equals(filter2)); - Assert.assertFalse(filter1.equals(new And())); + assertEquals(filter1, filter1b); + assertFalse(filter1.equals(filter2)); + assertFalse(filter1.equals(new And())); // hashCode() - Assert.assertEquals(filter1.hashCode(), filter1b.hashCode()); + assertEquals(filter1.hashCode(), filter1b.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java index cac985f359..9d622b4ecb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java @@ -16,7 +16,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Item; @@ -31,7 +33,6 @@ public class LikeFilterTest extends AbstractFilterTestBase<Like> { @Test public void testLikeWithNulls() { - Like filter = new Like("value", "a"); item1.addItemProperty("value", new ObjectProperty<String>("a")); @@ -39,10 +40,9 @@ public class LikeFilterTest extends AbstractFilterTestBase<Like> { item3.addItemProperty("value", new ObjectProperty<String>(null, String.class)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); - Assert.assertFalse(filter.passesFilter(null, item3)); - + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); + assertFalse(filter.passesFilter(null, item3)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java index cdf51abe5a..8a91edca11 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -17,10 +20,10 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter origFilter = new SameItemFilter(item1); Filter filter = new Not(origFilter); - Assert.assertTrue(origFilter.passesFilter(null, item1)); - Assert.assertFalse(origFilter.passesFilter(null, item2)); - Assert.assertFalse(filter.passesFilter(null, item1)); - Assert.assertTrue(filter.passesFilter(null, item2)); + assertTrue(origFilter.passesFilter(null, item1)); + assertFalse(origFilter.passesFilter(null, item2)); + assertFalse(filter.passesFilter(null, item1)); + assertTrue(filter.passesFilter(null, item2)); } @Test @@ -28,10 +31,10 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter filterA = new Not(new SameItemFilter(item1, "a")); Filter filterB = new Not(new SameItemFilter(item1, "b")); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -42,13 +45,13 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter filter2 = new Not(new SameItemFilter(item2)); // equals() - Assert.assertEquals(filter1, filter1b); - Assert.assertFalse(filter1.equals(filter2)); - Assert.assertFalse(filter1.equals(origFilter)); - Assert.assertFalse(filter1.equals(new And())); + assertEquals(filter1, filter1b); + assertFalse(filter1.equals(filter2)); + assertFalse(filter1.equals(origFilter)); + assertFalse(filter1.equals(new And())); // hashCode() - Assert.assertEquals(filter1.hashCode(), filter1b.hashCode()); + assertEquals(filter1.hashCode(), filter1b.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java index cf0af5fe7b..97da946cb3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class SimpleStringFilterTest @@ -28,50 +31,50 @@ public class SimpleStringFilterTest @Test public void testStartsWithCaseSensitive() { - Assert.assertTrue(passes(PROPERTY1, "ab", false, true)); - Assert.assertTrue(passes(PROPERTY1, "", false, true)); + assertTrue(passes(PROPERTY1, "ab", false, true)); + assertTrue(passes(PROPERTY1, "", false, true)); - Assert.assertFalse(passes(PROPERTY2, "ab", false, true)); - Assert.assertFalse(passes(PROPERTY1, "AB", false, true)); + assertFalse(passes(PROPERTY2, "ab", false, true)); + assertFalse(passes(PROPERTY1, "AB", false, true)); } @Test public void testStartsWithCaseInsensitive() { - Assert.assertTrue(passes(PROPERTY1, "AB", true, true)); - Assert.assertTrue(passes(PROPERTY2, "te", true, true)); - Assert.assertFalse(passes(PROPERTY2, "AB", true, true)); + assertTrue(passes(PROPERTY1, "AB", true, true)); + assertTrue(passes(PROPERTY2, "te", true, true)); + assertFalse(passes(PROPERTY2, "AB", true, true)); } @Test public void testContainsCaseSensitive() { - Assert.assertTrue(passes(PROPERTY1, "ab", false, false)); - Assert.assertTrue(passes(PROPERTY1, "abcde", false, false)); - Assert.assertTrue(passes(PROPERTY1, "cd", false, false)); - Assert.assertTrue(passes(PROPERTY1, "e", false, false)); - Assert.assertTrue(passes(PROPERTY1, "", false, false)); - - Assert.assertFalse(passes(PROPERTY2, "ab", false, false)); - Assert.assertFalse(passes(PROPERTY1, "es", false, false)); + assertTrue(passes(PROPERTY1, "ab", false, false)); + assertTrue(passes(PROPERTY1, "abcde", false, false)); + assertTrue(passes(PROPERTY1, "cd", false, false)); + assertTrue(passes(PROPERTY1, "e", false, false)); + assertTrue(passes(PROPERTY1, "", false, false)); + + assertFalse(passes(PROPERTY2, "ab", false, false)); + assertFalse(passes(PROPERTY1, "es", false, false)); } @Test public void testContainsCaseInsensitive() { - Assert.assertTrue(passes(PROPERTY1, "AB", true, false)); - Assert.assertTrue(passes(PROPERTY1, "aBcDe", true, false)); - Assert.assertTrue(passes(PROPERTY1, "CD", true, false)); - Assert.assertTrue(passes(PROPERTY1, "", true, false)); + assertTrue(passes(PROPERTY1, "AB", true, false)); + assertTrue(passes(PROPERTY1, "aBcDe", true, false)); + assertTrue(passes(PROPERTY1, "CD", true, false)); + assertTrue(passes(PROPERTY1, "", true, false)); - Assert.assertTrue(passes(PROPERTY2, "es", true, false)); + assertTrue(passes(PROPERTY2, "es", true, false)); - Assert.assertFalse(passes(PROPERTY2, "ab", true, false)); + assertFalse(passes(PROPERTY2, "ab", true, false)); } @Test public void testAppliesToProperty() { SimpleStringFilter filter = f(PROPERTY1, "ab", false, true); - Assert.assertTrue(filter.appliesToProperty(PROPERTY1)); - Assert.assertFalse(filter.appliesToProperty(PROPERTY2)); - Assert.assertFalse(filter.appliesToProperty("other")); + assertTrue(filter.appliesToProperty(PROPERTY1)); + assertFalse(filter.appliesToProperty(PROPERTY2)); + assertFalse(filter.appliesToProperty("other")); } @Test @@ -88,43 +91,43 @@ public class SimpleStringFilterTest SimpleStringFilter f4b = f(PROPERTY1, "ab", false, false); // equal but not same instance - Assert.assertEquals(f1, f1b); - Assert.assertEquals(f2, f2b); - Assert.assertEquals(f3, f3b); - Assert.assertEquals(f4, f4b); + assertEquals(f1, f1b); + assertEquals(f2, f2b); + assertEquals(f3, f3b); + assertEquals(f4, f4b); // more than one property differ - Assert.assertFalse(f1.equals(f2)); - Assert.assertFalse(f1.equals(f3)); - Assert.assertFalse(f1.equals(f4)); - Assert.assertFalse(f2.equals(f1)); - Assert.assertFalse(f2.equals(f3)); - Assert.assertFalse(f2.equals(f4)); - Assert.assertFalse(f3.equals(f1)); - Assert.assertFalse(f3.equals(f2)); - Assert.assertFalse(f3.equals(f4)); - Assert.assertFalse(f4.equals(f1)); - Assert.assertFalse(f4.equals(f2)); - Assert.assertFalse(f4.equals(f3)); + assertFalse(f1.equals(f2)); + assertFalse(f1.equals(f3)); + assertFalse(f1.equals(f4)); + assertFalse(f2.equals(f1)); + assertFalse(f2.equals(f3)); + assertFalse(f2.equals(f4)); + assertFalse(f3.equals(f1)); + assertFalse(f3.equals(f2)); + assertFalse(f3.equals(f4)); + assertFalse(f4.equals(f1)); + assertFalse(f4.equals(f2)); + assertFalse(f4.equals(f3)); // only one property differs - Assert.assertFalse(filter.equals(f1)); - Assert.assertFalse(filter.equals(f2)); - Assert.assertFalse(filter.equals(f3)); - Assert.assertFalse(filter.equals(f4)); - - Assert.assertFalse(f1.equals(null)); - Assert.assertFalse(f1.equals(new Object())); - - Assert.assertEquals(f1.hashCode(), f1b.hashCode()); - Assert.assertEquals(f2.hashCode(), f2b.hashCode()); - Assert.assertEquals(f3.hashCode(), f3b.hashCode()); - Assert.assertEquals(f4.hashCode(), f4b.hashCode()); + assertFalse(filter.equals(f1)); + assertFalse(filter.equals(f2)); + assertFalse(filter.equals(f3)); + assertFalse(filter.equals(f4)); + + assertFalse(f1.equals(null)); + assertFalse(f1.equals(new Object())); + + assertEquals(f1.hashCode(), f1b.hashCode()); + assertEquals(f2.hashCode(), f2b.hashCode()); + assertEquals(f3.hashCode(), f3b.hashCode()); + assertEquals(f4.hashCode(), f4b.hashCode()); } @Test public void testNonExistentProperty() { - Assert.assertFalse(passes("other1", "ab", false, true)); + assertFalse(passes("other1", "ab", false, true)); } @Test @@ -132,8 +135,7 @@ public class SimpleStringFilterTest TestItem<String, String> item = createTestItem(); item.addItemProperty("other1", new NullProperty()); - Assert.assertFalse( - f("other1", "ab", false, true).passesFilter(null, item)); + assertFalse(f("other1", "ab", false, true).passesFilter(null, item)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java index 7392674fce..c4fd631ad0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -9,7 +16,6 @@ import java.util.Arrays; import java.util.List; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property.ReadOnlyException; @@ -22,7 +28,7 @@ public class ColumnPropertyTest { public void constructor_legalParameters_shouldSucceed() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertNotNull(cp); + assertNotNull(cp); } @Test(expected = IllegalArgumentException.class) @@ -40,7 +46,7 @@ public class ColumnPropertyTest { public void getValue_defaultValue_returnsVille() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertEquals("Ville", cp.getValue()); + assertEquals("Ville", cp.getValue()); } @Test @@ -53,7 +59,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue("Kalle"); - Assert.assertEquals("Kalle", cp.getValue()); + assertEquals("Kalle", cp.getValue()); EasyMock.verify(container); } @@ -79,7 +85,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); EasyMock.verify(container); } @@ -93,7 +99,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue(null); - Assert.assertNotNull(cp.getValue()); + assertNotNull(cp.getValue()); EasyMock.verify(container); } @@ -101,21 +107,21 @@ public class ColumnPropertyTest { public void getType_normal_returnsStringClass() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertSame(String.class, cp.getType()); + assertSame(String.class, cp.getType()); } @Test public void isReadOnly_readWriteNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertFalse(cp.isReadOnly()); + assertFalse(cp.isReadOnly()); } @Test public void isReadOnly_readOnlyNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", true, true, true, false, "Ville", String.class); - Assert.assertTrue(cp.isReadOnly()); + assertTrue(cp.isReadOnly()); } @Test @@ -123,7 +129,7 @@ public class ColumnPropertyTest { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); cp.setReadOnly(true); - Assert.assertTrue(cp.isReadOnly()); + assertTrue(cp.isReadOnly()); } @Test @@ -131,14 +137,14 @@ public class ColumnPropertyTest { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); cp.setReadOnly(true); - Assert.assertFalse(cp.isReadOnly()); + assertFalse(cp.isReadOnly()); } @Test public void getPropertyId_normal_returnsNAME() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); - Assert.assertEquals("NAME", cp.getPropertyId()); + assertEquals("NAME", cp.getPropertyId()); } @Test @@ -151,8 +157,8 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue("Kalle"); - Assert.assertEquals("Kalle", cp.getValue()); - Assert.assertTrue(cp.isModified()); + assertEquals("Kalle", cp.getValue()); + assertTrue(cp.isModified()); EasyMock.verify(container); } @@ -160,7 +166,7 @@ public class ColumnPropertyTest { public void isModified_valueNotModified_returnsFalse() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); - Assert.assertFalse(cp.isModified()); + assertFalse(cp.isModified()); } @Test @@ -171,7 +177,7 @@ public class ColumnPropertyTest { new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); } @Test @@ -182,9 +188,9 @@ public class ColumnPropertyTest { new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue("asdf"); - Assert.assertEquals("asdf", cp.getValue()); + assertEquals("asdf", cp.getValue()); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); } @Test @@ -232,8 +238,8 @@ public class ColumnPropertyTest { Arrays.asList(property)); property.setValue("Kalle"); - Assert.assertEquals("Kalle", container.value); - Assert.assertTrue(container.modified); + assertEquals("Kalle", container.value); + assertTrue(container.modified); } @Test @@ -242,7 +248,7 @@ public class ColumnPropertyTest { false, "Ville", String.class); property.setVersionColumn(true); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -250,7 +256,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", true, false, true, false, "Ville", String.class); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -258,7 +264,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertTrue(property.isPersistent()); + assertTrue(property.isPersistent()); } @Test @@ -266,7 +272,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", true, true, true, false, "Ville", String.class); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -274,7 +280,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, true, "Ville", String.class); - Assert.assertTrue(property.isRowIdentifier()); + assertTrue(property.isRowIdentifier()); } @Test @@ -283,7 +289,7 @@ public class ColumnPropertyTest { false, "Ville", String.class); property.setVersionColumn(true); - Assert.assertTrue(property.isRowIdentifier()); + assertTrue(property.isRowIdentifier()); } @Test @@ -291,7 +297,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertFalse(property.isRowIdentifier()); + assertFalse(property.isRowIdentifier()); } @Test @@ -311,9 +317,9 @@ public class ColumnPropertyTest { property.setValue("Kalle"); // Just check that the new value was actually set... - Assert.assertEquals("Kalle", property.getValue()); + assertEquals("Kalle", property.getValue()); // Assert that old value is the original value... - Assert.assertEquals("Ville", property.getOldValue()); + assertEquals("Ville", property.getOldValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java index 02d59e4489..4eb6bea454 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java @@ -1,12 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertTrue; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import org.junit.Assert; - import com.vaadin.v7.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.v7.data.util.sqlcontainer.connection.JDBCConnectionPool; @@ -50,7 +50,7 @@ public class DataGenerator { statement.close(); statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from PEOPLE"); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); statement.close(); conn.commit(); connectionPool.releaseConnection(conn); @@ -102,7 +102,7 @@ public class DataGenerator { statement.close(); statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from VERSIONED"); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); statement.close(); conn.commit(); connectionPool.releaseConnection(conn); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java index b1208c7b94..e668a081d2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class ReadOnlyRowIdTest { @@ -9,47 +12,47 @@ public class ReadOnlyRowIdTest { public void getRowNum_shouldReturnRowNumGivenInConstructor() { int rowNum = 1337; ReadOnlyRowId rid = new ReadOnlyRowId(rowNum); - Assert.assertEquals(rowNum, rid.getRowNum()); + assertEquals(rowNum, rid.getRowNum()); } @Test public void hashCode_shouldBeEqualToHashCodeOfRowNum() { int rowNum = 1337; ReadOnlyRowId rid = new ReadOnlyRowId(rowNum); - Assert.assertEquals(Integer.valueOf(rowNum).hashCode(), rid.hashCode()); + assertEquals(Integer.valueOf(rowNum).hashCode(), rid.hashCode()); } @Test public void equals_compareWithNull_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); - Assert.assertFalse(rid.equals(null)); + assertFalse(rid.equals(null)); } @Test public void equals_compareWithSameInstance_shouldBeTrue() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); ReadOnlyRowId rid2 = rid; - Assert.assertTrue(rid.equals(rid2)); + assertTrue(rid.equals(rid2)); } @Test public void equals_compareWithOtherType_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); - Assert.assertFalse(rid.equals(new Object())); + assertFalse(rid.equals(new Object())); } @Test public void equals_compareWithOtherRowId_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); ReadOnlyRowId rid2 = new ReadOnlyRowId(42); - Assert.assertFalse(rid.equals(rid2)); + assertFalse(rid.equals(rid2)); } @Test public void toString_rowNumberIsReturned() { int i = 1; ReadOnlyRowId rowId = new ReadOnlyRowId(i); - Assert.assertEquals("Unexpected toString value", String.valueOf(i), + assertEquals("Unexpected toString value", String.valueOf(i), rowId.toString()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java index e9e869223d..7368bacfdf 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java @@ -1,6 +1,10 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class RowIdTest { @@ -8,7 +12,7 @@ public class RowIdTest { @Test public void constructor_withArrayOfPrimaryKeyColumns_shouldSucceed() { RowId id = new RowId(new Object[] { "id", "name" }); - Assert.assertArrayEquals(new Object[] { "id", "name" }, id.getId()); + assertArrayEquals(new Object[] { "id", "name" }, id.getId()); } @Test(expected = IllegalArgumentException.class) @@ -20,41 +24,41 @@ public class RowIdTest { public void hashCode_samePrimaryKeys_sameResult() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id", "name" }); - Assert.assertEquals(id.hashCode(), id2.hashCode()); + assertEquals(id.hashCode(), id2.hashCode()); } @Test public void hashCode_differentPrimaryKeys_differentResult() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id" }); - Assert.assertFalse(id.hashCode() == id2.hashCode()); + assertFalse(id.hashCode() == id2.hashCode()); } @Test public void equals_samePrimaryKeys_returnsTrue() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id", "name" }); - Assert.assertEquals(id, id2); + assertEquals(id, id2); } @Test public void equals_differentPrimaryKeys_returnsFalse() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id" }); - Assert.assertFalse(id.equals(id2.hashCode())); + assertFalse(id.equals(id2.hashCode())); } @Test public void equals_differentDataType_returnsFalse() { RowId id = new RowId(new Object[] { "id", "name" }); - Assert.assertFalse(id.equals("Tudiluu")); - Assert.assertFalse(id.equals(new Integer(1337))); + assertFalse(id.equals("Tudiluu")); + assertFalse(id.equals(new Integer(1337))); } @Test public void toString_defaultCtor_noException() { RowId rowId = new RowId(); - Assert.assertTrue("Unexpected to string for empty Row Id", + assertTrue("Unexpected to string for empty Row Id", rowId.toString().isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java index e04b6fc643..92e1fd61e1 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -5,9 +5,15 @@ import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.math.BigDecimal; import java.sql.Connection; @@ -19,7 +25,6 @@ import java.util.List; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -56,7 +61,7 @@ public class SQLContainerTableQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -227,9 +232,9 @@ public class SQLContainerTableQueryTest { for (Object o : itemIds) { oracle.add(o.toString()); } - Assert.assertArrayEquals(correct, oracle.toArray()); + assertArrayEquals(correct, oracle.toArray()); } else { - Assert.assertArrayEquals(new Object[] { zero, one, two, three }, + assertArrayEquals(new Object[] { zero, one, two, three }, itemIds.toArray()); } } @@ -376,10 +381,10 @@ public class SQLContainerTableQueryTest { @Test public void isFirstId_tableSecondId_returnsFalse() throws SQLException { if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isFirstId( + assertFalse(container.isFirstId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse(container + assertFalse(container .isFirstId(new RowId(new Object[] { 1 + offset }))); } } @@ -387,10 +392,10 @@ public class SQLContainerTableQueryTest { @Test public void isLastId_tableSecondId_returnsFalse() throws SQLException { if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isLastId( + assertFalse(container.isLastId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse( + assertFalse( container.isLastId(new RowId(new Object[] { 1 + offset }))); } } @@ -464,7 +469,7 @@ public class SQLContainerTableQueryTest { container.setAutoCommit(true); assertTrue(container.isAutoCommit()); container.setAutoCommit(false); - Assert.assertFalse(container.isAutoCommit()); + assertFalse(container.isAutoCommit()); } @Test @@ -521,7 +526,7 @@ public class SQLContainerTableQueryTest { @Test public void addItem_tableAddOneNewItem_returnsItemId() throws SQLException { Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); } @Test @@ -529,9 +534,9 @@ public class SQLContainerTableQueryTest { throws SQLException { container.setAutoCommit(true); Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); assertTrue(itemId instanceof RowId); - Assert.assertFalse(itemId instanceof TemporaryRowId); + assertFalse(itemId instanceof TemporaryRowId); } @Test @@ -558,8 +563,8 @@ public class SQLContainerTableQueryTest { Object id1 = container.addItem(); Object id2 = container.addItem(); assertEquals(size + 2, container.size()); - Assert.assertNotSame(id1, id2); - Assert.assertFalse(id1.equals(id2)); + assertNotSame(id1, id2); + assertFalse(id1.equals(id2)); } @Test @@ -576,7 +581,7 @@ public class SQLContainerTableQueryTest { Object lastId = container.lastItemId(); Object id = container.addItem(); assertEquals(id, container.lastItemId()); - Assert.assertNotSame(lastId, container.lastItemId()); + assertNotSame(lastId, container.lastItemId()); } @Test @@ -590,7 +595,7 @@ public class SQLContainerTableQueryTest { public void getItem_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException { Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); } @Test @@ -634,7 +639,7 @@ public class SQLContainerTableQueryTest { Object id = garbageContainer.addItem(); - Assert.assertSame(id, garbageContainer.firstItemId()); + assertSame(id, garbageContainer.firstItemId()); } @Test @@ -681,7 +686,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.firstItemId()); + assertNotSame(id, container.firstItemId()); assertEquals(originalSize - 1, container.size()); } @@ -689,7 +694,7 @@ public class SQLContainerTableQueryTest { public void containsId_tableRemovedItem_returnsFalse() throws SQLException { Object id = container.firstItemId(); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -699,7 +704,7 @@ public class SQLContainerTableQueryTest { int size = container.size(); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); assertEquals(size - 1, container.size()); } @@ -708,7 +713,7 @@ public class SQLContainerTableQueryTest { Object id = container.firstItemId(); assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -716,9 +721,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -728,7 +733,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.getItemIds().contains(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -738,7 +743,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.getItemIds().contains(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -747,7 +752,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.containsId(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -757,7 +762,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.containsId(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -810,7 +815,7 @@ public class SQLContainerTableQueryTest { Object first = container.firstItemId(); assertTrue(container.removeItem(first)); - Assert.assertNotSame(first, container.firstItemId()); + assertNotSame(first, container.firstItemId()); } @Test @@ -821,9 +826,9 @@ public class SQLContainerTableQueryTest { Object first = garbageContainer.addItem(); Object second = garbageContainer.addItem(); - Assert.assertSame(first, garbageContainer.firstItemId()); + assertSame(first, garbageContainer.firstItemId()); assertTrue(garbageContainer.removeItem(first)); - Assert.assertSame(second, garbageContainer.firstItemId()); + assertSame(second, garbageContainer.firstItemId()); } @Test @@ -832,7 +837,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertNotSame(last, container.lastItemId()); } @Test @@ -840,9 +845,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertNotSame(last, container.lastItemId()); } @Test @@ -851,7 +856,7 @@ public class SQLContainerTableQueryTest { Object first = container.firstItemId(); assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -862,9 +867,9 @@ public class SQLContainerTableQueryTest { Object first = garbageContainer.addItem(); garbageContainer.addItem(); - Assert.assertSame(first, garbageContainer.firstItemId()); + assertSame(first, garbageContainer.firstItemId()); assertTrue(garbageContainer.removeItem(first)); - Assert.assertFalse(garbageContainer.isFirstId(first)); + assertFalse(garbageContainer.isFirstId(first)); } @Test @@ -873,7 +878,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertFalse(container.isLastId(last)); } @Test @@ -881,9 +886,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertFalse(container.isLastId(last)); } @Test @@ -910,7 +915,7 @@ public class SQLContainerTableQueryTest { Object id = container.getIdByIndex(2); assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(2)); + assertNotSame(id, container.getIdByIndex(2)); } @Test @@ -921,7 +926,7 @@ public class SQLContainerTableQueryTest { int index = container.indexOfId(id); assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(index)); + assertNotSame(id, container.getIdByIndex(index)); } @Test @@ -967,9 +972,9 @@ public class SQLContainerTableQueryTest { container.getContainerProperty(id, NAME).setValue("New Name"); assertTrue(id instanceof TemporaryRowId); - Assert.assertSame(id, container.lastItemId()); + assertSame(id, container.lastItemId()); container.commit(); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertFalse(container.lastItemId() instanceof TemporaryRowId); assertEquals("New Name", container .getContainerProperty(container.lastItemId(), NAME).getValue()); } @@ -982,14 +987,14 @@ public class SQLContainerTableQueryTest { container.getContainerProperty(id, NAME).setValue("Herbert"); container.getContainerProperty(id2, NAME).setValue("Larry"); assertTrue(id2 instanceof TemporaryRowId); - Assert.assertSame(id2, container.lastItemId()); + assertSame(id2, container.lastItemId()); container.commit(); Object nextToLast = container.getIdByIndex(container.size() - 2); - Assert.assertFalse(nextToLast instanceof TemporaryRowId); + assertFalse(nextToLast instanceof TemporaryRowId); assertEquals("Herbert", container.getContainerProperty(nextToLast, NAME).getValue()); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertFalse(container.lastItemId() instanceof TemporaryRowId); assertEquals("Larry", container .getContainerProperty(container.lastItemId(), NAME).getValue()); } @@ -1001,7 +1006,7 @@ public class SQLContainerTableQueryTest { container.removeItem(last); container.commit(); - Assert.assertFalse(last.equals(container.lastItemId())); + assertFalse(last.equals(container.lastItemId())); } @Test @@ -1036,7 +1041,7 @@ public class SQLContainerTableQueryTest { assertEquals(size + 1, container.size()); container.rollback(); assertEquals(size, container.size()); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), NAME) .getValue())); } @@ -1059,7 +1064,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); container.getContainerProperty(last, NAME).setValue("foo"); container.rollback(); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), NAME) .getValue())); } @@ -1067,7 +1072,7 @@ public class SQLContainerTableQueryTest { @Test public void itemChangeNotification_table_isModifiedReturnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); RowItem last = (RowItem) container.getItem(container.lastItemId()); container.itemChangeNotification(last); assertTrue(container.isModified()); @@ -1116,21 +1121,21 @@ public class SQLContainerTableQueryTest { @Test public void isModified_tableRemovedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.removeItem(container.lastItemId()); assertTrue(container.isModified()); } @Test public void isModified_tableAddedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.addItem(); assertTrue(container.isModified()); } @Test public void isModified_tableChangedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.getContainerProperty(container.lastItemId(), NAME) .setValue("foo"); assertTrue(container.isModified()); @@ -1146,7 +1151,7 @@ public class SQLContainerTableQueryTest { assertEquals(3, sortableIds.size()); if (SQLTestsConstants.db == DB.MSSQL || SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(sortableIds.contains("rownum")); + assertFalse(sortableIds.contains("rownum")); } } @@ -1304,21 +1309,20 @@ public class SQLContainerTableQueryTest { try { container.getIdByIndex(4); - Assert.fail( - "SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); } catch (IndexOutOfBoundsException e) { // should throw exception - item is filtered out } - Assert.assertNull(container.nextItemId(container.getIdByIndex(3))); + assertNull(container.nextItemId(container.getIdByIndex(3))); - Assert.assertFalse(container.containsId(id2)); - Assert.assertFalse(container.getItemIds().contains(id2)); + assertFalse(container.containsId(id2)); + assertFalse(container.getItemIds().contains(id2)); - Assert.assertNull(container.getItem(id2)); + assertNull(container.getItem(id2)); assertEquals(-1, container.indexOfId(id2)); - Assert.assertNotSame(id2, container.lastItemId()); - Assert.assertSame(id1, container.lastItemId()); + assertNotSame(id2, container.lastItemId()); + assertSame(id1, container.lastItemId()); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java index fe344cf8ef..1842b41734 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java @@ -1,5 +1,15 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.math.BigDecimal; import java.sql.Connection; import java.sql.SQLException; @@ -14,7 +24,6 @@ import java.util.logging.Logger; import org.easymock.EasyMock; import org.easymock.IAnswer; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -50,7 +59,7 @@ public class SQLContainerTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -83,7 +92,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertTrue(container.containsId(new RowId(new Object[] { 1 }))); + assertTrue(container.containsId(new RowId(new Object[] { 1 }))); } @Test @@ -91,8 +100,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse( - container.containsId(new RowId(new Object[] { 1337 }))); + assertFalse(container.containsId(new RowId(new Object[] { 1337 }))); } @Test @@ -101,12 +109,12 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(new RowId( new Object[] { new BigDecimal(0 + offset) }), "NAME").getValue()); } else { - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty( new RowId(new Object[] { 0 + offset }), "NAME") .getValue()); @@ -118,7 +126,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getContainerProperty( + assertNull(container.getContainerProperty( new RowId(new Object[] { 1 + offset }), "asdf")); } @@ -127,7 +135,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getContainerProperty( + assertNull(container.getContainerProperty( new RowId(new Object[] { 1337 + offset }), "NAME")); } @@ -137,8 +145,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> propertyIds = container.getContainerPropertyIds(); - Assert.assertEquals(3, propertyIds.size()); - Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" }, + assertEquals(3, propertyIds.size()); + assertArrayEquals(new String[] { "ID", "NAME", "AGE" }, propertyIds.toArray()); } @@ -154,8 +162,8 @@ public class SQLContainerTest { } else { item = container.getItem(new RowId(new Object[] { 0 + offset })); } - Assert.assertNotNull(item); - Assert.assertEquals("Ville", item.getItemProperty("NAME").getValue()); + assertNotNull(item); + assertEquals("Ville", item.getItemProperty("NAME").getValue()); } @Test @@ -164,7 +172,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastItemId = container.lastItemId(); Object afterLast = container.nextItemId(lastItemId); - Assert.assertNull(afterLast); + assertNull(afterLast); } @Test @@ -173,7 +181,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object firstItemId = container.firstItemId(); Object beforeFirst = container.prevItemId(firstItemId); - Assert.assertNull(beforeFirst); + assertNull(beforeFirst); } @Test @@ -186,17 +194,15 @@ public class SQLContainerTest { if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem( new RowId(new Object[] { new BigDecimal(1337 + offset) })); - Assert.assertNotNull(item); - Assert.assertEquals(new BigDecimal(1337 + offset), + assertNotNull(item); + assertEquals(new BigDecimal(1337 + offset), item.getItemProperty("ID").getValue()); } else { item = container.getItem(new RowId(new Object[] { 1337 + offset })); - Assert.assertNotNull(item); - Assert.assertEquals(1337 + offset, - item.getItemProperty("ID").getValue()); + assertNotNull(item); + assertEquals(1337 + offset, item.getItemProperty("ID").getValue()); } - Assert.assertEquals("Person 1337", - item.getItemProperty("NAME").getValue()); + assertEquals("Person 1337", item.getItemProperty("NAME").getValue()); } @Test @@ -205,7 +211,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> itemIds = container.getItemIds(); - Assert.assertEquals(4, itemIds.size()); + assertEquals(4, itemIds.size()); RowId zero = new RowId(new Object[] { 0 + offset }); RowId one = new RowId(new Object[] { 1 + offset }); RowId two = new RowId(new Object[] { 2 + offset }); @@ -216,9 +222,9 @@ public class SQLContainerTest { for (Object o : itemIds) { oracle.add(o.toString()); } - Assert.assertArrayEquals(correct, oracle.toArray()); + assertArrayEquals(correct, oracle.toArray()); } else { - Assert.assertArrayEquals(new Object[] { zero, one, two, three }, + assertArrayEquals(new Object[] { zero, one, two, three }, itemIds.toArray()); } } @@ -228,7 +234,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(String.class, container.getType("NAME")); + assertEquals(String.class, container.getType("NAME")); } @Test @@ -237,9 +243,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(BigDecimal.class, container.getType("ID")); + assertEquals(BigDecimal.class, container.getType("ID")); } else { - Assert.assertEquals(Integer.class, container.getType("ID")); + assertEquals(Integer.class, container.getType("ID")); } } @@ -248,14 +254,14 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getType("asdf")); + assertNull(container.getType("asdf")); } @Test public void size_freeform_returnsFour() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); } @Test @@ -274,7 +280,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(5, container.size()); + assertEquals(5, container.size()); } @Test @@ -283,10 +289,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(3, container.indexOfId( + assertEquals(3, container.indexOfId( new RowId(new Object[] { new BigDecimal(3 + offset) }))); } else { - Assert.assertEquals(3, container + assertEquals(3, container .indexOfId(new RowId(new Object[] { 3 + offset }))); } } @@ -301,11 +307,11 @@ public class SQLContainerTest { if (SQLTestsConstants.db == DB.ORACLE) { container.getItem( new RowId(new Object[] { new BigDecimal(1337 + offset) })); - Assert.assertEquals(1337, container.indexOfId( + assertEquals(1337, container.indexOfId( new RowId(new Object[] { new BigDecimal(1337 + offset) }))); } else { container.getItem(new RowId(new Object[] { 1337 + offset })); - Assert.assertEquals(1337, container + assertEquals(1337, container .indexOfId(new RowId(new Object[] { 1337 + offset }))); } } @@ -319,12 +325,11 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( + assertEquals( new RowId(new Object[] { new BigDecimal(1337 + offset) }), itemId); } else { - Assert.assertEquals(new RowId(new Object[] { 1337 + offset }), - itemId); + assertEquals(new RowId(new Object[] { 1337 + offset }), itemId); } } @@ -382,12 +387,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(query); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1337 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1337 + offset }).toString(), itemId.toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1337 + offset }), - itemId); + assertEquals(new RowId(new Object[] { 1337 + offset }), itemId); } } @@ -400,11 +403,10 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1338 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1338 + offset }).toString(), container.nextItemId(itemId).toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1338 + offset }), + assertEquals(new RowId(new Object[] { 1338 + offset }), container.nextItemId(itemId)); } } @@ -418,11 +420,10 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1336 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1336 + offset }).toString(), container.prevItemId(itemId).toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1336 + offset }), + assertEquals(new RowId(new Object[] { 1336 + offset }), container.prevItemId(itemId)); } } @@ -432,11 +433,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 0 + offset }).toString(), + assertEquals(new RowId(new Object[] { 0 + offset }).toString(), container.firstItemId().toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 0 + offset }), + assertEquals(new RowId(new Object[] { 0 + offset }), container.firstItemId()); } } @@ -450,11 +450,10 @@ public class SQLContainerTest { new FreeformQuery("SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 4999 + offset }).toString(), + assertEquals(new RowId(new Object[] { 4999 + offset }).toString(), container.lastItemId().toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 4999 + offset }), + assertEquals(new RowId(new Object[] { 4999 + offset }), container.lastItemId()); } } @@ -465,10 +464,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isFirstId( + assertTrue(container.isFirstId( new RowId(new Object[] { new BigDecimal(0 + offset) }))); } else { - Assert.assertTrue(container + assertTrue(container .isFirstId(new RowId(new Object[] { 0 + offset }))); } } @@ -478,10 +477,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isFirstId( + assertFalse(container.isFirstId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse(container + assertFalse(container .isFirstId(new RowId(new Object[] { 1 + offset }))); } } @@ -491,10 +490,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isLastId( + assertFalse(container.isLastId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse( + assertFalse( container.isLastId(new RowId(new Object[] { 1 + offset }))); } } @@ -504,10 +503,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isLastId( + assertTrue(container.isLastId( new RowId(new Object[] { new BigDecimal(3 + offset) }))); } else { - Assert.assertTrue( + assertTrue( container.isLastId(new RowId(new Object[] { 3 + offset }))); } } @@ -520,10 +519,10 @@ public class SQLContainerTest { new FreeformQuery("SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isLastId( + assertTrue(container.isLastId( new RowId(new Object[] { new BigDecimal(4999 + offset) }))); } else { - Assert.assertTrue(container + assertTrue(container .isLastId(new RowId(new Object[] { 4999 + offset }))); } } @@ -532,10 +531,10 @@ public class SQLContainerTest { public void refresh_freeform_sizeShouldUpdate() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); container.refresh(); - Assert.assertEquals(5000, container.size()); + assertEquals(5000, container.size()); } @Test @@ -547,9 +546,9 @@ public class SQLContainerTest { // a NOP. SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); } @Test @@ -557,16 +556,16 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); container.setAutoCommit(true); - Assert.assertTrue(container.isAutoCommit()); + assertTrue(container.isAutoCommit()); container.setAutoCommit(false); - Assert.assertFalse(container.isAutoCommit()); + assertFalse(container.isAutoCommit()); } @Test public void getPageLength_freeform_returnsDefault100() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(100, container.getPageLength()); + assertEquals(100, container.getPageLength()); } @Test @@ -574,9 +573,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); container.setPageLength(20); - Assert.assertEquals(20, container.getPageLength()); + assertEquals(20, container.getPageLength()); container.setPageLength(200); - Assert.assertEquals(200, container.getPageLength()); + assertEquals(200, container.getPageLength()); } @Test(expected = UnsupportedOperationException.class) @@ -637,7 +636,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); } @Test @@ -647,7 +646,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); int size = container.size(); container.addItem(); - Assert.assertEquals(size + 1, container.size()); + assertEquals(size + 1, container.size()); } @Test @@ -658,9 +657,9 @@ public class SQLContainerTest { int size = container.size(); Object id1 = container.addItem(); Object id2 = container.addItem(); - Assert.assertEquals(size + 2, container.size()); - Assert.assertNotSame(id1, id2); - Assert.assertFalse(id1.equals(id2)); + assertEquals(size + 2, container.size()); + assertNotSame(id1, id2); + assertFalse(id1.equals(id2)); } @Test @@ -670,7 +669,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastId = container.lastItemId(); Object id = container.addItem(); - Assert.assertEquals(id, container.nextItemId(lastId)); + assertEquals(id, container.nextItemId(lastId)); } @Test @@ -680,8 +679,8 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastId = container.lastItemId(); Object id = container.addItem(); - Assert.assertEquals(id, container.lastItemId()); - Assert.assertNotSame(lastId, container.lastItemId()); + assertEquals(id, container.lastItemId()); + assertNotSame(lastId, container.lastItemId()); } @Test @@ -690,7 +689,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertEquals(4, container.indexOfId(id)); + assertEquals(4, container.indexOfId(id)); } @Test @@ -699,7 +698,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); } @Test @@ -709,7 +708,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addContainerFilter(new Equal("NAME", "asdf")); Object id = container.addItem(); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -719,7 +718,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addContainerFilter(new Equal("NAME", "asdf")); Object id = container.addItem(); - Assert.assertNotNull(container.getItemUnfiltered(id)); + assertNotNull(container.getItemUnfiltered(id)); } @Test @@ -728,7 +727,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); } @Test @@ -739,7 +738,7 @@ public class SQLContainerTest { Object id = container.addItem(); Item item = container.getItem(id); item.getItemProperty("NAME").setValue("asdf"); - Assert.assertEquals("asdf", + assertEquals("asdf", container.getContainerProperty(id, "NAME").getValue()); } @@ -749,7 +748,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); + assertTrue(container.containsId(id)); } @Test @@ -759,7 +758,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object id1 = container.addItem(); Object id2 = container.addItem(); - Assert.assertEquals(id1, container.prevItemId(id2)); + assertEquals(id1, container.prevItemId(id2)); } @Test @@ -769,7 +768,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM GARBAGE", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertSame(id, container.firstItemId()); + assertSame(id, container.firstItemId()); } @Test @@ -779,7 +778,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM GARBAGE", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.isFirstId(id)); + assertTrue(container.isFirstId(id)); } @Test @@ -788,7 +787,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.isLastId(id)); + assertTrue(container.isLastId(id)); } @Test @@ -798,7 +797,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addItem(); Object id2 = container.addItem(); - Assert.assertTrue(container.isLastId(id2)); + assertTrue(container.isLastId(id2)); } @Test @@ -807,7 +806,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertEquals(id, container.getIdByIndex(container.size() - 1)); + assertEquals(id, container.getIdByIndex(container.size() - 1)); } @Test @@ -817,9 +816,9 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); int size = container.size(); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.firstItemId()); - Assert.assertEquals(size - 1, container.size()); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.firstItemId()); + assertEquals(size - 1, container.size()); } @Test @@ -828,8 +827,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -839,7 +838,7 @@ public class SQLContainerTest { @Override public void publish(LogRecord record) { - Assert.fail("No messages should be logged"); + fail("No messages should be logged"); } @@ -858,7 +857,7 @@ public class SQLContainerTest { logger.addHandler(ensureNoLogging); try { - Assert.assertFalse(container.containsId(new Object())); + assertFalse(container.containsId(new Object())); } finally { logger.removeHandler(ensureNoLogging); } @@ -871,9 +870,9 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); int size = container.size(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); - Assert.assertEquals(size - 1, container.size()); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); + assertEquals(size - 1, container.size()); } @Test @@ -881,8 +880,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertTrue(container.removeItem(id)); + assertNull(container.getItem(id)); } @Test @@ -891,9 +890,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNotNull(container.getItem(id)); + assertTrue(container.removeItem(id)); + assertNull(container.getItem(id)); } @Test @@ -902,9 +901,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.getItemIds().contains(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -913,9 +912,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.getItemIds().contains(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -924,9 +923,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.containsId(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -935,9 +934,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -948,8 +947,8 @@ public class SQLContainerTest { Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(third, container.nextItemId(first)); + assertTrue(container.removeItem(second)); + assertEquals(third, container.nextItemId(first)); } @Test @@ -960,8 +959,8 @@ public class SQLContainerTest { Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(third, container.nextItemId(first)); + assertTrue(container.removeItem(second)); + assertEquals(third, container.nextItemId(first)); } @Test @@ -972,8 +971,8 @@ public class SQLContainerTest { Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(first, container.prevItemId(third)); + assertTrue(container.removeItem(second)); + assertEquals(first, container.prevItemId(third)); } @Test @@ -984,8 +983,8 @@ public class SQLContainerTest { Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(first, container.prevItemId(third)); + assertTrue(container.removeItem(second)); + assertEquals(first, container.prevItemId(third)); } @Test @@ -994,8 +993,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object first = container.firstItemId(); - Assert.assertTrue(container.removeItem(first)); - Assert.assertNotSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertNotSame(first, container.firstItemId()); } @Test @@ -1006,9 +1005,9 @@ public class SQLContainerTest { "SELECT * FROM GARBAGE", connectionPool, "ID")); Object first = container.addItem(); Object second = container.addItem(); - Assert.assertSame(first, container.firstItemId()); - Assert.assertTrue(container.removeItem(first)); - Assert.assertSame(second, container.firstItemId()); + assertSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertSame(second, container.firstItemId()); } @Test @@ -1017,8 +1016,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.lastItemId(); - Assert.assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertNotSame(last, container.lastItemId()); } @Test @@ -1027,9 +1026,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); - Assert.assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertNotSame(last, container.lastItemId()); } @Test @@ -1038,8 +1037,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object first = container.firstItemId(); - Assert.assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertTrue(container.removeItem(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -1050,9 +1049,9 @@ public class SQLContainerTest { "SELECT * FROM GARBAGE", connectionPool, "ID")); Object first = container.addItem(); container.addItem(); - Assert.assertSame(first, container.firstItemId()); - Assert.assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -1061,8 +1060,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.lastItemId(); - Assert.assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertTrue(container.removeItem(last)); + assertFalse(container.isLastId(last)); } @Test @@ -1071,9 +1070,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); - Assert.assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertFalse(container.isLastId(last)); } @Test @@ -1082,8 +1081,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(id)); - Assert.assertEquals(-1, container.indexOfId(id)); + assertTrue(container.removeItem(id)); + assertEquals(-1, container.indexOfId(id)); } @Test @@ -1092,9 +1091,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.indexOfId(id) != -1); - Assert.assertTrue(container.removeItem(id)); - Assert.assertEquals(-1, container.indexOfId(id)); + assertTrue(container.indexOfId(id) != -1); + assertTrue(container.removeItem(id)); + assertEquals(-1, container.indexOfId(id)); } @Test @@ -1103,8 +1102,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(2)); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.getIdByIndex(2)); } @Test @@ -1115,16 +1114,16 @@ public class SQLContainerTest { Object id = container.addItem(); container.addItem(); int index = container.indexOfId(id); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(index)); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.getIdByIndex(index)); } @Test public void removeAllItems_freeform_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertTrue(container.removeAllItems()); - Assert.assertEquals(0, container.size()); + assertTrue(container.removeAllItems()); + assertEquals(0, container.size()); } @Test @@ -1134,8 +1133,8 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addItem(); container.addItem(); - Assert.assertTrue(container.removeAllItems()); - Assert.assertEquals(0, container.size()); + assertTrue(container.removeAllItems()); + assertEquals(0, container.size()); } @SuppressWarnings("unchecked") @@ -1227,11 +1226,11 @@ public class SQLContainerTest { Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("New Name"); container.getContainerProperty(id, "AGE").setValue(30); - Assert.assertTrue(id instanceof TemporaryRowId); - Assert.assertSame(id, container.lastItemId()); + assertTrue(id instanceof TemporaryRowId); + assertSame(id, container.lastItemId()); container.commit(); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); - Assert.assertEquals("New Name", + assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertEquals("New Name", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1329,15 +1328,15 @@ public class SQLContainerTest { container.getContainerProperty(id, "AGE").setValue(30); container.getContainerProperty(id2, "NAME").setValue("Larry"); container.getContainerProperty(id2, "AGE").setValue(50); - Assert.assertTrue(id2 instanceof TemporaryRowId); - Assert.assertSame(id2, container.lastItemId()); + assertTrue(id2 instanceof TemporaryRowId); + assertSame(id2, container.lastItemId()); container.commit(); Object nextToLast = container.getIdByIndex(container.size() - 2); - Assert.assertFalse(nextToLast instanceof TemporaryRowId); - Assert.assertEquals("Herbert", + assertFalse(nextToLast instanceof TemporaryRowId); + assertEquals("Herbert", container.getContainerProperty(nextToLast, "NAME").getValue()); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); - Assert.assertEquals("Larry", + assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertEquals("Larry", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1414,7 +1413,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.removeItem(last); container.commit(); - Assert.assertFalse(last.equals(container.lastItemId())); + assertFalse(last.equals(container.lastItemId())); EasyMock.verify(delegate); } @@ -1492,7 +1491,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("Donald"); container.commit(); - Assert.assertEquals("Donald", + assertEquals("Donald", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1506,10 +1505,10 @@ public class SQLContainerTest { int size = container.size(); Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("foo"); - Assert.assertEquals(size + 1, container.size()); + assertEquals(size + 1, container.size()); container.rollback(); - Assert.assertEquals(size, container.size()); - Assert.assertFalse("foo".equals( + assertEquals(size, container.size()); + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), "NAME") .getValue())); } @@ -1522,10 +1521,10 @@ public class SQLContainerTest { int size = container.size(); Object last = container.lastItemId(); container.removeItem(last); - Assert.assertEquals(size - 1, container.size()); + assertEquals(size - 1, container.size()); container.rollback(); - Assert.assertEquals(size, container.size()); - Assert.assertEquals(last, container.lastItemId()); + assertEquals(size, container.size()); + assertEquals(last, container.lastItemId()); } @Test @@ -1536,7 +1535,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("foo"); container.rollback(); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), "NAME") .getValue())); } @@ -1546,10 +1545,10 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); RowItem last = (RowItem) container.getItem(container.lastItemId()); container.itemChangeNotification(last); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1605,18 +1604,18 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.removeItem(container.lastItemId()); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test public void isModified_freeformAddedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.addItem(); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1624,10 +1623,10 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.getContainerProperty(container.lastItemId(), "NAME") .setValue("foo"); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1636,10 +1635,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> sortableIds = container.getSortableContainerPropertyIds(); - Assert.assertTrue(sortableIds.contains("ID")); - Assert.assertTrue(sortableIds.contains("NAME")); - Assert.assertTrue(sortableIds.contains("AGE")); - Assert.assertEquals(3, sortableIds.size()); + assertTrue(sortableIds.contains("ID")); + assertTrue(sortableIds.contains("NAME")); + assertTrue(sortableIds.contains("AGE")); + assertEquals(3, sortableIds.size()); } @SuppressWarnings("unchecked") @@ -1733,19 +1732,19 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addOrderBy(new OrderBy("NAME", true)); // Börje, Kalle, Pelle, Ville - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1851,20 +1850,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.sort(new Object[] { "NAME" }, new boolean[] { true }); // Börje, Kalle, Pelle, Ville - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1927,15 +1926,15 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addContainerFilter(new Like("NAME", "%lle")); // Ville, Kalle, Pelle - Assert.assertEquals(3, container.size()); - Assert.assertEquals("Pelle", + assertEquals(3, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1998,13 +1997,13 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, false); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2068,14 +2067,14 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); // FIXME LIKE %asdf% doesn't match a string that begins with asdf container.addContainerFilter("NAME", "vi", true, true); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2139,20 +2138,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, false); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.removeAllContainerFilters(); - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2216,20 +2215,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, true); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.removeContainerFilters("NAME"); - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2293,8 +2292,8 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2306,41 +2305,40 @@ public class SQLContainerTest { container.addContainerFilter(new Like("NAME", "%lle")); // Ville, Kalle, Pelle, Palle - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Ville", + assertEquals(4, container.size()); + assertEquals("Ville", container .getContainerProperty(container.getIdByIndex(0), "NAME") .getValue()); - Assert.assertEquals("Kalle", + assertEquals("Kalle", container .getContainerProperty(container.getIdByIndex(1), "NAME") .getValue()); - Assert.assertEquals("Pelle", + assertEquals("Pelle", container .getContainerProperty(container.getIdByIndex(2), "NAME") .getValue()); - Assert.assertEquals("Palle", + assertEquals("Palle", container .getContainerProperty(container.getIdByIndex(3), "NAME") .getValue()); try { container.getIdByIndex(4); - Assert.fail( - "SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); } catch (IndexOutOfBoundsException e) { // should throw exception - item is filtered out } container.nextItemId(container.getIdByIndex(3)); - Assert.assertFalse(container.containsId(id2)); - Assert.assertFalse(container.getItemIds().contains(id2)); + assertFalse(container.containsId(id2)); + assertFalse(container.getItemIds().contains(id2)); - Assert.assertNull(container.getItem(id2)); - Assert.assertEquals(-1, container.indexOfId(id2)); + assertNull(container.getItem(id2)); + assertEquals(-1, container.indexOfId(id2)); - Assert.assertNotSame(id2, container.lastItemId()); - Assert.assertSame(id1, container.lastItemId()); + assertNotSame(id2, container.lastItemId()); + assertSame(id1, container.lastItemId()); EasyMock.verify(delegate); } @@ -2437,10 +2435,10 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2452,14 +2450,14 @@ public class SQLContainerTest { container.sort(new Object[] { "NAME" }, new boolean[] { true }); // Börje, Kalle, Pelle, Ville, Wilbert, Albert - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Wilbert", + assertEquals("Wilbert", container.getContainerProperty( container.getIdByIndex(container.size() - 2), "NAME") .getValue()); - Assert.assertEquals("Albert", + assertEquals("Albert", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java index cd8ad96e9a..f48524b338 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; import java.sql.SQLException; import java.util.ArrayList; @@ -8,7 +11,6 @@ import java.util.List; import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -105,23 +107,23 @@ public class TicketTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addContainerFilter(new Equal("AGE", 18)); // Pelle - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Pelle", + assertEquals(1, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(new BigDecimal(18), container + assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } else { - Assert.assertEquals(18, container + assertEquals(18, container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } @@ -135,21 +137,21 @@ public class TicketTest { SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter(new Equal("AGE", 18)); // Pelle - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Pelle", + assertEquals(1, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(new BigDecimal(18), container + assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } else { - Assert.assertEquals(18, container + assertEquals(18, container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } @@ -167,18 +169,17 @@ public class TicketTest { // set a different name item.getItemProperty("NAME").setValue("otherName"); - Assert.assertEquals("otherName", - item.getItemProperty("NAME").getValue()); + assertEquals("otherName", item.getItemProperty("NAME").getValue()); // access the item and reset the name to its old value Item item2 = container.getItem(id); item2.getItemProperty("NAME").setValue(name); - Assert.assertEquals(name, item2.getItemProperty("NAME").getValue()); + assertEquals(name, item2.getItemProperty("NAME").getValue()); Item item3 = container.getItem(id); String name3 = (String) item3.getItemProperty("NAME").getValue(); - Assert.assertEquals(name, name3); + assertEquals(name, name3); } @Test @@ -189,7 +190,6 @@ public class TicketTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people WHERE name='does_not_exist'", Arrays.asList("ID"), connectionPool)); - Assert.assertTrue("Got items while expected empty set", - container.size() == 0); + assertTrue("Got items while expected empty set", container.size() == 0); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java index f71c5b02e9..b5aaaa0841 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java @@ -1,50 +1,49 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class UtilTest { @Test public void escapeSQL_noQuotes_returnsSameString() { - Assert.assertEquals("asdf", SQLUtil.escapeSQL("asdf")); + assertEquals("asdf", SQLUtil.escapeSQL("asdf")); } @Test public void escapeSQL_singleQuotes_returnsEscapedString() { - Assert.assertEquals("O''Brien", SQLUtil.escapeSQL("O'Brien")); + assertEquals("O''Brien", SQLUtil.escapeSQL("O'Brien")); } @Test public void escapeSQL_severalQuotes_returnsEscapedString() { - Assert.assertEquals("asdf''ghjk''qwerty", + assertEquals("asdf''ghjk''qwerty", SQLUtil.escapeSQL("asdf'ghjk'qwerty")); } @Test public void escapeSQL_doubleQuotes_returnsEscapedString() { - Assert.assertEquals("asdf\\\"foo", SQLUtil.escapeSQL("asdf\"foo")); + assertEquals("asdf\\\"foo", SQLUtil.escapeSQL("asdf\"foo")); } @Test public void escapeSQL_multipleDoubleQuotes_returnsEscapedString() { - Assert.assertEquals("asdf\\\"foo\\\"bar", - SQLUtil.escapeSQL("asdf\"foo\"bar")); + assertEquals("asdf\\\"foo\\\"bar", SQLUtil.escapeSQL("asdf\"foo\"bar")); } @Test public void escapeSQL_backslashes_returnsEscapedString() { - Assert.assertEquals("foo\\\\nbar\\\\r", - SQLUtil.escapeSQL("foo\\nbar\\r")); + assertEquals("foo\\\\nbar\\\\r", SQLUtil.escapeSQL("foo\\nbar\\r")); } @Test public void escapeSQL_x00_removesX00() { - Assert.assertEquals("foobar", SQLUtil.escapeSQL("foo\\x00bar")); + assertEquals("foobar", SQLUtil.escapeSQL("foo\\x00bar")); } @Test public void escapeSQL_x1a_removesX1a() { - Assert.assertEquals("foobar", SQLUtil.escapeSQL("foo\\x1abar")); + assertEquals("foobar", SQLUtil.escapeSQL("foo\\x1abar")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java index 167b7c1fe4..0fad0cfa20 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java @@ -1,5 +1,7 @@ package com.vaadin.v7.data.util.sqlcontainer.connection; +import static org.junit.Assert.assertEquals; + import java.sql.Connection; import java.sql.SQLException; @@ -8,7 +10,6 @@ import javax.naming.NamingException; import javax.sql.DataSource; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; public class J2EEConnectionPoolTest { @@ -26,7 +27,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool(ds); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); EasyMock.verify(connection, ds); } @@ -44,7 +45,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool(ds); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); pool.releaseConnection(c); EasyMock.verify(connection, ds); } @@ -73,7 +74,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool("testDataSource"); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); pool.releaseConnection(c); EasyMock.verify(context, connection, ds); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java index 2d63b0a6ab..0e2507bf8e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java @@ -1,10 +1,14 @@ package com.vaadin.v7.data.util.sqlcontainer.connection; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.SQLException; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -25,7 +29,7 @@ public class SimpleJDBCConnectionPoolTest { public void reserveConnection_reserveNewConnection_returnsConnection() throws SQLException { Connection conn = connectionPool.reserveConnection(); - Assert.assertNotNull(conn); + assertNotNull(conn); } @Test @@ -33,7 +37,7 @@ public class SimpleJDBCConnectionPoolTest { throws SQLException { Connection conn = connectionPool.reserveConnection(); connectionPool.releaseConnection(conn); - Assert.assertFalse(conn.isClosed()); + assertFalse(conn.isClosed()); } @Test(expected = SQLException.class) @@ -44,13 +48,11 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } connectionPool.reserveConnection(); - Assert.fail( - "Reserving connection didn't fail even though no connections are available!"); + fail("Reserving connection didn't fail even though no connections are available!"); } @Test @@ -60,12 +62,11 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } Connection conn = connectionPool.reserveConnection(); - Assert.assertNotNull(conn); + assertNotNull(conn); } @Test @@ -77,8 +78,7 @@ public class SimpleJDBCConnectionPoolTest { conn2 = connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } connectionPool.releaseConnection(conn2); @@ -128,7 +128,7 @@ public class SimpleJDBCConnectionPoolTest { SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 0, 2); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); } @Test @@ -167,8 +167,8 @@ public class SimpleJDBCConnectionPoolTest { // not empty but only after cleanup of the real pool has been done } - Assert.assertTrue(c1.isClosed()); - Assert.assertTrue(c2.isClosed()); + assertTrue(c1.isClosed()); + assertTrue(c2.isClosed()); } @Test @@ -178,8 +178,8 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.releaseConnection(c1); connectionPool.releaseConnection(c2); connectionPool.destroy(); - Assert.assertTrue(c1.isClosed()); - Assert.assertTrue(c2.isClosed()); + assertTrue(c1.isClosed()); + assertTrue(c2.isClosed()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java index 59e486b686..bb73a66cac 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java @@ -1,7 +1,10 @@ package com.vaadin.v7.data.util.sqlcontainer.filters; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Item; @@ -27,156 +30,152 @@ public class BetweenTest { public void passesFilter_valueIsInRange_shouldBeTrue() { Item item = itemWithPropertyValue("foo", 15); Between between = new Between("foo", 1, 30); - Assert.assertTrue(between.passesFilter("foo", item)); + assertTrue(between.passesFilter("foo", item)); } @Test public void passesFilter_valueIsOutOfRange_shouldBeFalse() { Item item = itemWithPropertyValue("foo", 15); Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.passesFilter("foo", item)); + assertFalse(between.passesFilter("foo", item)); } @Test public void passesFilter_valueNotComparable_shouldBeFalse() { Item item = itemWithPropertyValue("foo", new Object()); Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.passesFilter("foo", item)); + assertFalse(between.passesFilter("foo", item)); } @Test public void appliesToProperty_differentProperties_shoudlBeFalse() { Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.appliesToProperty("bar")); + assertFalse(between.appliesToProperty("bar")); } @Test public void appliesToProperty_sameProperties_shouldBeTrue() { Between between = new Between("foo", 0, 2); - Assert.assertTrue(between.appliesToProperty("foo")); + assertTrue(between.appliesToProperty("foo")); } @Test public void hashCode_equalInstances_shouldBeEqual() { Between b1 = new Between("foo", 0, 2); Between b2 = new Between("foo", 0, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void equals_differentObjects_shouldBeFalse() { Between b1 = new Between("foo", 0, 2); Object obj = new Object(); - Assert.assertFalse(b1.equals(obj)); + assertFalse(b1.equals(obj)); } @Test public void equals_sameInstance_shouldBeTrue() { Between b1 = new Between("foo", 0, 2); Between b2 = b1; - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_equalInstances_shouldBeTrue() { Between b1 = new Between("foo", 0, 2); Between b2 = new Between("foo", 0, 2); - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_equalInstances2_shouldBeTrue() { Between b1 = new Between(null, null, null); Between b2 = new Between(null, null, null); - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_secondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", 0, 1); Between b2 = new Between("foo", 0, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_firstAndSecondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", 0, null); Between b2 = new Between("foo", 1, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_propertyAndFirstAndSecondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", null, 1); Between b2 = new Between("bar", 1, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_propertiesDiffer_shouldBeFalse() { Between b1 = new Between(null, 0, 1); Between b2 = new Between("bar", 0, 1); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void hashCode_nullStartValue_shouldBeEqual() { Between b1 = new Between("foo", null, 2); Between b2 = new Between("foo", null, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void hashCode_nullEndValue_shouldBeEqual() { Between b1 = new Between("foo", 0, null); Between b2 = new Between("foo", 0, null); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void hashCode_nullPropertyId_shouldBeEqual() { Between b1 = new Between(null, 0, 2); Between b2 = new Between(null, 0, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void passesFilter_nullValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, null))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, null))); } @Test public void passesFilter_nullStartValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, 2); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullEndValue_filterIsPassed() { String id = "id"; Between between = new Between(id, 0, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullStartValueAndEndValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullStartValueAndEndValueAndValueIsNotComparable_filterIsNotPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertFalse(between.passesFilter(id, + assertFalse(between.passesFilter(id, itemWithPropertyValue(id, new Object()))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java index 9739144b7f..897944a912 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.data.util.sqlcontainer.filters; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.filter.Compare; @@ -26,19 +28,19 @@ public class CompareTest { public void testEquals() { Compare c1 = new Compare.Equal("prop1", "val1"); Compare c2 = new Compare.Equal("prop1", "val1"); - Assert.assertTrue(c1.equals(c2)); + assertTrue(c1.equals(c2)); } @Test public void testDifferentTypeEquals() { Compare c1 = new Compare.Equal("prop1", "val1"); Compare c2 = new Compare.Greater("prop1", "val1"); - Assert.assertFalse(c1.equals(c2)); + assertFalse(c1.equals(c2)); } @Test public void testEqualsNull() { Compare c1 = new Compare.Equal("prop1", "val1"); - Assert.assertFalse(c1.equals(null)); + assertFalse(c1.equals(null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java index e09705e6f3..71906256c2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.sqlcontainer.filters; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Item; @@ -17,7 +20,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<Integer>(5)); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -27,7 +30,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfooghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -38,7 +41,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfOOghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -48,7 +51,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfOOghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -58,7 +61,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdbarghij")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -68,7 +71,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foo")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -78,7 +81,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("fo")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -88,7 +91,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foobar")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -98,7 +101,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("barfoo")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -108,7 +111,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("barfoo")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -118,7 +121,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foobar")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -128,102 +131,102 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("fooASDFbar")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test public void appliesToProperty_valueIsProperty_shouldBeTrue() { Like like = new Like("test", "%foo"); - Assert.assertTrue(like.appliesToProperty("test")); + assertTrue(like.appliesToProperty("test")); } @Test public void appliesToProperty_valueIsNotProperty_shouldBeFalse() { Like like = new Like("test", "%foo"); - Assert.assertFalse(like.appliesToProperty("bar")); + assertFalse(like.appliesToProperty("bar")); } @Test public void equals_sameInstances_shouldBeTrue() { Like like1 = new Like("test", "%foo"); Like like2 = like1; - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_twoEqualInstances_shouldBeTrue() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "foo"); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_differentValues_shouldBeFalse() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "bar"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentProperties_shouldBeFalse() { Like like1 = new Like("foo", "test"); Like like2 = new Like("bar", "test"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentPropertiesAndValues_shouldBeFalse() { Like like1 = new Like("foo", "bar"); Like like2 = new Like("baz", "zomg"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentClasses_shouldBeFalse() { Like like1 = new Like("foo", "bar"); Object obj = new Object(); - Assert.assertFalse(like1.equals(obj)); + assertFalse(like1.equals(obj)); } @Test public void equals_bothHaveNullProperties_shouldBeTrue() { Like like1 = new Like(null, "foo"); Like like2 = new Like(null, "foo"); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_bothHaveNullValues_shouldBeTrue() { Like like1 = new Like("foo", null); Like like2 = new Like("foo", null); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_onePropertyIsNull_shouldBeFalse() { Like like1 = new Like(null, "bar"); Like like2 = new Like("foo", "baz"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_oneValueIsNull_shouldBeFalse() { Like like1 = new Like("foo", null); Like like2 = new Like("baz", "bar"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void hashCode_equalInstances_shouldBeEqual() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "foo"); - Assert.assertEquals(like1.hashCode(), like2.hashCode()); + assertEquals(like1.hashCode(), like2.hashCode()); } @Test public void hashCode_differentPropertiesAndValues_shouldNotEqual() { Like like1 = new Like("foo", "bar"); Like like2 = new Like("baz", "zomg"); - Assert.assertTrue(like1.hashCode() != like2.hashCode()); + assertTrue(like1.hashCode() != like2.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java index 078363af19..5bf587dd09 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java @@ -1,12 +1,15 @@ package com.vaadin.v7.data.util.sqlcontainer.generator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,7 +42,7 @@ public class SQLGeneratorsTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -57,7 +60,7 @@ public class SQLGeneratorsTest { SQLGenerator sg = new DefaultSQLGenerator(); StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 0, 0, null); - Assert.assertEquals(sh.getQueryString(), "SELECT * FROM TABLE"); + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE"); } @Test @@ -65,7 +68,7 @@ public class SQLGeneratorsTest { SQLGenerator sg = new DefaultSQLGenerator(); StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 4, 8, "COL1, COL2, COL3"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT COL1, COL2, COL3 FROM TABLE LIMIT 8 OFFSET 4"); } @@ -79,7 +82,7 @@ public class SQLGeneratorsTest { f.add(new Like("name", "%lle")); List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE WHERE \"name\" LIKE ? ORDER BY \"name\" ASC"); } @@ -91,7 +94,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); // TODO - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE WHERE (\"name\" LIKE ? " + "OR \"name\" LIKE ?) ORDER BY \"name\" ASC"); } @@ -115,7 +118,7 @@ public class SQLGeneratorsTest { StatementHelper sh = sg.generateDeleteQuery("people", query.getPrimaryKeyColumns(), null, (RowItem) container .getItem(container.getItemIds().iterator().next())); - Assert.assertEquals("DELETE FROM people WHERE \"ID\" = ?", + assertEquals("DELETE FROM people WHERE \"ID\" = ?", sh.getQueryString()); } @@ -139,7 +142,7 @@ public class SQLGeneratorsTest { ri.getItemProperty("NAME").setValue("Viljami"); StatementHelper sh = sg.generateUpdateQuery("people", ri); - Assert.assertTrue( + assertTrue( "UPDATE people SET \"NAME\" = ?, \"AGE\" = ? WHERE \"ID\" = ?" .equals(sh.getQueryString()) || "UPDATE people SET \"AGE\" = ?, \"NAME\" = ? WHERE \"ID\" = ?" @@ -166,7 +169,7 @@ public class SQLGeneratorsTest { StatementHelper sh = sg.generateInsertQuery("people", ri); - Assert.assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)" + assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)" .equals(sh.getQueryString()) || "INSERT INTO people (\"AGE\", \"NAME\") VALUES (?, ?)" .equals(sh.getQueryString())); @@ -181,10 +184,9 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals( - "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" - + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?" - + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12", + assertEquals("SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" + + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?" + + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12", sh.getQueryString()); } @@ -197,7 +199,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT row_number() OVER " + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID " + "FROM TABLE WHERE \"name\" LIKE ?) " @@ -213,7 +215,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" + " (SELECT NAME, ID FROM TABLE WHERE (\"name\" LIKE ?" + " OR \"name\" LIKE ?) " @@ -229,7 +231,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT row_number() OVER " + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID " + "FROM TABLE WHERE (\"name\" LIKE ? " diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java index 1c6559dc73..aa9f61ddeb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.data.util.sqlcontainer.generator; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.PreparedStatement; import java.sql.SQLException; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.sqlcontainer.query.generator.StatementHelper; @@ -39,12 +41,12 @@ public class StatementHelperTest { // should throw SQLException, not NPE try { helper.setParameterValuesToStatement(statement); - Assert.fail("Expected SQLExecption for unsupported type"); + fail("Expected SQLExecption for unsupported type"); } catch (SQLException e) { // Exception should contain info about which parameter and the type // which was unsupported - Assert.assertTrue(e.getMessage().contains("parameter 0")); - Assert.assertTrue( + assertTrue(e.getMessage().contains("parameter 0")); + assertTrue( e.getMessage().contains(StatementHelper.class.getName())); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java index ea65310fc4..7ace7ae808 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,7 +17,6 @@ import java.util.List; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,7 +45,7 @@ public class FreeformQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -56,10 +62,10 @@ public class FreeformQueryTest { public void construction_legalParameters_shouldSucceed() { FreeformQuery ffQuery = new FreeformQuery("SELECT * FROM foo", Arrays.asList("ID"), connectionPool); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, ffQuery.getPrimaryKeyColumns().toArray()); - Assert.assertEquals("SELECT * FROM foo", ffQuery.getQueryString()); + assertEquals("SELECT * FROM foo", ffQuery.getQueryString()); } @Test(expected = IllegalArgumentException.class) @@ -97,7 +103,7 @@ public class FreeformQueryTest { public void getCount_simpleQuery_returnsFour() throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertEquals(4, query.getCount()); + assertEquals(4, query.getCount()); } @Test(expected = SQLException.class) @@ -130,7 +136,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertEquals(6, query.getCount()); + assertEquals(6, query.getCount()); } @Test @@ -138,7 +144,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "SELECT * FROM people WHERE \"NAME\" LIKE '%lle'", connectionPool, "ID"); - Assert.assertEquals(3, query.getCount()); + assertEquals(3, query.getCount()); } @Test @@ -149,7 +155,7 @@ public class FreeformQueryTest { query.getCount(); query.getCount(); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); // Cleanup to make test connection pool happy connectionPool.releaseConnection(c); } @@ -165,7 +171,7 @@ public class FreeformQueryTest { "SELECT COUNT(*) FROM people WHERE \"NAME\" LIKE '%lle'"); EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertEquals(3, query.getCount()); + assertEquals(3, query.getCount()); EasyMock.verify(delegate); } @@ -181,7 +187,7 @@ public class FreeformQueryTest { .andReturn("SELECT COUNT(*) FROM GARBAGE"); EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); EasyMock.verify(delegate); } @@ -194,23 +200,23 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -223,19 +229,19 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -249,9 +255,9 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); for (int i = 0; i < 5000; i++) { - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -290,7 +296,7 @@ public class FreeformQueryTest { try { query.storeRow(new RowItem(container, new RowId(new Object[] { 1 }), null)); - Assert.fail("storeRow should fail when there is no delegate"); + fail("storeRow should fail when there is no delegate"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -307,7 +313,7 @@ public class FreeformQueryTest { try { query.removeRow(new RowItem(container, new RowId(new Object[] { 1 }), null)); - Assert.fail("removeRow should fail when there is no delgate"); + fail("removeRow should fail when there is no delgate"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -349,7 +355,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -357,7 +363,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertFalse(query.containsRowWithKey(1337)); + assertFalse(query.containsRowWithKey(1337)); } // (expected = SQLException.class) @@ -366,7 +372,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertFalse(query.containsRowWithKey(38796)); + assertFalse(query.containsRowWithKey(38796)); } @Test @@ -375,7 +381,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "SELECT * FROM people WHERE \"NAME\" LIKE '%lle'", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -384,7 +390,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "select * from people where \"NAME\" like '%lle'", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -413,7 +419,7 @@ public class FreeformQueryTest { FreeformQueryDelegate delegate = EasyMock .createMock(FreeformQueryDelegate.class); query.setDelegate(delegate); - Assert.assertEquals(delegate, query.getDelegate()); + assertEquals(delegate, query.getDelegate()); } @Test @@ -474,15 +480,15 @@ public class FreeformQueryTest { if (SQLTestsConstants.db == DB.MSSQL) { rsoffset++; } - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1 + rsoffset)); - Assert.assertEquals("Ville", rs.getString(2 + rsoffset)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1 + rsoffset)); + assertEquals("Ville", rs.getString(2 + rsoffset)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1 + rsoffset)); - Assert.assertEquals("Kalle", rs.getString(2 + rsoffset)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1 + rsoffset)); + assertEquals("Kalle", rs.getString(2 + rsoffset)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); EasyMock.verify(delegate); query.commit(); @@ -515,10 +521,10 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(200, 100); for (int i = 0; i < 100; i++) { - Assert.assertTrue(rs.next()); - Assert.assertEquals(200 + i + offset, rs.getInt("ID")); + assertTrue(rs.next()); + assertEquals(200 + i + offset, rs.getInt("ID")); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -646,8 +652,7 @@ public class FreeformQueryTest { null); try { query.storeRow(row); - Assert.fail( - "storeRow should fail when delgate does not implement storeRow"); + fail("storeRow should fail when delgate does not implement storeRow"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -695,8 +700,7 @@ public class FreeformQueryTest { null); try { query.removeRow(row); - Assert.fail( - "removeRow should fail when delegate does not implement removeRow"); + fail("removeRow should fail when delegate does not implement removeRow"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -727,8 +731,7 @@ public class FreeformQueryTest { query.beginTransaction(); try { query.beginTransaction(); - Assert.fail( - "Should throw exception when starting a transaction while already in a transaction"); + fail("Should throw exception when starting a transaction while already in a transaction"); } catch (IllegalStateException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -882,7 +885,7 @@ public class FreeformQueryTest { query.setDelegate(delegate); // The id (key) used should be 1337 as above, for the call with key = 1 - Assert.assertFalse(query.containsRowWithKey(1)); + assertFalse(query.containsRowWithKey(1)); EasyMock.verify(delegate); } @@ -978,7 +981,7 @@ public class FreeformQueryTest { EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); EasyMock.verify(delegate); } @@ -990,7 +993,7 @@ public class FreeformQueryTest { "p1.ID"); query.setDelegate(new NonMatchingStatementDelegateWithGroupBy()); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); } @Test @@ -1000,6 +1003,6 @@ public class FreeformQueryTest { "p1.ID"); query.setDelegate(new NonMatchingDelegateWithGroupBy()); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java index b01af9b9ad..164a55b9c5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java @@ -1,10 +1,11 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -42,7 +43,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_equals() { StatementHelper sh = mockedStatementHelper("Fido"); Equal f = new Equal("NAME", "Fido"); - Assert.assertEquals("\"NAME\" = ?", + assertEquals("\"NAME\" = ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -51,7 +52,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_greater() { StatementHelper sh = mockedStatementHelper(18); Greater f = new Greater("AGE", 18); - Assert.assertEquals("\"AGE\" > ?", + assertEquals("\"AGE\" > ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -60,7 +61,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_less() { StatementHelper sh = mockedStatementHelper(65); Less f = new Less("AGE", 65); - Assert.assertEquals("\"AGE\" < ?", + assertEquals("\"AGE\" < ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -69,7 +70,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_greaterOrEqual() { StatementHelper sh = mockedStatementHelper(18); GreaterOrEqual f = new GreaterOrEqual("AGE", 18); - Assert.assertEquals("\"AGE\" >= ?", + assertEquals("\"AGE\" >= ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -78,7 +79,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_lessOrEqual() { StatementHelper sh = mockedStatementHelper(65); LessOrEqual f = new LessOrEqual("AGE", 65); - Assert.assertEquals("\"AGE\" <= ?", + assertEquals("\"AGE\" <= ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -88,7 +89,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("Vi%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", false, true); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -98,7 +99,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%Vi%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", false, false); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -108,7 +109,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%VI%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", true, false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -117,7 +118,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_startsWith() { StatementHelper sh = mockedStatementHelper("Vi%"); Like f = new Like("NAME", "Vi%"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -126,7 +127,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_startsWithNumber() { StatementHelper sh = mockedStatementHelper("1%"); Like f = new Like("AGE", "1%"); - Assert.assertEquals("\"AGE\" LIKE ?", + assertEquals("\"AGE\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -135,7 +136,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_endsWith() { StatementHelper sh = mockedStatementHelper("%lle"); Like f = new Like("NAME", "%lle"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -144,7 +145,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_contains() { StatementHelper sh = mockedStatementHelper("%ill%"); Like f = new Like("NAME", "%ill%"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -153,7 +154,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_between() { StatementHelper sh = mockedStatementHelper(18, 65); Between f = new Between("AGE", 18, 65); - Assert.assertEquals("\"AGE\" BETWEEN ? AND ?", + assertEquals("\"AGE\" BETWEEN ? AND ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -163,7 +164,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("FIDO"); Like f = new Like("NAME", "Fido"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -173,7 +174,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("VI%"); Like f = new Like("NAME", "Vi%"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -183,7 +184,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%LLE"); Like f = new Like("NAME", "%lle"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -193,7 +194,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%ILL%"); Like f = new Like("NAME", "%ill%"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -204,7 +205,7 @@ public class QueryBuilderTest { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Like("NAME", "%lle")); filters.add(new Greater("AGE", 18)); - Assert.assertEquals(" WHERE \"NAME\" LIKE ? AND \"AGE\" > ?", + assertEquals(" WHERE \"NAME\" LIKE ? AND \"AGE\" > ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -214,7 +215,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%lle", 18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new And(new Like("NAME", "%lle"), new Greater("AGE", 18))); - Assert.assertEquals(" WHERE (\"NAME\" LIKE ? AND \"AGE\" > ?)", + assertEquals(" WHERE (\"NAME\" LIKE ? AND \"AGE\" > ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -224,7 +225,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%lle", 18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Or(new Like("NAME", "%lle"), new Greater("AGE", 18))); - Assert.assertEquals(" WHERE (\"NAME\" LIKE ? OR \"AGE\" > ?)", + assertEquals(" WHERE (\"NAME\" LIKE ? OR \"AGE\" > ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -237,7 +238,7 @@ public class QueryBuilderTest { new And(new Like("NAME", "%lle"), new Or(new Less("AGE", 18), new Greater("AGE", 65))), new Equal("NAME", "Pelle"))); - Assert.assertEquals( + assertEquals( " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); @@ -253,7 +254,7 @@ public class QueryBuilderTest { new Or(new Less("AGE", 18), new Greater("AGE", 65))), new Equal("NAME", "Pelle"))); filters.add(new Equal("LASTNAME", "Virtanen")); - Assert.assertEquals( + assertEquals( " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?) AND \"LASTNAME\" = ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); @@ -262,7 +263,7 @@ public class QueryBuilderTest { @Test public void getWhereStringForFilters_emptyList_shouldReturnEmptyString() { List<Filter> filters = new ArrayList<Filter>(); - Assert.assertEquals("", QueryBuilder.getWhereStringForFilters(filters, + assertEquals("", QueryBuilder.getWhereStringForFilters(filters, new StatementHelper())); } @@ -271,7 +272,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper(18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new Equal("AGE", 18))); - Assert.assertEquals(" WHERE NOT \"AGE\" = ?", + assertEquals(" WHERE NOT \"AGE\" = ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -282,7 +283,7 @@ public class QueryBuilderTest { List<Filter> filters = new ArrayList<Filter>(); filters.add( new Not(new Or(new Equal("AGE", 65), new Equal("AGE", 18)))); - Assert.assertEquals(" WHERE NOT (\"AGE\" = ? OR \"AGE\" = ?)", + assertEquals(" WHERE NOT (\"AGE\" = ? OR \"AGE\" = ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -291,7 +292,7 @@ public class QueryBuilderTest { public void getWhereStringForFilters_isNull() { List<Filter> filters = new ArrayList<Filter>(); filters.add(new IsNull("NAME")); - Assert.assertEquals(" WHERE \"NAME\" IS NULL", QueryBuilder + assertEquals(" WHERE \"NAME\" IS NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); } @@ -299,7 +300,7 @@ public class QueryBuilderTest { public void getWhereStringForFilters_isNotNull() { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new IsNull("NAME"))); - Assert.assertEquals(" WHERE \"NAME\" IS NOT NULL", QueryBuilder + assertEquals(" WHERE \"NAME\" IS NOT NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); } @@ -308,7 +309,7 @@ public class QueryBuilderTest { QueryBuilder.setStringDecorator(new StringDecorator("[", "]")); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new IsNull("NAME"))); - Assert.assertEquals(" WHERE [NAME] IS NOT NULL", QueryBuilder + assertEquals(" WHERE [NAME] IS NOT NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); // Reset the default string decorator QueryBuilder.setStringDecorator(new StringDecorator("\"", "\"")); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java index 23dec7cbf6..bc3d0ac518 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -10,7 +17,6 @@ import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -38,7 +44,7 @@ public class TableQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); } @@ -57,22 +63,22 @@ public class TableQueryTest { public void construction_legalParameters_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, new DefaultSQLGenerator()); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, tQuery.getPrimaryKeyColumns().toArray()); boolean correctTableName = "people" .equalsIgnoreCase(tQuery.getTableName()); - Assert.assertTrue(correctTableName); + assertTrue(correctTableName); } @Test public void construction_legalParameters_defaultGenerator_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, tQuery.getPrimaryKeyColumns().toArray()); boolean correctTableName = "people" .equalsIgnoreCase(tQuery.getTableName()); - Assert.assertTrue(correctTableName); + assertTrue(correctTableName); } @Test(expected = IllegalArgumentException.class) @@ -102,7 +108,7 @@ public class TableQueryTest { public void getCount_simpleQuery_returnsFour() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertEquals(4, tQuery.getCount()); + assertEquals(4, tQuery.getCount()); } @Test @@ -127,7 +133,7 @@ public class TableQueryTest { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertEquals(6, tQuery.getCount()); + assertEquals(6, tQuery.getCount()); } @Test @@ -137,7 +143,7 @@ public class TableQueryTest { tQuery.getCount(); tQuery.getCount(); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); connectionPool.releaseConnection(c); } @@ -152,23 +158,23 @@ public class TableQueryTest { tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -183,9 +189,9 @@ public class TableQueryTest { tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); for (int i = 0; i < 5000; i++) { - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -201,8 +207,7 @@ public class TableQueryTest { tQuery.beginTransaction(); try { tQuery.beginTransaction(); - Assert.fail( - "Should throw exception when starting a transaction while already in a transaction"); + fail("Should throw exception when starting a transaction while already in a transaction"); } catch (IllegalStateException e) { // Cleanup to make test connection pool happy tQuery.rollback(); @@ -247,7 +252,7 @@ public class TableQueryTest { throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertTrue(tQuery.containsRowWithKey(1)); + assertTrue(tQuery.containsRowWithKey(1)); } @Test @@ -256,7 +261,7 @@ public class TableQueryTest { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertFalse(tQuery.containsRowWithKey(1337)); + assertFalse(tQuery.containsRowWithKey(1337)); } @Test @@ -270,7 +275,7 @@ public class TableQueryTest { } catch (SQLException se) { return; } - Assert.assertFalse(b); + assertFalse(b); } @Test @@ -304,7 +309,7 @@ public class TableQueryTest { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Like("NAME", "%lle")); tQuery.setFilters(filters); - Assert.assertEquals(3, tQuery.getCount()); + assertEquals(3, tQuery.getCount()); } @Test @@ -320,23 +325,23 @@ public class TableQueryTest { ResultSet rs; rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -353,23 +358,23 @@ public class TableQueryTest { ResultSet rs; rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -397,15 +402,15 @@ public class TableQueryTest { SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(false); - Assert.assertTrue( + assertTrue( container.removeItem(container.getItemIds().iterator().next())); - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(3, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(3, container.size()); container.commit(); - Assert.assertEquals(3, tQuery.getCount()); - Assert.assertEquals(3, container.size()); + assertEquals(3, tQuery.getCount()); + assertEquals(3, container.size()); } @Test @@ -416,7 +421,7 @@ public class TableQueryTest { SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(true); - Assert.assertFalse(container.removeItem("foo")); + assertFalse(container.removeItem("foo")); } /********************************************************************** @@ -432,14 +437,14 @@ public class TableQueryTest { container.setAutoCommit(false); Object item = container.addItem(); - Assert.assertNotNull(item); + assertNotNull(item); - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(5, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(5, container.size()); container.commit(); - Assert.assertEquals(5, tQuery.getCount()); - Assert.assertEquals(5, container.size()); + assertEquals(5, tQuery.getCount()); + assertEquals(5, container.size()); } @Test @@ -453,29 +458,29 @@ public class TableQueryTest { container.setAutoCommit(false); /* Check that the container size is correct and there is no 'Viljami' */ - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Equal("NAME", "Viljami")); tQuery.setFilters(filters); - Assert.assertEquals(0, tQuery.getCount()); + assertEquals(0, tQuery.getCount()); tQuery.setFilters(null); /* Fetch first item, modify and commit */ Object item = container .getItem(container.getItemIds().iterator().next()); - Assert.assertNotNull(item); + assertNotNull(item); RowItem ri = (RowItem) item; - Assert.assertNotNull(ri.getItemProperty("NAME")); + assertNotNull(ri.getItemProperty("NAME")); ri.getItemProperty("NAME").setValue("Viljami"); container.commit(); // Check that the size is still correct and only 1 'Viljami' is found - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(4, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(4, container.size()); tQuery.setFilters(filters); - Assert.assertEquals(1, tQuery.getCount()); + assertEquals(1, tQuery.getCount()); } @Test @@ -497,7 +502,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM PEOPLE WHERE \"NAME\" = ?"); stmt.setString(1, "R2D2"); ResultSet rs = stmt.executeQuery(); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); rs.close(); stmt.close(); connectionPool.releaseConnection(conn); @@ -513,7 +518,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); row.getItemProperty("TEXT").setValue("asdf"); container.commit(); @@ -523,7 +528,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?"); stmt.setString(1, "asdf"); ResultSet rs = stmt.executeQuery(); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); rs.close(); stmt.close(); conn.commit(); @@ -545,7 +550,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); row.getItemProperty("TEXT").setValue("asdf"); @@ -573,7 +578,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); container.removeItem(container.firstItemId()); container.commit(); @@ -583,7 +588,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?"); stmt.setString(1, "Junk"); ResultSet rs = stmt.executeQuery(); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); rs.close(); stmt.close(); conn.commit(); @@ -605,7 +610,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); // Update the version using another connection. Connection conn = connectionPool.reserveConnection(); @@ -637,7 +642,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); // Update the version using another connection. Connection conn = connectionPool.reserveConnection(); @@ -694,7 +699,7 @@ public class TableQueryTest { // metadata scanning at query creation time should not fail TableQuery tq1 = new TableQuery(null, "oaas", "product", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertNotNull(tq1); + assertNotNull(tq1); } finally { // cleanup - might not be an in-memory DB statement.execute(SQLTestsConstants.dropSchema); @@ -737,7 +742,7 @@ public class TableQueryTest { // name TableQuery tq1 = new TableQuery("sqlcontainer", "oaas", "product", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertNotNull(tq1); + assertNotNull(tq1); } finally { // cleanup - might not be an in-memory DB statement.execute(SQLTestsConstants.dropSchema); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java index db4cf97a1e..eae607048c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java @@ -16,9 +16,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -84,24 +85,23 @@ public class AnyEnumToStringConverterTest { @Test public void nullConversion() { - Assert.assertEquals(null, converter.convertToModel(null, null, null)); + assertEquals(null, converter.convertToModel(null, null, null)); } @Test public void enumToStringConversion() { - Assert.assertEquals(TestEnum.TWO.toString(), + assertEquals(TestEnum.TWO.toString(), converter.convertToModel(TestEnum.TWO, String.class, null)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), converter + assertEquals(AnotherTestEnum.TWO.toString(), converter .convertToModel(AnotherTestEnum.TWO, String.class, null)); } @Test public void stringToEnumConversion() { - Assert.assertEquals(TestEnum.TWO, converter.convertToPresentation( + assertEquals(TestEnum.TWO, converter.convertToPresentation( TestEnum.TWO.toString(), TestEnum.class, null)); - Assert.assertEquals(AnotherTestEnum.TWO, - converter.convertToPresentation(AnotherTestEnum.TWO.toString(), - AnotherTestEnum.class, null)); + assertEquals(AnotherTestEnum.TWO, converter.convertToPresentation( + AnotherTestEnum.TWO.toString(), AnotherTestEnum.class, null)); } @Test @@ -109,20 +109,19 @@ public class AnyEnumToStringConverterTest { TextField tf = new TextField(); tf.setConverter(new ReverseConverter(converter)); tf.setPropertyDataSource(new ObjectProperty(AnotherTestEnum.TWO)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); tf.setValue(AnotherTestEnum.ONE.toString()); - Assert.assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(AnotherTestEnum.ONE, + assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); + assertEquals(AnotherTestEnum.ONE, tf.getPropertyDataSource().getValue()); tf.setPropertyDataSource(new ObjectProperty(TestEnum.TWO)); - Assert.assertEquals(TestEnum.TWO.toString(), tf.getValue()); + assertEquals(TestEnum.TWO.toString(), tf.getValue()); tf.setValue(TestEnum.ONE.toString()); - Assert.assertEquals(TestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(TestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(TestEnum.ONE, - tf.getPropertyDataSource().getValue()); + assertEquals(TestEnum.ONE.toString(), tf.getValue()); + assertEquals(TestEnum.ONE, tf.getConvertedValue()); + assertEquals(TestEnum.ONE, tf.getPropertyDataSource().getValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java index 2727b610bc..1d6efcd75e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.VaadinSession; @@ -85,7 +86,7 @@ public class ConverterFactoryTest { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } @Test @@ -100,7 +101,7 @@ public class ConverterFactoryTest { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } @Test @@ -121,6 +122,6 @@ public class ConverterFactoryTest { // The application converter always returns 42. Application.getCurrent() // should not be used - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java index 6300ed9479..87edc99c0c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DateToLongConverter; @@ -13,14 +14,13 @@ public class DateToLongConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Long.class, null)); + assertEquals(null, converter.convertToModel(null, Long.class, null)); } @Test public void testValueConversion() { Date d = new Date(100, 0, 1); - Assert.assertEquals( + assertEquals( Long.valueOf(946677600000l + (d.getTimezoneOffset() + 120) * 60 * 1000L), converter.convertToModel(d, Long.class, null)); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java index 35a8c5dbec..3cd83f8d2a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DateToSqlDateConverter; @@ -14,7 +15,7 @@ public class DateToSqlDateConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel(null, java.sql.Date.class, null)); } @@ -22,7 +23,7 @@ public class DateToSqlDateConverterTest { public void testValueConversion() { Date testDate = new Date(100, 0, 1); long time = testDate.getTime(); - Assert.assertEquals(testDate, converter.convertToModel( - new java.sql.Date(time), java.sql.Date.class, Locale.ENGLISH)); + assertEquals(testDate, converter.convertToModel(new java.sql.Date(time), + java.sql.Date.class, Locale.ENGLISH)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java index a157884376..8426d16e68 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DefaultConverterFactory; @@ -105,18 +106,18 @@ public class DefaultConverterFactoryTest { U tConvertedToU = factory.createConverter(tClass, uClass) .convertToModel(t, uClass, Locale.ENGLISH); - Assert.assertEquals("Incorrect type of value converted from " + assertEquals("Incorrect type of value converted from " + tClass.getSimpleName() + " to " + uClass.getSimpleName(), uClass, tConvertedToU.getClass()); - Assert.assertEquals("Incorrect conversion of " + t + " to " + assertEquals("Incorrect conversion of " + t + " to " + uClass.getSimpleName(), u, tConvertedToU); T uConvertedToT = factory.createConverter(uClass, tClass) .convertToModel(u, tClass, Locale.ENGLISH); - Assert.assertEquals("Incorrect type of value converted from " + assertEquals("Incorrect type of value converted from " + uClass.getSimpleName() + " to " + tClass.getSimpleName(), tClass, uConvertedToT.getClass()); - Assert.assertEquals("Incorrect conversion of " + u + " to " + assertEquals("Incorrect conversion of " + u + " to " + tClass.getSimpleName(), t, uConvertedToT); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java index 5ec0caa5ee..366255d616 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java @@ -16,9 +16,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -92,21 +93,19 @@ public class SpecificEnumToStringConverterTest { @Test public void nullConversion() { - Assert.assertEquals(null, - testEnumConverter.convertToModel(null, null, null)); + assertEquals(null, testEnumConverter.convertToModel(null, null, null)); } @Test public void enumToStringConversion() { - Assert.assertEquals(TestEnum.TWO.toString(), testEnumConverter + assertEquals(TestEnum.TWO.toString(), testEnumConverter .convertToModel(TestEnum.TWO, String.class, null)); } @Test public void stringToEnumConversion() { - Assert.assertEquals(TestEnum.TWO, - testEnumConverter.convertToPresentation(TestEnum.TWO.toString(), - TestEnum.class, null)); + assertEquals(TestEnum.TWO, testEnumConverter.convertToPresentation( + TestEnum.TWO.toString(), TestEnum.class, null)); } @Test @@ -114,11 +113,11 @@ public class SpecificEnumToStringConverterTest { TextField tf = new TextField(); tf.setConverter(new ReverseConverter(anotherTestEnumConverter)); tf.setPropertyDataSource(new ObjectProperty(AnotherTestEnum.TWO)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); tf.setValue(AnotherTestEnum.ONE.toString()); - Assert.assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(AnotherTestEnum.ONE, + assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); + assertEquals(AnotherTestEnum.ONE, tf.getPropertyDataSource().getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java index 00e384e594..64159c1c5f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBigDecimalConverter; @@ -29,13 +30,13 @@ public class StringToBigDecimalConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel(null, BigDecimal.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel("", BigDecimal.class, null)); } @@ -44,7 +45,7 @@ public class StringToBigDecimalConverterTest { BigDecimal converted = converter.convertToModel("10", BigDecimal.class, null); BigDecimal expected = new BigDecimal(10); - Assert.assertEquals(expected, converted); + assertEquals(expected, converted); } @Test @@ -54,6 +55,6 @@ public class StringToBigDecimalConverterTest { String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - Assert.assertEquals(expected, converted); + assertEquals(expected, converted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java index f613950c71..2009e8523e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigInteger; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBigIntegerConverter; @@ -29,13 +30,13 @@ public class StringToBigIntegerConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, BigInteger.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", BigInteger.class, null)); } @@ -45,8 +46,7 @@ public class StringToBigIntegerConverterTest { BigInteger converted = converter.convertToModel(bigInt, BigInteger.class, null); BigInteger expected = new BigInteger(bigInt); - Assert.assertEquals( - "Value bigger than max long was converted incorrectly", + assertEquals("Value bigger than max long was converted incorrectly", expected, converted); } @@ -57,8 +57,7 @@ public class StringToBigIntegerConverterTest { String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - Assert.assertEquals( - "Value with specific locale was converted incorrectly", + assertEquals("Value with specific locale was converted incorrectly", expected, converted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java index 9f94a4185e..b472c2d02c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java @@ -1,10 +1,13 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBooleanConverter; @@ -36,47 +39,41 @@ public class StringToBooleanConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Boolean.class, null)); + assertEquals(null, converter.convertToModel(null, Boolean.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Boolean.class, null)); + assertEquals(null, converter.convertToModel("", Boolean.class, null)); } @Test public void testValueConversion() { - Assert.assertTrue( - converter.convertToModel("true", Boolean.class, null)); - Assert.assertFalse( - converter.convertToModel("false", Boolean.class, null)); + assertTrue(converter.convertToModel("true", Boolean.class, null)); + assertFalse(converter.convertToModel("false", Boolean.class, null)); } @Test public void testYesNoValueConversion() { - Assert.assertTrue( - yesNoConverter.convertToModel("yes", Boolean.class, null)); - Assert.assertFalse( - yesNoConverter.convertToModel("no", Boolean.class, null)); + assertTrue(yesNoConverter.convertToModel("yes", Boolean.class, null)); + assertFalse(yesNoConverter.convertToModel("no", Boolean.class, null)); - Assert.assertEquals("yes", + assertEquals("yes", yesNoConverter.convertToPresentation(true, String.class, null)); - Assert.assertEquals("no", yesNoConverter.convertToPresentation(false, + assertEquals("no", yesNoConverter.convertToPresentation(false, String.class, null)); } @Test public void testLocale() { - Assert.assertEquals("May 18, 2033", localeConverter - .convertToPresentation(true, String.class, Locale.US)); - Assert.assertEquals("January 24, 2065", localeConverter + assertEquals("May 18, 2033", localeConverter.convertToPresentation(true, + String.class, Locale.US)); + assertEquals("January 24, 2065", localeConverter .convertToPresentation(false, String.class, Locale.US)); - Assert.assertEquals("18. Mai 2033", localeConverter - .convertToPresentation(true, String.class, Locale.GERMANY)); - Assert.assertEquals("24. Januar 2065", localeConverter + assertEquals("18. Mai 2033", localeConverter.convertToPresentation(true, + String.class, Locale.GERMANY)); + assertEquals("24. Januar 2065", localeConverter .convertToPresentation(false, String.class, Locale.GERMANY)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java index 334114a41a..fe249f1594 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -16,33 +18,32 @@ public class StringToByteConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Byte.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals("Null value reversely was converted incorrectly", - null, + assertEquals("Null value reversely was converted incorrectly", null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Byte.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals("Byte value was converted incorrectly", + assertEquals("Byte value was converted incorrectly", Byte.valueOf((byte) 10), converter.convertToModel("10", Byte.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Byte value reversely was converted incorrectly", + assertEquals("Byte value reversely was converted incorrectly", reverseConverter.convertToModel((byte) 10, String.class, null), "10"); } @@ -50,17 +51,16 @@ public class StringToByteConverterTest { @Test public void testExtremeByteValueConversion() { byte b = converter.convertToModel("127", Byte.class, null); - Assert.assertEquals(Byte.MAX_VALUE, b); + assertEquals(Byte.MAX_VALUE, b); b = converter.convertToModel("-128", Byte.class, null); - Assert.assertEquals("Min byte value was converted incorrectly", - Byte.MIN_VALUE, b); + assertEquals("Min byte value was converted incorrectly", Byte.MIN_VALUE, + b); } @Test public void testValueOutOfRange() { - Double[] values = { Byte.MAX_VALUE * 2.0, - Byte.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Byte.MAX_VALUE * 2.0, Byte.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -71,6 +71,6 @@ public class StringToByteConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java index f6dc22face..83f32e249f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java @@ -15,6 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -26,7 +31,6 @@ import java.util.Locale; import java.util.Set; import java.util.Vector; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToCollectionConverter; @@ -46,11 +50,11 @@ public class StringToCollectionConverterTest { StringToCollectionConverter converter = new StringToCollectionConverter(); Collection<?> model = converter.convertToModel("a, b, c", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -59,11 +63,11 @@ public class StringToCollectionConverterTest { "x"); Collection<?> model = converter.convertToModel("axbxc", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -72,11 +76,11 @@ public class StringToCollectionConverterTest { ",", new StringToIntegerConverter(), Integer.class); Collection<?> model = converter.convertToModel("6,2,5", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", 6, iterator.next()); - Assert.assertEquals("Incorrect second token", 2, iterator.next()); - Assert.assertEquals("Incorrect third token", 5, iterator.next()); + assertEquals("Incorrect fist token", 6, iterator.next()); + assertEquals("Incorrect second token", 2, iterator.next()); + assertEquals("Incorrect third token", 5, iterator.next()); } @Test @@ -85,10 +89,10 @@ public class StringToCollectionConverterTest { " ", new StringToEnumConverter(), TestEnum.class); Collection<?> model = converter.convertToModel("Z X Y", Set.class, null); - Assert.assertTrue("Unexpected model class", model instanceof HashSet); + assertTrue("Unexpected model class", model instanceof HashSet); EnumSet<TestEnum> set = EnumSet.allOf(TestEnum.class); set.removeAll(model); - Assert.assertTrue("Some values are not in resutling collection", + assertTrue("Some values are not in resutling collection", set.isEmpty()); } @@ -106,11 +110,11 @@ public class StringToCollectionConverterTest { ", ", null, String.class, factory); Collection<?> model = converter.convertToModel("a, b, c", Collection.class, null); - Assert.assertTrue("Unexpected model class", model instanceof Vector); + assertTrue("Unexpected model class", model instanceof Vector); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -119,7 +123,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList("a", "b", "c"), String.class, null); - Assert.assertEquals("a, b, c", presentation); + assertEquals("a, b, c", presentation); } @Test @@ -129,7 +133,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList("a", "b", "c"), String.class, null); - Assert.assertEquals("axbxc", presentation); + assertEquals("axbxc", presentation); } @Test @@ -139,7 +143,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList(TestEnum.Z, TestEnum.Y), String.class, null); - Assert.assertEquals("Z,Y", presentation); + assertEquals("Z,Y", presentation); } @Test @@ -147,22 +151,22 @@ public class StringToCollectionConverterTest { StringToCollectionConverter converter = new StringToCollectionConverter(); Collection<?> model = converter.convertToModel("a", List.class, null); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertFalse("More than one item detected after conversation", + assertEquals("Incorrect fist token", "a", iterator.next()); + assertFalse("More than one item detected after conversation", iterator.hasNext()); } @Test public void convertToModel_null() { StringToCollectionConverter converter = new StringToCollectionConverter(); - Assert.assertNull(converter.convertToModel(null, ArrayList.class, + assertNull(converter.convertToModel(null, ArrayList.class, Locale.ENGLISH)); } @Test public void convertToPresentation_null() { StringToCollectionConverter converter = new StringToCollectionConverter(); - Assert.assertNull(converter.convertToPresentation(null, String.class, + assertNull(converter.convertToPresentation(null, String.class, Locale.ENGLISH)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java index c778e9e731..985ff81490 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToDateConverter; @@ -14,19 +15,17 @@ public class StringToDateConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Date.class, null)); + assertEquals(null, converter.convertToModel(null, Date.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Date.class, null)); + assertEquals(null, converter.convertToModel("", Date.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(new Date(100, 0, 1), converter.convertToModel( + assertEquals(new Date(100, 0, 1), converter.convertToModel( "Jan 1, 2000 12:00:00 AM", Date.class, Locale.ENGLISH)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java index a0891ecefe..5f69c47367 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToDoubleConverter; @@ -11,19 +12,17 @@ public class StringToDoubleConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Double.class, null)); + assertEquals(null, converter.convertToModel(null, Double.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Double.class, null)); + assertEquals(null, converter.convertToModel("", Double.class, null)); } @Test public void testValueConversion() { Double value = converter.convertToModel("10", Double.class, null); - Assert.assertEquals(10.0d, value, 0.01d); + assertEquals(10.0d, value, 0.01d); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java index a86b8b82e0..3bc13df230 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -46,15 +49,14 @@ public class StringToEnumConverterTest { @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Enum.class, null)); + assertEquals(null, converter.convertToModel("", Enum.class, null)); } @Test public void testInvalidEnumClassConversion() { try { converter.convertToModel("Foo", Enum.class, null); - Assert.fail("No exception thrown"); + fail("No exception thrown"); } catch (ConversionException e) { // OK } @@ -62,69 +64,68 @@ public class StringToEnumConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Enum.class, null)); + assertEquals(null, converter.convertToModel(null, Enum.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals(null, + assertEquals(null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(FooEnum.VALUE1, + assertEquals(FooEnum.VALUE1, converter.convertToModel("Value1", FooEnum.class, null)); - Assert.assertEquals(FooEnum.SOME_VALUE, + assertEquals(FooEnum.SOME_VALUE, converter.convertToModel("Some value", FooEnum.class, null)); - Assert.assertEquals(FooEnum.FOO_BAR_BAZ, + assertEquals(FooEnum.FOO_BAR_BAZ, converter.convertToModel("Foo bar baz", FooEnum.class, null)); - Assert.assertEquals(FooEnum.Bar, + assertEquals(FooEnum.Bar, converter.convertToModel("Bar", FooEnum.class, null)); - Assert.assertEquals(FooEnum.nonStandardCase, converter + assertEquals(FooEnum.nonStandardCase, converter .convertToModel("Nonstandardcase", FooEnum.class, null)); - Assert.assertEquals(FooEnum._HUGH, + assertEquals(FooEnum._HUGH, converter.convertToModel("_hugh", FooEnum.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Value1", reverseConverter - .convertToModel(FooEnum.VALUE1, String.class, null)); - Assert.assertEquals("Some value", reverseConverter + assertEquals("Value1", reverseConverter.convertToModel(FooEnum.VALUE1, + String.class, null)); + assertEquals("Some value", reverseConverter .convertToModel(FooEnum.SOME_VALUE, String.class, null)); - Assert.assertEquals("Foo bar baz", reverseConverter + assertEquals("Foo bar baz", reverseConverter .convertToModel(FooEnum.FOO_BAR_BAZ, String.class, null)); - Assert.assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar, + assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar, String.class, null)); - Assert.assertEquals("Nonstandardcase", reverseConverter + assertEquals("Nonstandardcase", reverseConverter .convertToModel(FooEnum.nonStandardCase, String.class, null)); - Assert.assertEquals("_hugh", reverseConverter - .convertToModel(FooEnum._HUGH, String.class, null)); + assertEquals("_hugh", reverseConverter.convertToModel(FooEnum._HUGH, + String.class, null)); } @Test public void preserveFormattingWithCustomToString() { for (EnumWithCustomToString e : EnumWithCustomToString.values()) { - Assert.assertEquals(e.toString(), convertToString(e)); + assertEquals(e.toString(), convertToString(e)); } } @Test public void findEnumWithCustomToString() { for (EnumWithCustomToString e : EnumWithCustomToString.values()) { - Assert.assertSame(e, + assertSame(e, convertToEnum(e.toString(), EnumWithCustomToString.class)); - Assert.assertSame(e, + assertSame(e, convertToEnum(e.name(), EnumWithCustomToString.class)); } } @Test public void unambigousValueInEnumWithAmbigous_succeed() { - Assert.assertSame(EnumWithAmbigousToString.FOO, + assertSame(EnumWithAmbigousToString.FOO, convertToEnum("foo", EnumWithAmbigousToString.class)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java index 70c408b808..c13782fc32 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToFloatConverter; @@ -11,19 +12,17 @@ public class StringToFloatConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Float.class, null)); + assertEquals(null, converter.convertToModel(null, Float.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Float.class, null)); + assertEquals(null, converter.convertToModel("", Float.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(Float.valueOf(10), + assertEquals(Float.valueOf(10), converter.convertToModel("10", Float.class, null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java index 7d2f9c8d7d..a75e1a0c35 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter.ConversionException; @@ -12,21 +14,18 @@ public class StringToIntegerConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Integer.class, null)); + assertEquals(null, converter.convertToModel(null, Integer.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Integer.class, null)); + assertEquals(null, converter.convertToModel("", Integer.class, null)); } @Test public void testValueOutOfRange() { - Double[] values = { Integer.MAX_VALUE * 2.0, - Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -37,12 +36,12 @@ public class StringToIntegerConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } @Test public void testValueConversion() { - Assert.assertEquals(Integer.valueOf(10), + assertEquals(Integer.valueOf(10), converter.convertToModel("10", Integer.class, null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java index 5e5b9f1d86..4c5e3db5dc 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -17,51 +18,49 @@ public class StringToLongConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Long.class, null)); + assertEquals(null, converter.convertToModel(null, Long.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals(null, + assertEquals(null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Long.class, null)); + assertEquals(null, converter.convertToModel("", Long.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(Long.valueOf(10), + assertEquals(Long.valueOf(10), converter.convertToModel("10", Long.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals( - reverseConverter.convertToModel(10L, String.class, null), "10"); + assertEquals(reverseConverter.convertToModel(10L, String.class, null), + "10"); } @Test public void testExtremeLongValueConversion() { long l = converter.convertToModel("9223372036854775807", Long.class, null); - Assert.assertEquals(Long.MAX_VALUE, l); + assertEquals(Long.MAX_VALUE, l); l = converter.convertToModel("-9223372036854775808", Long.class, null); - Assert.assertEquals(Long.MIN_VALUE, l); + assertEquals(Long.MIN_VALUE, l); } @Test public void testExtremeReverseLongValueConversion() { String str = reverseConverter.convertToModel(Long.MAX_VALUE, String.class, Locale.ENGLISH); - Assert.assertEquals("9,223,372,036,854,775,807", str); + assertEquals("9,223,372,036,854,775,807", str); str = reverseConverter.convertToModel(Long.MIN_VALUE, String.class, Locale.ENGLISH); - Assert.assertEquals("-9,223,372,036,854,775,808", str); + assertEquals("-9,223,372,036,854,775,808", str); } @Test @@ -69,10 +68,10 @@ public class StringToLongConverterTest { // Long.MAX_VALUE+1 is converted to Long.MAX_VALUE long l = converter.convertToModel("9223372036854775808", Long.class, null); - Assert.assertEquals(Long.MAX_VALUE, l); + assertEquals(Long.MAX_VALUE, l); // Long.MIN_VALUE-1 is converted to Long.MIN_VALUE l = converter.convertToModel("-9223372036854775809", Long.class, null); - Assert.assertEquals(Long.MIN_VALUE, l); + assertEquals(Long.MIN_VALUE, l); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java index fed000555c..be29555bf0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -16,33 +18,32 @@ public class StringToShortConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Short.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals("Null value reversely was converted incorrectly", - null, + assertEquals("Null value reversely was converted incorrectly", null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Short.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals("Short value was converted incorrectly", + assertEquals("Short value was converted incorrectly", Short.valueOf((short) 10), converter.convertToModel("10", Short.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Short value reversely was converted incorrectly", + assertEquals("Short value reversely was converted incorrectly", reverseConverter.convertToModel((short) 10, String.class, null), "10"); } @@ -50,17 +51,16 @@ public class StringToShortConverterTest { @Test public void testExtremeShortValueConversion() { short b = converter.convertToModel("32767", Short.class, null); - Assert.assertEquals(Short.MAX_VALUE, b); + assertEquals(Short.MAX_VALUE, b); b = converter.convertToModel("-32768", Short.class, null); - Assert.assertEquals("Min short value was converted incorrectly", + assertEquals("Min short value was converted incorrectly", Short.MIN_VALUE, b); } @Test public void testValueOutOfRange() { - Double[] values = { Integer.MAX_VALUE * 2.0, - Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -71,6 +71,6 @@ public class StringToShortConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java index 5547651107..37e0daca6c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java @@ -1,8 +1,10 @@ package com.vaadin.v7.tests.data.validator; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.validator.BigDecimalRangeValidator; @@ -20,41 +22,41 @@ public class BigDecimalRangeValidatorTest { @Test public void testNullValue() { - Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + assertTrue("Didn't accept null", cleanValidator.isValid(null)); + assertTrue("Didn't accept null", minValidator.isValid(null)); + assertTrue("Didn't accept null", maxValidator.isValid(null)); + assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } @Test public void testMinValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(-15.0))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minValidator.isValid(new BigDecimal(10.1))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minValidator.isValid(new BigDecimal(10.0))); } @Test public void testMaxValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(1120.0))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", maxValidator.isValid(new BigDecimal(15.0))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", maxValidator.isValid(new BigDecimal(100.6))); } @Test public void testMinMaxValue() { - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(10.5))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(100.5))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minMaxValidator.isValid(new BigDecimal(10.4))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", minMaxValidator.isValid(new BigDecimal(100.6))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java index 144ca370fa..2f157e898c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java @@ -1,8 +1,10 @@ package com.vaadin.v7.tests.data.validator; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigInteger; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.validator.BigIntegerRangeValidator; @@ -20,41 +22,41 @@ public class BigIntegerRangeValidatorTest { @Test public void testNullValue() { - Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + assertTrue("Didn't accept null", cleanValidator.isValid(null)); + assertTrue("Didn't accept null", minValidator.isValid(null)); + assertTrue("Didn't accept null", maxValidator.isValid(null)); + assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } @Test public void testMinValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(-15))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minValidator.isValid(BigInteger.valueOf(15))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minValidator.isValid(BigInteger.valueOf(9))); } @Test public void testMaxValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(1120))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", maxValidator.isValid(BigInteger.valueOf(15))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", maxValidator.isValid(BigInteger.valueOf(120))); } @Test public void testMinMaxValue() { - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(15))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(99))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minMaxValidator.isValid(BigInteger.valueOf(9))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", minMaxValidator.isValid(BigInteger.valueOf(110))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java index b8f8109028..e55d5e071e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.validator; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.validator.EmailValidator; @@ -11,21 +13,21 @@ public class EmailValidatorTest { @Test public void testEmailValidatorWithNull() { - Assert.assertTrue(validator.isValid(null)); + assertTrue(validator.isValid(null)); } @Test public void testEmailValidatorWithEmptyString() { - Assert.assertTrue(validator.isValid("")); + assertTrue(validator.isValid("")); } @Test public void testEmailValidatorWithFaultyString() { - Assert.assertFalse(validator.isValid("not.an.email")); + assertFalse(validator.isValid("not.an.email")); } @Test public void testEmailValidatorWithOkEmail() { - Assert.assertTrue(validator.isValid("my.name@email.com")); + assertTrue(validator.isValid("my.name@email.com")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java index b84388ad9c..612d1027e9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.server; +import static org.junit.Assert.fail; + import java.util.EventObject; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.event.ContextClickEvent; @@ -77,9 +78,9 @@ public class ContextClickListenerTest extends AbstractComponent { public void validate() { if (expected != null) { - Assert.fail("Expected context click never happened."); + fail("Expected context click never happened."); } else if (error != null) { - Assert.fail(error); + fail(error); } } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java index 5cc57a75b7..3557a7f87e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; + import java.text.NumberFormat; import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -53,13 +54,13 @@ public class AbsFieldDataSourceLocaleChangeTest { }); tf.setImmediate(true); tf.setConvertedValue(10000); - Assert.assertEquals("0000010000", tf.getValue()); + 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()); + assertEquals("10,000", tf.getValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java index 12ac5ccca7..b64f51e345 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java @@ -1,8 +1,8 @@ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.data.bean.Address; @@ -32,7 +32,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals( + assertEquals( "(Type: Integer) Converter exception message: Could not convert 'abc' to java.lang.Integer", e.getMessage()); } @@ -50,7 +50,7 @@ public class AbsFieldValueConversionErrorTest { tf.getConvertedValue(); fail(); } catch (ConversionException e) { - Assert.assertEquals( + assertEquals( "(Type: Integer) Converter exception message: Could not convert 'abc' to java.lang.Integer", e.getMessage()); } @@ -68,7 +68,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals(null, e.getMessage()); + assertEquals(null, e.getMessage()); } } @@ -84,8 +84,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals("Could not convert value to Integer", - e.getMessage()); + assertEquals("Could not convert value to Integer", e.getMessage()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index d4bdb4fe53..7ff7058e67 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -3,10 +3,10 @@ package com.vaadin.v7.tests.server.component.abstractfield; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.VaadinSession; @@ -266,8 +266,7 @@ public class AbsFieldValueConversionsTest { try { Object v = tf.getConvertedValue(); System.out.println(v); - Assert.fail( - "Trying to convert String -> Integer should fail when there is no converter"); + fail("Trying to convert String -> Integer should fail when there is no converter"); } catch (ConversionException e) { // ok, should happen when there is no converter but conversion is // needed diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java index 3ee4ce607b..4e70a70030 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java @@ -15,10 +15,13 @@ */ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.tests.VaadinClasses; @@ -36,7 +39,7 @@ public class FieldDefaultValuesTest { Object clearedValue = field.getValue(); - Assert.assertEquals( + assertEquals( "Expected to get default value after clearing " + field.getClass().getName(), originalValue, clearedValue); @@ -51,18 +54,18 @@ public class FieldDefaultValuesTest { field.clear(); if (field instanceof Slider) { - Assert.assertFalse( + assertFalse( "Slider should not be empty even after being cleared", field.isEmpty()); } else { - Assert.assertTrue( + assertTrue( field.getClass().getName() + " should be empty after being cleared", field.isEmpty()); } } - Assert.assertTrue(count > 0); + assertTrue(count > 0); } @SuppressWarnings("rawtypes") diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java index 6b0315a845..be22583697 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.v7.tests.server.component.abstractselect; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; import org.jsoup.parser.Tag; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.ExternalResource; @@ -179,7 +181,7 @@ public class AbstractSelectDeclarativeTest container.addContainerProperty("name", String.class, null); cb.setContainerDataSource(container); cb.readDesign(design, new DesignContext()); - Assert.assertTrue("Adding new items should be allowed.", + assertTrue("Adding new items should be allowed.", cb.isNewItemsAllowed()); assertEquals("Wrong item caption mode.", AbstractSelect.ItemCaptionMode.PROPERTY, @@ -188,7 +190,7 @@ public class AbstractSelectDeclarativeTest cb.getItemCaptionPropertyId()); assertEquals("Wrong item icon property id.", "icon", cb.getItemIconPropertyId()); - Assert.assertTrue("Null selection should be allowed.", + assertTrue("Null selection should be allowed.", cb.isNullSelectionAllowed()); assertEquals("Wrong null selection item id.", "No items selected", cb.getNullSelectionItemId()); @@ -199,12 +201,11 @@ public class AbstractSelectDeclarativeTest Element design = createDesignWithAttributesMultiSelect(); ListSelect ls = new ListSelect(); ls.readDesign(design, new DesignContext()); - Assert.assertTrue("Multi select should be allowed.", - ls.isMultiSelect()); + assertTrue("Multi select should be allowed.", ls.isMultiSelect()); assertEquals("Wrong caption mode.", AbstractSelect.ItemCaptionMode.EXPLICIT, ls.getItemCaptionMode()); - Assert.assertFalse("Null selection should not be allowed.", + assertFalse("Null selection should not be allowed.", ls.isNullSelectionAllowed()); } @@ -235,13 +236,13 @@ public class AbstractSelectDeclarativeTest cb.writeDesign(e, new DesignContext()); assertEquals("Wrong caption for the combo box.", "A combo box", e.attr("caption")); - Assert.assertTrue("Adding new items should be allowed.", + assertTrue("Adding new items should be allowed.", "".equals(e.attr("new-items-allowed"))); assertEquals("Wrong item caption mode.", "icon_only", e.attr("item-caption-mode")); assertEquals("Wrong item icon property id.", "icon", e.attr("item-icon-property-id")); - Assert.assertTrue("Null selection should be allowed.", + assertTrue("Null selection should be allowed.", "".equals(e.attr("null-selection-allowed")) || "true".equals(e.attr("null-selection-allowed"))); assertEquals("Wrong null selection item id.", "No item selected", @@ -255,7 +256,7 @@ public class AbstractSelectDeclarativeTest ls.writeDesign(e, new DesignContext()); assertEquals("Null selection should not be allowed.", "false", e.attr("null-selection-allowed")); - Assert.assertTrue("Multi select should be allowed.", + assertTrue("Multi select should be allowed.", "".equals(e.attr("multi-select")) || "true".equals(e.attr("multi-select"))); } @@ -267,7 +268,7 @@ public class AbstractSelectDeclarativeTest + " <option>> Two</option>" + "</vaadin7-combo-box>"; AbstractSelect read = read(design); - Assert.assertEquals("> One", read.getItemCaption("one")); + assertEquals("> One", read.getItemCaption("one")); AbstractSelect underTest = new ComboBox(); underTest.addItem("> One"); @@ -278,7 +279,7 @@ public class AbstractSelectDeclarativeTest DeclarativeTestBaseBase.ALWAYS_WRITE_DATA); underTest.writeDesign(root, dc); - Assert.assertEquals("> One", + assertEquals("> One", root.getElementsByTag("option").first().html()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java index 14f03739d1..5348d99f25 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.abstractselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.select.AbstractSelectState; @@ -31,7 +32,7 @@ public class AbstractSelectStateTest { public void getState_selectHasCustomState() { TestSelect select = new TestSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class AbstractSelectStateTest { public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { TestSelect combobox = new TestSelect(); AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, combobox.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + combobox.getPrimaryStyleName()); } @Test public void selectStateHasCustomPrimaryStyleName() { AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", "v-select", + assertEquals("Unexpected primary style name", "v-select", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java index 207d50f8aa..38ee0928a0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java @@ -211,7 +211,7 @@ public class CalendarBasicsTest { @Test public void isClientChangeAllowed_connectorEnabled() { TestCalendar calendar = new TestCalendar(true); - Assert.assertTrue( + assertTrue( "Calendar with enabled connector doesn't allow client change", calendar.isClientChangeAllowed()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java index a504d64a13..347628327a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java @@ -389,20 +389,20 @@ public class ContainerDataSourceTest { calendar.setLocale(Locale.getDefault()); calendar.beforeClientResponse(true); // simulate adding to UI - Assert.assertEquals(0, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(23, calendar.getLastVisibleHourOfDay()); + assertEquals(0, calendar.getFirstVisibleHourOfDay()); + assertEquals(23, calendar.getLastVisibleHourOfDay()); calendar.autoScaleVisibleHoursOfDay(); - Assert.assertEquals(8, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(18, calendar.getLastVisibleHourOfDay()); + assertEquals(8, calendar.getFirstVisibleHourOfDay()); + assertEquals(18, calendar.getLastVisibleHourOfDay()); // reset visible timing to something else, so that the added event is // not filtered out calendar.resetVisibleHoursOfDay(); calendar.beforeClientResponse(false); // simulate being attached - Assert.assertEquals(0, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(23, calendar.getLastVisibleHourOfDay()); + assertEquals(0, calendar.getFirstVisibleHourOfDay()); + assertEquals(23, calendar.getLastVisibleHourOfDay()); start.set(java.util.Calendar.HOUR_OF_DAY, 5); end.set(java.util.Calendar.HOUR_OF_DAY, 21); @@ -411,8 +411,8 @@ public class ContainerDataSourceTest { calendar.beforeClientResponse(false); // simulate being attached calendar.autoScaleVisibleHoursOfDay(); - Assert.assertEquals(5, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(21, calendar.getLastVisibleHourOfDay()); + assertEquals(5, calendar.getFirstVisibleHourOfDay()); + assertEquals(21, calendar.getLastVisibleHourOfDay()); } private static Indexed createTestBeanItemContainer() { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java index 84ab1edaa2..53cecb9904 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.server.component.calendar; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Calendar; import java.util.Date; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.BeanItemContainer; @@ -35,7 +37,7 @@ public class ContainerEventProviderTest { @Test public void testDefaultAllDayProperty() { ContainerEventProvider provider = new ContainerEventProvider(null); - Assert.assertEquals(ContainerEventProvider.ALL_DAY_PROPERTY, + assertEquals(ContainerEventProvider.ALL_DAY_PROPERTY, provider.getAllDayProperty()); } @@ -45,7 +47,7 @@ public class ContainerEventProviderTest { ContainerEventProvider provider = new ContainerEventProvider(null); Object prop = new Object(); provider.setAllDayProperty(prop); - Assert.assertEquals(prop, provider.getAllDayProperty()); + assertEquals(prop, provider.getAllDayProperty()); } @Test @@ -57,7 +59,7 @@ public class ContainerEventProviderTest { ContainerEventProvider provider = new ContainerEventProvider(container); List<CalendarEvent> events = provider.getEvents(bean.getStart(), bean.getEnd()); - Assert.assertTrue(events.get(0).isAllDay()); + assertTrue(events.get(0).isAllDay()); } public static class EventBean { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java index 83febabf43..d5276af153 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.combobox.ComboBoxState; @@ -30,7 +31,7 @@ public class ComboBoxStateTest { public void getState_comboboxHasCustomState() { TestComboBox combobox = new TestComboBox(); ComboBoxState state = combobox.getState(); - Assert.assertEquals("Unexpected state class", ComboBoxState.class, + assertEquals("Unexpected state class", ComboBoxState.class, state.getClass()); } @@ -38,14 +39,14 @@ public class ComboBoxStateTest { public void getPrimaryStyleName_comboboxHasCustomPrimaryStyleName() { ComboBox combobox = new ComboBox(); ComboBoxState state = new ComboBoxState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, combobox.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + combobox.getPrimaryStyleName()); } @Test public void comboboxStateHasCustomPrimaryStyleName() { ComboBoxState state = new ComboBoxState(); - Assert.assertEquals("Unexpected primary style name", "v-filterselect", + assertEquals("Unexpected primary style name", "v-filterselect", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java index 29eaf13e70..72cb590076 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java @@ -1,8 +1,8 @@ package com.vaadin.v7.tests.server.component.fieldgroup; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.PropertyId; @@ -88,13 +88,13 @@ public class BeanFieldGroupTest { .bindFieldsUnbuffered(myBean, viewStub); Field<String> field = (Field<String>) bindFields.getField("basicField"); - Assert.assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); + assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); field.setValue("Foo"); - Assert.assertEquals("Foo", myBean.basicField); + assertEquals("Foo", myBean.basicField); field = (Field<String>) bindFields.getField("anotherField"); field.setValue("Foo"); - Assert.assertEquals("Foo", myBean.anotherField); + assertEquals("Foo", myBean.anotherField); } @SuppressWarnings("unchecked") @@ -109,17 +109,17 @@ public class BeanFieldGroupTest { Field<String> basicField = (Field<String>) bindFields .getField("basicField"); basicField.setValue("Foo"); - Assert.assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); + assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); Field<String> anotherField = (Field<String>) bindFields .getField("anotherField"); anotherField.setValue("Foo"); - Assert.assertNull(myBean.anotherField); + assertNull(myBean.anotherField); bindFields.commit(); - Assert.assertEquals("Foo", myBean.basicField); - Assert.assertEquals("Foo", myBean.anotherField); + assertEquals("Foo", myBean.basicField); + assertEquals("Foo", myBean.anotherField); } @@ -156,7 +156,7 @@ public class BeanFieldGroupTest { group.setItemDataSource((MyBean) null); BeanItem<MyBean> dataSource = group.getItemDataSource(); - Assert.assertNull("Data source is null for null bean", dataSource); + assertNull("Data source is null for null bean", dataSource); } @Test @@ -165,7 +165,7 @@ public class BeanFieldGroupTest { group.setItemDataSource((Item) null); BeanItem<MyBean> dataSource = group.getItemDataSource(); - Assert.assertNull("Group returns not null data source", dataSource); + assertNull("Group returns not null data source", dataSource); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java index bd44a18c1a..bfb079566a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java @@ -15,6 +15,11 @@ */ package com.vaadin.v7.tests.server.component.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -22,7 +27,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Item; @@ -51,7 +55,7 @@ public class FieldGroupTest { fieldGroup.setReadOnly(true); - Assert.assertTrue("Field is not read only", field.isReadOnly()); + assertTrue("Field is not read only", field.isReadOnly()); } @Test @@ -63,7 +67,7 @@ public class FieldGroupTest { fieldGroup.setReadOnly(false); - Assert.assertFalse("Field is not writable", field.isReadOnly()); + assertFalse("Field is not writable", field.isReadOnly()); } @Test @@ -86,7 +90,7 @@ public class FieldGroupTest { try { fieldGroup.commit(); - Assert.fail("No commit exception is thrown"); + fail("No commit exception is thrown"); } catch (CommitException exception) { Map<Field<?>, ? extends InvalidValueException> invalidFields = exception .getInvalidFields(); @@ -94,10 +98,9 @@ public class FieldGroupTest { .entrySet()) { set.remove(entry.getKey()); } - Assert.assertEquals( - "Some fields are not found in the invalid fields map", 0, - set.size()); - Assert.assertEquals( + assertEquals("Some fields are not found in the invalid fields map", + 0, set.size()); + assertEquals( "Invalid value exception should be thrown for each field", 2, invalidFields.size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java index 0b30afbe0c..c5372bbd75 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.form; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.ui.Form; @@ -60,9 +62,9 @@ public class FormTest { form.addField("b", field2); form.focus(); - Assert.assertTrue("Field with enabled connector is not focused", + assertTrue("Field with enabled connector is not focused", secondFieldIsFocused[0]); - Assert.assertFalse("Field with disabled connector is focused", + assertFalse("Field with disabled connector is focused", firstFieldIsFocused[0]); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java index f9f7d8e3c8..a98c3b6319 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Before; import org.junit.Test; @@ -42,12 +44,12 @@ public class GridAddRowBuiltinContainerTest { public void testSimpleCase() { Object itemId = grid.addRow("Hello"); - Assert.assertEquals(Integer.valueOf(1), itemId); + assertEquals(Integer.valueOf(1), itemId); - Assert.assertEquals("There should be one item in the container", 1, + assertEquals("There should be one item in the container", 1, container.size()); - Assert.assertEquals("Hello", container.getItem(itemId) + assertEquals("Hello", container.getItem(itemId) .getItemProperty("myColumn").getValue()); } @@ -62,8 +64,8 @@ public class GridAddRowBuiltinContainerTest { // cast to Object to distinguish from a null varargs array Object itemId = grid.addRow((Object) null); - Assert.assertEquals(null, container.getItem(itemId) - .getItemProperty("myColumn").getValue()); + assertEquals(null, container.getItem(itemId).getItemProperty("myColumn") + .getValue()); } @Test(expected = IllegalArgumentException.class) @@ -78,9 +80,8 @@ public class GridAddRowBuiltinContainerTest { Object itemId = grid.addRow("Hello", Integer.valueOf(3)); Item item = container.getItem(itemId); - Assert.assertEquals("Hello", - item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Hello", item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -97,9 +98,9 @@ public class GridAddRowBuiltinContainerTest { grid.addRow(Integer.valueOf(3)); Item item = container.getItem(Integer.valueOf(1)); - Assert.assertEquals("Default value should be used for removed column", - "", item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Default value should be used for removed column", "", + item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -112,9 +113,8 @@ public class GridAddRowBuiltinContainerTest { grid.addRow(Integer.valueOf(3), "Hello"); Item item = container.getItem(Integer.valueOf(1)); - Assert.assertEquals("Hello", - item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Hello", item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -125,10 +125,9 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail("Adding wrong type should throw ClassCastException"); + fail("Adding wrong type should throw ClassCastException"); } catch (IllegalArgumentException e) { - Assert.assertEquals("No row should have been added", 0, - container.size()); + assertEquals("No row should have been added", 0, container.size()); } } @@ -141,11 +140,9 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail( - "Adding to BeanItemContainer container should throw UnsupportedOperationException"); + fail("Adding to BeanItemContainer container should throw UnsupportedOperationException"); } catch (UnsupportedOperationException e) { - Assert.assertEquals("No row should have been added", 0, - container.size()); + assertEquals("No row should have been added", 0, container.size()); } } @@ -164,9 +161,9 @@ public class GridAddRowBuiltinContainerTest { grid.addRow("name"); - Assert.assertEquals(1, container.size()); + assertEquals(1, container.size()); - Assert.assertEquals("name", container.getIdByIndex(0).getFirstName()); + assertEquals("name", container.getIdByIndex(0).getFirstName()); } @Test @@ -197,12 +194,12 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail("Adding row should throw MethodException"); + fail("Adding row should throw MethodException"); } catch (MethodException e) { - Assert.assertEquals("Got the wrong exception", "name", + assertEquals("Got the wrong exception", "name", e.getCause().getMessage()); - Assert.assertEquals("There should be no rows in the container", 0, + assertEquals("There should be no rows in the container", 0, container.size()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java index 4cee00af63..9e8da734e2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java @@ -15,11 +15,14 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -54,7 +57,7 @@ public class GridContainerTest { grid.setContainerDataSource(createContainer()); - Assert.assertEquals("DetailsGenerator changed", detGen, + assertEquals("DetailsGenerator changed", detGen, grid.getDetailsGenerator()); } @@ -91,9 +94,9 @@ public class GridContainerTest { grid.setContainerDataSource(ic); grid.setColumns("foo", "baz", "bar"); - Assert.assertEquals("foo", grid.getColumns().get(0).getPropertyId()); - Assert.assertEquals("baz", grid.getColumns().get(1).getPropertyId()); - Assert.assertEquals("bar", grid.getColumns().get(2).getPropertyId()); + assertEquals("foo", grid.getColumns().get(0).getPropertyId()); + assertEquals("baz", grid.getColumns().get(1).getPropertyId()); + assertEquals("bar", grid.getColumns().get(2).getPropertyId()); } @Test @@ -102,11 +105,10 @@ public class GridContainerTest { grid.setContainerDataSource(new IndexedContainer()); try { grid.addColumn("notInContainer"); - Assert.fail( - "Adding a property id not in the container should throw an exception"); + fail("Adding a property id not in the container should throw an exception"); } catch (IllegalStateException e) { - Assert.assertTrue(e.getMessage().contains("notInContainer")); - Assert.assertTrue( + assertTrue(e.getMessage().contains("notInContainer")); + assertTrue( e.getMessage().contains("does not exist in the container")); } } @@ -117,13 +119,12 @@ public class GridContainerTest { grid.setContainerDataSource(new IndexedContainer()); try { grid.setColumns("notInContainer", "notThereEither"); - Assert.fail( - "Setting columns for property ids not in the container should throw an exception"); + fail("Setting columns for property ids not in the container should throw an exception"); } catch (IllegalStateException e) { // addColumn is run in random order.. - Assert.assertTrue(e.getMessage().contains("notInContainer") + assertTrue(e.getMessage().contains("notInContainer") || e.getMessage().contains("notThereEither")); - Assert.assertTrue( + assertTrue( e.getMessage().contains("does not exist in the container")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java index cc72df39ab..99a0545fe8 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java @@ -21,12 +21,12 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Method; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -171,8 +171,7 @@ public class GridEditorTest { // Manual fail instead of @Test(expected=...) to check it is // saveEditor that fails and not setValue grid.saveEditor(); - Assert.fail( - "CommitException expected when saving an invalid field value"); + fail("CommitException expected when saving an invalid field value"); } catch (CommitException e) { // expected } @@ -279,7 +278,7 @@ public class GridEditorTest { try { doEditMethod.invoke(grid); } catch (Exception e) { - Assert.fail("Editing item " + ITEM_ID + " failed. Cause: " + fail("Editing item " + ITEM_ID + " failed. Cause: " + e.getCause().toString()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java index 2421e8d07a..e02d7c5286 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java @@ -379,7 +379,7 @@ public class GridSelectionTest { @Test public void selectionChangeEventWhenChangingSelectionModeSingleToNone() { grid.select(itemId1Present); - Assert.assertEquals(itemId1Present, grid.getSelectedRow()); + assertEquals(itemId1Present, grid.getSelectedRow()); mockListener.clearEvent(); grid.setSelectionMode(SelectionMode.NONE); assertTrue(mockListener.eventHasHappened()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java index b9ae44301b..978e05a73e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.grid.GridState; @@ -31,14 +32,14 @@ public class GridStateTest { public void getPrimaryStyleName_gridHasCustomPrimaryStyleName() { Grid grid = new Grid(); GridState state = new GridState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, grid.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + grid.getPrimaryStyleName()); } @Test public void gridStateHasCustomPrimaryStyleName() { GridState state = new GridState(); - Assert.assertEquals("Unexpected primary style name", "v-grid", + assertEquals("Unexpected primary style name", "v-grid", state.primaryStyleName); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java index 6e43eb2b85..c75b89816c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java @@ -1,6 +1,9 @@ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.server.ServerRpcManager.RpcInvocationException; @@ -63,21 +66,21 @@ public class ItemSetChangeDuringEditorCommit { .setValue("New last"); grid.saveEditor(); - Assert.assertEquals("New first", indexedContainer + assertEquals("New first", indexedContainer .getContainerProperty(grid.getEditedItemId(), "firstName") .getValue()); - Assert.assertEquals("New last", indexedContainer + assertEquals("New last", indexedContainer .getContainerProperty(grid.getEditedItemId(), "lastName") .getValue()); grid.cancelEditor(); - Assert.assertFalse(grid.isEditorActive()); + assertFalse(grid.isEditorActive()); editItem(grid, 0); - Assert.assertEquals("New first", + assertEquals("New first", ((TextField) grid.getEditorFieldGroup().getField("firstName")) .getValue()); - Assert.assertEquals("New last", + assertEquals("New last", ((TextField) grid.getEditorFieldGroup().getField("lastName")) .getValue()); saveEditor(grid, 0); @@ -90,7 +93,7 @@ public class ItemSetChangeDuringEditorCommit { invocation.setParameters(new Object[] { itemIndex }); grid.getRpcManager(EditorServerRpc.class.getName()) .applyInvocation(invocation); - Assert.assertTrue(grid.isEditorActive()); + assertTrue(grid.isEditorActive()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java index 7840b1f246..1031ad8b5a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java @@ -15,13 +15,16 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,9 +73,9 @@ public class MultiSelectionModelTest { @After public void tearDown() { - Assert.assertFalse("Some expected select event did not happen.", + assertFalse("Some expected select event did not happen.", expectingEvent); - Assert.assertFalse("Some expected deselect event did not happen.", + assertFalse("Some expected deselect event did not happen.", expectingDeselectEvent); } @@ -118,13 +121,13 @@ public class MultiSelectionModelTest { @Test public void testSelectAllWithoutItems() throws Throwable { - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); dataSource.removeAllItems(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); model.select(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); model.deselect(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); } @Test @@ -165,15 +168,15 @@ public class MultiSelectionModelTest { @Override public void select(SelectionEvent event) { - Assert.assertTrue("Selection did not contain expected items", + assertTrue("Selection did not contain expected items", event.getAdded().containsAll(select)); - Assert.assertTrue("Selection contained unexpected items", + assertTrue("Selection contained unexpected items", select.containsAll(event.getAdded())); select = new ArrayList<Object>(); - Assert.assertTrue("Deselection did not contain expected items", + assertTrue("Deselection did not contain expected items", event.getRemoved().containsAll(deselect)); - Assert.assertTrue("Deselection contained unexpected items", + assertTrue("Deselection contained unexpected items", deselect.containsAll(event.getRemoved())); deselect = new ArrayList<Object>(); @@ -189,7 +192,7 @@ public class MultiSelectionModelTest { && selected.containsAll(model.getSelectedRows())) { return; } - Assert.fail("Not all items were correctly selected"); + fail("Not all items were correctly selected"); } @Test(expected = IllegalStateException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java index 91d537824c..7a115c42ff 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java @@ -15,8 +15,10 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -53,8 +55,7 @@ public class SingleSelectionModelTest { @After public void tearDown() { - Assert.assertFalse("Some expected event did not happen.", - expectingEvent); + assertFalse("Some expected event did not happen.", expectingEvent); } private IndexedContainer createDataSource() { @@ -116,7 +117,7 @@ public class SingleSelectionModelTest { } catch (Exception e) { throw e.getCause(); } - Assert.assertTrue("Should still wait for event", expectingEvent); + assertTrue("Should still wait for event", expectingEvent); expectingEvent = false; } @@ -132,19 +133,18 @@ public class SingleSelectionModelTest { @Override public void select(SelectionEvent event) { if (selected != null) { - Assert.assertTrue("Selection did not contain expected item", + assertTrue("Selection did not contain expected item", event.getAdded().contains(selected)); } else { - Assert.assertTrue("Unexpected selection", + assertTrue("Unexpected selection", event.getAdded().isEmpty()); } if (deselected != null) { - Assert.assertTrue( - "DeSelection did not contain expected item", + assertTrue("DeSelection did not contain expected item", event.getRemoved().contains(deselected)); } else { - Assert.assertTrue("Unexpected selection", + assertTrue("Unexpected selection", event.getRemoved().isEmpty()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java index 71a0c7987e..a01e8dadce 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java @@ -54,14 +54,14 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { } private void compareHeaders(Grid expected, Grid actual) { - Assert.assertEquals("Different header row count", + assertEquals("Different header row count", expected.getHeaderRowCount(), actual.getHeaderRowCount()); for (int i = 0; i < expected.getHeaderRowCount(); ++i) { HeaderRow expectedRow = expected.getHeaderRow(i); HeaderRow actualRow = actual.getHeaderRow(i); if (expectedRow.equals(expected.getDefaultHeaderRow())) { - Assert.assertEquals("Different index for default header row", + assertEquals("Different index for default header row", actual.getDefaultHeaderRow(), actualRow); } @@ -74,11 +74,11 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -92,7 +92,7 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { } private void compareFooters(Grid expected, Grid actual) { - Assert.assertEquals("Different footer row count", + assertEquals("Different footer row count", expected.getFooterRowCount(), actual.getFooterRowCount()); for (int i = 0; i < expected.getFooterRowCount(); ++i) { FooterRow expectedRow = expected.getFooterRow(i); @@ -107,11 +107,11 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -127,7 +127,7 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { private void compareGridColumns(Grid expected, Grid actual) { List<Column> columns = expected.getColumns(); List<Column> actualColumns = actual.getColumns(); - Assert.assertEquals("Different amount of columns", columns.size(), + assertEquals("Different amount of columns", columns.size(), actualColumns.size()); for (int i = 0; i < columns.size(); ++i) { Column col1 = columns.get(i); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java index 064627ade1..87159d0024 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java @@ -307,8 +307,8 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { String actualFooter = grid.getFooterRow(0).getCell("> test").getText(); String expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); design = design.replace("plain-text=\"true\"", ""); grid = read(design); @@ -316,8 +316,8 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { actualFooter = grid.getFooterRow(0).getCell("> test").getHtml(); expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); grid = new Grid(); grid.setColumns("test"); @@ -332,9 +332,9 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { Element root = new Element(Tag.valueOf("vaadin7-grid"), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("td").get(0).html()); header = grid.addHeaderRowAt(0); @@ -347,9 +347,9 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { root = new Element(Tag.valueOf("vaadin7-grid"), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("& Test", + assertEquals("& Test", root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("& Test", + assertEquals("& Test", root.getElementsByTag("td").get(0).html()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java index 63eb1e7a66..d5ac086d46 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java @@ -117,7 +117,7 @@ public class GridInlineDataDeclarativeTest extends GridDeclarativeTestBase { Grid read = read(design); Container cds = read.getContainerDataSource(); - Assert.assertEquals("&Test", + assertEquals("&Test", cds.getItem(cds.getItemIds().iterator().next()) .getItemProperty("test").getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java index cc209c025e..5fd9096d52 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.server.component.grid.sort; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -41,17 +43,15 @@ public class SortTest { @Override public void sort(Object[] propertyId, boolean[] ascending) { - Assert.assertEquals( - "Different amount of expected and actual properties,", + assertEquals("Different amount of expected and actual properties,", expectedProperties.length, propertyId.length); - Assert.assertEquals( - "Different amount of expected and actual directions", + assertEquals("Different amount of expected and actual directions", expectedAscending.length, ascending.length); for (int i = 0; i < propertyId.length; ++i) { - Assert.assertEquals("Sorting properties differ", - expectedProperties[i], propertyId[i]); - Assert.assertEquals("Sorting directions differ", - expectedAscending[i], ascending[i]); + assertEquals("Sorting properties differ", expectedProperties[i], + propertyId[i]); + assertEquals("Sorting directions differ", expectedAscending[i], + ascending[i]); } sorted = true; } @@ -83,7 +83,7 @@ public class SortTest { } public void assertEventFired(SortOrder... expectedOrder) { - Assert.assertEquals(Arrays.asList(expectedOrder), order); + assertEquals(Arrays.asList(expectedOrder), order); // Reset for nest test order = null; @@ -108,7 +108,7 @@ public class SortTest { @After public void tearDown() { - Assert.assertTrue("Container was not sorted after the test.", + assertTrue("Container was not sorted after the test.", container.isSorted()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java index d9e31e6bc1..472e514cc2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.listselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.select.AbstractSelectState; @@ -31,7 +32,7 @@ public class ListSelectStateTest { public void getState_listSelectHasCustomState() { TestListSelect select = new TestListSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java index 85aff22711..ca47df9617 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.optiongroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.optiongroup.OptionGroupState; @@ -31,7 +32,7 @@ public class OptionGroupStateTest { public void getState_optionGroupHasCustomState() { TestOptionGroup group = new TestOptionGroup(); OptionGroupState state = group.getState(); - Assert.assertEquals("Unexpected state class", OptionGroupState.class, + assertEquals("Unexpected state class", OptionGroupState.class, state.getClass()); } @@ -39,15 +40,15 @@ public class OptionGroupStateTest { public void getPrimaryStyleName_optionGroupHasCustomPrimaryStyleName() { OptionGroup layout = new OptionGroup(); OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, layout.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + layout.getPrimaryStyleName()); } @Test public void optionGroupStateHasCustomPrimaryStyleName() { OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - "v-select-optiongroup", state.primaryStyleName); + assertEquals("Unexpected primary style name", "v-select-optiongroup", + state.primaryStyleName); } private static class TestOptionGroup extends OptionGroup { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java index 131dfa329b..9c0db8a7dc 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.richtextarea; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.textarea.RichTextAreaState; @@ -30,7 +31,7 @@ public class RichTextAreaStateTest { public void getState_areaHasCustomState() { TestRichTextArea area = new TestRichTextArea(); RichTextAreaState state = area.getState(); - Assert.assertEquals("Unexpected state class", RichTextAreaState.class, + assertEquals("Unexpected state class", RichTextAreaState.class, state.getClass()); } @@ -38,14 +39,14 @@ public class RichTextAreaStateTest { public void getPrimaryStyleName_areaHasCustomPrimaryStyleName() { RichTextArea area = new RichTextArea(); RichTextAreaState state = new RichTextAreaState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, area.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + area.getPrimaryStyleName()); } @Test public void areaStateHasCustomPrimaryStyleName() { RichTextAreaState state = new RichTextAreaState(); - Assert.assertEquals("Unexpected primary style name", "v-richtextarea", + assertEquals("Unexpected primary style name", "v-richtextarea", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java index ee3afb1268..3282124ef9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java @@ -16,7 +16,9 @@ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import org.junit.Test; import com.vaadin.v7.ui.Table; @@ -26,29 +28,27 @@ public class CacheUpdateExceptionCausesTest { @Test public void testSingleCauseException() { Table table = new Table(); - Throwable[] causes = { - new RuntimeException("Broken in one way.") }; + Throwable[] causes = { new RuntimeException("Broken in one way.") }; CacheUpdateException exception = new CacheUpdateException(table, "Error during Table cache update.", causes); - Assert.assertSame(causes[0], exception.getCause()); - Assert.assertEquals("Error during Table cache update.", + assertSame(causes[0], exception.getCause()); + assertEquals("Error during Table cache update.", exception.getMessage()); } @Test public void testMultipleCauseException() { Table table = new Table(); - Throwable[] causes = { - new RuntimeException("Broken in the first way."), + Throwable[] causes = { new RuntimeException("Broken in the first way."), new RuntimeException("Broken in the second way.") }; CacheUpdateException exception = new CacheUpdateException(table, "Error during Table cache update.", causes); - Assert.assertSame(causes[0], exception.getCause()); - Assert.assertEquals( + assertSame(causes[0], exception.getCause()); + assertEquals( "Error during Table cache update. Additional causes not shown.", exception.getMessage()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java index 5f9f19f19d..8e345a1d0d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.event.ContextClickEvent; @@ -49,9 +50,9 @@ public class TableContextClickTest extends Table { Section.BODY)); if (error != null) { - Assert.fail(error); + fail(error); } else if (!handled) { - Assert.fail("Event was not handled by the ContextClickListener"); + fail("Event was not handled by the ContextClickListener"); } } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java index a58aa0a1ec..28424b86d0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java @@ -171,9 +171,9 @@ public class TableDeclarativeTest extends TableDeclarativeTestBase { + " </tfoot>" + "</table>" + "</vaadin7-table>"; Table read = read(design); - Assert.assertEquals("& Test", + assertEquals("& Test", read.getContainerProperty("test", "test").getValue()); - Assert.assertEquals("& Test", read.getColumnHeader("test")); - Assert.assertEquals("& Test", read.getColumnFooter("test")); + assertEquals("& Test", read.getColumnHeader("test")); + assertEquals("& Test", read.getColumnFooter("test")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java index 4e12ed84e0..18ef3c7f2b 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java @@ -15,8 +15,10 @@ */ package com.vaadin.v7.tests.server.component.table; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property.ValueChangeListener; @@ -34,7 +36,7 @@ public class TableSelectableTest { Table table = new Table(); table.setSelectable(true); - Assert.assertTrue(table.isSelectable()); + assertTrue(table.isSelectable()); } @Test @@ -43,15 +45,15 @@ public class TableSelectableTest { table.addValueChangeListener( EasyMock.createMock(ValueChangeListener.class)); - Assert.assertTrue(table.isSelectable()); - Assert.assertTrue(table.markAsDirtyCalled); + assertTrue(table.isSelectable()); + assertTrue(table.markAsDirtyCalled); } @Test public void tableIsNotSelectableByDefult() { Table table = new Table(); - Assert.assertFalse(table.isSelectable()); + assertFalse(table.isSelectable()); } @Test @@ -61,7 +63,7 @@ public class TableSelectableTest { table.addValueChangeListener( EasyMock.createMock(ValueChangeListener.class)); - Assert.assertFalse(table.isSelectable()); + assertFalse(table.isSelectable()); } private static final class TestTable extends Table { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java index f61a027c0a..8f4a1a40bb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.table.TableState; @@ -31,7 +32,7 @@ public class TableStateTest { public void getState_tableHasCustomState() { TestTable table = new TestTable(); TableState state = table.getState(); - Assert.assertEquals("Unexpected state class", TableState.class, + assertEquals("Unexpected state class", TableState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class TableStateTest { public void getPrimaryStyleName_tableHasCustomPrimaryStyleName() { Table table = new Table(); TableState state = new TableState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void tableStateHasCustomPrimaryStyleName() { TableState state = new TableState(); - Assert.assertEquals("Unexpected primary style name", "v-table", + assertEquals("Unexpected primary style name", "v-table", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java index 5d0e8e80e4..fac607f833 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java @@ -49,7 +49,7 @@ public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> { public void testHtmlEntities() throws IOException { String design = "<vaadin7-text-area>& Test</vaadin7-text-area>"; TextArea read = read(design); - Assert.assertEquals("& Test", read.getValue()); + assertEquals("& Test", read.getValue()); read.setValue("& Test"); @@ -57,7 +57,7 @@ public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> { Element root = new Element(Tag.valueOf("vaadin-text-area"), ""); read.writeDesign(root, dc); - Assert.assertEquals("&amp; Test", root.html()); + assertEquals("&amp; Test", root.html()); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java index 9b5d4ea0a1..d746c08cf5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -26,24 +28,24 @@ public class TextFieldTest { @Test public void initiallyEmpty() { TextField tf = new TextField(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { TextField tf = new TextField(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { TextField tf = new TextField(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java index 9a35dbeacd..4973f2a9d8 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java @@ -1,10 +1,12 @@ package com.vaadin.v7.tests.server.component.textfield; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.HashMap; import java.util.Map; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -75,7 +77,7 @@ public class TextFieldValueChangeTest // get value should not fire value change again Object value = getField().getValue(); - Assert.assertEquals("Foo", value); + assertEquals("Foo", value); // Ensure listener still has been called only once EasyMock.verify(getListener()); @@ -121,7 +123,7 @@ public class TextFieldValueChangeTest // field value should be different from the original value and current // proeprty value boolean isValueEqualToInitial = value.equals(initialValue); - Assert.assertTrue(isValueEqualToInitial); + assertTrue(isValueEqualToInitial); // Ensure listener still has been called only once EasyMock.verify(getListener()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java index 4f4bdead4e..94f6847a0f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java @@ -148,7 +148,7 @@ public class TreeTest { public void getState_treeHasCustomState() { TestTree table = new TestTree(); TreeState state = table.getState(); - Assert.assertEquals("Unexpected state class", TreeState.class, + assertEquals("Unexpected state class", TreeState.class, state.getClass()); } @@ -156,14 +156,14 @@ public class TreeTest { public void getPrimaryStyleName_treeHasCustomPrimaryStyleName() { Tree table = new Tree(); TreeState state = new TreeState(); - Assert.assertEquals("Unexpected primary style name", + assertEquals("Unexpected primary style name", state.primaryStyleName, table.getPrimaryStyleName()); } @Test public void treeStateHasCustomPrimaryStyleName() { TreeState state = new TreeState(); - Assert.assertEquals("Unexpected primary style name", "v-tree", + assertEquals("Unexpected primary style name", "v-tree", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java index 302a42a8af..9339dbcedd 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.treetable; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.ui.declarative.DesignException; @@ -125,7 +126,7 @@ public class TreeTableDeclarativeTest extends TableDeclarativeTest { try { read(design); - Assert.fail("Malformed hierarchy should fail: " + hierarchy); + fail("Malformed hierarchy should fail: " + hierarchy); } catch (DesignException expected) { } } @@ -135,10 +136,10 @@ public class TreeTableDeclarativeTest extends TableDeclarativeTest { super.compareBody(read, expected); for (Object itemId : read.getItemIds()) { - Assert.assertEquals("parent of item " + itemId, + assertEquals("parent of item " + itemId, ((TreeTable) expected).getParent(itemId), ((TreeTable) read).getParent(itemId)); - Assert.assertEquals("collapsed status of item " + itemId, + assertEquals("collapsed status of item " + itemId, ((TreeTable) expected).isCollapsed(itemId), ((TreeTable) read).isCollapsed(itemId)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java index a0e0cc6c16..1f48ec8500 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.v7.tests.server.component.treetable; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.EnumSet; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.shared.ui.treetable.TreeTableState; @@ -36,7 +39,7 @@ public class TreeTableTest { TestTreeTable tree = new TestTreeTable(); tree.setRowHeaderMode(RowHeaderMode.ICON_ONLY); - Assert.assertFalse("Row headers are enabled for Icon header mode", + assertFalse("Row headers are enabled for Icon header mode", tree.rowHeadersAreEnabled()); } @@ -45,7 +48,7 @@ public class TreeTableTest { TestTreeTable tree = new TestTreeTable(); tree.setRowHeaderMode(RowHeaderMode.HIDDEN); - Assert.assertFalse("Row headers are enabled for Hidden header mode", + assertFalse("Row headers are enabled for Hidden header mode", tree.rowHeadersAreEnabled()); } @@ -58,8 +61,7 @@ public class TreeTableTest { for (RowHeaderMode mode : modes) { tree.setRowHeaderMode(mode); - Assert.assertTrue( - "Row headers are disabled for " + mode + " header mode", + assertTrue("Row headers are disabled for " + mode + " header mode", tree.rowHeadersAreEnabled()); } } @@ -68,7 +70,7 @@ public class TreeTableTest { public void getState_treeTableHasCustomState() { TestTreeTable table = new TestTreeTable(); TreeTableState state = table.getState(); - Assert.assertEquals("Unexpected state class", TreeTableState.class, + assertEquals("Unexpected state class", TreeTableState.class, state.getClass()); } @@ -76,14 +78,14 @@ public class TreeTableTest { public void getPrimaryStyleName_treeTableHasCustomPrimaryStyleName() { TreeTable table = new TreeTable(); TreeTableState state = new TreeTableState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void treeTableStateHasCustomPrimaryStyleName() { TreeTableState state = new TreeTableState(); - Assert.assertEquals("Unexpected primary style name", "v-table", + assertEquals("Unexpected primary style name", "v-table", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java index d2498d9160..f8b40d5b57 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.twincolselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.twincolselect.TwinColSelectState; @@ -31,7 +32,7 @@ public class TwinColSelectStateTest { public void getState_selectHasCustomState() { TestTwinColSelect select = new TestTwinColSelect(); TwinColSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", TwinColSelectState.class, + assertEquals("Unexpected state class", TwinColSelectState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class TwinColSelectStateTest { public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { TwinColSelect table = new TwinColSelect(); TwinColSelectState state = new TwinColSelectState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void selectStateHasCustomPrimaryStyleName() { TwinColSelectState state = new TwinColSelectState(); - Assert.assertEquals("Unexpected primary style name", "v-select-twincol", + assertEquals("Unexpected primary style name", "v-select-twincol", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java index a16729da03..992fe09e92 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.server.validation; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.data.bean.BeanToValidate; @@ -70,7 +71,7 @@ public class BeanValidationTest { causes = e.getCauses(); } - Assert.assertEquals(1, causes.length); + assertEquals(1, causes.length); } @Test @@ -84,7 +85,7 @@ public class BeanValidationTest { causes = e.getCauses(); } - Assert.assertEquals(2, causes.length); + assertEquals(2, causes.length); } @Test @@ -98,14 +99,14 @@ public class BeanValidationTest { fieldGroup.setItemDataSource(beanToValidate); Field<?> nameField = fieldGroup.buildAndBind("firstname"); - Assert.assertEquals(1, nameField.getValidators().size()); + assertEquals(1, nameField.getValidators().size()); try { nameField.validate(); } catch (InvalidValueException e) { // The 1 cause is from BeanValidator, where it tells what failed // 1 validation exception never gets wrapped. - Assert.assertEquals(1, e.getCauses().length); + assertEquals(1, e.getCauses().length); } // Create new, identical bean to cause duplicate validator unless #11045 @@ -114,14 +115,14 @@ public class BeanValidationTest { beanToValidate.setFirstname("a"); fieldGroup.setItemDataSource(beanToValidate); - Assert.assertEquals(1, nameField.getValidators().size()); + assertEquals(1, nameField.getValidators().size()); try { nameField.validate(); } catch (InvalidValueException e) { // The 1 cause is from BeanValidator, where it tells what failed // 1 validation exception never gets wrapped. - Assert.assertEquals(1, e.getCauses().length); + assertEquals(1, e.getCauses().length); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java index 635ba4e0e2..f90e10066d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java @@ -15,11 +15,15 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -30,8 +34,8 @@ public class AbsSelectTest { public void addItemsStrings() { NativeSelect ns = new NativeSelect(); ns.addItems("Foo", "bar", "baz"); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, ns.getItemIds().toArray()); } @@ -43,8 +47,8 @@ public class AbsSelectTest { NativeSelect ns = new NativeSelect(); ns.addItems(o1, o2, o3); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds().toArray()); } @@ -56,8 +60,8 @@ public class AbsSelectTest { itemIds.add("baz"); NativeSelect ns = new NativeSelect(); ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { "foo", "bar", "baz" }, ns.getItemIds().toArray()); } @@ -72,8 +76,8 @@ public class AbsSelectTest { itemIds.add(o3); NativeSelect ns = new NativeSelect(); ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds().toArray()); } @@ -81,7 +85,7 @@ public class AbsSelectTest { @Test public void singleSelectInitiallyEmpty() { AbstractSelect s = new ListSelect(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -91,9 +95,9 @@ public class AbsSelectTest { s.addItem("bar"); s.setPropertyDataSource(new ObjectProperty<String>("foo")); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -103,16 +107,16 @@ public class AbsSelectTest { s.addItem("bar"); s.setValue("bar"); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test public void multiSelectInitiallyEmpty() { AbstractSelect s = new ListSelect(); s.setMultiSelect(true); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -126,9 +130,9 @@ public class AbsSelectTest { sel.add("bar"); s.setPropertyDataSource(new ObjectProperty<HashSet>(sel)); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -140,9 +144,9 @@ public class AbsSelectTest { s.select("foo"); s.select("bar"); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java index 16f7eb2423..05be3a35e3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java @@ -1,11 +1,12 @@ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; + import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -29,9 +30,9 @@ public class ComboBoxTest { } List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(10, options.size()); + assertEquals(10, options.size()); for (int i = 0; i < 10; i++) { - Assert.assertEquals("" + i, options.get(i)); + assertEquals("" + i, options.get(i)); } } @@ -45,7 +46,7 @@ public class ComboBoxTest { setFilterAndCurrentPage(comboBox, "1", 0); List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(11, options.size()); + assertEquals(11, options.size()); } @@ -58,7 +59,7 @@ public class ComboBoxTest { setFilterAndCurrentPage(comboBox, "2", 0); List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(3, options.size()); + assertEquals(3, options.size()); } @@ -81,7 +82,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), false); - Assert.assertEquals(comboBox.getPageLength(), goingToClient.size()); + assertEquals(comboBox.getPageLength(), goingToClient.size()); } @@ -96,13 +97,13 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // Null item is shown on first page - Assert.assertEquals(comboBox.getPageLength() - 1, goingToClient.size()); + assertEquals(comboBox.getPageLength() - 1, goingToClient.size()); setFilterAndCurrentPage(comboBox, "", 1); goingToClient = comboBox.sanitizeList(comboBox.getFilteredOptions(), true); // Null item is not shown on the second page - Assert.assertEquals(comboBox.getPageLength(), goingToClient.size()); + assertEquals(comboBox.getPageLength(), goingToClient.size()); } @@ -116,7 +117,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), false); - Assert.assertEquals(nrOptions, goingToClient.size()); + assertEquals(nrOptions, goingToClient.size()); } @@ -131,7 +132,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // All items + null still fit on one page - Assert.assertEquals(nrOptions, goingToClient.size()); + assertEquals(nrOptions, goingToClient.size()); } @@ -146,13 +147,13 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // Null item on first page - Assert.assertEquals(nrOptions - 1, goingToClient.size()); + assertEquals(nrOptions - 1, goingToClient.size()); setFilterAndCurrentPage(comboBox, "", 1); goingToClient = comboBox.sanitizeList(comboBox.getFilteredOptions(), true); // All but one was on the first page - Assert.assertEquals(1, goingToClient.size()); + assertEquals(1, goingToClient.size()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java index 42d0d72867..e6b3554d92 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -52,17 +54,17 @@ public class LabelDataSourceTest { @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()); + assertEquals(STRING_DS_VALUE, label.getState().text); + assertEquals(STRING_DS_VALUE, label.getValue()); + 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()); + assertEquals(STRING_DS_VALUE, label.getState().text); + assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(null, label.getPropertyDataSource()); label.setValue("foo"); - Assert.assertEquals("foo", label.getState().text); - Assert.assertEquals("foo", label.getValue()); - Assert.assertNull(label.getPropertyDataSource()); + assertEquals("foo", label.getState().text); + assertEquals("foo", label.getValue()); + assertNull(label.getPropertyDataSource()); } @@ -70,18 +72,18 @@ public class LabelDataSourceTest { 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()); + assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + 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()); + assertEquals(INTEGER_STRING_VALUE_EN_US, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_EN_US, label.getValue()); + assertEquals(integerDataSource, label.getPropertyDataSource()); } @Test @@ -89,20 +91,20 @@ public class LabelDataSourceTest { 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()); + assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + assertEquals(integerDataSource, label.getPropertyDataSource()); } @Test public void setRemoveDataSource() { label.setValue("before"); label.setPropertyDataSource(stringDataSource); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(STRING_DS_VALUE, label.getValue()); label.setPropertyDataSource(null); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(STRING_DS_VALUE, label.getValue()); label.setValue("after"); - Assert.assertEquals("after", label.getValue()); + assertEquals("after", label.getValue()); } @Test @@ -113,6 +115,6 @@ public class LabelDataSourceTest { UI ui = new MockUI(); ui.setLocale(Locale.GERMANY); ui.setContent(label); - Assert.assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java index 5accba796d..b592927e7d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.Collections; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.IndexedContainer; @@ -51,7 +53,7 @@ public class NativeSelectTest { public void getState_listSelectHasCustomState() { TestNativeSelect select = new TestNativeSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } @@ -63,7 +65,7 @@ public class NativeSelectTest { } private void assertFocusRpcRegistered(NativeSelect s) { - Assert.assertNotNull("RPC is not correctly registered", s.getRpcManager( + assertNotNull("RPC is not correctly registered", s.getRpcManager( "com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc")); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java index 9d4bb9468e..e87cfe89e5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -24,24 +26,24 @@ public class RichTextAreaTest { @Test public void initiallyEmpty() { RichTextArea tf = new RichTextArea(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { RichTextArea tf = new RichTextArea(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { RichTextArea tf = new RichTextArea(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java index 9683c82424..576bdfcce9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java @@ -15,9 +15,13 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Collection; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,22 +38,22 @@ public class TableTest { @Test public void initiallyEmpty() { - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); } @Test public void emptyAfterClearSingleSelect() { table.setContainerDataSource( BeanItemContainerGenerator.createContainer(100)); - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); Object first = table.getContainerDataSource().getItemIds().iterator() .next(); table.setValue(first); - Assert.assertEquals(first, table.getValue()); - Assert.assertFalse(table.isEmpty()); + assertEquals(first, table.getValue()); + assertFalse(table.isEmpty()); table.clear(); - Assert.assertEquals(null, table.getValue()); - Assert.assertTrue(table.isEmpty()); + assertEquals(null, table.getValue()); + assertTrue(table.isEmpty()); } @Test @@ -58,21 +62,21 @@ public class TableTest { table.setContainerDataSource( BeanItemContainerGenerator.createContainer(100)); - Assert.assertTrue(table.isEmpty()); - Assert.assertArrayEquals(new Object[] {}, + assertTrue(table.isEmpty()); + assertArrayEquals(new Object[] {}, ((Collection) table.getValue()).toArray()); Object first = table.getContainerDataSource().getItemIds().iterator() .next(); table.select(first); - Assert.assertArrayEquals(new Object[] { first }, + assertArrayEquals(new Object[] { first }, ((Collection) table.getValue()).toArray()); - Assert.assertFalse(table.isEmpty()); + assertFalse(table.isEmpty()); table.clear(); - Assert.assertArrayEquals(new Object[] {}, + assertArrayEquals(new Object[] {}, ((Collection) table.getValue()).toArray()); - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java index 23b6f9f593..4d0dd17a83 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -24,24 +26,24 @@ public class TextAreaTest { @Test public void initiallyEmpty() { TextArea tf = new TextArea(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { TextArea tf = new TextArea(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { TextArea tf = new TextArea(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } |