Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup, STS warnings

  • Loading branch information...
commit 17b252e2f5c5cd2f3b8f97ebe13df32783713f89 1 parent 0008b96
Burt Beckwith authored
Showing with 347 additions and 390 deletions.
  1. +2 −5 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/support/GrailsRootLoader.java
  2. +14 −13 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/AbstractDependenciesConfigurer.java
  3. +3 −3 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/JarDependenciesConfigurer.java
  4. +54 −51 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/RepositoriesConfigurer.groovy
  5. +9 −8 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/ControllerArtefactHandler.java
  6. +0 −1  grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsApplication.java
  7. +8 −18 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsWebApplicationContext.java
  8. +6 −19 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectWatcher.java
  9. +23 −36 grails-core/src/main/groovy/org/codehaus/groovy/grails/project/packaging/GrailsProjectPackager.groovy
  10. +3 −3 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateGormEnhancer.groovy
  11. +0 −1  grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsHibernateUtil.java
  12. +0 −3  grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/PropertyConfig.groovy
  13. +2 −0  grails-plugin-gsp/src/ast/groovy/org/codehaus/groovy/grails/compiler/web/gsp/GroovyPageOptimizerVisitor.java
  14. +5 −5 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/RenderTagLib.groovy
  15. +3 −4 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ValidationTagLib.groovy
  16. +7 −7 grails-plugin-testing/src/main/groovy/grails/test/mixin/support/GrailsUnitTestMixin.groovy
  17. +44 −43 grails-plugin-testing/src/main/groovy/grails/test/mixin/web/ControllerUnitTestMixin.groovy
  18. +17 −18 grails-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlCreator.java
  19. +3 −3 ...-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingEvaluator.java
  20. +5 −4 grails-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingInfo.java
  21. +5 −5 ...ls-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingsHolder.java
  22. +23 −16 grails-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/RegexUrlMapping.java
  23. +4 −4 grails-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/ResponseCodeUrlMapping.java
  24. +2 −2 ...ls-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/filter/UrlMappingsFilter.java
  25. +10 −10 grails-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CustomIdSpec.groovy
  26. +26 −26 ...st-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/FirstAndLastMethodSpec.groovy
  27. +3 −5 grails-test-suite-uber/src/test/groovy/grails/spring/BeanBuilderTests.groovy
  28. +6 −6 grails-test-suite-web/src/test/groovy/grails/test/GrailsUrlMappingsTestCaseTests.groovy
  29. +0 −1  ...s-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/pages/GroovyPagesTemplateEngineTests.groovy
  30. +14 −16 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/LinkRenderingTagLibTests.groovy
  31. +4 −4 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/RenderTagLibTests.groovy
  32. +4 −4 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/ValidationTagLibTests.groovy
  33. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/AbstractUrlMapping.java
  34. +4 −4 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/UrlCreator.java
  35. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/UrlMapping.java
  36. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/UrlMappingInfo.java
  37. +2 −2 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/UrlMappingsHolder.java
  38. +2 −2 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPage.java
  39. +6 −7 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java
  40. +7 −8 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/GroovyPageAttributes.java
  41. +14 −20 scripts/_GrailsRun.groovy
