From 38f053e8a4cb24072c0e1853639c7c936dd1630b Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 20 Oct 2017 10:26:22 +0300 Subject: [PATCH] Revert https://github.com/vaadin/flow/pull/2375 due to https://github.com/vaadin/flow/issues/2730 --- .../com/vaadin/ui/formlayout/FormLayout.java | 3 +- .../vaadin/flow/tutorial/BootstrapPage.java | 5 +- .../flow/tutorial/binder/BinderBeans.java | 10 ++-- flow-server/pom.xml | 6 +- .../java/com/vaadin/flow/dom/Element.java | 3 +- .../java/com/vaadin/flow/dom/ElementUtil.java | 56 +++++++------------ .../AbstractTemplateBuilderFactory.java | 3 +- .../angular/parser/DataNodeFactory.java | 5 +- .../parser/DefaultElementBuilderFactory.java | 7 +-- .../DefaultTextModelBuilderFactory.java | 5 +- .../parser/ForElementBuilderFactory.java | 5 +- .../parser/TemplateNodeBuilderFactory.java | 3 +- .../angular/parser/TemplateParser.java | 19 +++---- .../java/com/vaadin/flow/util/HtmlUtils.java | 2 +- .../com/vaadin/server/BootstrapHandler.java | 11 ++-- .../vaadin/server/BootstrapPageResponse.java | 3 +- .../src/main/java/com/vaadin/ui/Html.java | 9 ++- .../DefaultTemplateParser.java | 14 ++--- .../polymertemplate/TemplateInitializer.java | 41 +++++++------- .../ui/polymertemplate/TemplateParser.java | 2 +- .../com/vaadin/flow/dom/ElementUtilTest.java | 4 +- .../vaadin/flow/model/TemplateModelTest.java | 2 +- .../PolymerServerEventHandlersTest.java | 7 +-- .../BootstrapHandlerDependenciesTest.java | 15 ++--- .../vaadin/server/BootstrapHandlerTest.java | 21 +++---- .../CustomElementRegistryInitializerTest.java | 13 ++--- .../server/startup/CustomElementsTest.java | 6 +- .../java/com/vaadin/ui/CompositeTest.java | 6 +- .../DefaultTemplateParserTest.java | 19 +++---- .../polymertemplate/PolymerTemplateTest.java | 15 +++-- .../TemplateInitializerTest.java | 12 ++-- .../dependencies/FrontendInlineApiView.java | 3 +- .../ui/template/LazyLoadingTemplateUI.java | 3 +- 33 files changed, 151 insertions(+), 187 deletions(-) diff --git a/flow-components-parent/flow-components/src/main/java/com/vaadin/ui/formlayout/FormLayout.java b/flow-components-parent/flow-components/src/main/java/com/vaadin/ui/formlayout/FormLayout.java index d2e0861ccb7..1cc2773c5f9 100644 --- a/flow-components-parent/flow-components/src/main/java/com/vaadin/ui/formlayout/FormLayout.java +++ b/flow-components-parent/flow-components/src/main/java/com/vaadin/ui/formlayout/FormLayout.java @@ -21,8 +21,7 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; -import org.jsoup.helper.StringUtil; - +import com.vaadin.external.jsoup.helper.StringUtil; import com.vaadin.ui.Component; import com.vaadin.ui.common.HasComponents; import com.vaadin.ui.common.HasSize; diff --git a/flow-documentation/src/main/java/com/vaadin/flow/tutorial/BootstrapPage.java b/flow-documentation/src/main/java/com/vaadin/flow/tutorial/BootstrapPage.java index e0b1389b248..934d63e6547 100644 --- a/flow-documentation/src/main/java/com/vaadin/flow/tutorial/BootstrapPage.java +++ b/flow-documentation/src/main/java/com/vaadin/flow/tutorial/BootstrapPage.java @@ -15,9 +15,8 @@ */ package com.vaadin.flow.tutorial; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; - +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Element; import com.vaadin.flow.tutorial.annotations.CodeFor; import com.vaadin.server.BootstrapListener; import com.vaadin.server.BootstrapPageResponse; diff --git a/flow-documentation/src/main/java/com/vaadin/flow/tutorial/binder/BinderBeans.java b/flow-documentation/src/main/java/com/vaadin/flow/tutorial/binder/BinderBeans.java index f0ad67e89e3..58eff3f0c7a 100644 --- a/flow-documentation/src/main/java/com/vaadin/flow/tutorial/binder/BinderBeans.java +++ b/flow-documentation/src/main/java/com/vaadin/flow/tutorial/binder/BinderBeans.java @@ -15,20 +15,18 @@ */ package com.vaadin.flow.tutorial.binder; -import java.util.List; -import java.util.stream.Collectors; - import javax.validation.constraints.Max; import javax.validation.constraints.NotEmpty; - -import org.jsoup.Jsoup; -import org.jsoup.safety.Whitelist; +import java.util.List; +import java.util.stream.Collectors; import com.vaadin.data.BeanValidationBinder; import com.vaadin.data.Binder; import com.vaadin.data.BinderValidationStatusHandler; import com.vaadin.data.ValidationResult; import com.vaadin.data.converter.StringToIntegerConverter; +import com.vaadin.external.jsoup.Jsoup; +import com.vaadin.external.jsoup.safety.Whitelist; import com.vaadin.flow.tutorial.annotations.CodeFor; import com.vaadin.ui.html.Label; import com.vaadin.ui.textfield.TextField; diff --git a/flow-server/pom.xml b/flow-server/pom.xml index b95ded9146a..cead8a6850b 100644 --- a/flow-server/pom.xml +++ b/flow-server/pom.xml @@ -45,9 +45,9 @@ - org.jsoup - jsoup - 1.10.3 + com.vaadin.external.jsoup + jsoup-case-sensitive + 1.9.2 com.helger diff --git a/flow-server/src/main/java/com/vaadin/flow/dom/Element.java b/flow-server/src/main/java/com/vaadin/flow/dom/Element.java index a5d21dca7fe..97f4ec25063 100644 --- a/flow-server/src/main/java/com/vaadin/flow/dom/Element.java +++ b/flow-server/src/main/java/com/vaadin/flow/dom/Element.java @@ -26,8 +26,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import org.jsoup.nodes.Document; - +import com.vaadin.external.jsoup.nodes.Document; import com.vaadin.flow.JsonCodec; import com.vaadin.flow.StateNode; import com.vaadin.flow.dom.impl.BasicElementStateProvider; diff --git a/flow-server/src/main/java/com/vaadin/flow/dom/ElementUtil.java b/flow-server/src/main/java/com/vaadin/flow/dom/ElementUtil.java index c3e3dc89615..ba3d4ad1957 100644 --- a/flow-server/src/main/java/com/vaadin/flow/dom/ElementUtil.java +++ b/flow-server/src/main/java/com/vaadin/flow/dom/ElementUtil.java @@ -19,10 +19,9 @@ import java.util.Optional; import java.util.regex.Pattern; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Node; -import org.jsoup.nodes.TextNode; - +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Node; +import com.vaadin.external.jsoup.nodes.TextNode; import com.vaadin.ui.Component; import com.vaadin.ui.Composite; @@ -48,8 +47,7 @@ private ElementUtil() { /** * Checks if the given tag name is valid. * - * @param tag - * the tag name + * @param tag the tag name * @return true if the string is valid as a tag name, false otherwise */ public static boolean isValidTagName(String tag) { @@ -59,8 +57,7 @@ public static boolean isValidTagName(String tag) { /** * Checks if the given attribute name is valid. * - * @param attribute - * the name of the attribute in lower case + * @param attribute the name of the attribute in lower case * @return true if the name is valid, false otherwise */ public static boolean isValidAttributeName(String attribute) { @@ -75,8 +72,8 @@ public static boolean isValidAttributeName(String attribute) { // APOSTROPHE ('), U+003E GREATER-THAN SIGN (>), U+002F SOLIDUS (/), and // U+003D EQUALS SIGN (=) characters, the control characters, and any // characters that are not defined by Unicode. - char[] illegalCharacters = new char[] { 0, ' ', '"', '\'', '>', '/', - '=' }; + char[] illegalCharacters = new char[]{0, ' ', '"', '\'', '>', '/', + '='}; for (char c : illegalCharacters) { if (attribute.indexOf(c) != -1) { return false; @@ -89,8 +86,7 @@ public static boolean isValidAttributeName(String attribute) { * Validates the given style property name and throws an exception if the * name is invalid. * - * @param name - * the style property name to validate + * @param name the style property name to validate */ public static void validateStylePropertyName(String name) { String reason = getInvalidStylePropertyNameError(name); @@ -128,8 +124,7 @@ private static String getInvalidStylePropertyNameError(String name) { /** * Checks if the given style property name is valid. * - * @param name - * the name to validate + * @param name the name to validate * @return true if the name is valid, false otherwise */ public static boolean isValidStylePropertyName(String name) { @@ -139,8 +134,7 @@ public static boolean isValidStylePropertyName(String name) { /** * Checks if the given style property value is valid. * - * @param value - * the value to validate + * @param value the value to validate * @return true if the value is valid, false otherwise */ public static boolean isValidStylePropertyValue(String value) { @@ -152,8 +146,7 @@ public static boolean isValidStylePropertyValue(String value) { *

