1   /*
2    * $Id: PGPKeyRingTestCase.java 10789 2008-02-12 20:04:43Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.pgp;
12  
13  import org.mule.tck.AbstractMuleTestCase;
14  
15  import java.net.URL;
16  
17  import cryptix.pki.KeyBundle;
18  
19  public class PGPKeyRingTestCase extends AbstractMuleTestCase
20  {
21      private PGPKeyRing keyManager;
22  
23      /*
24       * (non-Javadoc)
25       * 
26       * @see org.mule.tck.AbstractMuleTestCase#setUp()
27       */
28      protected void doSetUp() throws Exception
29      {
30          PGPKeyRingImpl keyM = new PGPKeyRingImpl();
31          URL url;
32  
33          url = Thread.currentThread().getContextClassLoader().getResource("./serverPublic.gpg");
34          keyM.setPublicKeyRingFileName(url.getFile());
35  
36          url = Thread.currentThread().getContextClassLoader().getResource("./serverPrivate.gpg");
37          keyM.setSecretKeyRingFileName(url.getFile());
38  
39          keyM.setSecretAliasId("0x6168F39C");
40          keyM.setSecretPassphrase("TestingPassphrase");
41          keyM.initialise();
42  
43          keyManager = keyM;
44      }
45  
46      /*
47       * (non-Javadoc)
48       * 
49       * @see org.mule.tck.AbstractMuleTestCase#tearDown()
50       */
51      protected void doTearDown() throws Exception
52      {
53          keyManager = null;
54      }
55  
56      public void testClientKey()
57      {
58          KeyBundle clientKey = keyManager.getKeyBundle("Mule client <mule_client@mule.com>");
59          assertNotNull(clientKey);
60      }
61  
62      public void testServerKey()
63      {
64          KeyBundle serverKey = keyManager.getSecretKeyBundle();
65          assertNotNull(serverKey);
66      }
67  }