diff options
author | Leif Åstrand <leif@vaadin.com> | 2014-07-15 16:11:40 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-07-17 08:18:18 +0000 |
commit | 2c1d7bdbc2e284264b485fbcf7d9f3d1ef3180f2 (patch) | |
tree | 1efca4a2aee81b76f5a9df587e910507bd3be067 /server/tests/src/com | |
parent | b8255a873283b610844b7dc9a535d2a0cd144844 (diff) | |
download | vaadin-framework-2c1d7bdbc2e284264b485fbcf7d9f3d1ef3180f2.tar.gz vaadin-framework-2c1d7bdbc2e284264b485fbcf7d9f3d1ef3180f2.zip |
Add asserts checking for negative container sizes (#14232)
Change-Id: I5b6298be367e4fe820320a5e3fd6bf5aaa7e2047
Diffstat (limited to 'server/tests/src/com')
-rw-r--r-- | server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java b/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java new file mode 100644 index 0000000000..04fd8d3cd1 --- /dev/null +++ b/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.data.util; + +import org.junit.Test; + +import com.vaadin.data.Container; +import com.vaadin.ui.Table; + +public class ContainerSizeAssertTest { + + @Test(expected = AssertionError.class) + public void testNegativeSizeAssert() { + Table table = createAttachedTable(); + + table.setContainerDataSource(createNegativeSizeContainer()); + } + + @Test + public void testZeroSizeNoAssert() { + Table table = createAttachedTable(); + + table.setContainerDataSource(new IndexedContainer()); + } + + private Container createNegativeSizeContainer() { + return new IndexedContainer() { + @Override + public int size() { + return -1; + } + }; + } + + private Table createAttachedTable() { + return new Table() { + private boolean initialized = true; + + @Override + public boolean isAttached() { + // This returns false until the super constructor has finished + return initialized; + } + }; + } +} |