From 03e7f8fac23596d4cebe141440f58ea48d9a1a4e Mon Sep 17 00:00:00 2001 From: Joseph Walton Date: Tue, 8 Sep 2015 00:33:22 +1000 Subject: [PATCH 1/3] Upgrade JUnit. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4f5754e4..88915519 100644 --- a/pom.xml +++ b/pom.xml @@ -493,7 +493,7 @@ junit junit - 3.8.2 + 4.12 jdom From 1b6c8863d66f5db08d16fd38a2c8d73a66dca586 Mon Sep 17 00:00:00 2001 From: Joseph Walton Date: Tue, 8 Sep 2015 00:54:00 +1000 Subject: [PATCH 2/3] Add a test, and fix the case where the count is unlimited. --- .../openid4java/message/ax/FetchResponse.java | 2 +- .../message/ax/FetchResponseTest.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/src/org/openid4java/message/ax/FetchResponseTest.java diff --git a/src/org/openid4java/message/ax/FetchResponse.java b/src/org/openid4java/message/ax/FetchResponse.java index 91ed98de..670b5278 100644 --- a/src/org/openid4java/message/ax/FetchResponse.java +++ b/src/org/openid4java/message/ax/FetchResponse.java @@ -117,7 +117,7 @@ else if (value instanceof List) // only send up the the maximum requested number int max = req.getCount(alias); if (max == 0) - max = ((List)values).size(); + max = ((List)value).size(); int count; for (count = 0; count < max && values.hasNext(); count++) { diff --git a/test/src/org/openid4java/message/ax/FetchResponseTest.java b/test/src/org/openid4java/message/ax/FetchResponseTest.java new file mode 100644 index 00000000..97853b21 --- /dev/null +++ b/test/src/org/openid4java/message/ax/FetchResponseTest.java @@ -0,0 +1,33 @@ +package org.openid4java.message.ax; + +import static org.junit.Assert.assertEquals; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openid4java.message.MessageException; +import org.openid4java.message.Parameter; +import org.openid4java.message.ParameterList; + +public class FetchResponseTest +{ + @Test + public void unlimitedCountWorksForLists() throws MessageException + { + ParameterList params = new ParameterList(); + params.set(new Parameter("required", "key")); + params.set(new Parameter("key", "value")); + params.set(new Parameter("count.key", "unlimited")); + + FetchRequest req = new FetchRequest(params); + + Map> userData = Collections.singletonMap("key", Collections.singletonList("value")); + + FetchResponse response = FetchResponse.createFetchResponse(req, userData); + + assertEquals(Collections.singletonList("value"), + response.getAttributeValues("key")); + } +} From 3cec32372455cca02b96c5601fc36a42ff5c03c8 Mon Sep 17 00:00:00 2001 From: Joseph Walton Date: Tue, 8 Sep 2015 00:59:42 +1000 Subject: [PATCH 3/3] Remove unnecessary parameter from test. --- test/src/org/openid4java/message/ax/FetchResponseTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/src/org/openid4java/message/ax/FetchResponseTest.java b/test/src/org/openid4java/message/ax/FetchResponseTest.java index 97853b21..f7c7c2bf 100644 --- a/test/src/org/openid4java/message/ax/FetchResponseTest.java +++ b/test/src/org/openid4java/message/ax/FetchResponseTest.java @@ -18,7 +18,6 @@ public void unlimitedCountWorksForLists() throws MessageException { ParameterList params = new ParameterList(); params.set(new Parameter("required", "key")); - params.set(new Parameter("key", "value")); params.set(new Parameter("count.key", "unlimited")); FetchRequest req = new FetchRequest(params);