* Throws an exception if it's certain the value is invalid * - * @param value - * the value to validate + * @param value the value to validate */ public static void validateStylePropertyValue(String value) { String reason = getInvalidStylePropertyValueError(value); @@ -179,10 +172,8 @@ private static String getInvalidStylePropertyValueError(String value) { * changed. The only exception is {@link Composite} which can overwrite the * mapping for its content. * - * @param element - * the element to map to the component - * @param component - * the component this element is attached to + * @param element the element to map to the component + * @param component the component this element is attached to */ public static void setComponent(Element element, Component component) { if (element == null) { @@ -197,7 +188,7 @@ public static void setComponent(Element element, Component component) { // Composite can replace its content boolean isCompositeReplacingItsContent = component instanceof Composite && component.getChildren().findFirst() - .get() == currentComponent.get(); + .get() == currentComponent.get(); if (!isCompositeReplacingItsContent) { throw new IllegalStateException("A component of type " + currentComponent.get().getClass().getName() @@ -213,10 +204,9 @@ public static void setComponent(Element element, Component component) { * If the element is mapped to a {@link Composite} or a {@link Composite} * chain, this will always return the outermost {@link Composite}. * - * @param element - * the element to retrieve the component for + * @param element the element to retrieve the component for * @return an optional component, or an empty optional if no component has - * been mapped to this element + * been mapped to this element */ public static Optional getComponent(Element element) { return element.getStateProvider().getComponent(element.getNode()); @@ -226,10 +216,8 @@ public static Optional getComponent(Element element) { * Converts the given element and its children to a JSoup node with * children. * - * @param document - * A JSoup document - * @param element - * The element to convert + * @param document A JSoup document + * @param element The element to convert * @return A JSoup node containing the converted element */ public static Node toJsoup(Document document, Element element) { @@ -237,7 +225,7 @@ public static Node toJsoup(Document document, Element element) { return new TextNode(element.getText(), document.baseUri()); } - org.jsoup.nodes.Element target = document + com.vaadin.external.jsoup.nodes.Element target = document .createElement(element.getTag()); if (element.hasProperty("innerHTML")) { target.html((String) element.getPropertyRaw("innerHTML")); @@ -264,8 +252,7 @@ public static Node toJsoup(Document document, Element element) { * Custom elements (Web Components) are recognized by having at least one * dash in the tag name. * - * @param element - * the element to check + * @param element the element to check * @return true if a custom element, false if not */ public static boolean isCustomElement(Element element) { @@ -275,8 +262,7 @@ public static boolean isCustomElement(Element element) { /** * Checks whether the given element is a script or not. * - * @param element - * the element to check + * @param element the element to check * @return true if a script, false if not */ public static boolean isScript(Element element) { diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/AbstractTemplateBuilderFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/AbstractTemplateBuilderFactory.java index e040db4f27f..37de50b241c 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/AbstractTemplateBuilderFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/AbstractTemplateBuilderFactory.java @@ -17,8 +17,7 @@ import java.util.regex.Pattern; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.AbstractBindingValueProvider; import com.vaadin.flow.template.angular.JsExpressionBindingProvider; import com.vaadin.flow.template.angular.ModelValueBindingProvider; diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DataNodeFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DataNodeFactory.java index 467de80a2a7..a9af1166d06 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DataNodeFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DataNodeFactory.java @@ -18,9 +18,8 @@ import java.util.Optional; import java.util.function.Function; -import org.jsoup.nodes.DataNode; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.nodes.DataNode; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.StaticBindingValueProvider; import com.vaadin.flow.template.angular.TemplateNodeBuilder; import com.vaadin.flow.template.angular.TextTemplateBuilder; diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultElementBuilderFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultElementBuilderFactory.java index 45926edc858..346511c2e90 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultElementBuilderFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultElementBuilderFactory.java @@ -19,10 +19,9 @@ import java.util.function.Function; import java.util.stream.Stream; -import org.jsoup.nodes.Attribute; -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.nodes.Attribute; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.AbstractBindingValueProvider; import com.vaadin.flow.template.angular.ElementTemplateBuilder; import com.vaadin.flow.template.angular.StaticBindingValueProvider; diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultTextModelBuilderFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultTextModelBuilderFactory.java index a66d0a0d53d..6d49ce63992 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultTextModelBuilderFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/DefaultTextModelBuilderFactory.java @@ -25,9 +25,8 @@ import java.util.function.Function; import java.util.stream.Collectors; -import org.jsoup.nodes.Node; -import org.jsoup.nodes.TextNode; - +import com.vaadin.external.jsoup.nodes.Node; +import com.vaadin.external.jsoup.nodes.TextNode; import com.vaadin.flow.template.angular.ChildSlotBuilder; import com.vaadin.flow.template.angular.StaticBindingValueProvider; import com.vaadin.flow.template.angular.TemplateNodeBuilder; diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/ForElementBuilderFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/ForElementBuilderFactory.java index c8805a620ba..dac17230b88 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/ForElementBuilderFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/ForElementBuilderFactory.java @@ -21,9 +21,8 @@ import java.util.StringTokenizer; import java.util.function.Function; -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.ElementTemplateBuilder; import com.vaadin.flow.template.angular.ForTemplateBuilder; import com.vaadin.flow.template.angular.TemplateNodeBuilder; diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateNodeBuilderFactory.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateNodeBuilderFactory.java index c3541ace377..57a8aa57a4a 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateNodeBuilderFactory.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateNodeBuilderFactory.java @@ -18,8 +18,7 @@ import java.util.Optional; import java.util.function.Function; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.TemplateNodeBuilder; /** diff --git a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateParser.java b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateParser.java index a729231b16b..94e7d0b0e06 100644 --- a/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateParser.java +++ b/flow-server/src/main/java/com/vaadin/flow/template/angular/parser/TemplateParser.java @@ -26,16 +26,15 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Comment; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; -import org.jsoup.nodes.TextNode; -import org.jsoup.select.Elements; -import org.jsoup.select.NodeTraversor; -import org.jsoup.select.NodeVisitor; - +import com.vaadin.external.jsoup.Jsoup; +import com.vaadin.external.jsoup.nodes.Comment; +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Node; +import com.vaadin.external.jsoup.nodes.TextNode; +import com.vaadin.external.jsoup.select.Elements; +import com.vaadin.external.jsoup.select.NodeTraversor; +import com.vaadin.external.jsoup.select.NodeVisitor; import com.vaadin.flow.template.angular.DelegateResolver; import com.vaadin.flow.template.angular.TemplateNode; import com.vaadin.flow.template.angular.TemplateNodeBuilder; diff --git a/flow-server/src/main/java/com/vaadin/flow/util/HtmlUtils.java b/flow-server/src/main/java/com/vaadin/flow/util/HtmlUtils.java index e41fe57f006..89cf7de038d 100644 --- a/flow-server/src/main/java/com/vaadin/flow/util/HtmlUtils.java +++ b/flow-server/src/main/java/com/vaadin/flow/util/HtmlUtils.java @@ -15,7 +15,7 @@ */ package com.vaadin.flow.util; -import org.jsoup.nodes.TextNode; +import com.vaadin.external.jsoup.nodes.TextNode; /** * Helpers for HTML related aspects. diff --git a/flow-server/src/main/java/com/vaadin/server/BootstrapHandler.java b/flow-server/src/main/java/com/vaadin/server/BootstrapHandler.java index 55e8e6f1fcf..6af1bdc0e62 100644 --- a/flow-server/src/main/java/com/vaadin/server/BootstrapHandler.java +++ b/flow-server/src/main/java/com/vaadin/server/BootstrapHandler.java @@ -35,12 +35,11 @@ import java.util.regex.Pattern; import java.util.stream.Stream; -import org.jsoup.nodes.DataNode; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.DocumentType; -import org.jsoup.nodes.Element; -import org.jsoup.parser.Tag; - +import com.vaadin.external.jsoup.nodes.DataNode; +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.DocumentType; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.parser.Tag; import com.vaadin.function.DeploymentConfiguration; import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.server.communication.UidlWriter; diff --git a/flow-server/src/main/java/com/vaadin/server/BootstrapPageResponse.java b/flow-server/src/main/java/com/vaadin/server/BootstrapPageResponse.java index d223664261e..fb98557b4bc 100644 --- a/flow-server/src/main/java/com/vaadin/server/BootstrapPageResponse.java +++ b/flow-server/src/main/java/com/vaadin/server/BootstrapPageResponse.java @@ -16,8 +16,7 @@ package com.vaadin.server; -import org.jsoup.nodes.Document; - +import com.vaadin.external.jsoup.nodes.Document; import com.vaadin.shared.VaadinUriResolver; import com.vaadin.ui.UI; diff --git a/flow-server/src/main/java/com/vaadin/ui/Html.java b/flow-server/src/main/java/com/vaadin/ui/Html.java index 4e4078c876d..5a6b8277f56 100644 --- a/flow-server/src/main/java/com/vaadin/ui/Html.java +++ b/flow-server/src/main/java/com/vaadin/ui/Html.java @@ -20,10 +20,9 @@ import java.io.UncheckedIOException; import java.util.logging.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Attributes; -import org.jsoup.nodes.Document; - +import com.vaadin.external.jsoup.Jsoup; +import com.vaadin.external.jsoup.nodes.Attributes; +import com.vaadin.external.jsoup.nodes.Document; import com.vaadin.flow.dom.Element; import com.vaadin.ui.common.PropertyDescriptor; import com.vaadin.ui.common.PropertyDescriptors; @@ -110,7 +109,7 @@ private void setOuterHtml(Document doc) { + nrChildren); } - org.jsoup.nodes.Element root = doc.body().child(0); + com.vaadin.external.jsoup.nodes.Element root = doc.body().child(0); Attributes attrs = root.attributes(); Component.setElement(this, new Element(root.tagName())); diff --git a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/DefaultTemplateParser.java b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/DefaultTemplateParser.java index c9177b9cce9..229776cb31e 100644 --- a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/DefaultTemplateParser.java +++ b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/DefaultTemplateParser.java @@ -15,6 +15,7 @@ */ package com.vaadin.ui.polymertemplate; +import javax.servlet.ServletContext; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -26,14 +27,11 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.servlet.ServletContext; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Comment; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; - +import com.vaadin.external.jsoup.Jsoup; +import com.vaadin.external.jsoup.nodes.Comment; +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.util.ReflectionCache; import com.vaadin.server.DependencyFilter; import com.vaadin.server.DependencyFilter.FilterContext; diff --git a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateInitializer.java b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateInitializer.java index 6987833d374..08b2867cc3a 100644 --- a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateInitializer.java +++ b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateInitializer.java @@ -27,8 +27,7 @@ import java.util.function.Function; import java.util.stream.Stream; -import org.jsoup.select.Elements; - +import com.vaadin.external.jsoup.select.Elements; import com.vaadin.flow.StateNode; import com.vaadin.flow.dom.Element; import com.vaadin.flow.dom.ShadowRoot; @@ -65,7 +64,7 @@ public class TemplateInitializer { private final ParserData parserData; private final Set notInjectableElementIds = new HashSet<>(); - private org.jsoup.nodes.Element parsedTemplateRoot; + private com.vaadin.external.jsoup.nodes.Element parsedTemplateRoot; private static class SubTemplateData { private final String id; @@ -144,8 +143,8 @@ public void initChildElements() { } private void inspectCustomElements( - org.jsoup.nodes.Element childElement, - org.jsoup.nodes.Element templateRoot) { + com.vaadin.external.jsoup.nodes.Element childElement, + com.vaadin.external.jsoup.nodes.Element templateRoot) { if (isInsideTemplate(childElement, templateRoot)) { storeNotInjectableElementId(childElement); } @@ -156,7 +155,7 @@ private void inspectCustomElements( } private void storeNotInjectableElementId( - org.jsoup.nodes.Element element) { + com.vaadin.external.jsoup.nodes.Element element) { String id = element.id(); if (id != null && !id.isEmpty()) { notInjectableElementIds.add(id); @@ -166,8 +165,8 @@ private void storeNotInjectableElementId( private void parseTemplate() { assert parsedTemplateRoot != null; Elements templates = parsedTemplateRoot.getElementsByTag("template"); - for (org.jsoup.nodes.Element element : templates) { - org.jsoup.nodes.Element parent = element.parent(); + for (com.vaadin.external.jsoup.nodes.Element element : templates) { + com.vaadin.external.jsoup.nodes.Element parent = element.parent(); if (parent != null && getElement().getTag().equals(parent.id())) { inspectCustomElements(element, element); } @@ -175,8 +174,8 @@ private void parseTemplate() { } private boolean isInsideTemplate( - org.jsoup.nodes.Element element, - org.jsoup.nodes.Element templateRoot) { + com.vaadin.external.jsoup.nodes.Element element, + com.vaadin.external.jsoup.nodes.Element templateRoot) { if (element == templateRoot) { return false; } @@ -187,8 +186,8 @@ private boolean isInsideTemplate( } private void requestAttachCustomElement( - org.jsoup.nodes.Element element, - org.jsoup.nodes.Element templateRoot) { + com.vaadin.external.jsoup.nodes.Element element, + com.vaadin.external.jsoup.nodes.Element templateRoot) { String tag = element.tagName(); if (CustomElementRegistry.getInstance() @@ -231,12 +230,12 @@ private void doRequestAttachCustomElement(String id, String tag, }); } - private JsonArray getPath(org.jsoup.nodes.Element element, - org.jsoup.nodes.Element templateRoot) { + private JsonArray getPath(com.vaadin.external.jsoup.nodes.Element element, + com.vaadin.external.jsoup.nodes.Element templateRoot) { List path = new ArrayList<>(); - org.jsoup.nodes.Element current = element; + com.vaadin.external.jsoup.nodes.Element current = element; while (!current.equals(templateRoot)) { - org.jsoup.nodes.Element parent = current.parent(); + com.vaadin.external.jsoup.nodes.Element parent = current.parent(); path.add(indexOf(parent, current)); current = parent; } @@ -249,7 +248,7 @@ private JsonArray getPath(org.jsoup.nodes.Element element, /** * Returns the index of the {@code child} in the collection of - * {@link org.jsoup.nodes.Element} children of the + * {@link com.vaadin.external.jsoup.nodes.Element} children of the * {@code parent} ignoring "style" elements. *

