/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2013-2015 ForgeRock AS
*/
/**
* Test {@link CSN} and {@link CSNGenerator}.
*/
@SuppressWarnings("javadoc")
{
/**
* Create CSN Data.
*/
long time = 0x12ABC;
return new Object[][] {
{1, 0, 1, "0000000000000001000100000000"},
};
}
/** Test CSN constructor. */
{
}
/**
* Test toString and constructor from String.
*/
{
// Create 2 CSN with the same data and check equality
}
/**
* Create CSN.
*/
{
{
}
return obj;
}
/** Test {@link CSN#hashCode()} method. */
{
}
/** Test {@link CSN#equals(Object)} method. */
{
}
/** Test {@link CSN#getTimeSec()} method. */
{
// Check time in sec
}
/** Test {@link CSN#compare(CSN, CSN)} method. */
{
}
/** Test {@link CSN#isOlderThan(CSN)} method. */
{
}
/** Test {@link CSN#isOlderThanOrEqualTo(CSN)} method. */
{
}
/** Test {@link CSN#isNewerThan(CSN)} method. */
{
}
/** Test {@link CSN#isNewerThanOrEqualTo(CSN)} method. */
{
}
/**
* Create a {@link CSNGenerator}, then call {@link CSNGenerator#newCSN()} and
* {@link CSNGenerator#adjust()}
* <p>
* FIXME these tests are calling Thread.sleep() which makes them slow. We
* should really have a way to control time (make it go slower or faster) for
* the unit tests to avoid such waits.
*/
@Test
{
// Generate 2 CSNs and check that they are different
// Generate a CSN separated by 10 milliseconds
// and check that they are different
// Generate a CSN separated by 300 milliseconds
// and check that they are different
// Adjust with the oldest CSN
// Adjust with the newest generated
// Adjust with the newest generated (time + 300)
// Adjust with the newest generated (seqmun + 10)
// Adjust with the newest generated (seqmun = 0XFFFF)
}
/**
* Test the difference in seq num between 2 CSNs.
*/
@Test
{
// 3-0 = 3
// 3-1 = 2
// 3-3 = 0
// 3-4 = 0 (csn1 must be newer otherwise 0 should be returned)
// 0-0 = 0
// 0-1 = 0 (csn1 must be newer otherwise 0 should be returned)
// 5-null = 5
// null-2 = 0
// null-null = 0
// csn1 older than csn2 -> 0
// csn1 seqnum looped
}
{
{
}
{
{
/*
* it is ok to compare to the exact same CSN to ensure operations are
* reflexive, and it is also ok to compare csn1 to csn2, and csn2 to
* csn1 to ensure operations are symmetric
*/
}
}
}
{
}
{
{
}
}
{
{
}
}
}