Search in sources :

Example 1 with ViewClassLocator

use of com.vaadin.flow.uitest.servlet.ViewClassLocator in project flow by vaadin.

the class ToStringTest method testViewsElementsStringable.

@Test
public void testViewsElementsStringable() throws Exception {
    Collection<Class<? extends Component>> viewClasses = new ViewClassLocator(getClass().getClassLoader()).getAllViewClasses();
    for (Class<? extends Component> viewClass : viewClasses) {
        Component view = viewClass.newInstance();
        String string = view.getElement().toString();
        Assert.assertNotNull(string);
        Assert.assertNotEquals("", string);
    }
}
Also used : Component(com.vaadin.flow.component.Component) ViewClassLocator(com.vaadin.flow.uitest.servlet.ViewClassLocator) Test(org.junit.Test)

Example 2 with ViewClassLocator

use of com.vaadin.flow.uitest.servlet.ViewClassLocator in project flow by vaadin.

the class SerializationTest method testViewsSerializable.

@Test
public void testViewsSerializable() throws Exception {
    UI ui = new UI();
    UI.setCurrent(ui);
    try {
        Collection<Class<? extends Component>> viewClasses = new ViewClassLocator(getClass().getClassLoader()).getAllViewClasses();
        for (Class<? extends Component> viewClass : viewClasses) {
            Component view = viewClass.newInstance();
            // Collections.emptyList(), Collections.emptyMap()));
            try {
                Assert.assertNotNull(serializeDeserialize(view));
            } catch (Exception e) {
                throw new AssertionError("Can't serialize view " + viewClass.getName(), e);
            }
        }
    } finally {
        UI.setCurrent(null);
    }
}
Also used : UI(com.vaadin.flow.component.UI) Component(com.vaadin.flow.component.Component) ViewClassLocator(com.vaadin.flow.uitest.servlet.ViewClassLocator) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Component (com.vaadin.flow.component.Component)2 ViewClassLocator (com.vaadin.flow.uitest.servlet.ViewClassLocator)2 Test (org.junit.Test)2 UI (com.vaadin.flow.component.UI)1 IOException (java.io.IOException)1