| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
           | 
  
            
  
    | 20 | 
    
            
    
     | 
    
           | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
           | 
  
            
  
    | 23 | 
    
            
    
     | 
    
           | 
  
            
  
    | 24 | 
    
            
    
     | 
    
           | 
  
            
  
    | 25 | 
    
            
    
     | 
    
           | 
  
            
  
    | 26 | 
    
            
    
     | 
    
           | 
  
            
  
    | 27 | 
    
            
    
     | 
    
           | 
  
            
  
    | 28 | 
    
            
    
     | 
    
           | 
  
            
  
    | 29 | 
    
            
    
     | 
    
           | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
            
    
     | 
    
           | 
  
            
  
    | 32 | 
    
            
    
     | 
    
      package net.sourceforge.pebble.dao.file;     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
            
    
     | 
    
      import net.sourceforge.pebble.dao.BlogEntryDAO;     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
      import net.sourceforge.pebble.domain.*;     | 
  
            
  
    | 36 | 
    
            
    
     | 
    
      import net.sourceforge.pebble.util.FileUtils;     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
           | 
  
            
  
    | 38 | 
    
            
    
     | 
    
      import java.io.File;     | 
  
            
  
    | 39 | 
    
            
    
     | 
    
      import java.text.SimpleDateFormat;     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 41 | 
    
            
    
     | 
    
      import java.util.Locale;     | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
            
  
    | 43 | 
    
            
    
     | 
    
           | 
  
            
  
    | 44 | 
    
            
    
     | 
    
           | 
  
            
  
    | 45 | 
    
            
    
     | 
    
           | 
  
            
  
    | 46 | 
    
            
    
     | 
    
      @author     | 
  
            
  
    | 47 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (78) | 
           Complexity: 3 | 
           Complexity Density: 0,04 | 
                        
            
        | 
    
  
  
    | 48 | 
    
            
    
     | 
    
      public class FileBlogEntryDAOTest extends SingleBlogTestCase {     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
           | 
  
            
  
    | 50 | 
    
            
    
     | 
    
        private BlogEntryDAO dao= new FileBlogEntryDAO();     | 
  
            
  
    | 51 | 
    
            
    
     | 
    
        private Locale defaultLocale;     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (3) | 
           Complexity: 1 | 
           Complexity Density: 0,33 | 
                        
            
        | 
    
  
  
    | 53 | 
    
           2
    
     | 
    
         protected void setUp() throws Exception {...     | 
  
            
  
    | 54 | 
    
           2
    
     | 
    
          super.setUp();     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
           | 
  
            
  
    | 56 | 
    
           2
    
     | 
    
          defaultLocale = Locale.getDefault();     | 
  
            
  
    | 57 | 
    
           2
    
     | 
    
          Locale.setDefault(Locale.ENGLISH);     | 
  
            
  
    | 58 | 
    
            
    
     | 
    
        }     | 
  
            
  
    | 59 | 
    
            
    
     | 
    
           | 
  
            
  
    | 60 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (2) | 
           Complexity: 1 | 
           Complexity Density: 0,5 | 
                        
            
        | 
    
  
  
    | 61 | 
    
           2
    
     | 
    
         public void tearDown() throws Exception {...     | 
  
            
  
    | 62 | 
    
           2
    
     | 
    
          super.tearDown();     | 
  
            
  
    | 63 | 
    
            
    
     | 
    
               | 
  
            
  
    | 64 | 
    
           2
    
     | 
    
          Locale.setDefault(defaultLocale);     | 
  
            
  
    | 65 | 
    
            
    
     | 
    
        }     | 
  
            
  
    | 66 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (70) | 
           Complexity: 1 | 
           Complexity Density: 0,01 | 
                              1
    PASS
   | 
                        
            
        | 
    
  
  
    | 67 | 
    
           2
    
     | 
    
         public void testLoadBlogEntryFomFile() throws Exception {...     | 
  
            
  
    | 68 | 
    
            
    
     | 
    
               | 
  
            
  
    | 69 | 
    
           2
    
     | 
    
          File source = new File(TEST_RESOURCE_LOCATION, "1081203335000.xml");     | 
  
            
  
    | 70 | 
    
           2
    
     | 
    
          File destination = new File(blog.getRoot(), "2004/04/05/");     | 
  
            
  
    | 71 | 
    
           2
    
     | 
    
          destination.mkdirs();     | 
  
            
  
    | 72 | 
    
           2
    
     | 
    
          FileUtils.copyFile(source, new File(destination, "1081203335000.xml"));     | 
  
            
  
    | 73 | 
    
            
    
     | 
    
           | 
  
            
  
    | 74 | 
    
           2
    
     | 
    
          Day day = blog.getBlogForDay(2004, 04, 05);     | 
  
            
  
    | 75 | 
    
           2
    
     | 
    
          Category category1 = new Category("/category1", "Category 1");     | 
  
            
  
    | 76 | 
    
           2
    
     | 
    
          blog.addCategory(category1);     | 
  
            
  
    | 77 | 
    
           2
    
     | 
    
          Category category2 = new Category("/category2", "Category 2");     | 
  
            
  
    | 78 | 
    
           2
    
     | 
    
          blog.addCategory(category2);     | 
  
            
  
    | 79 | 
    
           2
    
     | 
    
          BlogEntry blogEntry = dao.loadBlogEntry(blog, "1081203335000");     | 
  
            
  
    | 80 | 
    
           2
    
     | 
    
          SimpleDateFormat sdf = new SimpleDateFormat(FileBlogEntryDAO.NEW_PERSISTENT_DATETIME_FORMAT);     | 
  
            
  
    | 81 | 
    
            
    
     | 
    
           | 
  
            
  
    | 82 | 
    
            
    
     | 
    
               | 
  
            
  
    | 83 | 
    
           2
    
     | 
    
          assertEquals("Blog entry title", blogEntry.getTitle());     | 
  
            
  
    | 84 | 
    
           2
    
     | 
    
          assertEquals("Blog entry subtitle", blogEntry.getSubtitle());     | 
  
            
  
    | 85 | 
    
           2
    
     | 
    
          assertEquals("<p>Blog entry excerpt.</p>", blogEntry.getExcerpt());     | 
  
            
  
    | 86 | 
    
           2
    
     | 
    
          assertEquals("<p>Blog entry body.</p>", blogEntry.getBody());     | 
  
            
  
    | 87 | 
    
           2
    
     | 
    
          assertEquals(1081203335000L, blogEntry.getDate().getTime());     | 
  
            
  
    | 88 | 
    
           2
    
     | 
    
          assertEquals("Europe/Paris", blogEntry.getTimeZoneId());     | 
  
            
  
    | 89 | 
    
           2
    
     | 
    
          assertTrue(blogEntry.isUnpublished());     | 
  
            
  
    | 90 | 
    
           2
    
     | 
    
          assertEquals("simon", blogEntry.getAuthor());     | 
  
            
  
    | 91 | 
    
           2
    
     | 
    
          assertTrue(blogEntry.isCommentsEnabled());     | 
  
            
  
    | 92 | 
    
           2
    
     | 
    
          assertTrue(blogEntry.isTrackBacksEnabled());     | 
  
            
  
    | 93 | 
    
           2
    
     | 
    
          assertEquals(2, blogEntry.getCategories().size());     | 
  
            
  
    | 94 | 
    
           2
    
     | 
    
          assertTrue(blogEntry.getCategories().contains(category1));     | 
  
            
  
    | 95 | 
    
           2
    
     | 
    
          assertTrue(blogEntry.getCategories().contains(category2));     | 
  
            
  
    | 96 | 
    
           2
    
     | 
    
          assertEquals("sometag", blogEntry.getTags());     | 
  
            
  
    | 97 | 
    
            
    
     | 
    
           | 
  
            
  
    | 98 | 
    
            
    
     | 
    
               | 
  
            
  
    | 99 | 
    
           2
    
     | 
    
          Attachment attachment = blogEntry.getAttachment();     | 
  
            
  
    | 100 | 
    
           2
    
     | 
    
          assertNotNull(attachment);     | 
  
            
  
    | 101 | 
    
           2
    
     | 
    
          assertEquals("./files/java-development-on-mac-os-x.pdf", attachment.getUrl());     | 
  
            
  
    | 102 | 
    
           2
    
     | 
    
          assertEquals(3443670, attachment.getSize());     | 
  
            
  
    | 103 | 
    
           2
    
     | 
    
          assertEquals("application/pdf", attachment.getType());     | 
  
            
  
    | 104 | 
    
            
    
     | 
    
           | 
  
            
  
    | 105 | 
    
            
    
     | 
    
               | 
  
            
  
    | 106 | 
    
           2
    
     | 
    
          List comments = blogEntry.getComments();     | 
  
            
  
    | 107 | 
    
           2
    
     | 
    
          assertEquals(2, comments.size());     | 
  
            
  
    | 108 | 
    
           2
    
     | 
    
          Comment comment1 = (Comment)comments.get(0);     | 
  
            
  
    | 109 | 
    
           2
    
     | 
    
          assertEquals("Comment title 1", comment1.getTitle());     | 
  
            
  
    | 110 | 
    
           2
    
     | 
    
          assertEquals("<p>Comment 1.</p>", comment1.getBody());     | 
  
            
  
    | 111 | 
    
           2
    
     | 
    
          assertEquals("Comment author 1", comment1.getAuthor());     | 
  
            
  
    | 112 | 
    
           2
    
     | 
    
          assertEquals("me@author1.com", comment1.getEmail());     | 
  
            
  
    | 113 | 
    
           2
    
     | 
    
          assertEquals("http://www.author1.com", comment1.getWebsite());     | 
  
            
  
    | 114 | 
    
           2
    
     | 
    
          assertEquals("127.0.0.1", comment1.getIpAddress());     | 
  
            
  
    | 115 | 
    
           2
    
     | 
    
          assertTrue(comment1.isApproved());     | 
  
            
  
    | 116 | 
    
           2
    
     | 
    
          assertEquals(sdf.parse("05 Apr 2004 23:27:30:0 +0100"), comment1.getDate());     | 
  
            
  
    | 117 | 
    
           2
    
     | 
    
          assertFalse(comment1.isAuthenticated());     | 
  
            
  
    | 118 | 
    
            
    
     | 
    
           | 
  
            
  
    | 119 | 
    
           2
    
     | 
    
          Comment comment2 = (Comment)comments.get(1);     | 
  
            
  
    | 120 | 
    
           2
    
     | 
    
          assertEquals("Re: " + blogEntry.getTitle(), comment2.getTitle());     | 
  
            
  
    | 121 | 
    
           2
    
     | 
    
          assertEquals("<p>Comment 2.</p>", comment2.getBody());     | 
  
            
  
    | 122 | 
    
           2
    
     | 
    
          assertEquals("Comment author 2", comment2.getAuthor());     | 
  
            
  
    | 123 | 
    
           2
    
     | 
    
          assertEquals("me@author2.com", comment2.getEmail());     | 
  
            
  
    | 124 | 
    
           2
    
     | 
    
          assertEquals("http://www.author2.com", comment2.getWebsite());     | 
  
            
  
    | 125 | 
    
           2
    
     | 
    
          assertEquals("192.168.0.1", comment2.getIpAddress());     | 
  
            
  
    | 126 | 
    
           2
    
     | 
    
          assertTrue(comment2.isPending());     | 
  
            
  
    | 127 | 
    
           2
    
     | 
    
          assertEquals(sdf.parse("05 Apr 2004 23:31:00:0 +0100"), comment2.getDate());     | 
  
            
  
    | 128 | 
    
           2
    
     | 
    
          assertTrue(comment2.isAuthenticated());     | 
  
            
  
    | 129 | 
    
            
    
     | 
    
           | 
  
            
  
    | 130 | 
    
            
    
     | 
    
               | 
  
            
  
    | 131 | 
    
           2
    
     | 
    
          List trackBacks = blogEntry.getTrackBacks();     | 
  
            
  
    | 132 | 
    
           2
    
     | 
    
          assertEquals(2, trackBacks.size());     | 
  
            
  
    | 133 | 
    
           2
    
     | 
    
          TrackBack trackBack1 = (TrackBack)trackBacks.get(0);     | 
  
            
  
    | 134 | 
    
           2
    
     | 
    
          assertEquals("TrackBack title 1", trackBack1.getTitle());     | 
  
            
  
    | 135 | 
    
           2
    
     | 
    
          assertEquals("TrackBack body 1.", trackBack1.getExcerpt());     | 
  
            
  
    | 136 | 
    
           2
    
     | 
    
          assertEquals("http://www.author1.com/entry", trackBack1.getUrl());     | 
  
            
  
    | 137 | 
    
           2
    
     | 
    
          assertEquals("Blog name 1", trackBack1.getBlogName());     | 
  
            
  
    | 138 | 
    
           2
    
     | 
    
          assertEquals("127.0.0.1", trackBack1.getIpAddress());     | 
  
            
  
    | 139 | 
    
           2
    
     | 
    
          assertTrue(trackBack1.isApproved());     | 
  
            
  
    | 140 | 
    
           2
    
     | 
    
          assertEquals(sdf.parse("06 Apr 2004 07:09:24:0 +0100"), trackBack1.getDate());     | 
  
            
  
    | 141 | 
    
            
    
     | 
    
           | 
  
            
  
    | 142 | 
    
           2
    
     | 
    
          TrackBack trackBack2 = (TrackBack)trackBacks.get(1);     | 
  
            
  
    | 143 | 
    
           2
    
     | 
    
          assertEquals("TrackBack title 2", trackBack2.getTitle());     | 
  
            
  
    | 144 | 
    
           2
    
     | 
    
          assertEquals("TrackBack body 2.", trackBack2.getExcerpt());     | 
  
            
  
    | 145 | 
    
           2
    
     | 
    
          assertEquals("http://www.author2.com/entry", trackBack2.getUrl());     | 
  
            
  
    | 146 | 
    
           2
    
     | 
    
          assertEquals("Blog name 2", trackBack2.getBlogName());     | 
  
            
  
    | 147 | 
    
           2
    
     | 
    
          assertEquals("192.168.0.1", trackBack2.getIpAddress());     | 
  
            
  
    | 148 | 
    
           2
    
     | 
    
          assertTrue(trackBack2.isPending());     | 
  
            
  
    | 149 | 
    
           2
    
     | 
    
          assertEquals(sdf.parse("06 Apr 2004 07:09:24:0 +0100"), trackBack2.getDate());     | 
  
            
  
    | 150 | 
    
            
    
     | 
    
        }     | 
  
            
  
    | 151 | 
    
            
    
     | 
    
           | 
  
            
  
    | 152 | 
    
            
    
     | 
    
      }     |