diff --git a/README.md b/README.md index 13110a8a..dc83eed3 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,14 @@ see wiki for more information: [wiki](https://github.com/thmarx/cms/wiki) ## 5.3.0 -* **MAINTENANCE** Refactoring packages [#228](https://github.com/thmarx/cms/issues/228) +* **BUG** CMSRequestContext is empty in HookSystemRegisterExtentionPoint [#232](https://github.com/thmarx/cms/issues/232) * **FEATURE** Add HttpRequest to RequestFeature [#230](https://github.com/thmarx/cms/issues/230) * **FEATURE** Automatic load lof4j config from app directory [#229](https://github.com/thmarx/cms/issues/229) * **FEATURE** Make ShortCodes callable from template code [#219](https://github.com/thmarx/cms/issues/219) +* **MAINTENANCE** Refactoring packages [#228](https://github.com/thmarx/cms/issues/228) +* **MAINTENANCE** Performance optimizations [#234](https://github.com/thmarx/cms/issues/234) +* **MAINTENANCE** Update jetty dependency [#233](https://github.com/thmarx/cms/issues/233) +* **MAINTENANCE** Test suite [#231](https://github.com/thmarx/cms/issues/231) ## 5.2.0 diff --git a/cms-content/src/main/java/com/github/thmarx/cms/content/views/ViewParser.java b/cms-content/src/main/java/com/github/thmarx/cms/content/views/ViewParser.java index 62d7e74b..aa37500f 100644 --- a/cms-content/src/main/java/com/github/thmarx/cms/content/views/ViewParser.java +++ b/cms-content/src/main/java/com/github/thmarx/cms/content/views/ViewParser.java @@ -2,9 +2,6 @@ import com.github.thmarx.cms.content.views.model.View; import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; diff --git a/cms-extensions/src/main/java/com/github/thmarx/cms/extensions/ExtensionManager.java b/cms-extensions/src/main/java/com/github/thmarx/cms/extensions/ExtensionManager.java index 61a9f4be..f576684f 100644 --- a/cms-extensions/src/main/java/com/github/thmarx/cms/extensions/ExtensionManager.java +++ b/cms-extensions/src/main/java/com/github/thmarx/cms/extensions/ExtensionManager.java @@ -129,21 +129,6 @@ public RequestExtensions newContext(Theme theme, RequestContext requestContext) .fileSystem(new ExtensionFileSystem(db.getFileSystem().resolve("extensions/"), theme.extensionsPath())) .build()) .engine(engine).build(); - /* - Context themeContext = null; - if (!theme.empty()) { - themeContext = Context.newBuilder() - .allowAllAccess(true) - .allowHostClassLookup(className -> true) - .allowHostAccess(HostAccess.ALL) - .allowValueSharing(true) - .hostClassLoader(getClassLoader()) - .allowIO(IOAccess.newBuilder() - .fileSystem(new ExtensionFileSystem(theme.extensionsPath())) - .build()) - .engine(engine).build(); - } - */ RequestExtensions requestExtensions = new RequestExtensions(context); diff --git a/cms-server/hosts/features/extensions/http.extension.js b/cms-server/hosts/features/extensions/http.extension.js index 475e6f1a..1bd944c9 100644 --- a/cms-server/hosts/features/extensions/http.extension.js +++ b/cms-server/hosts/features/extensions/http.extension.js @@ -15,7 +15,7 @@ $hooks.registerAction("system/server/http/extension", (context) => { "/test2", (request, response) => { response.addHeader("Content-Type", "text/html; charset=utf-8") - response.write("ich bin einen test extension, registered via hook!", UTF_8) + response.write("http extension via hook!", UTF_8) } ) return null; diff --git a/cms-server/hosts/features/extensions/template.extension.js b/cms-server/hosts/features/extensions/template.extension.js index 919a6ee2..66022ea7 100644 --- a/cms-server/hosts/features/extensions/template.extension.js +++ b/cms-server/hosts/features/extensions/template.extension.js @@ -10,7 +10,7 @@ $template.registerTemplateSupplier( $hooks.registerAction("system/template/supplier", (context) => { context.arguments().get("suppliers").add( "myName", - () => "My name is Thorsten" + () => "My name is CondationCMS" ) return null; }) diff --git a/cms-server/hosts/features/templates/start.html b/cms-server/hosts/features/templates/start.html index 5c922b6a..2e30e459 100644 --- a/cms-server/hosts/features/templates/start.html +++ b/cms-server/hosts/features/templates/start.html @@ -77,9 +77,9 @@

-
+

- +
diff --git a/distribution/tests/base.tests.js b/distribution/test-suite/base.tests.js similarity index 100% rename from distribution/tests/base.tests.js rename to distribution/test-suite/base.tests.js diff --git a/distribution/test-suite/http-extensions.tests.js b/distribution/test-suite/http-extensions.tests.js new file mode 100644 index 00000000..2c674713 --- /dev/null +++ b/distribution/test-suite/http-extensions.tests.js @@ -0,0 +1,27 @@ +import { check } from 'k6'; +import http from 'k6/http'; + +export const options = { + thresholds: { + http_req_failed: ['rate<0.01'], // http errors should be less than 1% + http_req_duration: ['p(95)<250'], // 95% of requests should be below 200ms + }, +}; + +export default function () { + + + var res = http.get("http://localhost2:1010/extension/test2"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'verify content': (r) => + r.body.includes('http extension via hook!'), + }); + res = http.get("http://localhost2:1010/hello-route"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'verify content': (r) => + r.body.includes('route via hook!'), + }); + +} \ No newline at end of file diff --git a/distribution/tests/load.test.js b/distribution/test-suite/load.test.js similarity index 100% rename from distribution/tests/load.test.js rename to distribution/test-suite/load.test.js diff --git a/distribution/test-suite/module.tests.js b/distribution/test-suite/module.tests.js new file mode 100644 index 00000000..99d4f6d8 --- /dev/null +++ b/distribution/test-suite/module.tests.js @@ -0,0 +1,37 @@ +import { check } from 'k6'; +import http from 'k6/http'; + +export const options = { + thresholds: { + http_req_failed: ['rate<0.01'], // http errors should be less than 1% + http_req_duration: ['p(95)<250'], // 95% of requests should be below 200ms + }, +}; + +export default function () { + + let res = http.get("http://localhost2:1010/example/route"); + check(res, { + 'is status 200': (r) => r.status === 200, + }); + + res = http.get("http://localhost2:1010/module/example-module/world"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'verify content': (r) => + r.body.includes('Hello world!'), + }); + + res = http.get("http://localhost2:1010/example/route"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'verify content': (r) => + r.body.includes('example route\nHELlO: NO-NAME'), + }); + res = http.get("http://localhost2:1010/example/route?name=test-suite"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'verify content': (r) => + r.body.includes('example route\nHELlO: test-suite'), + }); +} \ No newline at end of file diff --git a/distribution/test-suite/template.tests.js b/distribution/test-suite/template.tests.js new file mode 100644 index 00000000..e56fbb71 --- /dev/null +++ b/distribution/test-suite/template.tests.js @@ -0,0 +1,35 @@ +import { check } from 'k6'; +import http from 'k6/http'; + +export const options = { + thresholds: { + http_req_failed: ['rate<0.01'], // http errors should be less than 1% + http_req_duration: ['p(95)<250'], // 95% of requests should be below 200ms + }, +}; + +export default function () { + + + var res = http.get("http://localhost2:1010"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'template supplier via extension hook': (r) => + r.body.includes('My name is CondationCMS'), + }); + res = http.get("http://localhost2:1010"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'template function via extension hook': (r) => + r.body.includes('Hello CondationCMS'), + }); + + res = http.get("http://localhost2:1010"); + check(res, { + 'is status 200': (r) => r.status === 200, + 'template calling a shortcode': (r) => + r.body.includes("Hello CondationCMS, I'm a TAG!"), + }); + + +} \ No newline at end of file