KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > util > PasswordUtilsTest


1 /*
2  * Copyright (c) 2006 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: PasswordUtilsTest.java,v 1.3 2007/01/07 06:14:55 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.util;
23
24 import junit.framework.TestCase;
25
26 import org.opensubsystems.core.error.OSSException;
27
28 /**
29  * Tests for common operations with passwords.
30  *
31  * @version $Id: PasswordUtilsTest.java,v 1.3 2007/01/07 06:14:55 bastafidli Exp $
32  * @author Miro Halas
33  * @code.reviewer Miro Halas
34  * @code.reviewed Initial revision
35  */

36 public class PasswordUtilsTest extends TestCase
37 {
38    /**
39     * Constructor.
40     *
41     * @param arg0 - name of the test
42     */

43    public PasswordUtilsTest(
44       String JavaDoc arg0
45    )
46    {
47       super(arg0);
48    }
49
50    /**
51     * Set up environment for the test case.
52     *
53     * @throws Exception - an error has occured during setting up test
54     */

55    protected void setUp(
56    ) throws Exception JavaDoc
57    {
58       super.setUp();
59    }
60
61    /**
62     * Restore original environment after the test case.
63     *
64     * @throws Exception - an error has occured during tearing down up test
65     */

66    protected void tearDown() throws Exception JavaDoc
67    {
68       super.tearDown();
69    }
70
71    /**
72     * Test calculating a message digest using a default algorithm
73     *
74     * @throws OSSException - an error has occured
75     */

76    public void testGetMessageDigest(
77    ) throws OSSException
78    {
79       String JavaDoc strTest = "Text to calculate digest for";
80       String JavaDoc strDigest;
81       
82       strDigest = PasswordUtils.getMessageDigest(strTest);
83       
84       assertNotNull("Digest cannot be null", strDigest);
85       assertTrue("Digest cannot be empty string", strDigest.length() > 0);
86       assertTrue("Digest cannot be the same as the original text",
87                  !strDigest.equals(strTest));
88    }
89 }
90
Popular Tags