2 * jFCPlib - FcpTest.java - Copyright © 2008 David Roden
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.fcp;
21 import java.io.IOException;
23 import junit.framework.TestCase;
26 * Tests various commands and the FCP connection.
28 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
30 public class FcpTest extends TestCase {
32 /** The FCP connection. */
33 private FcpConnection fcpConnection;
39 protected void setUp() throws Exception {
40 fcpConnection = new FcpConnection("wing");
41 fcpConnection.connect();
42 fcpConnection.sendMessage(new ClientHello("FcpTest"));
49 protected void tearDown() throws Exception {
50 fcpConnection.close();
54 * Tests the FCP connection be simply {@link #setUp() setting it up} and
55 * {@link #tearDown() tearing it down} again.
57 public void testFcpConnection() {
62 * Generates an SSK key pair.
65 * if an I/O error occurs
66 * @throws InterruptedException
67 * if {@link Object#wait()} wakes up spuriously
69 public void testGenerateSSK() throws IOException, InterruptedException {
70 final SSKKeypair[] keypair = new SSKKeypair[1];
71 FcpAdapter fcpAdapter = new FcpAdapter() {
77 public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) {
78 keypair[0] = sskKeypair;
84 fcpConnection.addFcpListener(fcpAdapter);
85 synchronized (fcpAdapter) {
86 fcpConnection.sendMessage(new GenerateSSK());
89 assertNotNull("ssk keypair", keypair[0]);