CAS Unit Tests
Clover coverage report - CAS Unit Tests
Coverage timestamp: Mon Jul 4 2005 18:13:17 CDT
file stats: LOC: 71   Methods: 3
NCLOC: 43   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestTrustAnchorData.java - 0% 0% 0%
coverage
 1    /*
 2    * Portions of this file Copyright 1999-2005 University of Chicago
 3    * Portions of this file Copyright 1999-2005 The University of Southern California.
 4    *
 5    * This file or a portion of this file is licensed under the
 6    * terms of the Globus Toolkit Public License, found at
 7    * http://www.globus.org/toolkit/download/license.html.
 8    * If you redistribute this file, with or without
 9    * modifications, you must include this notice in the file.
 10    */
 11    package org.globus.cas.impl.databaseAccess;
 12   
 13    import junit.framework.Test;
 14    import junit.framework.TestCase;
 15    import junit.framework.TestSuite;
 16   
 17    import org.globus.cas.types.TrustAnchorData;
 18   
 19    import org.apache.commons.logging.Log;
 20    import org.apache.commons.logging.LogFactory;
 21   
 22    public class TestTrustAnchorData extends TestCase {
 23   
 24    static Log logger =
 25    LogFactory.getLog(TestTrustAnchorData.class.getName());
 26   
 27  0 public TestTrustAnchorData(String name){
 28  0 super(name);
 29    }
 30   
 31  0 public static Test suite() {
 32  0 return new TestSuite(TestTrustAnchorData.class);
 33    }
 34   
 35  0 public void testTrustAnchorData() throws Exception {
 36   
 37  0 String nickname = "nickname" + System.currentTimeMillis();
 38  0 String authMethod = "authMethod";
 39  0 String authData ="authData";
 40   
 41    // Store trust anchor data
 42  0 TrustAnchorData trustAnchor = new TrustAnchorData();
 43  0 trustAnchor.setNickname(nickname);
 44  0 trustAnchor.setAuthMethod(authMethod);
 45  0 trustAnchor.setAuthData(authData);
 46  0 TrustAnchorDataHandler.storeObject(trustAnchor);
 47  0 logger.debug("Store object went through " + trustAnchor.toString());
 48   
 49    // List of all trust anchors
 50  0 String[] trustAnchorList = TrustAnchorDataHandler.list();
 51  0 assertTrue(trustAnchorList!=null);
 52  0 logger.debug("Trust anchor list is " + trustAnchorList);
 53   
 54    // Ensure that the stored and retrieved objects are the same
 55  0 TrustAnchorData retrieveAnchorData =
 56    (TrustAnchorData)TrustAnchorDataHandler.retrieveObject(nickname);
 57  0 assertTrue(retrieveAnchorData!=null);
 58  0 logger.debug("Retrieved trust anchor " + retrieveAnchorData.toString());
 59  0 assertTrue(retrieveAnchorData.equals(trustAnchor));
 60   
 61    // Retrive nickname for authdata nad method
 62  0 String retrievedNick = TrustAnchorDataHandler.getNickname(authData,
 63    authMethod);
 64  0 assertTrue(retrievedNick.equals(nickname));
 65   
 66  0 TrustAnchorDataHandler.deleteObject(nickname);
 67  0 TrustAnchorData deletedData =
 68    (TrustAnchorData)TrustAnchorDataHandler.retrieveObject(nickname);
 69  0 assertTrue(deletedData == null);
 70    }
 71    }