* "style" elements are handled differently depending on ES5/ES6. Also @@ -262,11 +261,11 @@ private JsonArray getPath(org.jsoup.nodes.Element element, * the child element whose index is calculated * @return the index of the {@code child} in the {@code parent} */ - private int indexOf(org.jsoup.nodes.Element parent, - org.jsoup.nodes.Element child) { + private int indexOf(com.vaadin.external.jsoup.nodes.Element parent, + com.vaadin.external.jsoup.nodes.Element child) { Elements children = parent.children(); int index = -1; - for (org.jsoup.nodes.Element nextChild : children) { + for (com.vaadin.external.jsoup.nodes.Element nextChild : children) { if (!"style".equals(nextChild.tagName())) { index++; } @@ -334,7 +333,7 @@ private Optional getTagName(String id) { } else { Optional tag = Optional .ofNullable(parsedTemplateRoot.getElementById(id)) - .map(org.jsoup.nodes.Element::tagName); + .map(com.vaadin.external.jsoup.nodes.Element::tagName); if (tag.isPresent()) { parserData.addTag(id, tag.get()); } diff --git a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateParser.java b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateParser.java index 75074c8b6c2..22ab31c95b6 100644 --- a/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateParser.java +++ b/flow-server/src/main/java/com/vaadin/ui/polymertemplate/TemplateParser.java @@ -15,7 +15,7 @@ */ package com.vaadin.ui.polymertemplate; -import org.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Element; /** * Template content parser. diff --git a/flow-server/src/test/java/com/vaadin/flow/dom/ElementUtilTest.java b/flow-server/src/test/java/com/vaadin/flow/dom/ElementUtilTest.java index 8b182c3acc7..5a316f4041e 100644 --- a/flow-server/src/test/java/com/vaadin/flow/dom/ElementUtilTest.java +++ b/flow-server/src/test/java/com/vaadin/flow/dom/ElementUtilTest.java @@ -15,12 +15,12 @@ */ package com.vaadin.flow.dom; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Node; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.flow.template.angular.InlineTemplate; import com.vaadin.ui.Component; diff --git a/flow-server/src/test/java/com/vaadin/flow/model/TemplateModelTest.java b/flow-server/src/test/java/com/vaadin/flow/model/TemplateModelTest.java index 0e509b518f0..ce237430249 100644 --- a/flow-server/src/test/java/com/vaadin/flow/model/TemplateModelTest.java +++ b/flow-server/src/test/java/com/vaadin/flow/model/TemplateModelTest.java @@ -10,11 +10,11 @@ import java.util.stream.Collectors; import org.hamcrest.Matchers; -import org.jsoup.Jsoup; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.StateNode; import com.vaadin.flow.change.NodeChange; import com.vaadin.flow.nodefeature.ElementPropertyMap; diff --git a/flow-server/src/test/java/com/vaadin/flow/nodefeature/PolymerServerEventHandlersTest.java b/flow-server/src/test/java/com/vaadin/flow/nodefeature/PolymerServerEventHandlersTest.java index 62c81c5b68c..22a0334da5c 100644 --- a/flow-server/src/test/java/com/vaadin/flow/nodefeature/PolymerServerEventHandlersTest.java +++ b/flow-server/src/test/java/com/vaadin/flow/nodefeature/PolymerServerEventHandlersTest.java @@ -16,9 +16,6 @@ package com.vaadin.flow.nodefeature; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -29,11 +26,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.jsoup.Jsoup; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.ConstantPoolKey; import com.vaadin.flow.StateNode; import com.vaadin.flow.dom.impl.BasicElementStateProvider; @@ -50,6 +47,8 @@ import elemental.json.Json; import elemental.json.JsonObject; import elemental.json.impl.JreJsonArray; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * @author Vaadin Ltd. diff --git a/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerDependenciesTest.java b/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerDependenciesTest.java index c3f38a53629..fdb5a1db952 100644 --- a/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerDependenciesTest.java +++ b/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerDependenciesTest.java @@ -9,6 +9,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.select.Elements; import com.vaadin.function.DeploymentConfiguration; import com.vaadin.server.BootstrapHandler.BootstrapContext; import com.vaadin.shared.ui.LoadMode; @@ -17,13 +25,6 @@ import com.vaadin.ui.common.HtmlImport; import com.vaadin.ui.common.JavaScript; import com.vaadin.ui.common.StyleSheet; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; import static org.hamcrest.CoreMatchers.both; import static org.hamcrest.CoreMatchers.containsString; diff --git a/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java b/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java index 4192c4895ea..fecd2b54bc2 100644 --- a/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java +++ b/flow-server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java @@ -9,6 +9,17 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicReference; +import org.apache.commons.io.IOUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mockito; + +import com.vaadin.external.jsoup.nodes.Document; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.select.Elements; import com.vaadin.flow.template.angular.InlineTemplate; import com.vaadin.router.PageTitle; import com.vaadin.server.BootstrapHandler.BootstrapContext; @@ -23,16 +34,6 @@ import com.vaadin.ui.common.HtmlImport; import com.vaadin.ui.common.JavaScript; import com.vaadin.ui.common.StyleSheet; -import org.apache.commons.io.IOUtils; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/flow-server/src/test/java/com/vaadin/server/startup/CustomElementRegistryInitializerTest.java b/flow-server/src/test/java/com/vaadin/server/startup/CustomElementRegistryInitializerTest.java index f8c3ecbe694..3789bb6d3c1 100644 --- a/flow-server/src/test/java/com/vaadin/server/startup/CustomElementRegistryInitializerTest.java +++ b/flow-server/src/test/java/com/vaadin/server/startup/CustomElementRegistryInitializerTest.java @@ -15,23 +15,20 @@ */ package com.vaadin.server.startup; -import static org.mockito.Mockito.when; - +import javax.servlet.ServletException; import java.lang.reflect.Field; import java.util.LinkedHashSet; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.servlet.ServletException; - -import org.jsoup.Jsoup; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.di.DefaultInstantiator; import com.vaadin.flow.dom.Element; import com.vaadin.flow.model.TemplateModel; @@ -45,6 +42,8 @@ import com.vaadin.ui.polymertemplate.TemplateParser; import com.vaadin.util.HasCurrentService; +import static org.mockito.Mockito.when; + /** * Test that correct @Tag custom elements get loaded by the initializer loader. */ @@ -119,7 +118,7 @@ public void registeringCustomElementWithInvalidNameThrowsException() throws ServletException { // Invalid name should throw an exception due to not being supported customElementRegistryInitializer.onStartup(Stream - .of(InvalidCustomElement.class).collect(Collectors.toSet()), + .of(InvalidCustomElement.class).collect(Collectors.toSet()), null); } @@ -161,7 +160,7 @@ public void nonPolymerTemplateElementsAreNotRegistered() public void creatingElementWithRegisteredCustomTagNameWiresComponentForElement() throws ServletException { customElementRegistryInitializer.onStartup(Stream - .of(CustomPolymerElement.class).collect(Collectors.toSet()), + .of(CustomPolymerElement.class).collect(Collectors.toSet()), null); Element polymerElement = new Element("custom-polymer-element"); diff --git a/flow-server/src/test/java/com/vaadin/server/startup/CustomElementsTest.java b/flow-server/src/test/java/com/vaadin/server/startup/CustomElementsTest.java index f4269dbcb19..09f6b5e4f9d 100644 --- a/flow-server/src/test/java/com/vaadin/server/startup/CustomElementsTest.java +++ b/flow-server/src/test/java/com/vaadin/server/startup/CustomElementsTest.java @@ -16,25 +16,25 @@ package com.vaadin.server.startup; -import static org.hamcrest.CoreMatchers.is; - import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import org.jsoup.Jsoup; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.model.TemplateModel; import com.vaadin.ui.Component; import com.vaadin.ui.Tag; import com.vaadin.ui.polymertemplate.PolymerTemplate; import com.vaadin.ui.polymertemplate.TemplateParser; +import static org.hamcrest.CoreMatchers.is; + /** * @author Vaadin Ltd. */ diff --git a/flow-server/src/test/java/com/vaadin/ui/CompositeTest.java b/flow-server/src/test/java/com/vaadin/ui/CompositeTest.java index 2d7e6875f02..bb3fd1ee966 100644 --- a/flow-server/src/test/java/com/vaadin/ui/CompositeTest.java +++ b/flow-server/src/test/java/com/vaadin/ui/CompositeTest.java @@ -1,18 +1,16 @@ package com.vaadin.ui; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.jsoup.Jsoup; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.dom.Element; import com.vaadin.flow.dom.ElementFactory; import com.vaadin.flow.model.TemplateModel; @@ -27,6 +25,8 @@ import com.vaadin.ui.event.DetachEvent; import com.vaadin.ui.polymertemplate.PolymerTemplate; +import static org.junit.Assert.assertEquals; + public class CompositeTest { // layoutWithSingleComponentComposite (TestLayout) diff --git a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/DefaultTemplateParserTest.java b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/DefaultTemplateParserTest.java index 1a6c52efce6..f299757c756 100644 --- a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/DefaultTemplateParserTest.java +++ b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/DefaultTemplateParserTest.java @@ -15,10 +15,8 @@ */ package com.vaadin.ui.polymertemplate; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.empty; -import static org.junit.Assert.assertThat; - +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.Collections; @@ -27,18 +25,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpSession; - -import org.jsoup.nodes.Comment; -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.nodes.Comment; +import com.vaadin.external.jsoup.nodes.Element; +import com.vaadin.external.jsoup.nodes.Node; import com.vaadin.server.DependencyFilter; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; @@ -55,6 +50,10 @@ import com.vaadin.ui.polymertemplate.PolymerTemplateTest.ModelClass; import com.vaadin.util.CurrentInstance; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.empty; +import static org.junit.Assert.assertThat; + public class DefaultTemplateParserTest { @Tag("foo") diff --git a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/PolymerTemplateTest.java b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/PolymerTemplateTest.java index 8cfd3751793..f9be6476390 100644 --- a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/PolymerTemplateTest.java +++ b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/PolymerTemplateTest.java @@ -16,12 +16,6 @@ package com.vaadin.ui.polymertemplate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - import java.io.Serializable; import java.lang.reflect.Field; import java.util.ArrayList; @@ -35,14 +29,14 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Element; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.vaadin.external.jsoup.Jsoup; +import com.vaadin.external.jsoup.nodes.Element; import com.vaadin.flow.StateNode; import com.vaadin.flow.di.DefaultInstantiator; import com.vaadin.flow.model.TemplateModel; @@ -61,6 +55,11 @@ import com.vaadin.util.HasCurrentService; import elemental.json.JsonArray; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; /** * @author Vaadin Ltd. diff --git a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/TemplateInitializerTest.java b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/TemplateInitializerTest.java index 0185bf10daf..a6917ab98db 100644 --- a/flow-server/src/test/java/com/vaadin/ui/polymertemplate/TemplateInitializerTest.java +++ b/flow-server/src/test/java/com/vaadin/ui/polymertemplate/TemplateInitializerTest.java @@ -16,15 +16,10 @@ package com.vaadin.ui.polymertemplate; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.jsoup.Jsoup; import org.junit.Before; import org.junit.Test; +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.dom.Element; import com.vaadin.flow.model.TemplateModel; import com.vaadin.function.DeploymentConfiguration; @@ -32,6 +27,11 @@ import com.vaadin.ui.Tag; import com.vaadin.util.HasCurrentService; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + /** * @author Vaadin Ltd. */ diff --git a/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/dependencies/FrontendInlineApiView.java b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/dependencies/FrontendInlineApiView.java index 67b4cf52bb5..9336354f588 100644 --- a/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/dependencies/FrontendInlineApiView.java +++ b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/dependencies/FrontendInlineApiView.java @@ -15,8 +15,7 @@ */ package com.vaadin.flow.uitest.ui.dependencies; -import org.jsoup.Jsoup; - +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.flow.model.TemplateModel; import com.vaadin.flow.router.View; import com.vaadin.shared.ui.LoadMode; diff --git a/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/template/LazyLoadingTemplateUI.java b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/template/LazyLoadingTemplateUI.java index 94872195698..08f591c8dc3 100644 --- a/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/template/LazyLoadingTemplateUI.java +++ b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/template/LazyLoadingTemplateUI.java @@ -18,8 +18,7 @@ import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; -import org.jsoup.Jsoup; - +import com.vaadin.external.jsoup.Jsoup; import com.vaadin.server.StreamResource; import com.vaadin.server.StreamResourceRegistration; import com.vaadin.server.VaadinRequest;