summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-01-26 19:34:36 +0200
committerArtur Signell <artur@vaadin.com>2015-01-26 19:35:10 +0200
commit8f056dd0317b3dc3e475fd7220a89021bb3166dc (patch)
tree3fed6f2a690de0d54ab1bd87ea8bf91e5a665d0a
parenta6a3060fb21441cf9925f70c5ff4fed327b47ca6 (diff)
parent17a9993995cfd3434259cd8b0f729f76da36de12 (diff)
downloadvaadin-framework-8f056dd0317b3dc3e475fd7220a89021bb3166dc.tar.gz
vaadin-framework-8f056dd0317b3dc3e475fd7220a89021bb3166dc.zip
Merge remote-tracking branch 'origin/master' into HEAD
Change-Id: I42718fcc8a07ca46f7e58016d3caf287ce88e3ed
-rw-r--r--server/src/com/vaadin/data/util/filter/Between.java44
-rw-r--r--server/src/com/vaadin/server/communication/PushRequestHandler.java4
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java61
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java5
-rw-r--r--uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java26
7 files changed, 125 insertions, 24 deletions
diff --git a/server/src/com/vaadin/data/util/filter/Between.java b/server/src/com/vaadin/data/util/filter/Between.java
index 48a610ed57..c50488c521 100644
--- a/server/src/com/vaadin/data/util/filter/Between.java
+++ b/server/src/com/vaadin/data/util/filter/Between.java
@@ -15,16 +15,20 @@
*/
package com.vaadin.data.util.filter;
+import java.util.Arrays;
+
import com.vaadin.data.Container.Filter;
import com.vaadin.data.Item;
+import com.vaadin.shared.util.SharedUtil;
public class Between implements Filter {
private final Object propertyId;
- private final Comparable startValue;
- private final Comparable endValue;
+ private final Comparable<?> startValue;
+ private final Comparable<?> endValue;
- public Between(Object propertyId, Comparable startValue, Comparable endValue) {
+ public Between(Object propertyId, Comparable<?> startValue,
+ Comparable<?> endValue) {
this.propertyId = propertyId;
this.startValue = startValue;
this.endValue = endValue;
@@ -47,9 +51,11 @@ public class Between implements Filter {
throws UnsupportedOperationException {
Object value = item.getItemProperty(getPropertyId()).getValue();
if (value instanceof Comparable) {
- Comparable cval = (Comparable) value;
- return cval.compareTo(getStartValue()) >= 0
- && cval.compareTo(getEndValue()) <= 0;
+ Comparable comparable = (Comparable) value;
+ return isAfterStartValue(comparable)
+ && isBeforeEndValue(comparable);
+ } else if (value == null) {
+ return getStartValue() == null && getEndValue() == null;
}
return false;
}
@@ -61,8 +67,8 @@ public class Between implements Filter {
@Override
public int hashCode() {
- return getPropertyId().hashCode() + getStartValue().hashCode()
- + getEndValue().hashCode();
+ return Arrays.hashCode(new Object[] { getPropertyId(), getStartValue(),
+ getEndValue() });
}
@Override
@@ -78,13 +84,23 @@ public class Between implements Filter {
final Between o = (Between) obj;
// Checks the properties one by one
- boolean propertyIdEqual = (null != getPropertyId()) ? getPropertyId()
- .equals(o.getPropertyId()) : null == o.getPropertyId();
- boolean startValueEqual = (null != getStartValue()) ? getStartValue()
- .equals(o.getStartValue()) : null == o.getStartValue();
- boolean endValueEqual = (null != getEndValue()) ? getEndValue().equals(
- o.getEndValue()) : null == o.getEndValue();
+ boolean propertyIdEqual = SharedUtil.equals(getPropertyId(),
+ o.getPropertyId());
+ boolean startValueEqual = SharedUtil.equals(getStartValue(),
+ o.getStartValue());
+ boolean endValueEqual = SharedUtil.equals(getEndValue(),
+ o.getEndValue());
return propertyIdEqual && startValueEqual && endValueEqual;
}
+
+ private boolean isAfterStartValue(Comparable comparable) {
+ return getStartValue() == null
+ || comparable.compareTo(getStartValue()) >= 0;
+ }
+
+ private boolean isBeforeEndValue(Comparable comparable) {
+ return getEndValue() == null
+ || comparable.compareTo(getEndValue()) <= 0;
+ }
}
diff --git a/server/src/com/vaadin/server/communication/PushRequestHandler.java b/server/src/com/vaadin/server/communication/PushRequestHandler.java
index d0367d0bed..74165a4988 100644
--- a/server/src/com/vaadin/server/communication/PushRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/PushRequestHandler.java
@@ -98,7 +98,9 @@ public class PushRequestHandler implements RequestHandler,
"true");
atmosphere.addInitParameter(ApplicationConfig.MESSAGE_DELIMITER,
String.valueOf(PushConstants.MESSAGE_DELIMITER));
-
+ atmosphere.addInitParameter(
+ ApplicationConfig.DROP_ACCESS_CONTROL_ALLOW_ORIGIN_HEADER,
+ "false");
// Disable heartbeat (it does not emit correct events client side)
// https://github.com/Atmosphere/atmosphere-javascript/issues/141
atmosphere.addInitParameter(
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
index 16171f67bc..6daf730e25 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
@@ -118,4 +118,65 @@ public class BetweenTest {
Between b2 = new Between("bar", 0, 1);
Assert.assertFalse(b1.equals(b2));
}
+
+ @Test
+ public void hashCode_nullStartValue_shouldBeEqual() {
+ Between b1 = new Between("foo", null, 2);
+ Between b2 = new Between("foo", null, 2);
+ Assert.assertEquals(b1.hashCode(), b2.hashCode());
+ }
+
+ @Test
+ public void hashCode_nullEndValue_shouldBeEqual() {
+ Between b1 = new Between("foo", 0, null);
+ Between b2 = new Between("foo", 0, null);
+ Assert.assertEquals(b1.hashCode(), b2.hashCode());
+ }
+
+ @Test
+ public void hashCode_nullPropertyId_shouldBeEqual() {
+ Between b1 = new Between(null, 0, 2);
+ Between b2 = new Between(null, 0, 2);
+ Assert.assertEquals(b1.hashCode(), b2.hashCode());
+ }
+
+ @Test
+ public void passesFilter_nullValue_filterIsPassed() {
+ String id = "id";
+ Between between = new Between(id, null, null);
+ Assert.assertTrue(between.passesFilter(id,
+ itemWithPropertyValue(id, null)));
+ }
+
+ @Test
+ public void passesFilter_nullStartValue_filterIsPassed() {
+ String id = "id";
+ Between between = new Between(id, null, 2);
+ Assert.assertTrue(between
+ .passesFilter(id, itemWithPropertyValue(id, 1)));
+ }
+
+ @Test
+ public void passesFilter_nullEndValue_filterIsPassed() {
+ String id = "id";
+ Between between = new Between(id, 0, null);
+ Assert.assertTrue(between
+ .passesFilter(id, itemWithPropertyValue(id, 1)));
+ }
+
+ @Test
+ public void passesFilter_nullStartValueAndEndValue_filterIsPassed() {
+ String id = "id";
+ Between between = new Between(id, null, null);
+ Assert.assertTrue(between
+ .passesFilter(id, itemWithPropertyValue(id, 1)));
+ }
+
+ @Test
+ public void passesFilter_nullStartValueAndEndValueAndValueIsNotComparable_filterIsNotPassed() {
+ String id = "id";
+ Between between = new Between(id, null, null);
+ Assert.assertFalse(between.passesFilter(id,
+ itemWithPropertyValue(id, new Object())));
+ }
}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java
index 31e3f754e3..077ab7f7ec 100644
--- a/uitest/src/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java
@@ -87,10 +87,6 @@ public class CalendarHtmlInEventsTest extends SingleBrowserTest {
By.className("v-calendar-event"));
}
- private void click(CheckBoxElement htmlAllowed2) {
- htmlAllowed2.findElement(By.xpath("input")).click();
- }
-
private WebElement getMonthDay(int i) {
return calendar.findElements(By.className("v-calendar-month-day")).get(
i);
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java
index 63e5c3f080..12ed650c19 100644
--- a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java
+++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java
@@ -43,11 +43,6 @@ public class CheckBoxNullValueTest extends MultiBrowserTest {
}
- private void click(CheckBoxElement checkbox) {
- checkbox.findElement(By.xpath("input")).click();
-
- }
-
private void assertValid(CheckBoxElement checkbox, boolean valid) {
boolean hasIndicator = false;
List<WebElement> e = checkbox.findElements(By
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 2e3d25cbbe..15585c7e45 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -67,6 +67,7 @@ import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchDriverProxy;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.TestBenchTestCase;
+import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.VerticalLayoutElement;
@@ -1327,4 +1328,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return JsonUtil.parse(writer.toString());
}
+ protected void click(CheckBoxElement checkbox) {
+ checkbox.findElement(By.xpath("input")).click();
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index ed5a2ed8aa..4a4354d67c 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -20,12 +20,17 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -151,6 +156,27 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
deleteFailureFiles(failurePng);
}
}
+ if (referenceToKeep != null) {
+ File errorPng = getErrorFileFromReference(referenceToKeep);
+ enableAutoswitch(new File(errorPng.getParentFile(),
+ errorPng.getName() + ".html"));
+ }
+ }
+
+ private void enableAutoswitch(File htmlFile) throws FileNotFoundException,
+ IOException {
+ if (htmlFile == null || !htmlFile.exists()) {
+ return;
+ }
+
+ String html = FileUtils.readFileToString(htmlFile);
+
+ html = html.replace("body onclick=\"",
+ "body onclick=\"clearInterval(autoSwitch);");
+ html = html.replace("</script>",
+ ";autoSwitch=setInterval(switchImage,500);</script>");
+
+ FileUtils.writeStringToFile(htmlFile, html);
}
private void deleteFailureFiles(File failurePng) {