View Javadoc

1   /*
2    * $Id: KBEStrategyUsingEncryptionTransformerTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.DefaultMuleEvent;
14  import org.mule.RequestContext;
15  import org.mule.tck.testmodels.fruit.Orange;
16  import org.mule.transformer.encryption.EncryptionTransformer;
17  import org.mule.transformer.simple.ByteArrayToObject;
18  
19  
20  public class KBEStrategyUsingEncryptionTransformerTestCase extends AbstractEncryptionStrategyTestCase
21  {
22      public void testEncrypt() throws Exception
23      {
24          String msg = "Test Message";
25          
26          DefaultMuleEvent event = (DefaultMuleEvent)getTestEvent(msg, getTestService("orange", Orange.class));
27          RequestContext.setEvent(event);
28          
29          EncryptionTransformer etrans = new EncryptionTransformer();
30          etrans.setStrategy(kbStrategy);
31          Object result = etrans.doTransform(msg.getBytes(), "UTF-8");
32          
33          assertNotNull(result);
34          String encrypted = (String) new ByteArrayToObject().doTransform(result,"UTF-8");
35          assertTrue(encrypted.startsWith("-----BEGIN PGP MESSAGE-----"));
36      }
37  }