-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JUNIT: Migrate assets dispatcher test to Kotlin #1341
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5cb54fb
moved groovy file to new location
MOOOOOSER 62cb44d
adapted Kotlin Syntax
MOOOOOSER 914b9d1
removed unnecessary '
MOOOOOSER 02620df
deleted old file
MOOOOOSER 3697ac0
Using correct Test annotation
MOOOOOSER 7dc64a1
Set required system property early on startup
mkeckmkeck 6046138
applied changes
MOOOOOSER File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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: 0 additions & 47 deletions
47
src/test/java/sirius/web/dispatch/AssetsDispatcherSpec.groovy
This file was deleted.
Oops, something went wrong.
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,8 +16,7 @@ class CORSSpec extends BaseSpecification { | |||||||||||||
|
||||||||||||||
def "expect 'Access-Control-Allow-Origin' for requests with 'origin'"() { | ||||||||||||||
when: | ||||||||||||||
// Allow us to set the Origin: header... | ||||||||||||||
System.setProperty("sun.net.http.allowRestrictedHeaders", "true") | ||||||||||||||
// Setting the "Origin: header" must be allowed by -Dsun.net.http.allowRestrictedHeaders=true | ||||||||||||||
HttpURLConnection c = new URL("http://localhost:9999/system/ok").openConnection() | ||||||||||||||
c.addRequestProperty("Origin", "TEST") | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
|
62 changes: 62 additions & 0 deletions
62
src/test/kotlin/sirius/web/dispatch/AssetDispatcherTest.kt
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,62 @@ | ||
/* | ||
* Made with all the love in the world | ||
* by scireum in Remshalden, Germany | ||
* | ||
* Copyright by scireum GmbH | ||
* http://www.scireum.de - info@scireum.de | ||
*/ | ||
|
||
package sirius.web.dispatch | ||
|
||
import io.netty.handler.codec.http.HttpHeaderNames | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.CsvSource | ||
import sirius.kernel.SiriusExtension | ||
import sirius.web.sass.Output | ||
import java.io.StringWriter | ||
import java.net.URL | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
|
||
/** | ||
* Tests the [AssetsDispatcher] class. | ||
*/ | ||
@ExtendWith(SiriusExtension::class) | ||
class AssetsDispatcherTest { | ||
@CsvSource( | ||
delimiter = '|', useHeadersInDisplayName = true, textBlock = """ | ||
uri | header | ||
/assets/test/test.css | public, max-age=21600 | ||
/assets/test/test.txt | public, max-age=21600 | ||
/assets/test/test.js | public, max-age=21600 | ||
/assets/no-cache/test/test.css | no-cache, max-age=0 | ||
/assets/no-cache/test/test.txt | no-cache, max-age=0 | ||
/assets/no-cache/test/test.js | no-cache, max-age=0 | ||
/assets/dynamic/X/test/test.css | public, max-age=615168000 | ||
/assets/dynamic/X/test/test.txt | public, max-age=615168000 | ||
/assets/dynamic/X/test/test.js | public, max-age=615168000""" | ||
) | ||
@ParameterizedTest | ||
fun `proper caching set for all kind of assets and cache-control URIs`(uri: String, header: String) { | ||
val connection = URL("http://localhost:9999" + uri).openConnection() | ||
assertEquals(header, connection.getHeaderField(HttpHeaderNames.CACHE_CONTROL.toString())) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: Remove empty line |
||
} | ||
|
||
@Test | ||
fun `Custom base64ResourceFunction works`() { | ||
val generator = SiriusSassGenerator() | ||
generator.importStylesheet("/assets/test_base64.scss") | ||
generator.compile() | ||
|
||
val writer = StringWriter() | ||
generator.generate(Output(writer, true)) | ||
assertEquals( | ||
"test { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QsODw4S4KU/XgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAdElEQVRYw+3Q3Q1AMAAA4ar+qHhghq7SBQ3CPsQO5a1JS0wh+nA3wZdr5hBEfUlRZbBgwYIFCxYsWLBgwYIFCxYsWLBgwYIFCxYsWLBgfZSqDRRtWv1eC2vx2zFGV7S5pX2U+n3M2SWX1ZCNv6a+aHNL/bQvbxUXkThEKBQAAAAASUVORK5CYII=); }\n ", | ||
writer.toString() | ||
) | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: Rename
c
toconnection