--- /dev/null
+package com.vaadin.tests.layouts;\r
+\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Button;\r
+import com.vaadin.ui.VerticalLayout;\r
+import com.vaadin.ui.Button.ClickEvent;\r
+\r
+public class NPEInReplaceComponent extends TestBase {\r
+\r
+ @Override\r
+ protected String getDescription() {\r
+ return "Clicking 'ReplaceComponent' should replace the 'Button' button with a VericalLayout, and move the button inside the verticalLayout. Visually this can be seen by the added margins of the VerticalLayout.";\r
+ }\r
+\r
+ @Override\r
+ protected Integer getTicketNumber() {\r
+ return 3195;\r
+ }\r
+\r
+ final Button button = new Button("Button");\r
+ final VerticalLayout outer = new VerticalLayout();\r
+\r
+ @Override\r
+ protected void setup() {\r
+ outer.setMargin(true);\r
+ \r
+ Button changer = new Button("ReplaceComponent");\r
+ changer.addListener(new Button.ClickListener() {\r
+ public void buttonClick(ClickEvent event) {\r
+ getLayout().replaceComponent(button, outer);\r
+ outer.addComponent(button);\r
+ }\r
+ });\r
+\r
+ getLayout().addComponent(button);\r
+ getLayout().addComponent(changer);\r
+\r
+ }\r
+\r
+}\r