-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Knotx/knotx-template-engine#20 Pebble Template Engine Integration Test
- Loading branch information
Showing
9 changed files
with
269 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/functionalTest/java/io/knotx/stack/functional/PebbleTemplateEngineIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2019 Knot.x Project | ||
* | ||
* 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 | ||
* | ||
* http://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 io.knotx.stack.functional; | ||
|
||
import io.knotx.junit5.KnotxApplyConfiguration; | ||
import io.knotx.junit5.KnotxExtension; | ||
import io.knotx.junit5.RandomPort; | ||
import io.knotx.stack.KnotxServerTester; | ||
import io.vertx.junit5.VertxTestContext; | ||
import io.vertx.reactivex.core.Vertx; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestInstance.Lifecycle; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@ExtendWith(KnotxExtension.class) | ||
@TestInstance(Lifecycle.PER_CLASS) | ||
class PebbleTemplateEngineIntegrationTest { | ||
|
||
@Test | ||
@DisplayName("Expect page with markup processed by Pebble Template Engine") | ||
@KnotxApplyConfiguration({"conf/application.conf", | ||
"scenarios/pebble-template-engine/mocks.conf", | ||
"scenarios/pebble-template-engine/tasks.conf"}) | ||
void requestPage(VertxTestContext context, Vertx vertx, | ||
@RandomPort Integer globalServerPort) { | ||
// when | ||
KnotxServerTester serverTester = KnotxServerTester.defaultInstance(globalServerPort); | ||
serverTester.testGetRequest(context, vertx, | ||
"/content/fullPebblePage.html?parameter%20with%20space=value&q=knotx", | ||
"results/fullPage.html"); | ||
} | ||
} |
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
src/functionalTest/resources/conf/knots/pebbleTemplateEngineKnot.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Vert.x event bus delivery options used when communicating with other verticles | ||
address = knotx.knot.te.pebble | ||
|
||
engine { | ||
factory = pebble | ||
config = { | ||
# Algorithm used to build a hash key of the compiled pebble templates. | ||
# The hash is computed for the snippet pebble source code using a selected algorithm. | ||
# The name should be a standard Java Security name (such as "SHA", "MD5", and so on). | ||
# Default value is MD5 | ||
# | ||
# cacheKeyAlgorithm = MD5 | ||
|
||
# Size of the compiled snippets cache. After reaching the max size, new elements will replace the oldest one. | ||
cacheSize = 1000 | ||
|
||
syntax = { | ||
# strictVariables = true | ||
} | ||
} | ||
} | ||
|
14 changes: 11 additions & 3 deletions
14
src/functionalTest/resources/conf/knots/templateEngineStack.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
########### Template Engine Stack ########### | ||
modules { | ||
templateEngine = "io.knotx.te.core.TemplateEngineKnot" | ||
hbsTemplateEngine = "io.knotx.te.core.TemplateEngineKnot" | ||
pebbleTemplateEngine = "io.knotx.te.core.TemplateEngineKnot" | ||
} | ||
|
||
########### Modules configurations ########### | ||
config.templateEngine { | ||
config.hbsTemplateEngine { | ||
options.config { | ||
include required(classpath("conf/knots/templateEngineKnot.conf")) | ||
include required(classpath("conf/knots/hbsTemplateEngineKnot.conf")) | ||
} | ||
} | ||
|
||
########### Modules configurations ########### | ||
config.pebbleTemplateEngine { | ||
options.config { | ||
include required(classpath("conf/knots/pebbleTemplateEngineKnot.conf")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<!-- | ||
Copyright (C) 2019 Knot.x Project | ||
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 | ||
http://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. | ||
--> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="shortcut icon" href="http://cognifide.com/favicon.ico?v=2"/> | ||
<title>Knot.x</title> | ||
<link href="https://bootswatch.com/4/simplex/bootstrap.min.css" rel="stylesheet"/> | ||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="jumbotron"> | ||
<h2> | ||
Hello Knot.x - reactive micro-service assembler world! | ||
</h2> | ||
<p> | ||
This template is served from the <strong>local</strong> repository. | ||
</p> | ||
<p> | ||
<a class="btn btn-primary btn-large" | ||
href="https://github.com/Knotx/knotx">Learn more</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<knotx:snippet data-knotx-task="books-and-authors-listing"> | ||
<div class="col-md-4"> | ||
<h2>Book</h2> | ||
<p>{{book._result.title}}</p> | ||
<p>Authors: {{book._result.info.authors}}</p> | ||
<div>Success! Status code : {{book._response.metadata.statusCode}}</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<h2>Author</h2> | ||
<p>{{author._result.name}}</p> | ||
<p>Bio: {{author._result.info.bio}}</p> | ||
<div>Success! Status code : {{author._response.metadata.statusCode}}</div> | ||
</div> | ||
</knotx:snippet> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<knotx:snippet data-knotx-task="authors-listing"> | ||
<h2>Portfolio: </h2> | ||
<ul> | ||
{% for this in author._result.info.portfolio %} | ||
<li>{{this}}</li> | ||
{% endfor %} | ||
</ul> | ||
</knotx:snippet> | ||
</div> | ||
<div class="col-md-4"> | ||
<knotx:snippet data-knotx-task="books-listing"> | ||
<h2>Tags: </h2> | ||
<ul> | ||
{% for this in book._result.info.tags %} | ||
<li>{{this}}</li> | ||
{% endfor %} | ||
</ul> | ||
</knotx:snippet> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
src/functionalTest/resources/scenarios/pebble-template-engine/mocks.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
########### Knot.x JUnit5 config ########### | ||
test.wiremock { | ||
mockRepository.port = 0 | ||
mockService.port = 0 | ||
} |
89 changes: 89 additions & 0 deletions
89
src/functionalTest/resources/scenarios/pebble-template-engine/tasks.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
global.handler.fragmentsHandler.config { | ||
tasks { | ||
tags-listing { | ||
action = tags | ||
onTransitions { | ||
_success { | ||
action = te-pebble | ||
} | ||
_error { | ||
action = tags-fallback | ||
} | ||
} | ||
} | ||
books-listing { | ||
action = book | ||
onTransitions { | ||
_success { | ||
action = te-pebble | ||
} | ||
} | ||
} | ||
authors-listing { | ||
action = author | ||
onTransitions { | ||
_success { | ||
action = te-pebble | ||
} | ||
} | ||
} | ||
books-and-authors-listing { | ||
actions = [ | ||
{ | ||
action = book | ||
}, | ||
{ | ||
action = author | ||
} | ||
] | ||
onTransitions { | ||
_success { | ||
action = te-pebble | ||
} | ||
} | ||
} | ||
} | ||
|
||
actions { | ||
book { | ||
factory = http | ||
config { | ||
endpointOptions { | ||
path = /service/mock/book.json | ||
domain = localhost | ||
port = ${test.wiremock.mockService.port} | ||
allowedRequestHeaders = ["Content-Type"] | ||
} | ||
} | ||
} | ||
author { | ||
factory = http | ||
config { | ||
endpointOptions { | ||
path = /service/mock/author.json | ||
domain = localhost | ||
port = ${test.wiremock.mockService.port} | ||
allowedRequestHeaders = [ "Content-Type" ] | ||
} | ||
} | ||
} | ||
} | ||
|
||
taskFactories = [ | ||
{ | ||
factory = default | ||
config { | ||
tasks = ${global.handler.fragmentsHandler.config.tasks} | ||
nodeFactories = [ | ||
{ | ||
factory = action | ||
config.actions = ${global.handler.fragmentsHandler.config.actions} | ||
} | ||
{ | ||
factory = subtasks | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |