Methods Summary |
---|
private com.google.gdata.data.Entry | createEntry()
Entry e = new Entry();
e.setTitle(new PlainTextConstruct("Test"));
return e;
|
private com.google.gdata.data.Feed | createFeed()
Feed feed = new Feed();
feed.getEntries().add(createEntry());
return feed;
|
protected void | setUp()
this.control = MockControl.createControl(HttpServletResponse.class);
this.httpResponse = (HttpServletResponse)this.control.getMock();
this.response = new GDataResponse(this.httpResponse);
|
protected void | tearDown()
super.tearDown();
|
public void | testConstructor()
try{
new GDataResponse(null);
fail("IllegalArgumentExceptin expected");
}catch (IllegalArgumentException e) {
// TODO: handle exception
}
|
public void | testSendResponseBaseEntryExtensionProfile()
try{
Entry e = null;
this.response.sendResponse(e, new ProvidedServiceStub());
fail("Exception expected");
}catch (IllegalArgumentException e) {
//
}
try{
Entry e = createEntry();
this.response.sendResponse(e,null);
fail("Exception expected");
}catch (IllegalArgumentException e) {
//
}
// // test Atom output
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
this.control.expectAndReturn(this.httpResponse.getWriter(),writer);
this.httpResponse.setContentType(GDataResponse.XMLMIME_ATOM);
this.response.setOutputFormat(OutputFormat.ATOM);
this.control.replay();
this.response.sendResponse(createEntry(), new ProvidedServiceStub());
assertEquals("Simple XML representation ATOM",stringWriter.toString(),generatedEntryAtom);
// test rss output
this.control.reset();
stringWriter = new StringWriter();
writer = new PrintWriter(stringWriter);
this.control.expectAndReturn(this.httpResponse.getWriter(),writer);
this.httpResponse.setContentType(GDataResponse.XMLMIME_RSS);
this.response.setOutputFormat(OutputFormat.RSS);
this.control.replay();
this.response.sendResponse(createEntry(), new ProvidedServiceStub());
assertEquals("Simple XML representation RSS",stringWriter.toString(),generatedEntryRSS);
|
public void | testSendResponseBaseFeedExtensionProfile()
try{
Feed f = null;
this.response.sendResponse(f, new ProvidedServiceStub());
fail("Exception expected");
}catch (IllegalArgumentException e) {
//
}
try{
Feed f = createFeed();
this.response.sendResponse(f,null);
fail("Exception expected");
}catch (IllegalArgumentException e) {
//
}
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
this.control.expectAndReturn(this.httpResponse.getWriter(),writer);
this.httpResponse.setContentType(GDataResponse.XMLMIME_ATOM);
this.response.setOutputFormat(OutputFormat.ATOM);
this.control.replay();
this.response.sendResponse(createFeed(), new ProvidedServiceStub());
assertEquals("Simple XML representation",stringWriter.toString(),generatedFeedAtom);
this.control.reset();
stringWriter = new StringWriter();
writer = new PrintWriter(stringWriter);
this.control.expectAndReturn(this.httpResponse.getWriter(),writer);
this.response.setOutputFormat(OutputFormat.RSS);
this.httpResponse.setContentType(GDataResponse.XMLMIME_RSS);
this.control.replay();
this.response.sendResponse(createFeed(), new ProvidedServiceStub());
assertEquals("Simple XML representation",stringWriter.toString(),generatedFeedRSS);
|