2 * jSite2 - FcpTest.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.util.fcp;
22 import java.io.IOException;
24 import junit.framework.TestCase;
27 * Tests various commands and the FCP connection.
29 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
32 public class FcpTest extends TestCase {
34 /** The FCP connection. */
35 private FcpConnection fcpConnection;
41 protected void setUp() throws Exception {
42 fcpConnection = new FcpConnection("wing");
43 fcpConnection.connect();
44 fcpConnection.sendMessage(new ClientHello("FcpTest"));
51 protected void tearDown() throws Exception {
52 fcpConnection.disconnect();
56 * Tests the FCP connection be simply {@link #setUp() setting it up} and
57 * {@link #tearDown() tearing it down} again.
59 public void testFcpConnection() {
64 * Generates an SSK key pair.
67 * if an I/O error occurs
68 * @throws InterruptedException
69 * if {@link Object#wait()} wakes up spuriously
71 public void testGenerateSSK() throws IOException, InterruptedException {
72 final SSKKeypair[] keypair = new SSKKeypair[1];
73 FcpAdapter fcpAdapter = new FcpAdapter() {
79 public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) {
80 keypair[0] = sskKeypair;
86 fcpConnection.addFcpListener(fcpAdapter);
87 synchronized (fcpAdapter) {
88 fcpConnection.sendMessage(new GenerateSSK());
91 assertNotNull("ssk keypair", keypair[0]);