Make sure ThymeleafAutoConfiguration works if imported directly

Before this change if Layout dialect not available then the nested class is
loaded and barfs because it depended on the layout dialect (in a
@ConditionalOnClass annotation).
pull/2/merge
Dave Syer 12 years ago
parent f12b3fbcd7
commit 969c7d6fa1

@ -0,0 +1,11 @@
@Grab("org.thymeleaf:thymeleaf-spring3:2.0.16")
@Controller
class Example {
@RequestMapping("/")
public String helloWorld(Map<String,Object> model) {
model.putAll([title: "My Page", date: new Date(), message: "Hello World"])
return "home";
}
}

@ -62,9 +62,19 @@ TARGETDIR=target/classes
if [ -f build.gradle ]; then if [ -f build.gradle ]; then
TARGETDIR=build/classes/main TARGETDIR=build/classes/main
fi fi
mkdir -p "${TARGETDIR%/}" if [ -f ${TARGETDIR} ]; then
if [ "${CLASSPATH}" == "" ]; then
CLASSPATH="${TARGETDIR}"
else
CLASSPATH="${CLASSPATH}":"${TARGETDIR}"
fi
fi
CLASSPATH="${CLASSPATH}":"${SPRING_BIN}":"${TARGETDIR}" if [ "${CLASSPATH}" == "" ]; then
CLASSPATH="${SPRING_BIN}"
else
CLASSPATH="${CLASSPATH}":"${SPRING_BIN}"
fi
for f in "${SPRING_HOME}"/classes "${SPRING_HOME}"/*.jar "${SPRING_HOME}"/lib/*.jar; do for f in "${SPRING_HOME}"/classes "${SPRING_HOME}"/*.jar "${SPRING_HOME}"/lib/*.jar; do
[ -f $f ] && CLASSPATH="${CLASSPATH}":$f [ -f $f ] && CLASSPATH="${CLASSPATH}":$f

@ -127,6 +127,19 @@ public class SampleIntegrationTests {
assertEquals("World!", result); assertEquals("World!", result);
} }
@Test
public void uiSample() throws Exception {
// To run this one from the command line you need to add target/test-classes to
// CLASSPATH
start("samples/ui.groovy");
String result = FileUtil.readEntirely(new URL("http://localhost:8080")
.openStream());
assertTrue("Wrong output: " + result, result.contains("Hello World"));
result = FileUtil.readEntirely(new URL(
"http://localhost:8080/css/bootstrap.min.css").openStream());
assertTrue("Wrong output: " + result, result.contains("container"));
}
@Test @Test
public void actuatorSample() throws Exception { public void actuatorSample() throws Exception {
start("samples/actuator.groovy"); start("samples/actuator.groovy");

File diff suppressed because one or more lines are too long

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="${title}">Title</title>
<link rel="stylesheet" th:href="@{/resources/css/bootstrap.min.css}"
href="../../resources/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="http://www.thymeleaf.org"> Thymeleaf -
Plain </a>
<ul class="nav">
<li><a th:href="@{/}" href="home.html"> Home </a></li>
</ul>
</div>
</div>
<h1 th:text="${title}">Title</h1>
<div th:text="${message}">Fake content</div>
<div id="created" th:text="${#dates.format(date)}">July 11,
2012 2:17:16 PM CDT</div>
</div>
</body>
</html>

@ -116,7 +116,7 @@ public class ThymeleafAutoConfiguration {
} }
@Configuration @Configuration
@ConditionalOnClass({ LayoutDialect.class }) @ConditionalOnClass(name = "nz.net.ultraq.web.thymeleaf.LayoutDialect")
@ConditionalOnMissingBean(SpringTemplateEngine.class) @ConditionalOnMissingBean(SpringTemplateEngine.class)
protected static class ThymeleafWebLayoutConfiguration { protected static class ThymeleafWebLayoutConfiguration {

Loading…
Cancel
Save