Skip to content
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

verify fails unless it is called after at least 1 second after the call. #129

Closed
ftrofin opened this issue Apr 30, 2015 · 4 comments
Closed

Comments

@ftrofin
Copy link

ftrofin commented Apr 30, 2015

I can't see this reported anywhere but it fails consistently for me. Consider this code:

// createVideo is not retryable automatically if the requests times out
@Test()
public void createVideoWithSocketTimeoutShouldNotRetry() throws Exception {
    mockVCServer = startClientAndServer(port);
    ReferenceId id = ApiTest.makeReferenceId();
    HttpRequest request = createVideoRequest(id);
    StringBody respBody = createVideoSuccessResponse(new VideoId(4205194938001L));
    mockRequestStub(request, 200, unlimited(), respBody, new Delay(TimeUnit.SECONDS, 11));

    try { // Fire the call and check that we got it only once
        VideoProperties props = makeVideoProps("retryWithSocketTimeout", "created by retryWithSocketTimeout test", id);
        props.put(VideoProperties.VideoFieldEnum.REFERENCEID, new ReferenceId(id.toString()));
        vcProxy.createVideo(props);
    }catch(RetryableVideoCloudException e) {
        Thread.sleep(1000); // Seems necessary or the verify below will fail
        mockVCServer.verify(request, VerificationTimes.once());
        return;
    }
    fail("createVideoWithSocketTimeoutShouldNotRetry did not get the expected exception");
}

private void mockRequestStub(HttpRequest request, int statusCode, Times times, Body body, Delay delay) {
    HttpResponse response = response()
            .withStatusCode(statusCode)
            .withHeaders(new Header("Content-Type", "application/json; charset=utf-8"));
    if (body != null)
        response.withBody(body);
    if (delay != null)
        response.withDelay(delay);

    mockVCServer.when(request, times).respond(response);
}

The verify fails consistently. It says that it did not see any request. It is lying. If I put a delay of at least 1 second just before it it works! Same if I run it in the debugger with a breakpoint on the verify.

I'm using version 3.9.2. Any newer versions than this fail at runtime with this callstack:

com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "not": org.mockserver.client.serialization.model.NotDTO#getNot(0 params) vs org.mockserver.client.serialization.model.NotDTO#isNot(0 params) (through reference chain: org.mockserver.client.serialization.model.ExpectationDTO["httpResponse"]->com.google.common.collect.TransformingRandomAccessList[0])
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:897)
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:429)
at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.java:38)
at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase._findAndAddDynamic(AsArraySerializerBase.java:277)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:90)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:21)
at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:180)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:120)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1728)
at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:258)
at com.fasterxml.jackson.core.JsonGenerator.writeObjectField(JsonGenerator.java:1110)
at org.mockserver.client.serialization.serializers.response.HttpResponseDTOSerializer.serialize(HttpResponseDTOSerializer.java:26)
at org.mockserver.client.serialization.serializers.response.HttpResponseDTOSerializer.serialize(HttpResponseDTOSerializer.java:13)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:544)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:551)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:143)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:120)
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:610)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:530)
at org.mockserver.client.serialization.ExpectationSerializer.serialize(ExpectationSerializer.java:26)
at org.mockserver.client.server.MockServerClient.sendExpectation(MockServerClient.java:178)
at org.mockserver.client.server.ForwardChainExpectation.respond(ForwardChainExpectation.java:24)
at com.adobe.ccv.service.videocloud.test.VideoCloudMockedApiTest.mockRequestStub(VideoCloudMockedApiTest.java:79)
at com.adobe.ccv.service.videocloud.test.VideoCloudMockedApiTest.createVideoWithSocketTimeoutShouldNotRetry(VideoCloudMockedApiTest.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.IllegalArgumentException: Conflicting getter definitions for property "not": org.mockserver.client.serialization.model.NotDTO#getNot(0 params) vs org.mockserver.client.serialization.model.NotDTO#isNot(0 params)
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getGetter(POJOPropertyBuilder.java:164)
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getAccessor(POJOPropertyBuilder.java:257)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.removeIgnorableTypes(BeanSerializerFactory.java:665)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.java:544)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.java:360)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.java:247)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:198)
at com.fasterxml.jackson.databind.ser.SerializerFactory.createSerializer(SerializerFactory.java:53)
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:935)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:892)
... 53 more

@jamesdbloom
Copy link
Collaborator

This has been fixed in #127, that fix is not yet realised but will be very soon (i.e. ~1-2 days)

I suspect you are having the problem because your project is explicitly specifying a Jackson version. If you do not want to wait for the fixed version of MockServer to be released please upgrade your Jackson version, as per #127.

@jamesdbloom
Copy link
Collaborator

I'm going to mark this as closed once I have released the new version if you're still having an issue please re-open.

@ftrofin
Copy link
Author

ftrofin commented Apr 30, 2015

Hi James,

Thanks for the quick reply. I do specify a version for Jackson in my parent
POM:

org.codehaus.jackson jackson-mapper-lgpl 1.9.13

This is the latest version of jackson. The issue (serialization error)
happened with this version.
Regarding the verify() behavior I reported: did you fix that in a later
version?

Thanks for your help,

Florin

On Thu, Apr 30, 2015 at 12:33 AM, James D Bloom notifications@github.com
wrote:

This has been fixed in #127
#127, that fix is not
yet realised but will be very soon (i.e. ~1-2 days)

I suspect you are having the problem because your project is explicitly
specifying a Jackson version. If you do not want to wait for the fixed
version of MockServer to be released please upgrade your Jackson version.


Reply to this email directly or view it on GitHub
#129 (comment)
.

@ftrofin
Copy link
Author

ftrofin commented Apr 30, 2015

I see. Jackson switched package names a while ago and 1.9.13 is the "latest" but is not maintained anymore. Arghh, this will be a lot of pain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants