|
From: <pe...@us...> - 2003-09-22 19:24:13
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv4908/src/test/org/neuclear/signers
Modified Files:
SimpleSignerStoreTest.java
Log Message:
More fixes throughout to problems caused by renaming.
Index: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SimpleSignerStoreTest.java 19 Sep 2003 14:42:03 -0000 1.1.1.1
--- SimpleSignerStoreTest.java 22 Sep 2003 19:24:03 -0000 1.2
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.2 2003/09/22 19:24:03 pelle
+ * More fixes throughout to problems caused by renaming.
+ *
* Revision 1.1.1.1 2003/09/19 14:42:03 pelle
* First import into the neuclear project. This was originally under the SF neudist
***************
*** 51,56 ****
import junit.framework.TestCase;
! import org.neuclear.utils.NeudistException;
! import org.neuclear.crypto.signerstores.SimpleSignerStore;
import java.io.File;
--- 54,59 ----
import junit.framework.TestCase;
! import org.neudist.crypto.signerstores.SimpleSignerStore;
! import org.neudist.utils.NeudistException;
import java.io.File;
***************
*** 63,129 ****
* @version $Revision$
**/
! public class SimpleSignerStoreTest extends TestCase {
! public SimpleSignerStoreTest(String name) throws GeneralSecurityException,NeudistException {
! super(name);
setUp();
}
/**
*/
! public static SimpleSignerStore getSignerStoreInstance() throws NeudistException, GeneralSecurityException{
return new SimpleSignerStore(new File("target/tests/keystores"));
}
! protected void setUp() throws NeudistException,GeneralSecurityException{
! store=getSignerStoreInstance();
generateKeys();
}
protected static synchronized void generateKeys() throws GeneralSecurityException {
! if (kg==null) {
System.out.println("Generating Test Keys");
! kg=KeyPairGenerator.getInstance("RSA");
! kg.initialize(1048,new SecureRandom("Bear it all with NeuDist".getBytes()));
! // kp=kg.generateKeyPair();
! root=kg.generateKeyPair();
! bob=kg.generateKeyPair();
}
}
protected void tearDown() {
! store=null;
}
! public void testAddKey() throws NeudistException,GeneralSecurityException,IOException {
! boolean success=false;
! try {
! store.addKey("root","root".toCharArray(),root.getPrivate());
! success=true;
! } catch (GeneralSecurityException e) {
e.printStackTrace();
! } catch (IOException e) {
! e.printStackTrace();
! }
! assertTrue("Managed to add a key",success);
! }
! public void testGetKey() throws NeudistException,GeneralSecurityException,IOException {
! boolean success=false;
! PrivateKey key=null;
! try {
! store.addKey("bob","bob".toCharArray(),bob.getPrivate());
! key=store.getKey("bob","bob".toCharArray());
! success=true;
! } catch (GeneralSecurityException e) {
e.printStackTrace();
! } catch (IOException e) {
! e.printStackTrace();
! }
! assertTrue("Managed to add and Fetch a key",success);
! assertNotNull("Key wasn't null",key);
! assertEquals("Gotten Key was the same as Stored Key",bob.getPrivate(),key);
! }
! public static void main (String[] args) {
try {
! SimpleSignerStoreTest test=new SimpleSignerStoreTest("SimpleSignerStoreTest");
test.setUp();
test.testGetKey();
--- 66,136 ----
* @version $Revision$
**/
! public class SimpleSignerStoreTest extends TestCase {
! public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeudistException {
! super(name);
setUp();
}
+
/**
*/
! public static SimpleSignerStore getSignerStoreInstance() throws NeudistException, GeneralSecurityException {
return new SimpleSignerStore(new File("target/tests/keystores"));
}
! protected void setUp() throws NeudistException, GeneralSecurityException {
! store = getSignerStoreInstance();
generateKeys();
}
+
protected static synchronized void generateKeys() throws GeneralSecurityException {
! if (kg == null) {
System.out.println("Generating Test Keys");
! kg = KeyPairGenerator.getInstance("RSA");
! kg.initialize(1048, new SecureRandom("Bear it all with NeuDist".getBytes()));
! // kp=kg.generateKeyPair();
! root = kg.generateKeyPair();
! bob = kg.generateKeyPair();
}
}
protected void tearDown() {
! store = null;
! }
!
! public void testAddKey() throws NeudistException, GeneralSecurityException, IOException {
! boolean success = false;
! try {
! store.addKey("root", "root".toCharArray(), root.getPrivate());
! success = true;
! } catch (GeneralSecurityException e) {
! e.printStackTrace();
! } catch (IOException e) {
! e.printStackTrace();
}
+ assertTrue("Managed to add a key", success);
+ }
! public void testGetKey() throws NeudistException, GeneralSecurityException, IOException {
! boolean success = false;
! PrivateKey key = null;
! try {
! store.addKey("bob", "bob".toCharArray(), bob.getPrivate());
! key = store.getKey("bob", "bob".toCharArray());
! success = true;
! } catch (GeneralSecurityException e) {
e.printStackTrace();
! } catch (IOException e) {
e.printStackTrace();
! }
! assertTrue("Managed to add and Fetch a key", success);
! assertNotNull("Key wasn't null", key);
! assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
! }
!
! public static void main(String[] args) {
try {
! SimpleSignerStoreTest test = new SimpleSignerStoreTest("SimpleSignerStoreTest");
test.setUp();
test.testGetKey();
***************
*** 132,141 ****
// ((NeudistException)e).getParcel().printStackTrace();
// } else
! e.printStackTrace();
}
// junit.textui.TestRunner.run (suite());
! }
private SimpleSignerStore store;
--- 139,148 ----
// ((NeudistException)e).getParcel().printStackTrace();
// } else
! e.printStackTrace();
}
// junit.textui.TestRunner.run (suite());
! }
private SimpleSignerStore store;
|