1
2
3
4
5
6
7
8
9
10
11 package org.mule.mule.security;
12
13 import org.mule.security.PasswordBasedEncryptionStrategy;
14 import org.mule.tck.junit4.AbstractMuleTestCase;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotSame;
20
21 public class PbeEncryptionStrategyTestCase extends AbstractMuleTestCase
22 {
23
24 @Test
25 public void testRoundTripEncryption() throws Exception
26 {
27 PasswordBasedEncryptionStrategy pbe = new PasswordBasedEncryptionStrategy();
28 pbe.setPassword("test");
29 pbe.initialise();
30
31 byte[] b = pbe.encrypt("hello".getBytes(), null);
32
33 assertNotSame(new String(b), "hello");
34 String s = new String(pbe.decrypt(b, null), "UTF-8");
35 assertEquals("hello", s);
36 }
37 }