diff --git a/.idea/misc.xml b/.idea/misc.xml
index 1eb8d79..2d17eca 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -17,6 +17,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts
index 3f2e9ce..2bd34c1 100644
--- a/lib/build.gradle.kts
+++ b/lib/build.gradle.kts
@@ -25,6 +25,7 @@ dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
+ testImplementation("org.assertj:assertj-core:3.24.2")
}
configurations {
diff --git a/lib/src/main/java/rife/render/DateIso.java b/lib/src/main/java/rife/render/DateIso.java
index c32cccb..d5565d4 100644
--- a/lib/src/main/java/rife/render/DateIso.java
+++ b/lib/src/main/java/rife/render/DateIso.java
@@ -21,7 +21,6 @@ import rife.template.Template;
import rife.template.ValueRenderer;
import rife.tools.Localization;
-import java.text.DateFormat;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
diff --git a/lib/src/main/java/rife/render/SwapCase.java b/lib/src/main/java/rife/render/SwapCase.java
index 943e98d..f534915 100644
--- a/lib/src/main/java/rife/render/SwapCase.java
+++ b/lib/src/main/java/rife/render/SwapCase.java
@@ -40,6 +40,7 @@ public class SwapCase implements ValueRenderer {
* @param src the String to swap the case of
* @return the modified String or null
*/
+ @SuppressWarnings("PMD.AvoidReassigningLoopVariables")
public static String swapCase(final String src) {
if (src == null || src.isEmpty()) {
return src;
diff --git a/lib/src/test/java/rife/render/TestDateTime.java b/lib/src/test/java/rife/render/TestDateTime.java
new file mode 100644
index 0000000..6d7e538
--- /dev/null
+++ b/lib/src/test/java/rife/render/TestDateTime.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package rife.render;
+
+import org.junit.jupiter.api.Test;
+import rife.template.TemplateFactory;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+class TestDateTime {
+ @Test
+ void testDateIso() {
+ var t = TemplateFactory.HTML.get("dateIso");
+ assertThatCode(() -> DateIso.iso8601Formatter.parse(t.getContent())).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testDateTimeIso() {
+ var t = TemplateFactory.HTML.get("dateTimeIso");
+ assertThatCode(() -> DateTimeIso.iso8601Formatter.parse(t.getContent())).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testDateTimeRfc2822() {
+ var t = TemplateFactory.HTML.get("dateTimeRfc2822");
+ assertThatCode(() -> DateTimeRfc2822.rfc2822Formatter.parse(t.getContent())).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testTimeIso() {
+ var t = TemplateFactory.HTML.get("timeIso");
+ assertThatCode(() -> TimeIso.iso8601Formatter.parse(t.getContent())).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testYear() {
+ var t = TemplateFactory.HTML.get("year");
+ var year = java.time.Year.now().toString();
+ assertThat(t.getContent()).isEqualTo(year + "
\n" + year);
+ }
+}
diff --git a/lib/src/test/java/rife/render/TestEncode.java b/lib/src/test/java/rife/render/TestEncode.java
new file mode 100644
index 0000000..edff752
--- /dev/null
+++ b/lib/src/test/java/rife/render/TestEncode.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package rife.render;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import rife.template.TemplateFactory;
+
+import static org.assertj.core.api.Assertions.assertThat;
+class TestEncode {
+ @Disabled("Until renderer can access beans")
+ @Test
+ void testEncodeUrl() {
+ var t = TemplateFactory.HTML.get("encodeUrl");
+ t.setBean(new ValueBean("a test &"));
+ var encodedValue = "a%20test%20%26";
+ assertThat(t.getContent()).isEqualTo(encodedValue + "
\n" + encodedValue);
+ }
+}
diff --git a/lib/src/test/java/rife/render/ValueBean.java b/lib/src/test/java/rife/render/ValueBean.java
new file mode 100644
index 0000000..6bf98fc
--- /dev/null
+++ b/lib/src/test/java/rife/render/ValueBean.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package rife.render;
+
+public class ValueBean {
+ private String value;
+
+ ValueBean(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/lib/src/test/resources/templates/dateIso.html b/lib/src/test/resources/templates/dateIso.html
new file mode 100644
index 0000000..754a329
--- /dev/null
+++ b/lib/src/test/resources/templates/dateIso.html
@@ -0,0 +1 @@
+{{v render:rife.render.DateIso/}}
\ No newline at end of file
diff --git a/lib/src/test/resources/templates/dateTimeIso.html b/lib/src/test/resources/templates/dateTimeIso.html
new file mode 100644
index 0000000..b4f05a1
--- /dev/null
+++ b/lib/src/test/resources/templates/dateTimeIso.html
@@ -0,0 +1 @@
+{{v render:rife.render.DateTimeIso/}}
\ No newline at end of file
diff --git a/lib/src/test/resources/templates/dateTimeRfc2822.html b/lib/src/test/resources/templates/dateTimeRfc2822.html
new file mode 100644
index 0000000..c2ec0de
--- /dev/null
+++ b/lib/src/test/resources/templates/dateTimeRfc2822.html
@@ -0,0 +1 @@
+{{v render:rife.render.DateTimeRfc2822/}}
\ No newline at end of file
diff --git a/lib/src/test/resources/templates/encodeUrl.html b/lib/src/test/resources/templates/encodeUrl.html
new file mode 100644
index 0000000..9203592
--- /dev/null
+++ b/lib/src/test/resources/templates/encodeUrl.html
@@ -0,0 +1,2 @@
+}
+{{v render:rife.render.EncodeUrl:value/}}
\ No newline at end of file
diff --git a/lib/src/test/resources/templates/timeIso.html b/lib/src/test/resources/templates/timeIso.html
new file mode 100644
index 0000000..08c13b5
--- /dev/null
+++ b/lib/src/test/resources/templates/timeIso.html
@@ -0,0 +1 @@
+{{v render:rife.render.TimeIso/}}
\ No newline at end of file
diff --git a/lib/src/test/resources/templates/year.html b/lib/src/test/resources/templates/year.html
new file mode 100644
index 0000000..15637e5
--- /dev/null
+++ b/lib/src/test/resources/templates/year.html
@@ -0,0 +1,2 @@
+
+{{v render:rife.render.Year/}}
\ No newline at end of file