Package pygmy.nntp

Examples of pygmy.nntp.Article


    }

    public void testAddArticle() throws Exception {
        String name = "comp.lang.java.programmer";
        NewsGroup group = forum.createNewsgroup(name);
        Article article = NntpTestUtil.createArticle("test.eml");
        forum.addArticle( article, "foo");
        File repository = forum.getArticleRepository();

        File[] list = repository.listFiles();
        assertEquals( NntpUtil.base64Encode( article.getMessageId() ), list[0].getName() );
        assertEquals( 1, group.size() );
    }
View Full Code Here


            }
        }
    }

    protected byte[] getArticleBytes( String filename ) throws IOException {
        Article article = NntpTestUtil.createArticle( filename );
        ByteArrayOutputStream articleBaos = new ByteArrayOutputStream();
        article.save( new InternetOutputStream( articleBaos ) );
        return articleBaos.toByteArray();
    }
View Full Code Here

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testArticle() throws IOException {
        Article article = NntpTestUtil.createArticle("test.eml");

        assertEquals( "1.0", article.getHeader().get("Mime-Version") );
        assertEquals( "<blkdu9$pd8$1@hood.uits.indiana.edu>", article.getMessageId() );
        assertEquals( "Re: Static inner classes", article.getSubject() );
        String[] newsgroups = { "comp.lang.java.programmer" };
        for( int i = 0; i < newsgroups.length; i++ ) {
            assertEquals( newsgroups[i], article.getNewsgroups()[i] );
        }
    }
View Full Code Here

    public static Article createArticle(String filename) throws IOException {
        File file = new File( System.getProperty("nntp.root"), filename );
        NntpInputStream is = null;
        try {
            is = new NntpInputStream( new FileInputStream( file ) );
            Article article = new Article( is );
            return article;
        } finally {
            if( is != null ) {
                is.close();
            }
View Full Code Here

    public void testAddArticle() throws Exception {
        System.out.println("NewsGroupTest.testAddArticle");
        assertEquals( 0, group.size() );

        Article article = addTestArticle();
        assertEquals( 1, group.size() );
        assertEquals( group.getFirstIndex(), group.getLastIndex() );
        assertEquals( group.getLastIndex(), article.getArticleNumber() );

        Article article2 = NntpTestUtil.createArticle("test.eml");
        article2.setMessageId(null);
        String oldPath2 = article2.getHeader().get("Path");
        group.addArticle( article2, "localhost" );
        assertEquals( 2, group.size() );
        assertTrue( "Assert that first and last indexes are different after adding two articles.", group.getFirstIndex() != group.getLastIndex() );
        assertEquals( "Assert the first article is the firstIndex", group.getFirstIndex(), article.getArticleNumber() );
        assertEquals( "Assert the last article is the last index", group.getLastIndex(), article2.getArticleNumber() );
        assertTrue( "Assert the old path is contained with the new path, and it doesn't start at index 0.", article2.getHeader().get("Path").indexOf(oldPath2) > 0 );
        assertTrue( "Assert the old path starts with localhost.", article2.getHeader().get("Path").startsWith("localhost") );
        assertNotNull( "Assert messsage ID is not NULL.", article2.getMessageId() );
        assertNotNull( "Assert Date-Received is not NULL", article2.getHeader().get("Date-Received") );
    }
View Full Code Here

        assertNotNull( "Assert messsage ID is not NULL.", article2.getMessageId() );
        assertNotNull( "Assert Date-Received is not NULL", article2.getHeader().get("Date-Received") );
    }

    private Article addTestArticle() throws IOException {
        Article article = NntpTestUtil.createArticle("test.eml");
        group.addArticle( article, "localhost" );
        return article;
    }
View Full Code Here

    }

    public void testGetMessage() throws Exception {
        System.out.println("NewsGroupTest.testGetMessage");

        Article article = addTestArticle();
        Article sameArticle = group.getMessage( article.getArticleNumber() );

        assertEquals( "Assert that their message IDs are the same.  Assume the rest is the same.", sameArticle.getMessageId(), article.getMessageId() );
        assertEquals( "Assert that their article numbers are the same.  Assume the rest is the same.", sameArticle.getArticleNumber(), article.getArticleNumber() );
    }
View Full Code Here

TOP

Related Classes of pygmy.nntp.Article

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.