]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ensure no unknown attribute warnings are logged in design tests (#19429)
authorArtur Signell <artur@vaadin.com>
Sat, 2 Jan 2016 12:48:55 +0000 (14:48 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Tue, 5 Jan 2016 12:06:44 +0000 (14:06 +0200)
* Adds missing custom attributes to Slider/AbstractEmbedded

Change-Id: Iad6c963bdc4334630c613995b9c0f0555d5d19a8

server/src/com/vaadin/ui/AbstractEmbedded.java
server/src/com/vaadin/ui/Slider.java
server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java

index d004ca7635cd3e3e8dab772d4f1566630a2bd2c3..a38e9bb788e1674f503bb0b9c77583cb7beb1170 100644 (file)
@@ -108,6 +108,7 @@ public abstract class AbstractEmbedded extends AbstractComponent {
     protected Collection<String> getCustomAttributes() {
         Collection<String> c = super.getCustomAttributes();
         c.add("alternate-text");
+        c.add("alt");
         return c;
     }
 }
index e85f634ac4927298a0786475eb642aad48b8ba34..1fd6d425fe6559ee751cda3cda19d635e96a58b3 100644 (file)
@@ -392,6 +392,7 @@ public class Slider extends AbstractField<Double> {
     protected Collection<String> getCustomAttributes() {
         Collection<String> result = super.getCustomAttributes();
         result.add("orientation");
+        result.add("vertical");
         return result;
     }
 }
index e7bb8955cfbf90f73a67a07581b0ec1f7898797d..a7ff7174b2ab083b9ae4769e37c7547e4bfbc553 100644 (file)
@@ -23,6 +23,9 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
 
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Attribute;
@@ -32,6 +35,7 @@ import org.jsoup.nodes.Node;
 import org.jsoup.nodes.TextNode;
 import org.junit.Assert;
 
+import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.declarative.Design;
 import com.vaadin.ui.declarative.DesignContext;
@@ -149,14 +153,55 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
 
     }
 
+    public static class TestLogHandler {
+        final List<String> messages = new ArrayList<String>();
+        Handler handler = new Handler() {
+            @Override
+            public void publish(LogRecord record) {
+                messages.add(record.getMessage());
+            }
+
+            @Override
+            public void flush() {
+            }
+
+            @Override
+            public void close() throws SecurityException {
+
+            }
+        };
+
+        public TestLogHandler() {
+            Logger.getLogger(AbstractComponent.class.getName()).getParent()
+                    .addHandler(handler);
+        }
+
+        public String getMessages() {
+            if (messages.isEmpty()) {
+                return "";
+            }
+
+            String r = "";
+            for (String message : messages) {
+                r += message + "\n";
+            }
+            return r;
+        }
+
+    }
+
     public T testRead(String design, T expected) {
+        TestLogHandler l = new TestLogHandler();
         T read = read(design);
         assertEquals(expected, read);
+        Assert.assertEquals("", l.getMessages());
         return read;
     }
 
     public void testWrite(String design, T expected) {
+        TestLogHandler l = new TestLogHandler();
         testWrite(design, expected, false);
+        Assert.assertEquals("", l.getMessages());
     }
 
     public void testWrite(String design, T expected, boolean writeData) {