java


Testing async controllers using MockMvc


I have a controller that returns a DeferredResult, it is a POST.
Controller:
#RequestMapping(value = "/{customerId}/cards", method = RequestMethod.POST)
#ResponseBody
public DeferredResult<CardSummaryQuery> createCard(
#PathVariable String customerId,
#RequestBody CustomerDto payload) {
DeferredResult<CardSummaryQuery> deferred = new DeferredResult<>();
Observable<CardSummaryQuery> observable =
cardService.registerCardObservable(customerId, payload);
observable.subscribe(deferred::setResult, deferred::setErrorResult);
return deferred;
}
I am trying to test it but receiving the following error: "java.lang.AssertionError: Content type not set"
MvcResult result = mockMvc
.perform(post("/customers/55e5d-4df4r-v4fgt/cards").content(payload)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(request().asyncStarted())
.andExpect(request().asyncResult("Deferred result")).andReturn();
mockMvc.perform(asyncDispatch(result)).andExpect(jsonPath("$.success").value(true));
What can I do to solve?

Related Links

Can Java Logger output not get written if an Exception occurs immediately after Log.info call?
Implementing webservice provider + sts
How can I get all the indexes of a Particular String in String Array?
How to switch between different statements in a loop
Get ASIN from amazon's URL
Spring 4.2 combine multiple ListenableFutures
Rewrite url on Spring Zuul server
Can I use a java policy file to safely run an un-trusted app with sudo
Is there a way to reset the buffer when using ReversedLinesFileReader?
How to get file path from JavaFX FileChooser?
I want to find the range of the week between a given date
Is it safe to serialize a class instance with a resource reference attribute?
Annotation Processing Tool add code to existing class
List Selection Item
Durable queues using Spring Rabbitmq Stomp
Java generics, Unbound wildcards <?> vs <Object>

Categories

HOME
mockito
drivers
mfc
nullpointerexception
smarty
jsrender
cakephp-2.5
fancybox
applepay
slick-slider
session-variables
vifm
rascal
nstableview
hapi
dynamics-crm-online
serverless-framework
libtiff
saxon
fatal-error
textfield
predix
zapier
one-hot-encoding
dcevm
tapestry
kvc
django-storage
typo3-6.2.x
windows-server-2000
google-cloud-nl
delicious-api
phonegap
functor
rotational-matrices
mapdb
revolution-slider
tasker
bootstrap-dialog
thin
filepicker
strptime
jquery-validate
blogengine.net
typescript1.8
return-value
dotnetzip
nativeapplication
sqlclient
android-cursor
r-forge
akka-cluster
parallel-data-warehouse
slicknav
etsy
bstr
lua-5.1
make-install
kendonumerictextbox
rtbkit
maven-tomcat-plugin
thredds
tmuxinator
spidermonkey
iis-arr
ideamart
php-ci
mono-embedding
unity3d-gui
coldbox
xcode-6.2
titanium-modules
markers
castle
phpthumb
kgdb
monomac
viadeo
.aspxauth
google-cloud-save
quartz-graphics
ftps
flash-builder4.5
jplaton
ora-00911
gwt-rpc
back-stack
cascalog
tridion-worldserver
chrono
gwt-ext
android-sdk-2.1
.nettiers
suppress
fixed-width
mtj
yagni
port-number
spec#
caching-application-block

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile