Coverage report

  %line %branch
examples.nntp.MessageThreading
0% 
0% 

 1  
 /*
 2  
  * Copyright 2001-2005 The Apache Software Foundation
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package examples.nntp;
 18  
 
 19  
 import java.io.IOException;
 20  
 import java.io.PrintWriter;
 21  
 import java.net.SocketException;
 22  
 
 23  
 import org.apache.commons.net.nntp.Article;
 24  
 import org.apache.commons.net.nntp.NNTPClient;
 25  
 import org.apache.commons.net.nntp.NewsgroupInfo;
 26  
 import org.apache.commons.net.nntp.Threader;
 27  
 
 28  
 import examples.PrintCommandListener;
 29  
 
 30  
 public class MessageThreading {
 31  0
 	public MessageThreading() {
 32  0
 	}
 33  
 	
 34  
 	public static void main(String[] args) throws SocketException, IOException {
 35  
 		
 36  0
 		if (args.length != 3)
 37  0
 			usage();
 38  
 		
 39  0
 		String hostname = args[0];
 40  0
 		String user = args[1];
 41  0
 		String password = args[2];
 42  
 		
 43  0
 		NNTPClient client = new NNTPClient();
 44  0
 		client.addProtocolCommandListener(new PrintCommandListener(class="keyword">new PrintWriter(System.out)));
 45  0
 		client.connect(hostname);
 46  
 		
 47  0
 		if(!client.authenticate(user, password)) {
 48  0
 			System.out.println("Authentication failed for user " + user + "!");
 49  0
 			System.exit(1);
 50  
 		}
 51  
 		
 52  0
 		NewsgroupInfo group = new NewsgroupInfo();
 53  0
 		client.selectNewsgroup("comp.lang.lisp", group);
 54  
 		
 55  0
 		int lowArticleNumber = group.getFirstArticle();
 56  0
 		int highArticleNumber = lowArticleNumber + 100;
 57  
 		
 58  0
 		System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
 59  0
 		Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);
 60  
 		
 61  0
 		System.out.println("Building message thread tree...");
 62  0
 		Threader threader = new Threader();
 63  0
 		Article root = (Article)threader.thread(articles);
 64  
 		
 65  0
 		Article.printThread(root, 0);	
 66  
 		
 67  0
 	}
 68  
 	
 69  
 	
 70  
 	public static void usage() {
 71  0
 		System.out.println("Usage: MessageThreading <hostname> <user> <password>");
 72  0
 		System.exit(0);
 73  0
 	}
 74  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.