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

Maven does not download dependencies which it requires for an external project
Build path entry is missing in eclipse
Java: Strange output with printstream, why toString doesn't convert?
minecraft wont run on eclipse
How to Connect My Home Layout to Ringdroid layout Android
Running Arquillian App Engine Container Test
Why calling this function recursively does not throw a NullPointerException
JAVA - Answers are not calculating upon output?
Testing GWT and GAE
Making a class loader
Android - Canvas Doesn't Show
Java TimerTask already scheduled or deleted
How do you randomize an array in netbeans using a List?
Fractions Reducing Function
RegId required: java.io.FileNotFoundException: GCMRegId.txt (The system cannot find the file specified)
Java, write in file by saving the old inputs and adding the new inputs in new lines

Categories

HOME
vim
oracle11g
activiti
heroku
tinymce
onedrive
electron
cplex
adb
survey
ip
angular-ui-bootstrap
ravendb
fancybox
basic
medical
maude-system
google-cloud-spanner
remote-access
task
fortumo
decomposition
fatal-error
windows-7-x64
serilog
viewport
paging
functional-testing
pass-by-reference
ping
large-file-upload
libuv
sql-server-2012-express
key-value-observing
framemaker
y86
html5-fullscreen
wixsharp
simplexml
space-complexity
withings
twitch
trim
ensembles
import-from-excel
acoustics
angular-resource
rainbowtable
filepicker
theming
veracode
composite-key
magma
zendesk-app
mcafee
firmata
azure-sdk
probability-density
azure-virtual-network
thrust
ready-api
kendonumerictextbox
tcpserver
msys
endeca-workbench
cyclomatic-complexity
feedback
fluid-dynamics
bigbluebutton
rake-task
dd
network-interface
internet-connection
app42
java.nio.file
mcts
ms-project-server-2010
mqx
sharp-repository
html-editor
android-hardware
e4x
unc
gil
cisco-jtapi
broken-links
dice
onsubmit
code-cleanup
work-stealing
gnustep
doh
coredump
xtype
datareader
web-application-design
wise
nhibernate.search
asp.net-profiles
webkit.net
uimenucontroller
eqatec
zend-decorators
lzh
ajax-forms
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html