-
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.
Added Jetty12 backed extension and factory and fixed loading via exte…
…nsion factories
- Loading branch information
1 parent
3a44fee
commit b673ea1
Showing
21 changed files
with
995 additions
and
22 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
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,3 +1,4 @@ | ||
rootProject.name = 'wiremock-grpc-extension' | ||
|
||
include 'wiremock-grpc-extension-standalone' | ||
include 'wiremock-grpc-extension-jetty12' |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
37 changes: 37 additions & 0 deletions
37
src/testFixtures/resources/wiremock/mappings/hello-world.json
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,37 @@ | ||
{ | ||
"mappings": [{ | ||
"request": { | ||
"headers": {"Accept": {"or": [ | ||
{"equalTo": "*/*"}, | ||
{"equalTo": "text/plain"} | ||
]}}, | ||
"method": "GET", | ||
"urlPath": "/hello" | ||
}, | ||
"metadata": {"mocklab": { | ||
"response-example-attachment": "Hello World", | ||
"created": { | ||
"at": "2024-01-09T15:32:35.424189986Z", | ||
"by": "vqe9q", | ||
"via": "ADMIN_API" | ||
}, | ||
"updated": { | ||
"at": "2024-01-09T15:34:11.584464236Z", | ||
"by": "vqe9q", | ||
"via": "ADMIN_API" | ||
} | ||
}}, | ||
"response": { | ||
"headers": {"Content-Type": "text/plain"}, | ||
"body": "Hello World!", | ||
"status": 200 | ||
}, | ||
"name": "Hello", | ||
"postServeActions": [], | ||
"id": "d469c289-22fb-4186-90ab-deb6ffb6db5c", | ||
"persistent": true, | ||
"priority": 5, | ||
"uuid": "d469c289-22fb-4186-90ab-deb6ffb6db5c" | ||
}], | ||
"meta": {"total": 1} | ||
} |
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,146 @@ | ||
buildscript { | ||
repositories { | ||
maven { | ||
url "https://oss.sonatype.org" | ||
} | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java-library' | ||
id 'java-test-fixtures' | ||
id 'signing' | ||
id 'maven-publish' | ||
id 'idea' | ||
id 'eclipse' | ||
id 'project-report' | ||
id 'com.diffplug.spotless' version '6.25.0' | ||
id 'com.github.johnrengelman.shadow' version '8.1.1' | ||
id "com.google.protobuf" version "0.9.4" | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
group 'org.wiremock' | ||
|
||
dependencies { | ||
api project(":"), { | ||
exclude group: 'org.eclipse.jetty' | ||
exclude group: 'org.eclipse.jetty.http2' | ||
} | ||
api "org.wiremock:wiremock-jetty12:$versions.wiremock" | ||
|
||
testImplementation(testFixtures(project(":")), { | ||
exclude group: 'org.eclipse.jetty' | ||
exclude group: 'org.eclipse.jetty.http2' | ||
}) | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
archiveClassifier.set('sources') | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
archiveClassifier.set('javadoc') | ||
from javadoc.destinationDir | ||
} | ||
|
||
task testJar(type: Jar, dependsOn: testClasses) { | ||
archiveClassifier.set('tests') | ||
from sourceSets.test.output | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = "https://maven.pkg.github.com/wiremock/wiremock-grpc-extension" | ||
credentials { | ||
username = System.getenv("GITHUB_ACTOR") | ||
password = System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
main(MavenPublication) { publication -> | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
artifact testJar | ||
|
||
pom.packaging 'jar' | ||
pom.withXml { | ||
asNode().appendNode('description', 'Mock gRPC services with WireMock') | ||
asNode().children().last() + pomInfo | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
// Docs: https://github.com/wiremock/community/blob/main/infra/maven-central.md | ||
required { | ||
!version.toString().contains("SNAPSHOT") && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishToMavenLocal")) | ||
} | ||
def signingKey = providers.environmentVariable("OSSRH_GPG_SECRET_KEY").orElse("").get() | ||
def signingPassphrase = providers.environmentVariable("OSSRH_GPG_SECRET_KEY_PASSWORD").orElse("").get() | ||
if (!signingKey.isEmpty() && !signingPassphrase.isEmpty()) { | ||
println "Using PGP key from env vars" | ||
useInMemoryPgpKeys(signingKey, signingPassphrase) | ||
} else { | ||
println "Using default PGP key" | ||
} | ||
|
||
sign publishing.publications | ||
} | ||
|
||
assemble.dependsOn clean, shadowJar | ||
publishMainPublicationToMavenLocal.dependsOn jar | ||
publishMainPublicationToGitHubPackagesRepository.dependsOn jar | ||
|
||
|
||
task localRelease { | ||
dependsOn clean, assemble, publishToMavenLocal | ||
} | ||
|
||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "PASSED", "FAILED", "SKIPPED" | ||
exceptionFormat "full" | ||
} | ||
} | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:4.27.5" | ||
} | ||
|
||
plugins { | ||
grpc { | ||
artifact = "io.grpc:protoc-gen-grpc-java:$versions.grpc" | ||
} | ||
} | ||
generateProtoTasks { | ||
all()*.plugins { | ||
grpc { | ||
outputSubDir = 'java' | ||
} | ||
} | ||
|
||
all().each { task -> | ||
task.generateDescriptorSet = true | ||
task.descriptorSetOptions.path = "$projectDir/src/test/resources/wiremock/grpc/services.dsc" | ||
} | ||
} | ||
} | ||
|
||
processTestResources.dependsOn generateProto | ||
processTestResources.dependsOn generateTestProto |
41 changes: 41 additions & 0 deletions
41
...k-grpc-extension-jetty12/src/main/java/org/wiremock/grpc/Jetty12GrpcExtensionFactory.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,41 @@ | ||
/* | ||
* Copyright (C) 2023-2024 Thomas Akehurst | ||
* | ||
* 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 org.wiremock.grpc; | ||
|
||
import com.github.tomakehurst.wiremock.extension.Extension; | ||
import com.github.tomakehurst.wiremock.extension.ExtensionFactory; | ||
import com.github.tomakehurst.wiremock.extension.WireMockServices; | ||
import java.util.List; | ||
|
||
import com.github.tomakehurst.wiremock.http.HttpServerFactoryLoader; | ||
import org.wiremock.annotations.Beta; | ||
import org.wiremock.grpc.internal.GrpcAdminApiExtension; | ||
import org.wiremock.grpc.internal.GrpcHttpServerFactory; | ||
import org.wiremock.grpc.internal.Jetty12GrpcHttpServerFactory; | ||
|
||
@Beta(justification = "Incubating extension: https://github.com/wiremock/wiremock/issues/2383") | ||
public class Jetty12GrpcExtensionFactory implements ExtensionFactory { | ||
|
||
@Override | ||
public List<Extension> create(WireMockServices services) { | ||
return List.of(new Jetty12GrpcHttpServerFactory(services.getStores().getBlobStore("grpc"))); | ||
} | ||
|
||
@Override | ||
public boolean isLoadable() { | ||
return !HttpServerFactoryLoader.isJetty11(); | ||
} | ||
} |
Oops, something went wrong.