View
7 ...ls-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/support/GrailsRootLoader.java
@@ -29,7 +29,6 @@
*/
public class GrailsRootLoader extends RootLoader {
-
public GrailsRootLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
@@ -41,12 +40,10 @@ public GrailsRootLoader() {
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
try {
- if(name.startsWith("java.") || name.startsWith("javax.xml.") || name.startsWith("org.w3c.dom.")) {
+ if (name.startsWith("java.") || name.startsWith("javax.xml.") || name.startsWith("org.w3c.dom.")) {
return getParent().loadClass(name);
}
- else {
- return super.loadClass(name, resolve);
- }
+ return super.loadClass(name, resolve);
}
catch (LinkageError e) {
return getParent().loadClass(name);
View
27 ...main/groovy/org/codehaus/groovy/grails/resolve/config/AbstractDependenciesConfigurer.java
@@ -48,26 +48,27 @@ public Object invokeMethod(String name, Object args) {
}
List<Object> argsList = Arrays.asList((Object[])args);
- if (argsList.size() == 0) {
+ if (argsList.isEmpty()) {
GrailsConsole.getInstance().error("WARNING: Configurational method [" + name + "] in grails-app/conf/BuildConfig.groovy doesn't exist. Ignoring..");
return null;
}
if (isOnlyStrings(argsList)) {
addDependencyStrings(name, argsList, null, null);
-
- } else if (isProperties(argsList)) {
+ }
+ else if (isProperties(argsList)) {
addDependencyMaps(name, argsList, null);
-
- } else if (isStringsAndConfigurer(argsList)) {
+ }
+ else if (isStringsAndConfigurer(argsList)) {
addDependencyStrings(name, argsList.subList(0, argsList.size() - 1), null, (Closure<?>)argsList.get(argsList.size() - 1));
-
- } else if (isPropertiesAndConfigurer(argsList)) {
+ }
+ else if (isPropertiesAndConfigurer(argsList)) {
addDependencyMaps(name, argsList.subList(0, argsList.size() - 1), (Closure<?>)argsList.get(argsList.size() - 1));
- } else if (isStringsAndProperties(argsList)) {
+ }
+ else if (isStringsAndProperties(argsList)) {
addDependencyStrings(name, argsList.subList(0, argsList.size() - 1), (Map<Object, Object>)argsList.get(argsList.size() - 1), null);
-
- } else {
+ }
+ else {
GrailsConsole.getInstance().error("WARNING: Configurational method [" + name + "] in grails-app/conf/BuildConfig.groovy doesn't exist. Ignoring..");
}
@@ -168,9 +169,9 @@ private void addDependency(String scope, Map<Object, Object> dependency, Closure
boolean transitive = getBooleanValueOrDefault(dependency, "transitive", true);
Boolean export = getExportSetting(dependency);
- boolean isExcluded = context.pluginName != null ?
- context.dependencyManager.isExcludedFromPlugin(context.pluginName, name) :
- context.dependencyManager.isExcluded(name);
+ boolean isExcluded = context.pluginName == null ?
+ context.dependencyManager.isExcluded(name) :
+ context.dependencyManager.isExcludedFromPlugin(context.pluginName, name);
if (isExcluded) {
return;
View
6 .../src/main/groovy/org/codehaus/groovy/grails/resolve/config/JarDependenciesConfigurer.java
@@ -33,11 +33,11 @@ protected void addDependency(String scope, EnhancedDefaultDependencyDescriptor d
@Override
protected void handleExport(EnhancedDefaultDependencyDescriptor descriptor, Boolean export) {
- if (export != null) {
- descriptor.setExported(export);
+ if (export == null) {
+ descriptor.setExport(true);
}
else {
- descriptor.setExport(true);
+ descriptor.setExported(export);
}
}
View
105 ...p/src/main/groovy/org/codehaus/groovy/grails/resolve/config/RepositoriesConfigurer.groovy
@@ -14,6 +14,10 @@
*/
package org.codehaus.groovy.grails.resolve.config
+import groovy.transform.CompileStatic
+import groovy.transform.TypeCheckingMode
+import groovy.util.slurpersupport.GPathResult
+
import org.apache.ivy.plugins.latest.LatestTimeStrategy
import org.apache.ivy.plugins.resolver.DependencyResolver
import org.apache.ivy.plugins.resolver.FileSystemResolver
@@ -23,10 +27,6 @@ import org.apache.ivy.util.Message
import org.codehaus.groovy.grails.resolve.GrailsPluginsDirectoryResolver
import org.codehaus.groovy.grails.resolve.GrailsRepoResolver
import org.codehaus.groovy.grails.resolve.SnapshotAwareM2Resolver
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import groovy.util.slurpersupport.GPathResult
-
class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@@ -48,36 +48,36 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
void flatDir(Map args) {
def name = args.get('name')?.toString()
def dirsO = args.get('dirs')
- if (name && dirsO) {
- def fileSystemResolver = new FileSystemResolver()
- fileSystemResolver.local = true
- fileSystemResolver.name = name
-
- Collection dirs = (Collection)(args.get('dirs') instanceof Collection ? args.get('dirs'): [args.get('dirs')])
-
- dependencyManager.repositoryData << ['type':'flatDir', name:name, dirs:dirs.join(',')]
- dirs.each { dir ->
- def path = new File(dir?.toString()).absolutePath
- fileSystemResolver.addIvyPattern("${path}/[module]-[revision](-[classifier]).xml")
- fileSystemResolver.addArtifactPattern "${path}/[module]-[revision](-[classifier]).[ext]"
- }
- fileSystemResolver.settings = dependencyManager.ivySettings
+ if (!name || !dirsO) {
+ return
+ }
+
+ def fileSystemResolver = new FileSystemResolver()
+ fileSystemResolver.local = true
+ fileSystemResolver.name = name
- addToChainResolver(fileSystemResolver)
+ Collection dirs = (Collection)(args.get('dirs') instanceof Collection ? args.get('dirs'): [args.get('dirs')])
+
+ dependencyManager.repositoryData << [type: 'flatDir', name:name, dirs:dirs.join(',')]
+ dirs.each { dir ->
+ def path = new File(dir?.toString()).absolutePath
+ fileSystemResolver.addIvyPattern("${path}/[module]-[revision](-[classifier]).xml")
+ fileSystemResolver.addArtifactPattern "${path}/[module]-[revision](-[classifier]).[ext]"
}
- }
+ fileSystemResolver.settings = dependencyManager.ivySettings
+ addToChainResolver(fileSystemResolver)
+ }
@CompileStatic
void grailsPlugins() {
- if (!context.offline) {
- if (isResolverNotAlreadyDefined('grailsPlugins')) {
- dependencyManager.repositoryData << [type: 'grailsPlugins', name:"grailsPlugins"]
- if (dependencyManager.buildSettings != null) {
- def pluginResolver = new GrailsPluginsDirectoryResolver(dependencyManager.buildSettings, dependencyManager.ivySettings)
- addToChainResolver(pluginResolver)
- }
- }
+ if (context.offline || !isResolverNotAlreadyDefined('grailsPlugins')) {
+ return
+ }
+
+ dependencyManager.repositoryData << [type: 'grailsPlugins', name:"grailsPlugins"]
+ if (dependencyManager.buildSettings != null) {
+ addToChainResolver new GrailsPluginsDirectoryResolver(dependencyManager.buildSettings, dependencyManager.ivySettings)
}
}
@@ -117,25 +117,26 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@CompileStatic
void mavenRepo(String url) {
- if (!context.offline && isResolverNotAlreadyDefined(url) ) {
- dependencyManager.repositoryData << ['type':'mavenRepo', root:url, name:url, m2compatbile:true]
- def resolver = new SnapshotAwareM2Resolver()
- resolver.name = url
- resolver.root = url
- resolver.m2compatible = true
- resolver.settings = dependencyManager.ivySettings
- resolver.changingPattern = ".*SNAPSHOT"
- addToChainResolver(resolver)
+ if (context.offline || !isResolverNotAlreadyDefined(url)) {
+ return
}
- }
+ dependencyManager.repositoryData << [type: 'mavenRepo', root: url, name: url, m2compatbile: true]
+ def resolver = new SnapshotAwareM2Resolver()
+ resolver.name = url
+ resolver.root = url
+ resolver.m2compatible = true
+ resolver.settings = dependencyManager.ivySettings
+ resolver.changingPattern = ".*SNAPSHOT"
+ addToChainResolver(resolver)
+ }
@CompileStatic
void mavenRepo(Map args) {
def name = args?.get('name')
if (args && name) {
if (!context.offline && isResolverNotAlreadyDefined(name?.toString())) {
- dependencyManager.repositoryData << (['type':'mavenRepo'] + args)
+ dependencyManager.repositoryData << ([type: 'mavenRepo'] + args)
args.settings = dependencyManager.ivySettings
def resolver = createSnapshotResolver(args)
@@ -163,17 +164,19 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@CompileStatic
void ebr() {
if (!context.offline && isResolverNotAlreadyDefined('ebr')) {
- dependencyManager.repositoryData << ['type':'ebr']
- IBiblioResolver ebrReleaseResolver = createSnapshotResolver(name:"ebrRelease",
- root:"http://repository.springsource.com/maven/bundles/release",
- m2compatible:true,
- settings:dependencyManager.ivySettings)
+ dependencyManager.repositoryData << [type: 'ebr']
+ IBiblioResolver ebrReleaseResolver = createSnapshotResolver(
+ name:"ebrRelease",
+ root:"http://repository.springsource.com/maven/bundles/release",
+ m2compatible:true,
+ settings:dependencyManager.ivySettings)
addToChainResolver(ebrReleaseResolver)
- IBiblioResolver ebrExternalResolver = createSnapshotResolver(name:"ebrExternal",
- root:"http://repository.springsource.com/maven/bundles/external",
- m2compatible:true,
- settings:dependencyManager.ivySettings)
+ IBiblioResolver ebrExternalResolver = createSnapshotResolver(
+ name:"ebrExternal",
+ root:"http://repository.springsource.com/maven/bundles/external",
+ m2compatible:true,
+ settings:dependencyManager.ivySettings)
addToChainResolver(ebrExternalResolver)
}
@@ -189,7 +192,7 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@CompileStatic
void grailsRepo(String url, String name=null) {
if (!context.offline && isResolverNotAlreadyDefined(name ?: url)) {
- dependencyManager.repositoryData << ['type':'grailsRepo', url:url]
+ dependencyManager.repositoryData << [type: 'grailsRepo', url:url]
def urlResolver = new GrailsRepoResolver(name ?: url, new URL(url))
urlResolver.addArtifactPattern("${url}/grails-[module]/tags/RELEASE_*/grails-[module]-[revision].[ext]")
urlResolver.addIvyPattern("${url}/grails-[module]/tags/RELEASE_*/[module]-[revision].pom")
@@ -211,7 +214,7 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@CompileStatic
void mavenCentral() {
if (!context.offline && isResolverNotAlreadyDefined('mavenCentral')) {
- dependencyManager.repositoryData << ['type':'mavenCentral']
+ dependencyManager.repositoryData << [type: 'mavenCentral']
IBiblioResolver mavenResolver = createSnapshotResolver(name:"mavenCentral")
mavenResolver.m2compatible = true
mavenResolver.settings = dependencyManager.ivySettings
@@ -223,7 +226,7 @@ class RepositoriesConfigurer extends AbstractDependencyManagementConfigurer {
@CompileStatic
void mavenLocal(String repoPath = null) {
if (isResolverNotAlreadyDefined('mavenLocal')) {
- dependencyManager.repositoryData << ['type':'mavenLocal']
+ dependencyManager.repositoryData << [type: 'mavenLocal']
FileSystemResolver localMavenResolver = new FileSystemResolver()
localMavenResolver.name = 'localMavenResolver'
localMavenResolver.local = true
View
17 ...ls-core/src/main/groovy/org/codehaus/groovy/grails/commons/ControllerArtefactHandler.java
@@ -72,16 +72,17 @@ public String getPluginName() {
return PLUGIN_NAME;
}
+ @SuppressWarnings("rawtypes")
@Override
public GrailsClass getArtefactForFeature(Object featureId) {
if (artefactInfo == null) {
return null;
}
-
- String uri = null;
+
+ String uri;
String pluginName = null;
- if(featureId instanceof Map) {
+ if (featureId instanceof Map) {
Map featureIdMap = (Map)featureId;
uri = (String)featureIdMap.get("uri");
pluginName = (String)featureIdMap.get("pluginName");
@@ -93,9 +94,9 @@ public GrailsClass getArtefactForFeature(Object featureId) {
if (controllerClass == null) {
final ApplicationContext mainContext = grailsApplication.getMainContext();
GrailsPluginManager grailsPluginManager = null;
- if(mainContext.containsBean(GrailsPluginManager.BEAN_NAME)) {
+ if (mainContext.containsBean(GrailsPluginManager.BEAN_NAME)) {
final Object pluginManagerBean = mainContext.getBean(GrailsPluginManager.BEAN_NAME);
- if(pluginManagerBean instanceof GrailsPluginManager) {
+ if (pluginManagerBean instanceof GrailsPluginManager) {
grailsPluginManager = (GrailsPluginManager) pluginManagerBean;
}
}
@@ -105,15 +106,15 @@ public GrailsClass getArtefactForFeature(Object featureId) {
GrailsClass c = controllerClasses[i];
if (((GrailsControllerClass) c).mapsToURI(uri)) {
boolean foundController = false;
- if(pluginName != null && grailsPluginManager != null) {
+ if (pluginName != null && grailsPluginManager != null) {
final GrailsPlugin pluginForClass = grailsPluginManager.getPluginForClass(c.getClazz());
- if(pluginForClass != null && pluginName.equals(pluginForClass.getName())) {
+ if (pluginForClass != null && pluginName.equals(pluginForClass.getName())) {
foundController = true;
}
} else {
foundController = true;
}
- if(foundController) {
+ if (foundController) {
controllerClass = c;
break;
}
View
1  grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsApplication.java
@@ -23,7 +23,6 @@
import groovy.util.ConfigObject;
import java.io.IOException;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
View
26 ...rc/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsWebApplicationContext.java
@@ -74,22 +74,16 @@ public GrailsWebApplicationContext(DefaultListableBeanFactory defaultListableBea
@Override
public ClassLoader getClassLoader() {
GrailsApplication application = getGrailsApplication();
-
- if (application != null) {
- return application.getClassLoader();
- }
-
- return super.getClassLoader();
+ return application == null ? super.getClassLoader() : application.getClassLoader();
}
-
+
private GrailsApplication getGrailsApplication() {
ApplicationContext parent = getParent();
- GrailsApplication application = null;
- if (parent != null && parent.containsBean(GrailsApplication.APPLICATION_ID)) {
- application = (GrailsApplication) parent.getBean(GrailsApplication.APPLICATION_ID);
-
+ if (parent == null || !parent.containsBean(GrailsApplication.APPLICATION_ID)) {
+ return null;
}
- return application;
+
+ return (GrailsApplication)parent.getBean(GrailsApplication.APPLICATION_ID);
}
/**
@@ -183,18 +177,14 @@ public ServletConfig getServletConfig() {
@Override
protected ConfigurableEnvironment createEnvironment() {
GrailsApplication grailsApplication = getGrailsApplication();
- if (grailsApplication != null) {
- return new GrailsEnvironment(grailsApplication);
- }
- return new StandardServletEnvironment();
+ return grailsApplication == null ? new StandardServletEnvironment() : new GrailsEnvironment(grailsApplication);
}
@Override
public ConfigurableWebEnvironment getEnvironment() {
ConfigurableEnvironment env = super.getEnvironment();
Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
- "ConfigurableWebApplication environment must be of type " +
- "ConfigurableWebEnvironment");
+ "ConfigurableWebApplication environment must be of type ConfigurableWebEnvironment");
return (ConfigurableWebEnvironment) env;
}
}
View
25 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectWatcher.java
@@ -38,7 +38,7 @@
import org.springframework.util.ClassUtils;
/**
- * Watches a Grails projects and re-compiles sources when they change or fires events to the pluginManager.
+ * Watches a Grails project and re-compiles sources when they change or fires events to the pluginManager.
*
* @author Graeme Rocher
* @since 2.0
@@ -217,13 +217,14 @@ protected boolean fileIsReloadable(File file) {
// These are expanded for readability
if (fileIsExcluded == true) {
return false;
- } else if (fileIsIncluded == true) {
+ }
+ if (fileIsIncluded == true) {
return true;
- } else if (fileIsExcluded == false && fileIsIncluded == false && reloadIncludes.size() > 0) {
+ }
+ if (fileIsExcluded == false && fileIsIncluded == false && reloadIncludes.size() > 0) {
return false;
- } else {
- return true;
}
+ return true;
}
private void reloadPlugin(File file) {
@@ -248,7 +249,6 @@ private void informPluginManager(final File file, boolean isNew) {
// add to class change event queue
String className = GrailsResourceUtils.getClassName(file.getAbsolutePath());
if (className != null) {
-
classChangeEventQueue.put(className, new ClassUpdate() {
public void run(Class<?> cls) {
try {
@@ -290,7 +290,6 @@ private void compileIfSource(File file) {
}
}
-
private void sleep(int time) {
try {
Thread.sleep(time);
@@ -308,18 +307,6 @@ private boolean isSourceFile(File file) {
return false;
}
- private String getDottedClassName(File file) {
- String absolutePath = file.getName();
- for (String dir : compiler.getSrcDirectories()) {
- if (absolutePath.startsWith(dir)) {
- String srcPath = absolutePath.replaceAll(String.format("^%s", dir), "");
- String dottedPath = srcPath.replaceAll(file.separator, ".");
- return dottedPath;
- }
- }
- return null;
- }
-
private interface ClassUpdate {
void run(Class<?> cls);
}
View
59 ...src/main/groovy/org/codehaus/groovy/grails/project/packaging/GrailsProjectPackager.groovy
@@ -121,7 +121,6 @@ class GrailsProjectPackager extends BaseSettingsApi {
return serverContextPath
}
-
@CompileStatic
AntBuilder getAnt() {
if (ant == null) {
@@ -136,8 +135,8 @@ class GrailsProjectPackager extends BaseSettingsApi {
void generateWebXml(GrailsPluginManager pluginManager) {
File projectWorkDir = buildSettings.projectWorkDir
ConfigObject buildConfig = buildSettings.config
- def webXml = new FileSystemResource("${basedir}/src/templates/war/web.xml")
- def tmpWebXml = "${projectWorkDir}/web.xml.tmp"
+ def webXml = new FileSystemResource("$basedir/src/templates/war/web.xml")
+ String tmpWebXml = "$projectWorkDir/web.xml.tmp"
final baseWebXml = getBaseWebXml(buildConfig)
if (baseWebXml) {
@@ -151,11 +150,11 @@ class GrailsProjectPackager extends BaseSettingsApi {
exit(1)
}
} else {
- if (!webXml.exists()) {
- copyGrailsResource(tmpWebXml, grailsResource("src/war/WEB-INF/web${servletVersion}.template.xml"))
+ if (webXml.exists()) {
+ ant.copy(file:webXml.file, tofile:tmpWebXml, overwrite:true)
}
else {
- ant.copy(file:webXml.file, tofile:tmpWebXml, overwrite:true)
+ copyGrailsResource(tmpWebXml, grailsResource("src/war/WEB-INF/web${servletVersion}.template.xml"))
}
}
webXml = new FileSystemResource(tmpWebXml)
@@ -173,7 +172,7 @@ class GrailsProjectPackager extends BaseSettingsApi {
}
}
catch (Exception e) {
- grailsConsole.error("Error generating web.xml file",e)
+ grailsConsole.error("Error generating web.xml file", e)
exit(1)
}
}
@@ -221,7 +220,7 @@ class GrailsProjectPackager extends BaseSettingsApi {
def resourceList = pluginSettings.getArtefactResourcesForOne(descriptor.parentFile.absolutePath)
// Work out what the name of the plugin is from the name of the descriptor file.
- def pluginName = GrailsNameUtils.getPluginName(descriptor.name)
+ String pluginName = GrailsNameUtils.getPluginName(descriptor.name)
// Remove the existing 'plugin.xml' if there is one.
def pluginXml = new File(pluginBaseDir, "plugin.xml")
@@ -305,10 +304,7 @@ class GrailsProjectPackager extends BaseSettingsApi {
}
try {
- classLoader
- .loadClass(LOGGING_INITIALIZER_CLASS)
- .newInstance()
- .initialize(config)
+ classLoader.loadClass(LOGGING_INITIALIZER_CLASS).newInstance().initialize(config)
} catch (e) {
throw new PackagingException("Error initializing logging: $e.message",e)
}
@@ -342,11 +338,9 @@ class GrailsProjectPackager extends BaseSettingsApi {
}
}
- def dataSourceFile = new File(basedir, "grails-app/conf/DataSource.groovy")
- if (dataSourceFile.exists()) {
+ if (new File(basedir, "grails-app/conf/DataSource.groovy").exists()) {
try {
- def dataSourceConfig = configSlurper.parse(classLoader.loadClass("DataSource"))
- config.merge(dataSourceConfig)
+ config.merge configSlurper.parse(classLoader.loadClass("DataSource"))
}
catch(ClassNotFoundException e) {
grailsConsole.error "Warning", "DataSource.groovy not found, assuming dataSource bean is configured by Spring"
@@ -369,16 +363,14 @@ class GrailsProjectPackager extends BaseSettingsApi {
if (!native2ascii) {
ant.copy(todir:i18nDir) {
- fileset(dir:"${basedir}/grails-app/i18n", includes:"**/*.properties")
+ fileset(dir:"$basedir/grails-app/i18n", includes:"**/*.properties")
}
return
}
def ant = new GrailsConsoleAntBuilder(ant.project)
- ant.native2ascii(src: "${basedir}/grails-app/i18n",
- dest: i18nDir,
- includes: "**/*.properties",
- encoding: "UTF-8")
+ ant.native2ascii(src: "$basedir/grails-app/i18n", dest: i18nDir,
+ includes: "**/*.properties", encoding: "UTF-8")
PluginBuildSettings settings = pluginSettings
def i18nPluginDirs = settings.pluginI18nDirectories
@@ -400,19 +392,16 @@ class GrailsProjectPackager extends BaseSettingsApi {
return
}
- def pluginDirName = pluginDir.name
def destDir = "$resourcesDirPath/plugins/${info.name}-${info.version}/grails-app/i18n"
try {
def localAnt = new GrailsConsoleAntBuilder(ant.project)
localAnt.project.defaultInputStream = System.in
localAnt.mkdir(dir: destDir)
- localAnt.native2ascii(src: file,
- dest: destDir,
- includes: "**/*.properties",
- encoding: "UTF-8")
+ localAnt.native2ascii(src: file, dest: destDir,
+ includes: "**/*.properties", encoding: "UTF-8")
}
catch (e) {
- grailsConsole.error "native2ascii error converting i18n bundles for plugin [${pluginDirName}] ${e.message}"
+ grailsConsole.error "native2ascii error converting i18n bundles for plugin [$pluginDir.name] $e.message"
}
}.curry(r))
}
@@ -422,13 +411,13 @@ class GrailsProjectPackager extends BaseSettingsApi {
def logic = {
def ant = new GrailsConsoleAntBuilder(ant.project)
def files = ant.fileScanner {
- fileset(dir:"${basedir}/grails-app/views", includes:"**/*.jsp")
+ fileset(dir:"$basedir/grails-app/views", includes:"**/*.jsp")
}
if (files.iterator().hasNext()) {
- ant.mkdir(dir:"${basedir}/web-app/WEB-INF/grails-app/views")
- ant.copy(todir:"${basedir}/web-app/WEB-INF/grails-app/views") {
- fileset(dir:"${basedir}/grails-app/views", includes:"**/*.jsp")
+ ant.mkdir(dir:"$basedir/web-app/WEB-INF/grails-app/views")
+ ant.copy(todir:"$basedir/web-app/WEB-INF/grails-app/views") {
+ fileset(dir:"$basedir/grails-app/views", includes:"**/*.jsp")
}
}
}
@@ -495,17 +484,15 @@ class GrailsProjectPackager extends BaseSettingsApi {
@CompileStatic
void packageTlds() {
- // We don't know until runtime what servlet version to use, so
- // install the relevant TLDs now.
- copyGrailsResources("${basedir}/web-app/WEB-INF/tld",
- "src/war/WEB-INF/tld/${servletVersion}/*", false)
+ // We don't know until runtime what servlet version to use, so install the relevant TLDs now
+ copyGrailsResources("$basedir/web-app/WEB-INF/tld", "src/war/WEB-INF/tld/${servletVersion}/*", false)
}
void packageTemplates(scaffoldDir) {
ant.mkdir(dir:scaffoldDir)
if (new File(basedir, "src/templates/scaffolding").exists()) {
ant.copy(todir:scaffoldDir, overwrite:true) {
- fileset(dir:"${basedir}/src/templates/scaffolding", includes:"**")
+ fileset(dir:"$basedir/src/templates/scaffolding", includes:"**")
}
}
else {
View
6 ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateGormEnhancer.groovy
@@ -332,7 +332,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
D first(Map m) {
def entityMapping = GrailsDomainBinder.getMapping(persistentEntity.javaClass)
- if(entityMapping?.identity instanceof CompositeIdentity) {
+ if (entityMapping?.identity instanceof CompositeIdentity) {
throw new UnsupportedOperationException('The first() method is not supported for domain classes that have composite keys.')
}
super.first(m)
@@ -340,12 +340,12 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
D last(Map m) {
def entityMapping = GrailsDomainBinder.getMapping(persistentEntity.javaClass)
- if(entityMapping?.identity instanceof CompositeIdentity) {
+ if (entityMapping?.identity instanceof CompositeIdentity) {
throw new UnsupportedOperationException('The last() method is not supported for domain classes that have composite keys.')
}
super.last(m)
}
-
+
/**
* Finds a single result for the given query and arguments and a maximum results to return value
*
View
1  ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsHibernateUtil.java
@@ -20,7 +20,6 @@
import groovy.lang.GroovySystem;
import groovy.lang.MetaClass;
-import java.lang.reflect.Modifier;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
View
3  ...ernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/PropertyConfig.groovy
@@ -80,9 +80,6 @@ class PropertyConfig {
*/
boolean updateable = true
- /**
- *
- */
List<ColumnConfig> columns = []
boolean lazy = true
View
2  ...rc/ast/groovy/org/codehaus/groovy/grails/compiler/web/gsp/GroovyPageOptimizerVisitor.java
@@ -64,6 +64,7 @@ public GroovyPageOptimizerVisitor(ClassNode targetGroovyPage) {
// innerClosures.pop();
// }
+ @SuppressWarnings("unused")
private void introduceThisObjectVariable(ClosureExpression closureExpression) {
if (closureExpression.getCode() instanceof BlockStatement) {
List<Statement> oldBlock = ((BlockStatement)closureExpression.getCode()).getStatements();
@@ -99,6 +100,7 @@ private boolean isCallFromOutOrCodecOut(MethodCallExpression expression) {
&& expression.getMethodAsString().equals(PRINT_METHOD);
}
+ @SuppressWarnings("unused")
private void proceedCallFromGroovyPageClass(MethodCallExpression call) {
List<MethodNode> methodNodeList = groovyPageClassNode.getMethods(call.getMethodAsString());
View
10 ...gin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/RenderTagLib.groovy
@@ -251,11 +251,11 @@ class RenderTagLib implements RequestConstants {
// check if there is an component content buffer
propertyValue = htmlPage.getContentBuffer(names[i])
}
-
+
if (!propertyValue) {
propertyValue = htmlPage.getProperty(names[i])
}
-
+
if (propertyValue) {
if(attrs.containsKey('equals')) {
if (attrs.equals instanceof List) {
@@ -421,9 +421,9 @@ class RenderTagLib implements RequestConstants {
// display firststep link when beginstep is not firststep
if (beginstep > firststep && !attrs.boolean('omitFirst')) {
linkParams.offset = 0
- writer << link(linkTagAttrs.clone()) {firststep.toString()}
+ writer << link(linkTagAttrs.clone()) {firststep.toString()}
}
- //show a gap if beginstep isn't immediately after firststep, and if were not omitting first or rev
+ //show a gap if beginstep isn't immediately after firststep, and if were not omitting first or rev
if (beginstep > firststep+1 && (!attrs.boolean('omitFirst') || !attrs.boolean('omitPrev')) ) {
writer << '<span class="step gap">..</span>'
}
@@ -439,7 +439,7 @@ class RenderTagLib implements RequestConstants {
}
}
- //show a gap if beginstep isn't immediately before firststep, and if were not omitting first or rev
+ //show a gap if beginstep isn't immediately before firststep, and if were not omitting first or rev
if (endstep+1 < laststep && (!attrs.boolean('omitLast') || !attrs.boolean('omitNext'))) {
writer << '<span class="step gap">..</span>'
}
View
7 ...gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ValidationTagLib.groovy
@@ -77,9 +77,9 @@ class ValidationTagLib {
Closure fieldValue = { attrs, body ->
def bean = attrs.bean
def field = attrs.field?.toString()
-
+
def tagSyntaxCall = (attrs instanceof GroovyPageAttributes) ? attrs.isGspTagSyntaxCall() : false
-
+
if (bean && field) {
if (bean.metaClass.hasProperty(bean,'errors')) {
Errors errors = bean.errors
@@ -232,8 +232,7 @@ class ValidationTagLib {
* @attr model The model reference to check for errors
*/
Closure renderErrors = { attrs, body ->
- def renderAs = attrs.remove('as')
- if (!renderAs) renderAs = 'list'
+ def renderAs = attrs.remove('as') ?: 'list'
if (renderAs == 'list') {
def codec = attrs.codec ?: 'HTML'
View
14 grails-plugin-testing/src/main/groovy/grails/test/mixin/support/GrailsUnitTestMixin.groovy
@@ -120,7 +120,6 @@ class GrailsUnitTestMixin {
GroovySystem.metaClassRegistry.addMetaClassRegistryChangeEventListener metaClassRegistryListener
}
-
static void cleanupModifiedMetaClasses() {
metaClassRegistryListener.clean()
}
@@ -198,11 +197,14 @@ class GrailsUnitTestMixin {
}
if (th == null) {
- throw new AssertionFailedError("Closure " + code + " should have failed with an exception of type " + clazz.getName())
- } else if (!clazz.isInstance(th)) {
- throw new AssertionFailedError("Closure " + code + " should have failed with an exception of type " + clazz.getName() + ", instead got Exception " + th);
+ throw new AssertionFailedError("Closure $code should have failed with an exception of type $clazz.name")
+ }
+
+ if (!clazz.isInstance(th)) {
+ throw new AssertionFailedError("Closure $code should have failed with an exception of type $clazz.name, instead got Exception $th")
}
- return th.getMessage();
+
+ return th.message
}
/**
* Loads the given codec, adding the "encodeAs...()" and "decode...()"
@@ -225,8 +227,6 @@ class GrailsUnitTestMixin {
Object.metaClass."decode$codecName" = { -> codec.decode(delegate) }
}
-
-
@AfterClass
static void shutdownApplicationContext() {
if (applicationContext.isActive()) {
View
87 grails-plugin-testing/src/main/groovy/grails/test/mixin/web/ControllerUnitTestMixin.groovy
@@ -29,6 +29,14 @@ import javax.servlet.http.HttpServletResponse
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler
import org.codehaus.groovy.grails.commons.UrlMappingsArtefactHandler
import org.codehaus.groovy.grails.commons.metaclass.MetaClassEnhancer
+import org.codehaus.groovy.grails.plugins.codecs.Base64Codec
+import org.codehaus.groovy.grails.plugins.codecs.HTMLCodec
+import org.codehaus.groovy.grails.plugins.codecs.HexCodec
+import org.codehaus.groovy.grails.plugins.codecs.JavaScriptCodec
+import org.codehaus.groovy.grails.plugins.codecs.MD5Codec
+import org.codehaus.groovy.grails.plugins.codecs.SHA1Codec
+import org.codehaus.groovy.grails.plugins.codecs.SHA256Codec
+import org.codehaus.groovy.grails.plugins.codecs.URLCodec
import org.codehaus.groovy.grails.plugins.converters.ConvertersGrailsPlugin
import org.codehaus.groovy.grails.plugins.converters.ConvertersPluginSupport
import org.codehaus.groovy.grails.plugins.converters.api.ConvertersControllersApi
@@ -38,12 +46,13 @@ import org.codehaus.groovy.grails.plugins.web.ServletsGrailsPluginSupport
import org.codehaus.groovy.grails.plugins.web.api.*
import org.codehaus.groovy.grails.plugins.web.mimes.MimeTypesFactoryBean
import org.codehaus.groovy.grails.plugins.web.mimes.MimeTypesGrailsPlugin
+import org.codehaus.groovy.grails.web.context.ServletContextHolder
import org.codehaus.groovy.grails.web.mapping.DefaultLinkGenerator
import org.codehaus.groovy.grails.web.mapping.UrlMappingsHolderFactoryBean
import org.codehaus.groovy.grails.web.mime.MimeType
import org.codehaus.groovy.grails.web.pages.GroovyPageUtils
import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine
-import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer;
+import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer
import org.codehaus.groovy.grails.web.pages.discovery.GrailsConventionGroovyPageLocator
import org.codehaus.groovy.grails.web.pages.ext.jsp.TagLibraryResolver
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils
@@ -55,25 +64,16 @@ import org.junit.After
import org.junit.AfterClass
import org.junit.Before
import org.junit.BeforeClass
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory
import org.springframework.mock.web.MockHttpSession
import org.springframework.mock.web.MockServletContext
import org.springframework.util.ClassUtils
import org.springframework.web.context.WebApplicationContext
import org.springframework.web.context.request.RequestContextHolder
import org.springframework.web.multipart.commons.CommonsMultipartResolver
-import org.codehaus.groovy.grails.plugins.codecs.HTMLCodec
-import org.codehaus.groovy.grails.plugins.codecs.JavaScriptCodec
-import org.codehaus.groovy.grails.plugins.codecs.HexCodec
-import org.codehaus.groovy.grails.plugins.codecs.MD5Codec
-import org.codehaus.groovy.grails.plugins.codecs.SHA1Codec
-import org.codehaus.groovy.grails.plugins.codecs.SHA256Codec
-import org.codehaus.groovy.grails.plugins.codecs.URLCodec
-import org.codehaus.groovy.grails.plugins.codecs.Base64Codec
-import org.codehaus.groovy.grails.web.context.ServletContextHolder
/**
- * A mixin that can be applied to a unit test in order to test controllers.
+ * Applied to a unit test to test controllers.
*
* @author Graeme Rocher
* @since 2.0
@@ -128,8 +128,7 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
* @return The model of the current controller
*/
Map getModel() {
- final controller = webRequest.currentRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER)
- return controller?.modelAndView?.model ?: [:]
+ webRequest.currentRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER)?.modelAndView?.model ?: [:]
}
/**
@@ -147,7 +146,7 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
GroovyPageUtils.getViewURI(webRequest.controllerName, webRequest.actionName)
}
else {
- return null;
+ return null
}
}
@@ -194,8 +193,8 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
def lazyBean = { bean ->
bean.lazyInit = true
}
- jspTagLibraryResolver(TagLibraryResolver,lazyBean)
- gspTagLibraryLookup(LazyTagLibraryLookup,lazyBean)
+ jspTagLibraryResolver(TagLibraryResolver, lazyBean)
+ gspTagLibraryLookup(LazyTagLibraryLookup, lazyBean)
groovyPageLocator(GrailsConventionGroovyPageLocator) {
resourceLoader = new GroovyPageUnitTestResourceLoader(groovyPages)
}
@@ -233,32 +232,33 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
mockCodec(SHA1Codec)
mockCodec(SHA256Codec)
- if (webRequest == null) {
- webRequest = GrailsWebRequest.lookup()
- if (webRequest == null || !(webRequest.currentRequest instanceof GrailsMockHttpServletRequest)) {
+ if (webRequest != null) {
+ return
+ }
- if (!applicationContext.isActive()) {
- applicationContext.refresh()
- }
+ webRequest = GrailsWebRequest.lookup()
+ if (webRequest?.currentRequest instanceof GrailsMockHttpServletRequest) {
+ request = webRequest.currentRequest
+ response = webRequest.currentResponse
+ servletContext = webRequest.servletContext
+ return
+ }
- applicationContext.servletContext = servletContext
+ if (!applicationContext.isActive()) {
+ applicationContext.refresh()
+ }
- ServletsGrailsPluginSupport.enhanceServletApi()
- ConvertersPluginSupport.enhanceApplication(grailsApplication,applicationContext)
+ applicationContext.servletContext = servletContext
- request = new GrailsMockHttpServletRequest(requestMimeTypesApi: new TestRequestMimeTypesApi(grailsApplication: grailsApplication))
- response = new GrailsMockHttpServletResponse(responseMimeTypesApi: new TestResponseMimeTypesApi(grailsApplication: grailsApplication))
- webRequest = GrailsWebUtil.bindMockWebRequest(applicationContext, request, response)
- request = webRequest.getCurrentRequest()
- response = webRequest.getCurrentResponse()
- servletContext = webRequest.getServletContext()
- }
- else {
- request = webRequest.currentRequest
- response = webRequest.currentResponse
- servletContext = webRequest.servletContext
- }
- }
+ ServletsGrailsPluginSupport.enhanceServletApi()
+ ConvertersPluginSupport.enhanceApplication(grailsApplication,applicationContext)
+
+ request = new GrailsMockHttpServletRequest(requestMimeTypesApi: new TestRequestMimeTypesApi(grailsApplication: grailsApplication))
+ response = new GrailsMockHttpServletResponse(responseMimeTypesApi: new TestResponseMimeTypesApi(grailsApplication: grailsApplication))
+ webRequest = GrailsWebUtil.bindMockWebRequest(applicationContext, request, response)
+ request = webRequest.getCurrentRequest()
+ response = webRequest.getCurrentResponse()
+ servletContext = webRequest.getServletContext()
}
/**
@@ -294,7 +294,7 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
}
defineBeans {
- "${controllerClass.name}"(controllerClass) { bean ->
+ "$controllerClass.name"(controllerClass) { bean ->
bean.scope = 'prototype'
bean.autowire = true
}
@@ -306,6 +306,7 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller)
controller
}
+
controllerClass.metaClass.constructor = callable
return callable.call()
@@ -327,17 +328,17 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
@After
void clearGrailsWebRequest() {
- def ctx = webRequest?.applicationContext
webRequest = null
request = null
response = null
RequestContextHolder.setRequestAttributes(null)
views.clear()
+ def ctx = webRequest?.applicationContext
if (ctx?.containsBean("groovyPagesTemplateEngine")) {
- ctx?.getBean("groovyPagesTemplateEngine")?.clearPageCache()
+ ctx.groovyPagesTemplateEngine.clearPageCache()
}
if (ctx?.containsBean("grovyPagesTemplateRenderer")) {
- ctx?.getBean("groovyPagesTemplateRenderer")?.clearCache()
+ ctx.groovyPagesTemplateRenderer.clearCache()
}
}
}
View
35 ...rl-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlCreator.java
@@ -15,6 +15,15 @@
package org.codehaus.groovy.grails.web.mapping;
import grails.util.GrailsWebUtil;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.grails.commons.GrailsControllerClass;
import org.codehaus.groovy.grails.web.pages.FastStringWriter;
@@ -24,10 +33,6 @@
import org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException;
import org.springframework.web.context.request.RequestContextHolder;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.*;
-
/**
* The default implementation of the UrlCreator interface that constructs URLs in Grails
* default pattern of /controllerName/actionName/id.
@@ -44,7 +49,6 @@
public static final String ARGUMENT_ID = "id";
private static final String ENTITY_AMPERSAND = "&";
-
public DefaultUrlCreator(String controller, String action) {
controllerName = controller;
actionName = action;
@@ -62,8 +66,7 @@ public String createURL(Map parameterValues, String encoding, String fragment) {
}
@SuppressWarnings("unchecked")
- private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest webRequest,
- boolean includeContextPath) {
+ private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest webRequest, boolean includeContextPath) {
GrailsRequestStateLookupStrategy requestStateLookupStrategy = new DefaultRequestStateLookupStrategy(webRequest);
@@ -105,14 +108,13 @@ private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest web
public String createURL(String controller, String action, Map parameterValues, String encoding) {
return createURL(controller, action, null, parameterValues, encoding);
}
-
+
@SuppressWarnings("unchecked")
public String createURL(String controller, String action, String pluginName, Map parameterValues, String encoding) {
- return createURLInternal(controller, action, pluginName, parameterValues, true);
+ return createURLInternal(controller, action, parameterValues, true);
}
- private String createURLInternal(String controller, String action, String pluginName,
- Map<String, String> parameterValues, boolean includeContextPath) {
+ private String createURLInternal(String controller, String action, Map<String, String> parameterValues, boolean includeContextPath) {
GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.getRequestAttributes();
if (parameterValues == null) parameterValues = new HashMap<String, String>();
@@ -139,24 +141,22 @@ private String createURLInternal(String controller, String action, String plugin
}
}
- @SuppressWarnings("unchecked")
public String createRelativeURL(String controller, String action, Map parameterValues, String encoding) {
return createRelativeURL(controller, action, null, parameterValues, encoding);
}
-
+
@SuppressWarnings("unchecked")
public String createRelativeURL(String controller, String action, String pluginName, Map parameterValues, String encoding) {
- return createURLInternal(controller, action, pluginName, parameterValues, false);
+ return createURLInternal(controller, action, parameterValues, false);
}
- @SuppressWarnings("unchecked")
public String createRelativeURL(String controller, String action, Map parameterValues, String encoding, String fragment) {
return createRelativeURL(controller, action, null, parameterValues, encoding, fragment);
}
@SuppressWarnings("unchecked")
public String createRelativeURL(String controller, String action, String pluginName, Map parameterValues, String encoding, String fragment) {
- final String url = createURLInternal(controller, action, pluginName, parameterValues, false);
+ final String url = createURLInternal(controller, action, parameterValues, false);
return createUrlWithFragment(encoding, fragment, url);
}
@@ -186,8 +186,7 @@ private String createUrlWithFragment(String encoding, String fragment, String ur
/*
* Appends all the request parameters to the URI buffer
*/
- private void appendRequestParams(FastStringWriter actualUriBuf, Map<Object, Object> params,
- String encoding) {
+ private void appendRequestParams(FastStringWriter actualUriBuf, Map<Object, Object> params, String encoding) {
boolean querySeparator = false;
View
6 ...gs/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingEvaluator.java
@@ -293,11 +293,11 @@ public void setController(Object controller) {
public Object getController() {
return controllerName;
}
-
+
public void setPlugin(Object plugin) {
pluginName = plugin;
}
-
+
public Object getPlugin() {
return pluginName;
}
@@ -496,7 +496,7 @@ private UrlMappingData createUrlMappingData(String methodName, boolean responseC
}
private boolean isResponseCode(String s) {
- for (int i = 0; i < s.length(); i++) {
+ for (int count = s.length(), i = 0; i < count; i++) {
if (!Character.isDigit(s.charAt(i))) return false;
}
View
9 ...appings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingInfo.java
@@ -114,9 +114,9 @@ public boolean isParsingRequest() {
public void setParsingRequest(boolean parsingRequest) {
this.parsingRequest = parsingRequest;
}
-
+
public String getPluginName() {
- return pluginName != null ? pluginName.toString() : null;
+ return pluginName == null ? null : pluginName.toString();
}
public String getControllerName() {
@@ -131,7 +131,7 @@ public String getControllerName() {
public String getActionName() {
GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.getRequestAttributes();
- String name = webRequest != null ? checkDispatchAction(webRequest.getCurrentRequest()) : null;
+ String name = webRequest == null ? null : checkDispatchAction(webRequest.getCurrentRequest());
if (name == null) {
name = evaluateNameForValue(actionName, webRequest);
}
@@ -147,7 +147,8 @@ public String getId() {
}
private String checkDispatchAction(HttpServletRequest request) {
- if (request.getAttribute(GrailsExceptionResolver.EXCEPTION_ATTRIBUTE)!= null) return null;
+ if (request.getAttribute(GrailsExceptionResolver.EXCEPTION_ATTRIBUTE) != null) return null;
+
String dispatchActionName = null;
Enumeration<String> paramNames = tryMultipartParams(request, request.getParameterNames());
View
10 ...ings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingsHolder.java
@@ -187,7 +187,7 @@ public List getExcludePatterns() {
public UrlCreator getReverseMapping(final String controller, final String action, Map params) {
return getReverseMapping(controller, action, null, params);
}
-
+
/**
* @see UrlMappingsHolder#getReverseMapping(String, String, java.util.Map)
*/
@@ -212,7 +212,7 @@ public UrlCreator getReverseMapping(final String controller, final String action
public UrlCreator getReverseMappingNoDefault(String controller, String action, Map params) {
return getReverseMappingNoDefault(controller, action, null, params);
}
-
+
public UrlCreator getReverseMappingNoDefault(String controller, String action, String pluginName, Map params) {
if (params == null) params = Collections.EMPTY_MAP;
@@ -235,8 +235,8 @@ public UrlCreator getReverseMappingNoDefault(String controller, String action, S
@SuppressWarnings("unchecked")
private UrlCreator resolveUrlCreator(final String controller,
- final String action,
- final String pluginName,
+ final String action,
+ final String pluginName,
Map params, boolean useDefault) {
UrlMapping mapping = null;
@@ -500,7 +500,7 @@ public int compareTo(Object o) {
comparison = pluginName != null ? pluginName.compareTo(other.pluginName) : EQUAL;
if (comparison != EQUAL) return comparison;
-
+
return EQUAL;
}
}
View
39 ...-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/RegexUrlMapping.java
@@ -16,6 +16,23 @@
import grails.util.GrailsWebUtil;
import groovy.lang.Closure;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import javax.servlet.ServletContext;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,15 +47,6 @@
import org.springframework.validation.MapBindingResult;
import org.springframework.web.context.request.RequestContextHolder;
-import javax.servlet.ServletContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
/**
* <p>A UrlMapping implementation that takes a Grails URL pattern and turns it into a regex matcher so that
* URLs can be matched and information captured from the match.</p>
@@ -296,7 +304,7 @@ public String createURL(String controller, String action, Map paramValues, Strin
public String createURL(String controller, String action, String pluginName, Map paramValues, String encoding) {
return createURLInternal(controller, action, pluginName, paramValues, encoding, true);
}
-
+
@SuppressWarnings("unchecked")
private String createURLInternal(String controller, String action, String pluginName, Map paramValues,
String encoding, boolean includeContextPath) {
@@ -340,9 +348,8 @@ public String createRelativeURL(String controller, String action, Map paramValue
public String createRelativeURL(String controller, String action, String pluginName, Map paramValues, String encoding) {
return createURLInternal(controller, action, pluginName, paramValues, encoding, false);
}
-
- public String createRelativeURL(String controller, String action, Map paramValues,
- String encoding, String fragment) {
+
+ public String createRelativeURL(String controller, String action, Map paramValues, String encoding, String fragment) {
return createRelativeURL(controller, action, null, paramValues, encoding, fragment);
}
@@ -351,7 +358,7 @@ public String createRelativeURL(String controller, String action, String pluginN
final String url = createURLInternal(controller, action, pluginName, paramValues, encoding, false);
return createUrlWithFragment(url, fragment, encoding);
}
-
+
public String createURL(String controller, String action, Map paramValues,
String encoding, String fragment) {
return createURL(controller, action, null, paramValues, encoding, fragment);
@@ -362,7 +369,7 @@ public String createURL(String controller, String action, String pluginName, Map
String url = createURL(controller, action, pluginName, paramValues, encoding);
return createUrlWithFragment(url, fragment, encoding);
}
-
+
private String createUrlWithFragment(String url, String fragment, String encoding) {
if (fragment != null) {
// A 'null' encoding will cause an exception, so default to 'UTF-8'.
@@ -451,7 +458,7 @@ private UrlMappingInfo createUrlMappingInfo(String uri, Matcher m) {
Map params = new HashMap();
Errors errors = new MapBindingResult(params, "urlMapping");
String lastGroup = null;
- for (int i = 0; i < m.groupCount(); i++) {
+ for (int i = 0, count = m.groupCount(); i < count; i++) {
lastGroup = m.group(i + 1);
int j = lastGroup.indexOf('?');
if (j > -1) {
View
8 ...ppings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/ResponseCodeUrlMapping.java
@@ -96,7 +96,7 @@ public String createURL(String controller, String action, Map values, String enc
public String createURL(String controller, String action, String pluginName, Map values, String encoding) {
throw new UnsupportedOperationException("Method createURL not implemented in " + getClass());
}
-
+
public String createRelativeURL(String controller, String action, Map values, String encoding) {
throw new UnsupportedOperationException("Method createRelativeURL not implemented in " + getClass());
}
@@ -104,7 +104,7 @@ public String createRelativeURL(String controller, String action, Map values, St
public String createRelativeURL(String controller, String action, String pluginName, Map values, String encoding) {
throw new UnsupportedOperationException("Method createRelativeURL not implemented in " + getClass());
}
-
+
public String createRelativeURL(String controller, String action, Map values, String encoding, String fragment) {
throw new UnsupportedOperationException("Method createRelativeURL not implemented in " + getClass());
}
@@ -112,7 +112,7 @@ public String createRelativeURL(String controller, String action, Map values, St
public String createRelativeURL(String controller, String action, String pluginName, Map values, String encoding, String fragment) {
throw new UnsupportedOperationException("Method createRelativeURL not implemented in " + getClass());
}
-
+
public String createURL(String controller, String action, Map values, String encoding, String fragment) {
throw new UnsupportedOperationException("Method createURL not implemented in " + getClass());
}
@@ -120,7 +120,7 @@ public String createURL(String controller, String action, Map values, String enc
public String createURL(String controller, String action, String pluginName, Map values, String encoding, String fragment) {
throw new UnsupportedOperationException("Method createURL not implemented in " + getClass());
}
-
+
public UrlMappingInfo match(int responseCode) {
if (responseCode == urlData.getResponseCode()) {
return new DefaultUrlMappingInfo(controllerName, actionName, pluginName, viewName,
View
4 ...ings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/filter/UrlMappingsFilter.java
@@ -178,9 +178,9 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
final String controllerName = info.getControllerName();
String pluginName = info.getPluginName();
String featureUri = WebUtils.SLASH + urlConverter.toUrlElement(controllerName) + WebUtils.SLASH + urlConverter.toUrlElement(action);
-
+
Object featureId = null;
- if(pluginName != null) {
+ if (pluginName != null) {
Map featureIdMap = new HashMap();
featureIdMap.put("uri", featureUri);
featureIdMap.put("pluginName", pluginName);
View
20 ...-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CustomIdSpec.groovy
@@ -10,7 +10,7 @@ class CustomIdSpec extends GormSpec {
void 'Test saving an object with a custom id'() {
when:
def o = new ClassWithCustomId(name: 'Jeff')
-
+
then:
o.save()
}
@@ -18,31 +18,31 @@ class CustomIdSpec extends GormSpec {
void 'Test saving an object with a custom id that uses the assigned generator'() {
when:
new ClassWithAssignedCustomId(name: 'Jeff').save()
-
+
then:
HibernateSystemException ex = thrown()
ex.rootCause instanceof IdentifierGenerationException
-
+
when:
def o = new ClassWithAssignedCustomId(name: 'Jeff', myId: 42)
-
+
then:
o.save()
}
-
+
void 'Test that a custom id properly is configured as such'() {
given:
def grailsDomainClass = grailsApplication.getDomainClass(ClassWithCustomId.name)
-
+
when:
def myIdProperty = grailsDomainClass.getPersistentProperty('myId')
def myNameProperty = grailsDomainClass.getPersistentProperty('name')
-
+
then:
!myNameProperty.isIdentity()
myIdProperty.isIdentity()
}
-
+
@Override
public List getDomainClasses() {
[ClassWithCustomId, ClassWithAssignedCustomId]
@@ -54,7 +54,7 @@ class CustomIdSpec extends GormSpec {
class ClassWithCustomId {
String name
Long myId
-
+
static mapping = {
id name: 'myId'
}
@@ -64,7 +64,7 @@ class ClassWithCustomId {
class ClassWithAssignedCustomId {
String name
Long myId
-
+
static mapping = {
id name: 'myId', generator: 'assigned'
}
View
52 ...ce/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/FirstAndLastMethodSpec.groovy
@@ -13,10 +13,10 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result == null
-
+
when:
result = SimpleWidget.last()
-
+
then:
result == null
}
@@ -33,14 +33,14 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.name == 'one'
-
+
when:
result = SimpleWidget.last()
-
+
then:
result?.name == 'three'
}
-
+
void "Test first and last method with one entity"() {
given:
assert new SimpleWidget(name: 'one', spanishName: 'uno').save()
@@ -51,14 +51,14 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.name == 'one'
-
+
when:
result = SimpleWidget.last()
-
+
then:
result?.name == 'one'
}
-
+
void "Test first and last method with sort parameter"() {
given:
assert new SimpleWidget(name: 'one', spanishName: 'uno').save()
@@ -71,10 +71,10 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.name == 'one'
-
+
when:
result = SimpleWidget.last(sort: 'name')
-
+
then:
result?.name == 'two'
@@ -83,10 +83,10 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.name == 'one'
-
+
when:
result = SimpleWidget.last('name')
-
+
then:
result?.name == 'two'
@@ -95,10 +95,10 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.spanishName == 'dos'
-
+
when:
result = SimpleWidget.last(sort: 'spanishName')
-
+
then:
result?.spanishName == 'uno'
@@ -107,14 +107,14 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.spanishName == 'dos'
-
+
when:
result = SimpleWidget.last('spanishName')
-
+
then:
result?.spanishName == 'uno'
}
-
+
void "Test first and last method with non standard identifier"() {
given:
['one', 'two', 'three'].each { name ->
@@ -127,14 +127,14 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
result?.name == 'one'
-
+
when:
result = SimpleWidgetWithNonStandardId.last()
-
+
then:
result?.name == 'three'
}
-
+
void "Test first and last method with composite key"() {
when:
PersonWithCompositeKey.first()
@@ -142,35 +142,35 @@ class FirstAndLastMethodSpec extends GormSpec {
then:
UnsupportedOperationException ex = thrown()
'The first() method is not supported for domain classes that have composite keys.' == ex.message
-
+
when:
PersonWithCompositeKey.first(sort: 'firstName')
then:
ex = thrown()
'The first() method is not supported for domain classes that have composite keys.' == ex.message
-
+
when:
PersonWithCompositeKey.first('firstName')
then:
ex = thrown()
'The first() method is not supported for domain classes that have composite keys.' == ex.message
-
+
when:
PersonWithCompositeKey.last()
then:
ex = thrown()
'The last() method is not supported for domain classes that have composite keys.' == ex.message
-
+
when:
PersonWithCompositeKey.last(sort: 'firstName')
then:
ex = thrown()
'The last() method is not supported for domain classes that have composite keys.' == ex.message
-
+
when:
PersonWithCompositeKey.last('firstName')
@@ -178,7 +178,7 @@ class FirstAndLastMethodSpec extends GormSpec {
ex = thrown()
'The last() method is not supported for domain classes that have composite keys.' == ex.message
}
-
+
@Override
List getDomainClasses() {
[SimpleWidget, PersonWithCompositeKey, SimpleWidgetWithNonStandardId]
View
8 grails-test-suite-uber/src/test/groovy/grails/spring/BeanBuilderTests.groovy
@@ -15,16 +15,14 @@
*/
package grails.spring
-import org.codehaus.groovy.grails.plugins.GrailsPluginManager;
-import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.springframework.aop.SpringProxy
-import org.springframework.beans.factory.BeanIsAbstractException;
+import org.springframework.beans.factory.BeanIsAbstractException
import org.springframework.beans.factory.ObjectFactory
import org.springframework.beans.factory.config.Scope
import org.springframework.context.ApplicationContext
import org.springframework.context.support.GenericApplicationContext
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.mock.jndi.SimpleNamingContextBuilder
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver
import org.springframework.stereotype.Component
/**
View
12 grails-test-suite-web/src/test/groovy/grails/test/GrailsUrlMappingsTestCaseTests.groovy
@@ -423,21 +423,21 @@ class MockUrlMapping implements UrlMapping {
String createURL(Map parameterValues, String encoding, String fragment) { null }
String createURL(String controller, String action, Map parameterValues, String encoding) { null }
-
+
String createURL(String controller, String action, String pluginName, Map parameterValues, String encoding) { null }
-
+
String createRelativeURL(String controller, String action, Map parameterValues, String encoding) { null }
String createRelativeURL(String controller, String action, String pluginName, Map parameterValues, String encoding) { null }
-
+
String createRelativeURL(String controller, String action, Map parameterValues, String encoding, String fragment) { null }
String createRelativeURL(String controller, String action, String pluginName, Map parameterValues, String encoding, String fragment) { null }
-
+
String createURL(String controller, String action, Map parameterValues, String encoding, String fragment) { null }
String createURL(String controller, String action, String pluginName, Map parameterValues, String encoding, String fragment) { null }
-
+
ConstrainedProperty[] getConstraints() { new ConstrainedProperty[0] }
Object getControllerName() { controller }
@@ -445,7 +445,7 @@ class MockUrlMapping implements UrlMapping {
Object getActionName() { action }
Object getPluginName() { plugin }
-
+
Object getViewName() { null }
void setParameterValues(Map parameterValues) {}
View
1  ...rc/test/groovy/org/codehaus/groovy/grails/web/pages/GroovyPagesTemplateEngineTests.groovy
@@ -5,7 +5,6 @@ import grails.util.GrailsWebUtil
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.codehaus.groovy.grails.commons.GrailsClass
-import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
import org.codehaus.groovy.grails.support.MockStringResourceLoader
import org.springframework.core.io.ByteArrayResource
import org.springframework.core.io.UrlResource
View
30 ...web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/LinkRenderingTagLibTests.groovy
@@ -1,7 +1,6 @@
-package org.codehaus.groovy.grails.web.taglib;
+package org.codehaus.groovy.grails.web.taglib
-import org.codehaus.groovy.runtime.InvokerHelper
-import org.codehaus.groovy.grails.commons.*
+import org.codehaus.groovy.grails.commons.UrlMappingsArtefactHandler
class LinkRenderingTagLibTests extends AbstractGrailsTagTests {
@@ -55,41 +54,41 @@ class TestUrlMappings {
void testMappingsWhichSpecifyAPlugin() {
def template = '<g:link controller="first" action="index" plugin="firstUtil">click</g:link>'
assertOutputEquals '<a href="/pluginOneFirstController">click</a>', template
-
+
template = '<g:link controller="first" action="index" plugin="secondUtil">click</g:link>'
assertOutputEquals '<a href="/pluginTwoFirstController">click</a>', template
-
+
template = '<g:link controller="first" action="index" plugin="thirdUtil">click</g:link>'
assertOutputEquals '<a href="/pluginThreeFirstController">click</a>', template
-
+
template = '<g:link controller="first" action="index" plugin="firstUtil" params="[num: 42]" >click</g:link>'
assertOutputEquals '<a href="/pluginOneFirstController?num=42">click</a>', template
-
+
template = '<g:link controller="first" action="index" plugin="secondUtil" params="[num: 42]" >click</g:link>'
assertOutputEquals '<a href="/pluginTwoFirstController/42">click</a>', template
-
+
template = '<g:link controller="first" action="index" plugin="thirdUtil" params="[num: 42]" >click</g:link>'
assertOutputEquals '<a href="/pluginThreeFirstController?num=42">click</a>', template
-
+
template = '<g:createLink controller="first" action="index" plugin="firstUtil" />'
assertOutputEquals '/pluginOneFirstController', template
-
+
template = '<g:createLink controller="first" action="index" plugin="secondUtil" />'
assertOutputEquals '/pluginTwoFirstController', template
-
+
template = '<g:createLink controller="first" action="index" plugin="thirdUtil" />'
assertOutputEquals '/pluginThreeFirstController', template
-
+
template = '<g:createLink controller="first" action="index" plugin="firstUtil" params="[num: 42]" />'
assertOutputEquals '/pluginOneFirstController?num=42', template
-
+
template = '<g:createLink controller="first" action="index" plugin="secondUtil" params="[num: 42]" />'
assertOutputEquals '/pluginTwoFirstController/42', template
-
+
template = '<g:createLink controller="first" action="index" plugin="thirdUtil" params="[num: 42]" />'
assertOutputEquals '/pluginThreeFirstController?num=42', template
}
-
+
void testLinkTagWithAttributeValueContainingEqualSignFollowedByQuote() {
// Some of these tests look peculiar but they relate to
// scenarios that were broken before GRAILS-7229 was addressed
@@ -216,5 +215,4 @@ class TestUrlMappings {
template = '''<g:createLink controller="test2" action="show" id="jim" params="[age: 31]" />'''
assertOutputEquals("/test2/show/jim?age=31", template, [:])
}
-
}
View
8 ...-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/RenderTagLibTests.groovy
@@ -97,7 +97,7 @@ class RenderTagLibTests extends AbstractGrailsTagTests {
template = '<g:paginate max="2" total="20" offset="14" maxsteps="3" controller="book" action="list" />'
assertOutputContains '<a href="/book/list?offset=16&amp;max=2" class="step">9</a><a href="/book/list?offset=18&amp;max=2" class="step">10</a>', template
}
-
+
protected void onInit() {
if(name == 'testPaginateMappingAndAction') {
def mappingClass = gcl.parseClass('''
@@ -110,11 +110,11 @@ class RenderTagLibTests extends AbstractGrailsTagTests {
}
}
''')
-
+
grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, mappingClass)
}
- }
-
+ }
+
void testPaginateMappingAndAction() {
def template = '<g:paginate next="Forward" prev="Back" maxsteps="8" max="10" id="1" mapping="claimTab" total="12" action="documents"/>'
assertOutputEquals '<span class="currentStep">1</span><a href="/claim/1/documents?offset=10&amp;max=10" class="step">2</a><a href="/claim/1/documents?offset=10&amp;max=10" class="nextLink">Forward</a>', template
View
8 ...te-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/ValidationTagLibTests.groovy
@@ -124,7 +124,7 @@ enum Title implements org.springframework.context.MessageSourceResolvable {
assertOutputEquals(expected, template, [book:b])
assertOutputEquals(expected, htmlCodecDirective + template, [book:b])
}
-
+
void testFieldValueHtmlEscapingWithFunctionSyntaxCall() {
def b = ga.getDomainClass("ValidationTagLibBook").newInstance()
b.properties = [title:"<script>alert('escape me')</script>"]
@@ -143,12 +143,12 @@ enum Title implements org.springframework.context.MessageSourceResolvable {
def template = '''${fieldValue(bean:book, field:"title")}'''
def htmlCodecDirective = '<%@page defaultCodec="HTML" %>'
def expected = "&lt;script&gt;alert(&#39;escape me&#39;)&lt;/script&gt;"
-
+
def resourceLoader = new MockStringResourceLoader()
resourceLoader.registerMockResource('/_sometemplate.gsp', htmlCodecDirective + template)
resourceLoader.registerMockResource('/_sometemplate_nocodec.gsp', template)
appCtx.groovyPagesTemplateEngine.groovyPageLocator.addResourceLoader(resourceLoader)
-
+
assertOutputEquals(expected, '<g:render template="/sometemplate" model="[book:book]" />', [book:b])
assertOutputEquals(expected + expected, template + '<g:render template="/sometemplate" model="[book:book]" />', [book:b])
assertOutputEquals(expected + expected, htmlCodecDirective + template + '<g:render template="/sometemplate" model="[book:book]" />', [book:b])
@@ -161,7 +161,7 @@ enum Title implements org.springframework.context.MessageSourceResolvable {
assertOutputEquals(expected + expected, '<g:render template="/sometemplate_nocodec" model="[book:book]" />' + template, [book:b])
assertOutputEquals(expected + expected, htmlCodecDirective + '<g:render template="/sometemplate_nocodec" model="[book:book]" />' + template, [book:b])
}
-
+
void testFieldValueTag() {
def b = ga.getDomainClass("ValidationTagLibBook").newInstance()
b.properties = [publisherURL:"a_bad_url"]
View
2  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/AbstractUrlMapping.java
@@ -96,7 +96,7 @@ public Object getActionName() {
public Object getPluginName() {
return pluginName;
}
-
+
/**
* @see org.codehaus.groovy.grails.web.mapping.UrlMapping#getViewName()
*
View
8 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/UrlCreator.java
@@ -70,7 +70,7 @@
* @return The created URL for the given arguments
*/
String createURL(String controller, String action, String pluginName, Map parameterValues, String encoding);
-
+
/**
* Creates a URL for the given parameters values, controller and action names without the context path information
*
@@ -81,7 +81,7 @@
* @return The created URL for the given arguments
*/
String createRelativeURL(String controller, String action, Map parameterValues, String encoding);
-
+
/**
* Creates a URL for the given parameters values, controller and action names without the context path information
*
@@ -118,7 +118,7 @@
* @return The created URL for the given arguments
*/
String createRelativeURL(String controller, String action, String pluginName, Map parameterValues, String encoding, String fragment);
-
+
/**
* Creates a URL for the given parameters values, controller and action names
*