|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BlogEntryToPdfActionTest | Line # 48 | 29 | 0% | 6 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (10) | |||
| Result | |||
|
0.17142858
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForUnpublishedBlogEntry
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForUnpublishedBlogEntry
|
1 PASS | |
|
0.17142858
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntry
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntry
|
1 PASS | |
|
0.17142858
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForUnpublishedBlogEntry
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForUnpublishedBlogEntry
|
1 PASS | |
|
0.17142858
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntry
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntry
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNullBlogEntryId
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNullBlogEntryId
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntryInvalidParameterName
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntryInvalidParameterName
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNullBlogEntryId
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNullBlogEntryId
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNonExistingBlogEntryId
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNonExistingBlogEntryId
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntryInvalidParameterName
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForPublishedBlogEntryInvalidParameterName
|
1 PASS | |
|
0.114285715
|
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNonExistingBlogEntryId
net.sourceforge.pebble.web.action.BlogEntryToPdfActionTest.testPdfViewForNonExistingBlogEntryId
|
1 PASS | |
| 1 | /* | |
| 2 | * Copyright (c) 2003-2006, Simon Brown | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions are met: | |
| 7 | * | |
| 8 | * - Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * | |
| 11 | * - Redistributions in binary form must reproduce the above copyright | |
| 12 | * notice, this list of conditions and the following disclaimer in | |
| 13 | * the documentation and/or other materials provided with the | |
| 14 | * distribution. | |
| 15 | * | |
| 16 | * - Neither the name of Pebble nor the names of its contributors may | |
| 17 | * be used to endorse or promote products derived from this software | |
| 18 | * without specific prior written permission. | |
| 19 | * | |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | */ | |
| 32 | package net.sourceforge.pebble.web.action; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.domain.Blog; | |
| 35 | import net.sourceforge.pebble.domain.BlogEntry; | |
| 36 | import net.sourceforge.pebble.domain.BlogService; | |
| 37 | import net.sourceforge.pebble.web.view.View; | |
| 38 | import net.sourceforge.pebble.web.view.PdfView; | |
| 39 | import net.sourceforge.pebble.web.view.BinaryView; | |
| 40 | import net.sourceforge.pebble.web.view.NotFoundView; | |
| 41 | ||
| 42 | ||
| 43 | /** | |
| 44 | * Tests for the BlogEntryToPdfAction class. | |
| 45 | * | |
| 46 | * @author Alexander Zagniotov | |
| 47 | */ | |
| 48 | public class BlogEntryToPdfActionTest extends SingleBlogActionTestCase { | |
| 49 | ||
| 50 | private BlogEntry unpublishedEntry; | |
| 51 | private BlogEntry publishedEntry; | |
| 52 | private BlogService service; | |
| 53 | ||
| 54 | 10 |
protected void setUp() throws Exception { |
| 55 | ||
| 56 | 10 | action = new BlogEntryToPdfAction(); |
| 57 | ||
| 58 | 10 | super.setUp(); |
| 59 | ||
| 60 | 10 | unpublishedEntry = new BlogEntry(blog); |
| 61 | 10 | unpublishedEntry.setTitle("This is some unpublished entry title"); |
| 62 | ||
| 63 | 10 | publishedEntry = new BlogEntry(blog); |
| 64 | 10 | publishedEntry.setTitle("This is some published entry title that is very important"); |
| 65 | 10 | publishedEntry.setPublished(true); |
| 66 | ||
| 67 | 10 | service = new BlogService(); |
| 68 | 10 | service.putBlogEntry(publishedEntry); |
| 69 | 10 | service.putBlogEntry(unpublishedEntry); |
| 70 | } | |
| 71 | ||
| 72 | 2 |
public void testPdfViewForNonExistingBlogEntryId() throws Exception { |
| 73 | 2 | request.setParameter("entry", "88888888888"); |
| 74 | 2 | View view = action.process(request, response); |
| 75 | 2 | assertTrue(view instanceof NotFoundView); |
| 76 | } | |
| 77 | ||
| 78 | 2 |
public void testPdfViewForPublishedBlogEntryInvalidParameterName() throws Exception { |
| 79 | 2 | request.setParameter("momo", publishedEntry.getId()); |
| 80 | 2 | View view = action.process(request, response); |
| 81 | 2 | assertTrue(view instanceof NotFoundView); |
| 82 | } | |
| 83 | ||
| 84 | 2 |
public void testPdfViewForNullBlogEntryId() throws Exception { |
| 85 | 2 | request.setParameter("entry", ""); |
| 86 | 2 | View view = action.process(request, response); |
| 87 | 2 | assertTrue(view instanceof NotFoundView); |
| 88 | } | |
| 89 | ||
| 90 | 2 |
public void testPdfViewForUnpublishedBlogEntry() throws Exception { |
| 91 | 2 | request.setParameter("entry", unpublishedEntry.getId()); |
| 92 | 2 | View view = action.process(request, response); |
| 93 | 2 | assertTrue(view instanceof PdfView); |
| 94 | ||
| 95 | 2 | PdfView pdfView = (PdfView) view; |
| 96 | 2 | assertEquals("application/pdf", pdfView.getContentType()); |
| 97 | } | |
| 98 | ||
| 99 | 2 |
public void testPdfViewForPublishedBlogEntry() throws Exception { |
| 100 | 2 | request.setParameter("entry", publishedEntry.getId()); |
| 101 | 2 | View view = action.process(request, response); |
| 102 | 2 | assertTrue(view instanceof PdfView); |
| 103 | ||
| 104 | 2 | PdfView pdfView = (PdfView) view; |
| 105 | 2 | assertEquals("application/pdf", pdfView.getContentType()); |
| 106 | ||
| 107 | } | |
| 108 | } | |
|
||||||||||||