From 23301d878318125213338766b5767cf36279282f Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 13 Mar 2024 20:32:41 +0200 Subject: [PATCH] chore: Java 11 compatibility cont. - Add compiler release and compatibility locale configurations - Rename systemProperties to systemPropertyVariables for maven-failsafe-plugin - update failsafe and surefire plugins to newest version - update maven-source-plugin, maven-assembly-plugin, maven-bundle-plugin, maven-javadoc-plugin, maven-dependency-plugin to newest version - Remove MaxPermSize configurations - Remove unnecessary module-info.java exclusion - Add current javassist dependency to fix reflection issues - Added log4j dependency to test scope - Converted listeners to extend SerializableEventListener and the listener handling to use Registration objects - Fixed number format check to use locale-specific minus sign Test fixes - Expand maximum allowed rows for a locale selector - Update expected minus sign for Finnish locale - Added delay to a column resize - Stabilized file loading - Tweaked search for images --- pom.xml | 1 + vaadin-spreadsheet-charts/pom.xml | 22 +++-- vaadin-spreadsheet-testbench-api/pom.xml | 9 +- vaadin-spreadsheet/pom.xml | 41 +++++++-- .../addon/spreadsheet/CellValueManager.java | 3 +- .../vaadin/addon/spreadsheet/PopupButton.java | 35 +++++--- .../vaadin/addon/spreadsheet/Spreadsheet.java | 85 +++++++++++++------ .../spreadsheet/test/GeneralRoundingTest.java | 7 +- .../test/GeneralSmallRoundingTest.java | 31 +++++-- .../addon/spreadsheet/test/ImageTests.java | 13 ++- .../test/demoapps/SpreadsheetDemoUI.java | 1 + .../test/pageobjects/HeaderPage.java | 7 +- .../test/tb3/MultiBrowserTest.java | 10 +-- .../src/test/resources/log4j.properties | 7 ++ 14 files changed, 193 insertions(+), 79 deletions(-) create mode 100644 vaadin-spreadsheet/src/test/resources/log4j.properties diff --git a/pom.xml b/pom.xml index fd1da2a52..041759f10 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ org.apache.maven.plugins maven-assembly-plugin + 3.7.0 vaadin-spreadsheet-${project.version} false diff --git a/vaadin-spreadsheet-charts/pom.xml b/vaadin-spreadsheet-charts/pom.xml index 9f3d88484..e722f7a89 100644 --- a/vaadin-spreadsheet-charts/pom.xml +++ b/vaadin-spreadsheet-charts/pom.xml @@ -4,6 +4,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + + 8 + + -Djava.locale.providers=COMPAT + 1.8 1.8 UTF-8 @@ -12,7 +18,7 @@ ${vaadin.version} 5.3.0 ${vaadin.version} - 9.4.54.v20240208 + 9.3.30.v20211001 testbench-hub.intra.itmill.com @@ -151,6 +157,7 @@ UTF-8 1.8 1.8 + 8 @@ -168,7 +175,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9 + 3.6.3 8 false @@ -186,7 +193,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -262,7 +269,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + 3.2.5 @@ -276,7 +283,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.19.1 + 3.2.5 **/*TBTest.java @@ -403,11 +410,9 @@ maven-compiler-plugin 3.12.1 - - module-info.java - 1.8 1.8 + 8 UTF-8 @@ -499,6 +504,7 @@ 1.8 1.8 + 8 UTF-8 diff --git a/vaadin-spreadsheet-testbench-api/pom.xml b/vaadin-spreadsheet-testbench-api/pom.xml index ccbcb4980..4e0a6b7d2 100644 --- a/vaadin-spreadsheet-testbench-api/pom.xml +++ b/vaadin-spreadsheet-testbench-api/pom.xml @@ -11,6 +11,10 @@ 2013 + + + 8 + 1.8 1.8 UTF-8 @@ -73,7 +77,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9 + 3.6.3 8 false @@ -95,12 +99,13 @@ UTF-8 1.8 1.8 + 8 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources diff --git a/vaadin-spreadsheet/pom.xml b/vaadin-spreadsheet/pom.xml index b86c9e937..547b02c76 100755 --- a/vaadin-spreadsheet/pom.xml +++ b/vaadin-spreadsheet/pom.xml @@ -18,6 +18,12 @@ Spreadsheet add-on for Vaadin --> + + + 8 + + -Djava.locale.providers=COMPAT + UTF-8 9.4.54.v20240208 8.14.3 @@ -68,6 +74,7 @@ UTF-8 1.8 1.8 + 8 @@ -126,7 +133,7 @@ org.apache.felix maven-bundle-plugin - 2.5.4 + 5.1.9 bundle-manifest @@ -153,7 +160,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9 + 3.6.3 8 -Xdoclint:none @@ -171,7 +178,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -185,6 +192,7 @@ org.apache.maven.plugins maven-dependency-plugin + 3.6.1 copy-dependencies @@ -203,6 +211,7 @@ org.apache.maven.plugins maven-assembly-plugin + 3.7.0 directorystuff false @@ -230,7 +239,7 @@ ${project.build.directory}/testwebapp/VAADIN/widgetsets - -Xmx1g -Xms1g -XX:MaxPermSize=512m + -Xmx1g -Xms1g ${project.build.directory}/testwebapp true http://localhost:9998/ @@ -245,7 +254,7 @@ maven-surefire-plugin - 2.17 + 3.2.5 **/junit/* @@ -255,7 +264,7 @@ maven-failsafe-plugin - 2.17 + 3.2.5 + + org.javassist + javassist + 3.30.2-GA + + + + org.slf4j + slf4j-log4j12 + 1.6.1 + test + diff --git a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/CellValueManager.java b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/CellValueManager.java index 05d90d7c1..a5de7a73b 100644 --- a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/CellValueManager.java +++ b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/CellValueManager.java @@ -428,7 +428,8 @@ public String getOriginalCellValue(Cell cell) { } private boolean valueContainsOnlyNumbers(String value) { - return value.matches("^-?\\d+(" + return value.matches("^" + localeDecimalSymbols.getMinusSign() + + "?\\d+(" + localeDecimalSymbols.getDecimalSeparator() + "\\d+)?$"); } diff --git a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/PopupButton.java b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/PopupButton.java index fb8e6a8b8..64e645aeb 100644 --- a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/PopupButton.java +++ b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/PopupButton.java @@ -17,7 +17,6 @@ * #L% */ -import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collections; import java.util.Iterator; @@ -28,6 +27,8 @@ import com.vaadin.addon.spreadsheet.client.PopupButtonServerRpc; import com.vaadin.addon.spreadsheet.client.PopupButtonState; import com.vaadin.addon.spreadsheet.client.PopupButtonWidget; +import com.vaadin.event.SerializableEventListener; +import com.vaadin.shared.Registration; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractSingleComponentContainer; import com.vaadin.ui.Component; @@ -255,21 +256,26 @@ public boolean isActive() { /** * Adds a {@link PopupOpenListener} to this pop-up button. - * + * * @param listener * The listener to add + * @return a registration object for removing the listener */ - public void addPopupOpenListener(PopupOpenListener listener) { - addListener(PopupOpenEvent.class, listener, + public Registration addPopupOpenListener(PopupOpenListener listener) { + return addListener(PopupOpenEvent.class, listener, PopupOpenListener.POPUP_OPEN_METHOD); } /** * Removes the given {@link PopupOpenListener} from this pop-up button. - * + * * @param listener * The listener to remove + * @deprecated use a {@link Registration} from + * {@link #removePopupOpenListener(PopupOpenListener)} to remove + * a listener */ + @Deprecated public void removePopupOpenListener(PopupOpenListener listener) { removeListener(PopupOpenEvent.class, listener, PopupOpenListener.POPUP_OPEN_METHOD); @@ -277,19 +283,26 @@ public void removePopupOpenListener(PopupOpenListener listener) { /** * Adds a {@link PopupCloseListener} to this pop-up button. - * + * * @param listener + * the listener to add + * @return a registration object for removing the listener */ - public void addPopupCloseListener(PopupCloseListener listener) { - addListener(PopupCloseEvent.class, listener, + public Registration addPopupCloseListener(PopupCloseListener listener) { + return addListener(PopupCloseEvent.class, listener, PopupCloseListener.POPUP_CLOSE_METHOD); } /** * Removes the given {@link PopupCloseListener} from this pop-up button. - * + * * @param listener + * the listener to remove + * @deprecated use a {@link Registration} from + * {@link #removePopupCloseListener(PopupCloseListener)} to + * remove a listener */ + @Deprecated public void removePopupCloseListener(PopupCloseListener listener) { removeListener(PopupCloseEvent.class, listener, PopupCloseListener.POPUP_CLOSE_METHOD); @@ -345,7 +358,7 @@ public PopupButton getPopupButton() { * Interface for listening for a {@link PopupOpenEvent} fired by a * {@link PopupButton}. */ - public interface PopupOpenListener extends Serializable { + public interface PopupOpenListener extends SerializableEventListener { public static final Method POPUP_OPEN_METHOD = ReflectTools.findMethod( PopupOpenListener.class, "onPopupOpen", PopupOpenEvent.class); @@ -389,7 +402,7 @@ public PopupButton getPopupButton() { * Interface for listening for a {@link PopupCloseEvent} fired by a * {@link PopupButton}. */ - public interface PopupCloseListener extends Serializable { + public interface PopupCloseListener extends SerializableEventListener { public static final Method POPUP_CLOSE_METHOD = ReflectTools .findMethod(PopupCloseListener.class, "onPopupClose", PopupCloseEvent.class); diff --git a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/Spreadsheet.java b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/Spreadsheet.java index b888bcaa5..ae69c4185 100644 --- a/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/Spreadsheet.java +++ b/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/Spreadsheet.java @@ -88,7 +88,9 @@ import com.vaadin.addon.spreadsheet.shared.SpreadsheetState; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; +import com.vaadin.event.SerializableEventListener; import com.vaadin.server.Resource; +import com.vaadin.shared.Registration; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; import com.vaadin.ui.Component.Focusable; @@ -1945,11 +1947,12 @@ private void fireRowHeaderDoubleClick(int rowIndex) { * adds a {@link RowHeaderDoubleClickListener} to the Spreadsheet * * @param listener - * The listener to add + * The listener to add + * @return a registration object for removing the listener **/ - public void addRowHeaderDoubleClickListener( + public Registration addRowHeaderDoubleClickListener( RowHeaderDoubleClickListener listener) { - addListener(RowHeaderDoubleClickEvent.class, listener, + return addListener(RowHeaderDoubleClickEvent.class, listener, RowHeaderDoubleClickListener.ON_ROW_ON_ROW_HEADER_DOUBLE_CLICK); } @@ -4352,7 +4355,7 @@ private static Set getAllSelectedCells( /** * Used for knowing when a user has changed the cell selection in any way. */ - public interface SelectionChangeListener extends Serializable { + public interface SelectionChangeListener extends SerializableEventListener { public static final Method SELECTION_CHANGE_METHOD = ReflectTools .findMethod(SelectionChangeListener.class, "onSelectionChange", SelectionChangeEvent.class); @@ -4370,7 +4373,7 @@ public interface SelectionChangeListener extends Serializable { * Used for knowing when a user has changed the cell value in Spreadsheet * UI. */ - public interface CellValueChangeListener extends Serializable { + public interface CellValueChangeListener extends SerializableEventListener { public static final Method CELL_VALUE_CHANGE_METHOD = ReflectTools .findMethod(CellValueChangeListener.class, "onCellValueChange", CellValueChangeEvent.class); @@ -4388,7 +4391,8 @@ public interface CellValueChangeListener extends Serializable { * Used for knowing when a cell referenced by a formula cell has changed in * the Spreadsheet UI making the formula value change */ - public interface FormulaValueChangeListener extends Serializable { + public interface FormulaValueChangeListener + extends SerializableEventListener { public static final Method FORMULA_VALUE_CHANGE_METHOD = ReflectTools .findMethod(FormulaValueChangeListener.class, "onFormulaValueChange", FormulaValueChangeEvent.class); @@ -4404,44 +4408,53 @@ public interface FormulaValueChangeListener extends Serializable { /** * Adds the given SelectionChangeListener to this Spreadsheet. - * + * * @param listener * Listener to add. + * @return a registration object for removing the listener */ - public void addSelectionChangeListener(SelectionChangeListener listener) { - addListener(SelectionChangeEvent.class, listener, + public Registration addSelectionChangeListener( + SelectionChangeListener listener) { + return addListener(SelectionChangeEvent.class, listener, SelectionChangeListener.SELECTION_CHANGE_METHOD); } /** * Adds the given CellValueChangeListener to this Spreadsheet. - * + * * @param listener * Listener to add. + * @return a registration object for removing the listener */ - public void addCellValueChangeListener(CellValueChangeListener listener) { - addListener(CellValueChangeEvent.class, listener, + public Registration addCellValueChangeListener( + CellValueChangeListener listener) { + return addListener(CellValueChangeEvent.class, listener, CellValueChangeListener.CELL_VALUE_CHANGE_METHOD); } /** * Adds the given FormulaValueChangeListener to this Spreadsheet. - * + * * @param listener * Listener to add. + * @return a registration object for removing the listener */ - public void addFormulaValueChangeListener( + public Registration addFormulaValueChangeListener( FormulaValueChangeListener listener) { - addListener(FormulaValueChangeEvent.class, listener, + return addListener(FormulaValueChangeEvent.class, listener, FormulaValueChangeListener.FORMULA_VALUE_CHANGE_METHOD); } /** * Removes the given SelectionChangeListener from this Spreadsheet. - * + * * @param listener * Listener to remove. + * @deprecated use a {@link Registration} from + * {@link #addSelectionChangeListener(SelectionChangeListener)} + * to remove a listener */ + @Deprecated public void removeSelectionChangeListener(SelectionChangeListener listener) { removeListener(SelectionChangeEvent.class, listener, SelectionChangeListener.SELECTION_CHANGE_METHOD); @@ -4449,10 +4462,14 @@ public void removeSelectionChangeListener(SelectionChangeListener listener) { /** * Removes the given CellValueChangeListener from this Spreadsheet. - * + * * @param listener * Listener to remove. + * @deprecated use a {@link Registration} from + * {@link #addCellValueChangeListener(CellValueChangeListener)} + * to remove a listener */ + @Deprecated public void removeCellValueChangeListener(CellValueChangeListener listener) { removeListener(CellValueChangeEvent.class, listener, CellValueChangeListener.CELL_VALUE_CHANGE_METHOD); @@ -4472,7 +4489,7 @@ public ProtectedEditEvent(Component source) { /** * A listener for when an attempt to modify a locked cell has been made. */ - public interface ProtectedEditListener extends Serializable { + public interface ProtectedEditListener extends SerializableEventListener { public static final Method SELECTION_CHANGE_METHOD = ReflectTools .findMethod(ProtectedEditListener.class, "writeAttempted", ProtectedEditEvent.class); @@ -4492,21 +4509,27 @@ public interface ProtectedEditListener extends Serializable { /** * Add listener for when an attempt to modify a locked cell has been made. - * + * * @param listener * The listener to add. + * @return a registration object for removing the listener */ - public void addProtectedEditListener(ProtectedEditListener listener) { - addListener(ProtectedEditEvent.class, listener, + public Registration addProtectedEditListener( + ProtectedEditListener listener) { + return addListener(ProtectedEditEvent.class, listener, ProtectedEditListener.SELECTION_CHANGE_METHOD); } /** * Removes the given ProtectedEditListener. - * + * * @param listener * The listener to remove. + * @deprecated use a {@link Registration} from + * {@link #addProtectedEditListener(ProtectedEditListener)} to + * remove a listener */ + @Deprecated public void removeProtectedEditListener(ProtectedEditListener listener) { removeListener(ProtectedEditEvent.class, listener, ProtectedEditListener.SELECTION_CHANGE_METHOD); @@ -4645,7 +4668,7 @@ public int getNewSheetPOIIndex() { /** * A listener for when a sheet is selected. */ - public interface SheetChangeListener extends Serializable { + public interface SheetChangeListener extends SerializableEventListener { public static final Method SHEET_CHANGE_METHOD = ReflectTools .findMethod(SheetChangeListener.class, "onSheetChange", SheetChangeEvent.class); @@ -4662,21 +4685,26 @@ public interface SheetChangeListener extends Serializable { /** * Adds the given SheetChangeListener to this Spreadsheet. - * + * * @param listener * Listener to add + * @return a registration object for removing the listener */ - public void addSheetChangeListener(SheetChangeListener listener) { - addListener(SheetChangeEvent.class, listener, + public Registration addSheetChangeListener(SheetChangeListener listener) { + return addListener(SheetChangeEvent.class, listener, SheetChangeListener.SHEET_CHANGE_METHOD); } /** * Removes the given SheetChangeListener from this Spreadsheet. - * + * * @param listener * Listener to remove + * @deprecated use a {@link Registration} from + * {@link #addSheetChangeListener(SheetChangeListener)} to + * remove a listener */ + @Deprecated public void removeSheetChangeListener(SheetChangeListener listener) { removeListener(SheetChangeEvent.class, listener, SheetChangeListener.SHEET_CHANGE_METHOD); @@ -5368,7 +5396,8 @@ public int getRowIndex() { /** * Interface for listening a {@link RowHeaderDoubleClickEvent} event **/ - public interface RowHeaderDoubleClickListener extends Serializable { + public interface RowHeaderDoubleClickListener + extends SerializableEventListener { Method ON_ROW_ON_ROW_HEADER_DOUBLE_CLICK = ReflectTools .findMethod(RowHeaderDoubleClickListener.class, "onRowHeaderDoubleClick", RowHeaderDoubleClickEvent.class); diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralRoundingTest.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralRoundingTest.java index 4b8a3d243..f50d90fbb 100644 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralRoundingTest.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralRoundingTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; + import java.util.Locale; import org.junit.Test; @@ -91,15 +92,13 @@ public void generalFormat_spreadsheetWithGeneralFormatAndLocaleUS_negativeNumber @Test public void generalFormat_spreadsheetWithGeneralFormatAndLocaleFI_negativeNumbersRoundedCorrectly() { - //TODO Vaadin8 use setLocale instead of setLocaleForNativeSElect - //When https://github.com/vaadin/framework8-issues/issues/477 is fixed setLocale(new Locale("fi", "FI")); headerPage.loadFile("negative_general_round.xlsx", this); SpreadsheetElement spreadsheet = $(SpreadsheetElement.class).first(); String cellBeforeResize = spreadsheet.getCellAt("A7").getValue(); assertThat(cellBeforeResize, not(containsString("."))); - assertThat(cellBeforeResize, containsString("-")); + assertThat(cellBeforeResize, containsString("−")); assertThat(cellBeforeResize, not(containsString("#"))); headerPage.loadTestFixture(TestFixtures.FirstColumnWidth); @@ -109,7 +108,7 @@ public void generalFormat_spreadsheetWithGeneralFormatAndLocaleFI_negativeNumber assertLessThan("Number not shortened", cellAfterResize.length(), cellBeforeResize.length()); assertThat(cellAfterResize, not(containsString("."))); - assertThat(cellAfterResize, containsString("-")); + assertThat(cellAfterResize, containsString("−")); assertThat(cellAfterResize, not(containsString("#"))); } diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralSmallRoundingTest.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralSmallRoundingTest.java index 5ad636888..e18c339b1 100644 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralSmallRoundingTest.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/GeneralSmallRoundingTest.java @@ -4,9 +4,13 @@ import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; + import java.util.Locale; import org.junit.Test; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.addon.spreadsheet.elements.SpreadsheetElement; import com.vaadin.addon.spreadsheet.test.fixtures.TestFixtures; @@ -66,25 +70,38 @@ public void generalFormat_spreadsheetWithGeneralFormatAndLocaleUS_negativeNumber @Test public void generalFormat_spreadsheetWithGeneralFormatAndLocaleFI_negativeNumbersRoundedCorrectly() { - //TODO Vaadin8 use setLocale instead of setLocaleForNativeSElect - //When https://github.com/vaadin/framework8-issues/issues/477 is fixed setLocale(new Locale("fi", "FI")); headerPage.loadFile("negative_general_round.xlsx", this); SpreadsheetElement spreadsheet = $(SpreadsheetElement.class).first(); String cellBeforeResize = spreadsheet.getCellAt(TARGET_CELL).getValue(); assertThat(cellBeforeResize, not(containsString("."))); - assertThat(cellBeforeResize, containsString("-")); + assertThat(cellBeforeResize, containsString("−")); assertThat(cellBeforeResize, not(containsString("#"))); headerPage.loadTestFixture(TestFixtures.FirstColumnWidth); - String cellAfterResize = spreadsheet.getCellAt(TARGET_CELL).getValue(); + String cellAfterResize; + try { + cellAfterResize = waitUntil(new ExpectedCondition() { + @Override + public String apply(WebDriver input) { + String newContent = spreadsheet.getCellAt(TARGET_CELL) + .getValue(); + if (newContent.length() < cellBeforeResize.length()) { + return newContent; + } + return null; + } + }); + } catch (TimeoutException e) { + cellAfterResize = spreadsheet.getCellAt(TARGET_CELL).getValue(); + assertThat("Number not shortened", cellAfterResize.length(), + lessThan(cellBeforeResize.length())); + } - assertThat("Number not shortened", cellAfterResize.length(), - lessThan(cellBeforeResize.length())); assertThat(cellAfterResize, not(containsString("."))); - assertThat(cellAfterResize, containsString("-")); + assertThat(cellAfterResize, containsString("−")); assertThat(cellAfterResize, not(containsString("#"))); } } diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/ImageTests.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/ImageTests.java index 48baafc47..e2d7d2dc1 100644 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/ImageTests.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/ImageTests.java @@ -2,12 +2,19 @@ import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.addon.spreadsheet.elements.SpreadsheetElement; public class ImageTests extends AbstractSpreadsheetTestCase { + private SpreadsheetElement spreadsheet; + @Test public void testFromUpload() { headerPage.loadFile("picture_sheet.xlsx", this); + testBench(driver).waitForVaadin(); + spreadsheet = $(SpreadsheetElement.class).first(); assertInRange(200, imageWidth("C2"), 260); @@ -19,8 +26,8 @@ public void testFromUpload() { } public double imageWidth(String cell) { - testBench(driver).waitForVaadin(); - return driver.findElement( - By.xpath(sheetController.cellToXPath(cell) + "/img")).getSize().width; + WebElement image = spreadsheet.findElement( + By.xpath(sheetController.cellToXPath(cell) + "/img")); + return image.getSize().width; } } diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/demoapps/SpreadsheetDemoUI.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/demoapps/SpreadsheetDemoUI.java index bc9627870..f8a4c37a1 100755 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/demoapps/SpreadsheetDemoUI.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/demoapps/SpreadsheetDemoUI.java @@ -256,6 +256,7 @@ public InputStream getStream() { localeSelect = new NativeSelect<>(); localeSelect.setWidth("200px"); localeSelect.setId("localeSelect"); + localeSelect.getDataCommunicator().setMaximumAllowedRows(1000); final List locales = Arrays .asList(Locale.getAvailableLocales()); diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/pageobjects/HeaderPage.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/pageobjects/HeaderPage.java index df7ab5fab..39e46da8b 100644 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/pageobjects/HeaderPage.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/pageobjects/HeaderPage.java @@ -3,8 +3,10 @@ import static org.junit.Assert.assertEquals; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; import com.vaadin.addon.spreadsheet.test.fixtures.TestFixtures; +import com.vaadin.testbench.By; import com.vaadin.testbench.TestBenchTestCase; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.ComboBoxElement; @@ -24,7 +26,10 @@ public SpreadsheetPage createNewSpreadsheet() { public SpreadsheetPage loadFile(String testSheetFilename, TestBenchTestCase tbtc) { - ComboBoxElement testSheetSelect = $(ComboBoxElement.class).id("testSheetSelect"); + waitUntil(ExpectedConditions + .presenceOfElementLocated(By.id("testSheetSelect"))); + ComboBoxElement testSheetSelect = $(ComboBoxElement.class) + .id("testSheetSelect"); testSheetSelect.selectByText(testSheetFilename); testSheetSelect.waitForVaadin(); $(ButtonElement.class).id("update").click(); diff --git a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/tb3/MultiBrowserTest.java b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/tb3/MultiBrowserTest.java index 43eb05927..e56c74419 100644 --- a/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/tb3/MultiBrowserTest.java +++ b/vaadin-spreadsheet/src/test/java/com/vaadin/addon/spreadsheet/test/tb3/MultiBrowserTest.java @@ -52,7 +52,8 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration { public TestName testName = new TestName(); @Override - public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) { + public void setDesiredCapabilities( + DesiredCapabilities desiredCapabilities) { if (BrowserUtil.isIE(desiredCapabilities)) { desiredCapabilities.setCapability( InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); @@ -63,10 +64,9 @@ public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) { desiredCapabilities.setCapability("project", "Vaadin Spreadsheet"); desiredCapabilities.setCapability("build", String.format("%s / %s", getDeploymentHostname(), Calendar.getInstance().getTime())); - desiredCapabilities.setCapability( - "name", - String.format("%s.%s", getClass().getCanonicalName(), - testName.getMethodName())); + String name = String.format("%s.%s", getClass().getCanonicalName(), + testName.getMethodName()); + desiredCapabilities.setCapability("name", name); super.setDesiredCapabilities(desiredCapabilities); } diff --git a/vaadin-spreadsheet/src/test/resources/log4j.properties b/vaadin-spreadsheet/src/test/resources/log4j.properties new file mode 100644 index 000000000..a6a4c5a39 --- /dev/null +++ b/vaadin-spreadsheet/src/test/resources/log4j.properties @@ -0,0 +1,7 @@ +# Root logger option +log4j.rootLogger=INFO, stdout +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{dd/MM/yy HH:mm:ss.SSS} %-5p [%c{1}] %m%n \ No newline at end of file