Search code examples
javarequestspark-java

How to Create a Request and Response objects in Java-Spark microservice framework?


There is a scenario which I'm currently facing where I have to manually create an instance of the spark.Request & spark.Responseobject. Can anyone help me with this?


Solution

  • I am creating both request and response objects for testing purposes.

    My implementation looks like this

    package spark;
    
    public class RequestStub extends Request {
        // Implement the methods needed
        // I fake my return values
    }
    

    This works well for testing.

    If this isn't what you need, then please share more details and perhaps a code sample to describe your problem.