From da5a55ccdf3c5a1732ae246c43370051633c9265 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 1 Mar 2013 16:10:50 +0200 Subject: Update test to use default classloader instead of null Support for setting null as the classloader was removed at the time when Application was removed. Change-Id: Ib3d75dae1d1d81d8760b93616d05ba0746323e3c --- .../com/vaadin/tests/server/component/ui/CustomUIClassLoader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server/tests/src') diff --git a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java index e02fafeaff..8884c0c27c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java +++ b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java @@ -52,13 +52,14 @@ public class CustomUIClassLoader extends TestCase { * @throws Exception * if thrown */ - public void testWithNullClassLoader() throws Exception { + public void testWithDefaultClassLoader() throws Exception { VaadinSession application = createStubApplication(); application.setConfiguration(createConfigurationMock()); DefaultUIProvider uiProvider = new DefaultUIProvider(); Class uiClass = uiProvider - .getUIClass(new UIClassSelectionEvent(createRequestMock(null))); + .getUIClass(new UIClassSelectionEvent( + createRequestMock(getClass().getClassLoader()))); assertEquals(MyUI.class, uiClass); } -- cgit v1.2.3 From 48b5c927b9e4e614e7cc334fb9c8b0bed42d28c8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 4 Mar 2013 20:06:00 +0200 Subject: Catch NoSuchFieldException instead of NoSuchFieldError (#10944) Change-Id: I0ece22fc53388a7c9eb268c00ae46c589859a1f1 --- .../com/vaadin/data/fieldgroup/BeanFieldGroup.java | 2 +- .../vaadin/data/fieldgroup/BeanFieldGroupTest.java | 71 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 server/tests/src/com/vaadin/data/fieldgroup/BeanFieldGroupTest.java (limited to 'server/tests/src') diff --git a/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java b/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java index b0d03af8d6..9dc6037d83 100644 --- a/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java @@ -72,7 +72,7 @@ public class BeanFieldGroup extends FieldGroup { java.lang.reflect.Field field1 = cls .getDeclaredField(propertyId); return field1; - } catch (NoSuchFieldError e) { + } catch (NoSuchFieldException e) { // Try super classes until we reach Object Class superClass = cls.getSuperclass(); if (superClass != Object.class) { diff --git a/server/tests/src/com/vaadin/data/fieldgroup/BeanFieldGroupTest.java b/server/tests/src/com/vaadin/data/fieldgroup/BeanFieldGroupTest.java new file mode 100644 index 0000000000..a01c2dea8f --- /dev/null +++ b/server/tests/src/com/vaadin/data/fieldgroup/BeanFieldGroupTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2012 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.fieldgroup; + +import junit.framework.Assert; + +import org.junit.Test; + +public class BeanFieldGroupTest { + + class Main { + private String mainField; + + public String getMainField() { + return mainField; + } + + public void setMainField(String mainField) { + this.mainField = mainField; + } + + } + + class Sub1 extends Main { + private Integer sub1Field; + + public Integer getSub1Field() { + return sub1Field; + } + + public void setSub1Field(Integer sub1Field) { + this.sub1Field = sub1Field; + } + + } + + class Sub2 extends Sub1 { + private boolean sub2field; + + public boolean isSub2field() { + return sub2field; + } + + public void setSub2field(boolean sub2field) { + this.sub2field = sub2field; + } + + } + + @Test + public void propertyTypeWithoutItem() { + BeanFieldGroup s = new BeanFieldGroup( + Sub2.class); + Assert.assertEquals(boolean.class, s.getPropertyType("sub2field")); + Assert.assertEquals(Integer.class, s.getPropertyType("sub1Field")); + Assert.assertEquals(String.class, s.getPropertyType("mainField")); + } +} -- cgit v1.2.3