From c5c939bbce9396050f8d8915f8046a25d4aa126a Mon Sep 17 00:00:00 2001 From: David Sowerby Date: Thu, 18 Feb 2016 19:13:18 +0000 Subject: [PATCH 1/4] Corrected Travis reference in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92a779c17..6188ae9e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![License](http://img.shields.io/:license-apache-blue.svg) [![Gitter](https://badges.gitter.im/davidsowerby/krail.svg)](https://gitter.im/davidsowerby/krail?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -[![Build Status](https://travis-ci.org/davidsowerby/krailkrail.svg?branch=master)](https://travis-ci.org/davidsowerby/krail) +[![Build Status](https://travis-ci.org/davidsowerby/krail.svg?branch=master)](https://travis-ci.org/davidsowerby/krail) [![Coverage Status](https://coveralls.io/repos/github/davidsowerby/krail/badge.svg?branch=master)](https://coveralls.io/github/davidsowerby/krail?branch=master) Krail provides a framework for rapid Java web development by combining Vaadin, Guice, Apache Shiro, Apache Commons Configuration and others. For more information, see the comprehensive [Tutorial](http://krail.readthedocs.org/en/master/), which also makes a reasonable demo. (You can clone directly from the [Tutorial repo](https://github.com/davidsowerby/krail-tutorial)) From 229c9a0b9d59f835bb353763749e3230a81ab04a Mon Sep 17 00:00:00 2001 From: sureshbabuinfo Date: Wed, 8 Jun 2016 22:40:18 +0530 Subject: [PATCH 2/4] Fixed MessageFormat which is not working when the same argument is repeated --- src/main/java/uk/q3c/util/MessageFormat.java | 19 ++++++++++--------- .../java/uk/q3c/util/MessageFormatTest.java | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/uk/q3c/util/MessageFormat.java b/src/main/java/uk/q3c/util/MessageFormat.java index 67593b6e1..12070c67a 100644 --- a/src/main/java/uk/q3c/util/MessageFormat.java +++ b/src/main/java/uk/q3c/util/MessageFormat.java @@ -115,16 +115,17 @@ private static String scanForParameters(String pattern, List parameters } private static Object[] sortArguments(List parameters, Object[] arguments, String pattern) { - if (parameters.size() != arguments.length) { - Object[] args = new Object[]{parameters.size(), arguments.length, pattern}; - log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " + - "and {} arguments. The pattern is: '{}'", args); + try { + List sortedArguments = new ArrayList<>(); + for (Integer i : parameters) { + sortedArguments.add(arguments[i]); + } + return sortedArguments.toArray(); + } catch (IndexOutOfBoundsException e) { + Object[] args = new Object[] { parameters.size(), arguments.length, pattern }; + log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " + + "and {} arguments. The pattern is: '{}'", args); throw new RuntimeException(); } - List sortedArguments = new ArrayList<>(); - for (Integer i : parameters) { - sortedArguments.add(arguments[i]); - } - return sortedArguments.toArray(); } } diff --git a/src/test/java/uk/q3c/util/MessageFormatTest.java b/src/test/java/uk/q3c/util/MessageFormatTest.java index ec7b9c8cf..139d328dc 100644 --- a/src/test/java/uk/q3c/util/MessageFormatTest.java +++ b/src/test/java/uk/q3c/util/MessageFormatTest.java @@ -16,6 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.util.ArrayList; +import java.util.List; + public class MessageFormatTest { @Test public void formatValid() { @@ -29,7 +32,20 @@ public void formatValid() { assertThat(result).isEqualTo("This is a simple pattern where the parameters can be in any order"); } + + @Test + public void formatValidRepeatedArgument() { + + // given + String pattern = "This is a {0} pattern where the same argument is {0}"; + Object[] arguments = new Object[]{"repeated"}; + // when + String result = MessageFormat.format(pattern, arguments); + // then + assertThat(result).isEqualTo("This is a repeated pattern where the same argument is repeated"); + } + @Test public void formatValidContiguous() { From c48cd5c8db6b2c12630b78d31e4979e53be8015b Mon Sep 17 00:00:00 2001 From: David Sowerby Date: Thu, 9 Jun 2016 16:55:39 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Revert=20"Fixed=20MessageFormat=20=20which?= =?UTF-8?q?=20is=20not=20working=20when=20the=20same=20argument=20is=20r?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/uk/q3c/util/MessageFormat.java | 19 +++++++++---------- .../java/uk/q3c/util/MessageFormatTest.java | 16 ---------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/main/java/uk/q3c/util/MessageFormat.java b/src/main/java/uk/q3c/util/MessageFormat.java index 12070c67a..67593b6e1 100644 --- a/src/main/java/uk/q3c/util/MessageFormat.java +++ b/src/main/java/uk/q3c/util/MessageFormat.java @@ -115,17 +115,16 @@ private static String scanForParameters(String pattern, List parameters } private static Object[] sortArguments(List parameters, Object[] arguments, String pattern) { - try { - List sortedArguments = new ArrayList<>(); - for (Integer i : parameters) { - sortedArguments.add(arguments[i]); - } - return sortedArguments.toArray(); - } catch (IndexOutOfBoundsException e) { - Object[] args = new Object[] { parameters.size(), arguments.length, pattern }; - log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " - + "and {} arguments. The pattern is: '{}'", args); + if (parameters.size() != arguments.length) { + Object[] args = new Object[]{parameters.size(), arguments.length, pattern}; + log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " + + "and {} arguments. The pattern is: '{}'", args); throw new RuntimeException(); } + List sortedArguments = new ArrayList<>(); + for (Integer i : parameters) { + sortedArguments.add(arguments[i]); + } + return sortedArguments.toArray(); } } diff --git a/src/test/java/uk/q3c/util/MessageFormatTest.java b/src/test/java/uk/q3c/util/MessageFormatTest.java index 139d328dc..ec7b9c8cf 100644 --- a/src/test/java/uk/q3c/util/MessageFormatTest.java +++ b/src/test/java/uk/q3c/util/MessageFormatTest.java @@ -16,9 +16,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.util.ArrayList; -import java.util.List; - public class MessageFormatTest { @Test public void formatValid() { @@ -32,20 +29,7 @@ public void formatValid() { assertThat(result).isEqualTo("This is a simple pattern where the parameters can be in any order"); } - - @Test - public void formatValidRepeatedArgument() { - - // given - String pattern = "This is a {0} pattern where the same argument is {0}"; - Object[] arguments = new Object[]{"repeated"}; - // when - String result = MessageFormat.format(pattern, arguments); - // then - assertThat(result).isEqualTo("This is a repeated pattern where the same argument is repeated"); - } - @Test public void formatValidContiguous() { From db7d463ebc034e11512ccf8d24260906bd4e4620 Mon Sep 17 00:00:00 2001 From: Soso Tughushi Date: Fri, 1 Jul 2016 16:22:01 +0400 Subject: [PATCH 4/4] Fixed rule 'Public constants and fields initialized at declaration should be "static final" rather than merely "final"'. --- .../q3c/krail/core/view/Grid3x3ViewBase.java | 4 +- .../StrictURIFragmentHandlerTest.java | 42 +++++++++---------- .../sitemap/DefaultSitemapServiceTest.java | 6 +-- .../uk/q3c/krail/core/ui/ScopedUITest.java | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/uk/q3c/krail/core/view/Grid3x3ViewBase.java b/src/main/java/uk/q3c/krail/core/view/Grid3x3ViewBase.java index d7edaac76..5dd9fec75 100644 --- a/src/main/java/uk/q3c/krail/core/view/Grid3x3ViewBase.java +++ b/src/main/java/uk/q3c/krail/core/view/Grid3x3ViewBase.java @@ -23,8 +23,8 @@ import static com.google.common.base.Preconditions.checkArgument; public class Grid3x3ViewBase extends ViewBase { - private final float[] defaultColumnWidths = new float[]{1f, 1f, 1f}; - private final float[] defaultRowHeights = new float[]{1f, 1f, 1f}; + private static final float[] defaultColumnWidths = new float[]{1f, 1f, 1f}; + private static final float[] defaultRowHeights = new float[]{1f, 1f, 1f}; private GridLayout grid; @Inject diff --git a/src/test/java/uk/q3c/krail/core/navigate/StrictURIFragmentHandlerTest.java b/src/test/java/uk/q3c/krail/core/navigate/StrictURIFragmentHandlerTest.java index 880f6b538..27401f612 100644 --- a/src/test/java/uk/q3c/krail/core/navigate/StrictURIFragmentHandlerTest.java +++ b/src/test/java/uk/q3c/krail/core/navigate/StrictURIFragmentHandlerTest.java @@ -27,27 +27,27 @@ @GuiceContext({}) public class StrictURIFragmentHandlerTest { - final String view = "view1"; - final String view_ = "view1/"; - final String view_p = "view1/a=b"; - final String view_p2 = "view1/a=b/year=1970"; - final String view_p2m1 = "view1/a=b/year="; - final String view_p2m2 = "view1/a=b/=1970"; - final String view_p2m3 = "view1/a=b/1970"; - final String view_p2m5 = "view1/=b/year=1970"; - final String view_p2m6 = "view1/a=/year=1970"; - - final String subView = "view1/subView"; - final String subView_ = "view1/subView/"; - final String subView_p = "view1/subView/a=b"; - final String subView_p2 = "view1/subView/a=b/year=1970"; - final String dbl = "view//subView"; - - final String home = ""; - final String home_p = "a=b"; - final String home_p2 = "a=b/year=1970"; - - final String subView_p2_bang = "!view1/subView/a=b/year=1970"; + static final String view = "view1"; + static final String view_ = "view1/"; + static final String view_p = "view1/a=b"; + static final String view_p2 = "view1/a=b/year=1970"; + static final String view_p2m1 = "view1/a=b/year="; + static final String view_p2m2 = "view1/a=b/=1970"; + static final String view_p2m3 = "view1/a=b/1970"; + static final String view_p2m5 = "view1/=b/year=1970"; + static final String view_p2m6 = "view1/a=/year=1970"; + + static final String subView = "view1/subView"; + static final String subView_ = "view1/subView/"; + static final String subView_p = "view1/subView/a=b"; + static final String subView_p2 = "view1/subView/a=b/year=1970"; + static final String dbl = "view//subView"; + + static final String home = ""; + static final String home_p = "a=b"; + static final String home_p2 = "a=b/year=1970"; + + static final String subView_p2_bang = "!view1/subView/a=b/year=1970"; @Inject StrictURIFragmentHandler uriHandler; diff --git a/src/test/java/uk/q3c/krail/core/navigate/sitemap/DefaultSitemapServiceTest.java b/src/test/java/uk/q3c/krail/core/navigate/sitemap/DefaultSitemapServiceTest.java index 6674576eb..259a6a313 100644 --- a/src/test/java/uk/q3c/krail/core/navigate/sitemap/DefaultSitemapServiceTest.java +++ b/src/test/java/uk/q3c/krail/core/navigate/sitemap/DefaultSitemapServiceTest.java @@ -75,9 +75,9 @@ public class DefaultSitemapServiceTest { static VaadinService vaadinService; static ResourceUtils resourceUtils = new DefaultResourceUtils(); - private final int FILE_NODE_COUNT = 4; - private final int DIRECT_NODE_COUNT = 2; - private final int STANDARD_NODE_COUNT = 5; + private static final int FILE_NODE_COUNT = 4; + private static final int DIRECT_NODE_COUNT = 2; + private static final int STANDARD_NODE_COUNT = 5; @Inject DefaultSitemapService service; @Inject diff --git a/src/test/java/uk/q3c/krail/core/ui/ScopedUITest.java b/src/test/java/uk/q3c/krail/core/ui/ScopedUITest.java index 44d08eba4..a4c7dda45 100644 --- a/src/test/java/uk/q3c/krail/core/ui/ScopedUITest.java +++ b/src/test/java/uk/q3c/krail/core/ui/ScopedUITest.java @@ -60,7 +60,7 @@ public class ScopedUITest { static int connectCount; - protected final String baseUri = "http://example.com"; + protected static final String baseUri = "http://example.com"; ScopedUI ui; @Mock Navigator navigator;