Coverage report

| %line | %branch
--- | --- | ---
examples.nntp.ExtendedNNTPOps |
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 |  |
     package examples.nntp;
17 |  |
18 |  |
     import java.io.IOException;
19 |  |
     import java.io.PrintWriter;
20 |  |
21 |  |
     import org.apache.commons.net.nntp.Article;
22 |  |
     import org.apache.commons.net.nntp.NNTPClient;
23 |  |
     import org.apache.commons.net.nntp.NewsgroupInfo;
24 |  |
25 |  |
     import examples.PrintCommandListener;
26 |  |
27 |  |
     /**
28 |  |
      * Simple class showing some of the extended commands (AUTH, XOVER, LIST ACTIVE)
29 |  |
      *
30 |  |
      * @author Rory Winston <rwinston@checkfree.com>
31 |  |
      */
32 |  |
     public class ExtendedNNTPOps {
33 |  |
34 |  |
35 |  |
     	NNTPClient client;
36 |  |
37 | 0 |
     	public ExtendedNNTPOps() {
38 | 0 |
     		client = new NNTPClient();
39 | 0 |
     		client.addProtocolCommandListener(new PrintCommandListener(class="keyword">new PrintWriter(System.out)));
40 | 0 |
     	}
41 |  |
42 |  |
43 |  |
     	public void demo(String host, String user, String password) {
44 |  |
     		try {
45 | 0 |
     			client.connect(host);
46 |  |
47 |  |
     			// AUTHINFO USER/AUTHINFO PASS
48 | 0 |
     			boolean success = client.authenticate(user, password);
49 | 0 |
     			if (success) {
50 | 0 |
     				System.out.println("Authentication succeeded");
51 |  |
     			} else {
52 | 0 |
     				System.out.println("Authentication failed, error =" + client.getReplyString());
53 |  |
     			}
54 |  |
55 |  |
     			// XOVER
56 | 0 |
     			NewsgroupInfo testGroup = new NewsgroupInfo();
57 | 0 |
     			client.selectNewsgroup("alt.test", testGroup);
58 | 0 |
     			int lowArticleNumber = testGroup.getFirstArticle();
59 | 0 |
     			int highArticleNumber = lowArticleNumber + 100;
60 | 0 |
     			Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);
61 |  |
62 | 0 |
     			for (int i = 0; i < articles.length; ++i) {
63 | 0 |
     				System.out.println(articles[i].getSubject());
64 |  |
     			}
65 |  |
66 |  |
     			// LIST ACTIVE
67 | 0 |
     			NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
68 | 0 |
     			for (int i = 0; i < fanGroups.length; ++i) {
69 | 0 |
     				System.out.println(fanGroups[i].getNewsgroup());
70 |  |
     			}
71 |  |
72 | 0 |
     		} catch (IOException e) {
73 | 0 |
     			e.printStackTrace();
74 | 0 |
     		}
75 | 0 |
     	}
76 |  |
77 |  |
     	public static void main(String[] args) {
78 |  |
     		ExtendedNNTPOps ops;
79 |  |
80 | 0 |
     		if (args.length != 3) {
81 | 0 |
     			System.err.println("usage: ExtendedNNTPOps nntpserver username password");
82 | 0 |
     			System.exit(1);
83 |  |
     		}
84 |  |
85 | 0 |
     		ops = new ExtendedNNTPOps();
86 | 0 |
     		ops.demo(args[0], args[1], args[2]);
87 | 0 |
     	}
88 |  |
89 |  |
     }
90 |  |
91 |  |
     /* Emacs configuration
92 |  |
      * Local variables:        **
93 |  |
      * mode:             java  **
94 |  |
      * c-basic-offset:   4     **
95 |  |
      * indent-tabs-mode: nil   **
96 |  |
      * End:                    **
97 |  |
      */

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