Skip to content

Commit 90c9d5a

Browse files
committed
The value of basePath in GroovyPageUnitTestResourceLoader is wrong after initialization
Closes gh-864
1 parent 8b5cdcf commit 90c9d5a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

grace-test-support/src/main/groovy/org/grails/testing/runtime/support/GroovyPageUnitTestResourceLoader.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,8 +34,6 @@
3434
import grails.core.support.GrailsApplicationAware;
3535
import grails.util.BuildSettings;
3636

37-
import org.grails.io.support.GrailsResourceUtils;
38-
3937
/**
4038
* A {@link org.springframework.core.io.ResourceLoader} implementation
4139
* that loads GSP views relative to the project base directory for unit tests.
@@ -66,11 +64,6 @@ public Resource getResource(String location) {
6664
return new ByteArrayResource(this.groovyPages.get(location).getBytes(StandardCharsets.UTF_8), location);
6765
}
6866

69-
if (this.basePath == null) {
70-
String basedir = BuildSettings.BASE_DIR.getAbsolutePath();
71-
this.basePath = basedir + File.separatorChar + GrailsResourceUtils.VIEWS_DIR_PATH;
72-
}
73-
7467
String path = this.basePath + location;
7568
path = makeCanonical(path);
7669
return new FileSystemResource(path);
@@ -99,6 +92,10 @@ public void afterPropertiesSet() throws Exception {
9992
this.basePath = viewDir;
10093
}
10194
}
95+
if (this.basePath == null) {
96+
String appDir = BuildSettings.GRAILS_APP_DIR.getAbsolutePath();
97+
this.basePath = appDir + File.separatorChar + "views";
98+
}
10299
}
103100

104101
}

0 commit comments

Comments
 (0)