@@ -0,0 +1,1102 @@
+package com.vaadin.tests.layouts;%0D%0A%0D%0Aimport com.vaadin.tests.components.TestBase;%0D%0Aimport com.vaadin.ui.Button;%0D%0Aimport com.vaadin.ui.VerticalLayout;%0D%0Aimport com.vaadin.ui.Button.ClickEvent;%0D%0A%0D%0Apublic class NPEInReplaceComponent extends TestBase %7B%0D%0A%0D%0A%09@Override%0D%0A%09protected String getDescription() %7B%0D%0A%09%09return %22Clicking '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.%22;%0D%0A%09%7D%0D%0A%0D%0A%09@Override%0D%0A%09protected Integer getTicketNumber() %7B%0D%0A%09%09return 3195;%0D%0A%09%7D%0D%0A%0D%0A%09final Button button = new Button(%22Button%22);%0D%0A%09final VerticalLayout outer = new VerticalLayout();%0D%0A%0D%0A%09@Override%0D%0A%09protected void setup() %7B%0D%0A%09%09outer.setMargin(true);%0D%0A%09%09%0D%0A%09%09Button changer = new Button(%22ReplaceComponent%22);%0D%0A%09%09changer.addListener(new Button.ClickListener() %7B%0D%0A%09%09%09public void buttonClick(ClickEvent event) %7B%0D%0A%09%09%09%09getLayout().replaceComponent(button, outer);%0D%0A%09%09%09%09outer.addComponent(button);%0D%0A%09%09%09%7D%0D%0A%09%09%7D);%0D%0A%0D%0A%09%09getLayout().addComponent(button);%0D%0A%09%09getLayout().addComponent(changer);%0D%0A%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

Test case for #3195