Skip to content
Snippets Groups Projects
Commit 406da094 authored by Sören Henning's avatar Sören Henning
Browse files

Fix build and add test

parent f769f8e7
No related branches found
No related tags found
1 merge request!202Add option to generate load via HTTP
Pipeline #6065 failed
...@@ -13,14 +13,16 @@ repositories { ...@@ -13,14 +13,16 @@ repositories {
} }
dependencies { dependencies {
implementation 'com.google.guava:guava:30.1-jre'
implementation 'com.hazelcast:hazelcast:4.1.1' implementation 'com.hazelcast:hazelcast:4.1.1'
implementation 'com.hazelcast:hazelcast-kubernetes:2.2.1' implementation 'com.hazelcast:hazelcast-kubernetes:2.2.1'
implementation 'org.slf4j:slf4j-simple:1.7.25' implementation 'org.slf4j:slf4j-simple:1.7.25'
implementation 'com.google.guava:guava:30.1-jre'
implementation 'com.google.code.gson:gson:2.8.2'
implementation('org.industrial-devops:titan-ccp-common:0.1.0-SNAPSHOT') { changing = true } implementation('org.industrial-devops:titan-ccp-common:0.1.0-SNAPSHOT') { changing = true }
implementation('org.industrial-devops:titan-ccp-common-kafka:0.1.0-SNAPSHOT') { changing = true } implementation('org.industrial-devops:titan-ccp-common-kafka:0.1.0-SNAPSHOT') { changing = true }
implementation 'org.apache.kafka:kafka-streams:2.6.0' // TODO required? implementation 'org.apache.kafka:kafka-streams:2.6.0' // TODO required?
// Use JUnit test framework // Use JUnit test framework
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.32.0'
} }
package theodolite.commons.workloadgeneration;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.exactly;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.google.gson.Gson;
import java.net.URI;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import titan.ccp.model.records.ActivePowerRecord;
public class HttpRecordSenderTest {
private HttpRecordSender<ActivePowerRecord> httpRecordSender;
private Gson gson;
@Rule
public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort());
@Before
public void setup() {
this.httpRecordSender =
new HttpRecordSender<>(URI.create("http://localhost:" + this.wireMockRule.port()));
this.gson = new Gson();
}
@Test
public void testValidUri() {
this.wireMockRule.stubFor(
post(urlPathEqualTo("/"))
.willReturn(
aResponse()
.withStatus(200)
.withBody("received")));
final ActivePowerRecord record = new ActivePowerRecord("my-id", 12345L, 12.34);
this.httpRecordSender.send(record);
verify(exactly(1), postRequestedFor(urlEqualTo("/"))
.withRequestBody(equalTo(this.gson.toJson(record)))); // toJson
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment