You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/20 23:18:50 UTC
svn commit: r613691 - in /tapestry/tapestry5/trunk/tapestry-ioc/src:
main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java
test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java
Author: hlship
Date: Sun Jan 20 14:18:49 2008
New Revision: 613691
URL: http://svn.apache.org/viewvc?rev=613691&view=rev
Log:
TAPESTRY-1315: Context expression without period results in StringIndexOutOfBoundsException
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java?rev=613691&r1=613690&r2=613691&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGenerator.java Sun Jan 20 14:18:49 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
import java.util.NoSuchElementException;
/**
- * Used in a wide variety of resource searches. Generates a series of name variations from a path
- * (which must include a suffix) and locale.
+ * Used in a wide variety of resource searches. Generates a series of name variations from a path (which must include a
+ * suffix) and locale.
* <p/>
* This class is not threadsafe.
*/
@@ -60,6 +60,11 @@
{
int dotx = path.lastIndexOf('.');
+ // When there is no dot in the name, pretend it exists after the
+ // end of the string. The locale extensions will be tacked on there.
+
+ if (dotx == -1) dotx = path.length();
+
// TODO: Case where there is no suffix
String baseName = path.substring(0, dotx);
@@ -107,8 +112,7 @@
// If _country is null, then we've already generated this string
// as state LCV and we can continue directly to state L
- if (InternalUtils.isBlank(_variant) || InternalUtils.isBlank(_country))
- continue;
+ if (InternalUtils.isBlank(_variant) || InternalUtils.isBlank(_country)) continue;
return;
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java?rev=613691&r1=613690&r2=613691&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/LocalizedNameGeneratorTest.java Sun Jan 20 14:18:49 2008
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2008 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -57,11 +57,20 @@
// does not. To keep this test happyt, we selected an all-uppercase
// locale.
- run(
- "fred.foo",
- new Locale("en", "", "GEEK"),
- "fred_en__GEEK.foo",
- "fred_en.foo",
- "fred.foo");
+ run("fred.foo", new Locale("en", "", "GEEK"), "fred_en__GEEK.foo", "fred_en.foo", "fred.foo");
+ }
+
+ @Test
+ public void locale_with_just_language_no_period()
+ {
+ run("context:/blah", Locale.FRENCH, "context:/blah_fr", "context:/blah");
+ }
+
+ @Test
+ public void locale_with_variant_but_no_country_no_period()
+ {
+ run("context:/blah", new Locale("fr", "", "GEEK"), "context:/blah_fr__GEEK", "context:/blah_fr",
+ "context:/blah");
+
}
}