123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package com.vaadin.tests.components;
-
- import com.vaadin.server.VaadinRequest;
- import com.vaadin.ui.AbstractComponent;
- import com.vaadin.ui.Button;
- import com.vaadin.ui.Button.ClickEvent;
- import com.vaadin.ui.Button.ClickListener;
- import com.vaadin.ui.Label;
- import com.vaadin.ui.VerticalLayout;
- import com.vaadin.v7.ui.Table;
- import com.vaadin.v7.ui.Table.RowHeaderMode;
-
- public class SaneErrors extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- final Button b = new Button("Show me my NPE!");
- b.addClickListener(event -> throwError());
-
- /*
- * Errors from "legacy variable changes"
- */
- final Table table = new Table();
- table.addItem("Show me my NPE!");
- table.setRowHeaderMode(RowHeaderMode.ID);
- table.addItemClickListener(event -> throwError());
-
- final VerticalLayout content = new VerticalLayout(b, table);
-
- /**
- * Button that shows reported exception for TB integration test
- */
- Button button = new Button("Collect exceptions", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- reportException(b, content);
- reportException(table, content);
- }
-
- private void reportException(final AbstractComponent b,
- final VerticalLayout content) {
- String message = b.getErrorMessage().getFormattedHtmlMessage();
- message = message.replaceAll(".", ".");
- message = message.substring(message.indexOf("h2>") + 3,
- message.indexOf(" "));
- Label label = new Label(message);
- content.addComponent(label);
- }
- });
- content.addComponent(button);
-
- setContent(content);
-
- }
-
- private void throwError() {
- Object o = null;
- o.getClass();
- }
-
- @Override
- protected String getTestDescription() {
- return "Vaadin should by default report exceptions relevant for the developer.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 11599;
- }
-
- }
|