From 8a2e8ff43e477f6269dc21469efee044d65e12b8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 5 Apr 2013 18:41:52 +0300 Subject: Fixed broken tests * Added missing screenshot identifiers * Removed redundant test * DebugConsole -> DebugWindow * Updated test to show why serialization fails * Fixed problems caused by added maximize button Change-Id: I5cf76fec7170747120b7243f9693851cd52c12af --- .../tests/components/ui/UIInitException.html | 4 +- .../tests/components/ui/UISerialization.java | 56 ++++++++++++---------- 2 files changed, 34 insertions(+), 26 deletions(-) (limited to 'uitest/src/com/vaadin/tests/components/ui') diff --git a/uitest/src/com/vaadin/tests/components/ui/UIInitException.html b/uitest/src/com/vaadin/tests/components/ui/UIInitException.html index c2b1b33059..68b11e7942 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIInitException.html +++ b/uitest/src/com/vaadin/tests/components/ui/UIInitException.html @@ -17,9 +17,9 @@ - assertText - //html/body/div/pre + assertTextPresent Catch me if you can + diff --git a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java index 5f3d8d97de..90021a0bf4 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java +++ b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java @@ -20,15 +20,19 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.PrintWriter; import java.io.Serializable; +import java.io.StringWriter; import java.util.Date; import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; public class UISerialization extends AbstractTestUI { @@ -42,21 +46,29 @@ public class UISerialization extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { Date d = new Date(); - byte[] result = serialize(UISerialization.this); - long elapsed = new Date().getTime() - d.getTime(); - log.log("Serialized UI in " + elapsed + "ms into " - + result.length + " bytes"); - Object diffStateBefore = getConnectorTracker().getDiffState( - UISerialization.this); - UISerialization app = (UISerialization) deserialize(result); - log.log("Deserialized UI in " + elapsed + "ms"); - Object diffStateAfter = getConnectorTracker().getDiffState( - UISerialization.this); - if (diffStateBefore.equals(diffStateAfter)) { - log.log("Diff states match, size: " - + diffStateBefore.toString().length()); - } else { - log.log("Diff states do not match"); + try { + byte[] result = serialize(UISerialization.this); + long elapsed = new Date().getTime() - d.getTime(); + log.log("Serialized UI in " + elapsed + "ms into " + + result.length + " bytes"); + Object diffStateBefore = getConnectorTracker() + .getDiffState(UISerialization.this); + UISerialization app = (UISerialization) deserialize(result); + log.log("Deserialized UI in " + elapsed + "ms"); + Object diffStateAfter = getConnectorTracker().getDiffState( + UISerialization.this); + if (diffStateBefore.equals(diffStateAfter)) { + log.log("Diff states match, size: " + + diffStateBefore.toString().length()); + } else { + log.log("Diff states do not match"); + } + } catch (Exception e) { + log.log("Exception caught: " + e.getMessage()); + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + addComponent(new Label(sw.toString(), + ContentMode.PREFORMATTED)); } } @@ -64,20 +76,16 @@ public class UISerialization extends AbstractTestUI { } protected void serializeInstance(Class cls) - throws InstantiationException, IllegalAccessException { + throws InstantiationException, IllegalAccessException, IOException { serialize((Serializable) cls.newInstance()); } - protected byte[] serialize(Serializable serializable) { + protected byte[] serialize(Serializable serializable) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos; - try { - oos = new ObjectOutputStream(os); - oos.writeObject(serializable); - return os.toByteArray(); - } catch (IOException e) { - throw new RuntimeException("Serialization failed", e); - } + oos = new ObjectOutputStream(os); + oos.writeObject(serializable); + return os.toByteArray(); } protected Object deserialize(byte[] result) { -- cgit v1.2.3