TokenTestUtils.java revision b334b83b7ac2d9a8c60d935cad0365506f13333b
/**
* Copyright 2013 ForgeRock, AS.
*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*/
/**
* Provides CTS based Token testing functionality, specifically for unit testing.
*
* @author robert.wapshott@forgerock.com
*/
public class TokenTestUtils {
/**
* Logic for comparing two tokens. It might be useful to move this to a .equals method at some point.
*
* @param result Non null.
* @param expected Non null.
*/
"Milliseconds did not match for date field {0}:\n" +
"Expected: {1}\n" +
" Result: {2}",
resultCal.getTimeInMillis()));
}
if (resultOffset != expectedOffset) {
"TimeZone offset did not match for date field {0}:\n" +
"Expected: {1}\n" +
" Result: {2}",
resultOffset));
}
"Value did not match for byte[] field {0}:\n" +
"Expected: {1} bytes\n" +
" Result: {2} bytes",
}
} else {
"Value did not match for field {0}:\n" +
"Expected: {1}\n" +
" Result: {2}",
resultValue));
}
}
}
}
/**
* Required to correctly account for all factors when dealing with TimeZones.
*
* @param zone Non null.
* @return
*/
int r = zone.getRawOffset();
if (zone.useDaylightTime()) {
r += zone.getDSTSavings();
}
return r;
}
/**
* This method is needed because the TestNG assertEquals method didn't seem to work for the
* enum TokenType.
*
* @param first Non null.
* @param second Non null.
* @return True if the objects compare.
*/
return true;
}
return true;
}
return false;
}
public static Token generateToken() {
// Set to expire now.
// Some extra data
// Some binary data
return token;
}
}