You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2015/09/23 21:31:48 UTC

[1/2] wicket git commit: Optimize imports

Repository: wicket
Updated Branches:
  refs/heads/master 679e61d7b -> eb1258656


Optimize imports


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/de5982bb
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/de5982bb
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/de5982bb

Branch: refs/heads/master
Commit: de5982bb5e7570ff881e6c1937a9153d5b7040b0
Parents: 679e61d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Sep 21 19:21:22 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Sep 21 19:21:51 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/bean/validation/PropertyValidator.java  | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/de5982bb/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
----------------------------------------------------------------------
diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
index aca4adf..862a69b 100644
--- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
+++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
@@ -18,8 +18,6 @@ import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.IPropertyReflectionAwareModel;
-import org.apache.wicket.model.IWrapModel;
 import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.validation.IValidatable;
 import org.apache.wicket.validation.IValidator;


[2/2] wicket git commit: WICKET-5981 Fix the behavior of MarkupContainer#get(int) for non-empty MarkupContainer and non-existing index

Posted by mg...@apache.org.
WICKET-5981 Fix the behavior of MarkupContainer#get(int) for non-empty MarkupContainer and non-existing index


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/eb125865
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/eb125865
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/eb125865

Branch: refs/heads/master
Commit: eb125865624747fd2d216e16133a8d9181c19265
Parents: de5982b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Sep 23 21:30:20 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Sep 23 21:30:20 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/MarkupContainer.java |  8 +++--
 .../org/apache/wicket/MarkupContainerTest.java  | 33 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/eb125865/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 7941203..b739d47 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1016,15 +1016,17 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
 	@Deprecated
 	public final Component get(int index)
 	{
+		final int requestedIndex = index;
 		Component childAtIndex = null;
 		Iterator<Component> childIterator = iterator();
-		while (index-- >= 0 && childIterator.hasNext())
+		while (index >= 0 && childIterator.hasNext())
 		{
 			childAtIndex = childIterator.next();
+			index--;
 		}
-		if(childAtIndex == null) 
+		if(index >= 0 || childAtIndex == null)
 		{
-			throw new ArrayIndexOutOfBoundsException(Integer.toString(index));
+			throw new ArrayIndexOutOfBoundsException(Integer.toString(requestedIndex));
 		}
 		return childAtIndex;
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/eb125865/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java b/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
index b21757d..1a5698e 100644
--- a/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
@@ -18,8 +18,6 @@ package org.apache.wicket;
 
 import static org.hamcrest.CoreMatchers.is;
 
-import java.util.NoSuchElementException;
-
 import org.apache.wicket.markup.IMarkupResourceStreamProvider;
 import org.apache.wicket.markup.html.WebComponent;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -27,7 +25,6 @@ import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.StringResourceStream;
 import org.apache.wicket.util.tester.WicketTestCase;
-import org.junit.Assert;
 import org.junit.Test;
 
 
@@ -131,6 +128,36 @@ public class MarkupContainerTest extends WicketTestCase
 	}
 
 	/**
+	 * Tests the get(int) method of MarkupContainer with non-existing index.
+	 */
+	@Test(expected = ArrayIndexOutOfBoundsException.class)
+	public void getIndexedOutOfBounds()
+	{
+		MarkupContainer c = new WebMarkupContainer("parent");
+		Component c1 = new WebComponent("c1");
+
+		c.add(c1);
+
+		assertThat(c.get(0), is(c1));
+		c.get(1);
+	}
+
+	/**
+	 * Tests the get(int) method of MarkupContainer with negative index.
+	 */
+	@Test(expected = ArrayIndexOutOfBoundsException.class)
+	public void getIndexedNegative()
+	{
+		MarkupContainer c = new WebMarkupContainer("parent");
+		Component c1 = new WebComponent("c1");
+
+		c.add(c1);
+
+		assertThat(c.get(0), is(c1));
+		c.get(-1);
+	}
+
+	/**
 	 * Tests the get(int) method of MarkupContainer when the index exceeds the number of children.
 	 */
 	@Test(expected = ArrayIndexOutOfBoundsException.class)