SynchronizationMsgTest.java revision f35ef9dedc3f32e78624740bf01973f5a5a851cf
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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-2010 Sun Microsystems, Inc.
* Portions copyright 2011-2012 ForgeRock AS
*/
/**
* Test the constructors, encoders and decoders of the replication protocol
* PDUs classes (message classes)
*/
public class SynchronizationMsgTest extends ReplicationTestCase
{
/**
* Set up the environment for performing the tests in this Class.
*
* @throws Exception
* If the environment could not be set up.
*/
{
super.setUp();
// Be sure we use the latest protocol version for these tests
}
/**
* Build some data for the ModifyMsg test below.
*/
public Object[][] createModifyData() {
for (int i = 0; i < 10; i++)
{
}
// Entry attributes
return new Object[][] {
{ cn2, "dc=test with a much longer dn in case this would "
{ cn2, "dc=test, cn=with a, o=more complex, ou=dn", mods1, false, AssuredMode.SAFE_READ_MODE, (byte)5, eclIncludes},
{ cn2, "dc=test with several mod", mods2, false, AssuredMode.SAFE_DATA_MODE, (byte)16, eclIncludes},
};
}
/**
* Create a ModifyMsg from the data provided above.
* The call getBytes() to test the encoding of the Msg and
* create another ModifyMsg from the encoded byte array.
* Finally test that both Msg matches.
*/
byte safeDataLevel,
throws Exception
{
// Set ECL entry inlcuded attributes
if (entryAttrList != null)
{
}
// Test that generated attributes match original attributes.
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
}
/**
* Create an Update Message from the data provided above.
* The call getBytes() to test the encoding of the Msg and
* create another ModifyMsg from the encoded byte array.
* Finally test that both Msgs match.
*/
byte safeDataLevel ,
throws Exception
{
// Check isAssured
// Check assured mode
// Check safe data level
// Check equals
// Check change number
// Check hashCode
// Check compareTo
// Check Get / Set DN
// Check uuid
// Check assured flag
// Check assured mode
// Check safe data level
}
/**
* Build some data for the DeleteMsg test below.
*/
public Object[][] createDeleteData()
{
// Entry attributes
return new Object[][] {
{"dc=com", entryAttrList, false},
{"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn", null, true},
};
}
/**
* Create a Delete from the data provided above.
* The call getBytes() to test the encoding of the Msg and
* create another DeleteMsg from the encoded byte array.
* Finally test that both Msg matches.
*/
boolean subtree)
throws Exception
{
if (subtree)
{
}
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create an update message from this op
}
public Object[][] createModifyDnData() {
for (int i = 0; i < 10; i++)
{
}
// Entry attributes
return new Object[][] {
{"dc=test,dc=com", "dc=new", false, "dc=change", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte)0, entryAttrList},
{"dc=test,dc=com", "dc=new", true, "dc=change", mods2, true, AssuredMode.SAFE_READ_MODE, (byte)1, null},
// testNG does not like null argument so use "" for the newSuperior
// instead of null
{"dc=test,dc=com", "dc=new", false, "", mods3, true, AssuredMode.SAFE_READ_MODE, (byte)3, entryAttrList},
{"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn",
};
}
throws Exception
{
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Test that generated attributes match original attributes.
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create an update message from this op
}
public Object[][] createAddData()
{
// Entry attributes
return new Object[][] {
}
throws Exception
{
.getObjectClassAttributeType(), "organization");
"organization");
HashMap<AttributeType, List<Attribute>> userAttList = new HashMap<AttributeType, List<Attribute>>();
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Test that generated attributes match original attributes.
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create an new Add Operation from the current addMsg
//Create an Add operation and generate and Add msg from it
"parentUniqueId");
if (entryAttrList != null)
{
}
// TODO : should test that generated attributes match original attributes.
// Create an update message from this op
}
/**
* Build some data for the AckMsg test below.
*/
public Object[][] createAckData() {
return new Object[][] {
};
}
throws Exception
{
// Constructor test (with ChangeNumber)
// Check that retrieved CN is OK
// Check default values for error info
// Check constructor with error info
// Constructor test (with byte[])
// Check invalid bytes for constructor
try
{
// This should generated an exception
assertTrue(false);
}
catch (DataFormatException e)
{
assertTrue(true);
}
// Check that retrieved CN is OK
}
public void eclUpdateMsg()
throws Exception
{
// create a msg to put in the eclupdatemsg
int draftcn = 21;
// create a cookie
"o=test:000001210b6f21e904b100000001 000001210b6f21e904b200000001;" +
"o=test2:000001210b6f21e904b100000002 000001210b6f21e904b200000002;");
// Constructor test
// Constructor test (with byte[])
}
{
state = new ServerState();
state = new ServerState();
}
/**
* Test that ServerStartMsg encoding and decoding works
* by checking that : msg == new ServerStartMsg(msg.getBytes()).
*/
{
}
{
state = new ServerState();
state = new ServerState();
}
/**
* Test that ReplServerStartMsg encoding and decoding works
* by checking that : msg == new ReplServerStartMsg(msg.getBytes()).
*/
{
}
{
state = new ServerState();
Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456, 3, 31512};
state = new ServerState();
Object[] set3 = new Object[] {36, baseDN, 100, "anotherHostAgain:8017", state, 6841L, (byte)32, 2496, 630, 9524};
}
/**
* Test that ReplServerStartDSMsg encoding and decoding works
* by checking that : msg == new ReplServerStartMsg(msg.getBytes()).
*/
{
}
/**
* Test that StopMsg encoding and decoding works
* by checking that : msg == new StopMsg(msg.getBytes()).
*/
@Test
public void stopMsgTest() throws Exception
{
}
/**
* Test that WindowMsg encoding and decoding works
* by checking that : msg == new WindowMsg(msg.getBytes()).
*/
@Test()
public void windowMsgTest() throws Exception
{
}
/**
* Test that WindowProbeMsg encoding and decoding works
* by checking that : new WindowProbeMsg(msg.getBytes()) does not throws
* an exception.
*/
@Test()
public void windowProbeMsgTest() throws Exception
{
}
{
TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber");
return new Object [][] {
};
}
/**
* Test TopologyMsg encoding and decoding.
*/
throws Exception
{
}
/**
* Provider for the StartSessionMsg test.
*/
public Object[][] createStartSessionData()
{
TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber");
+ "?sub?(&(departmentnumber=04*) (l=Juneau))");
return new Object[][]{
};
}
/**
* Test StartSessionMsg encoding and decoding.
*/
throws Exception
{
}
/**
* Provider for the ChangeStatusMsg test
*/
public Object[][] createChangeStatusData()
{
return new Object[][]{
};
}
/**
* Test ChangeStatusMsg encoding and decoding.
*/
throws Exception
{
}
/**
* Test HeartbeatMsg encoding and decoding.
*/
@Test
public void heartbeatMsgTest() throws Exception
{
}
/**
* Test ResetGenerationIdMsg encoding and decoding.
*/
@Test
public void resetGenerationIdMsgTest() throws Exception
{
}
/**
* Test MonitorRequestMsg encoding and decoding.
*/
@Test
public void monitorRequestMsgTest() throws Exception
{
}
/**
* Test MonitorMsg.
*/
@Test()
public void monitorMsgTest() throws Exception
{
int sender = 2;
int dest = 3;
// RS State
// LS1 state
int sid1 = 111;
// LS2 state
int sid2 = 222;
// LS3 state
int sid3 = 56789;
{
{
}
{
}
else
{
}
}
{
{
}
else
{
}
}
}
/**
* Test that EntryMsg encoding and decoding works
* by checking that : msg == new EntryMessageTest(msg.getBytes()).
*/
@Test()
public void entryMsgTest() throws Exception
{
",cn=Scheduled Tasks,cn=Tasks\n" +
"objectclass: top\n" +
"objectclass: ds-task\n" +
"objectclass: ds-task-initialize\n" +
"ds-task-class-name: org.opends.server.replication.api.InitializeTask\n" +
"ds-task-initialize-source: 1\n");
int sender = 1;
int target = 45678;
}
/**
* Test that InitializeRequestMsg encoding and decoding works
*/
@Test()
public void initializeRequestMsgTest() throws Exception
{
int sender = 1;
int target = 56789;
InitializeRequestMsg newMsg = new InitializeRequestMsg(msg.getBytes(),ProtocolVersion.getCurrentVersion());
}
/**
* Test that InitializeTargetMsg encoding and decoding works
*/
@Test()
public void initializeTargetMsgTest() throws Exception
{
int senderID = 45678;
int targetID = 2;
int requestorID = 3;
long entryCount = 4;
int initWindow = 100;
InitializeTargetMsg newMsg = new InitializeTargetMsg(msg.getBytes(),ProtocolVersion.getCurrentVersion());
}
/**
* Test that DoneMsg encoding and decoding works
*/
@Test()
public void doneMsgTest() throws Exception
{
}
/**
* Test that ErrorMsg encoding and decoding works
*/
@Test()
public void errorMsgTest() throws Exception
{
}
/**
* Test Generic UpdateMsg
*/
@Test
public void UpdateMsgTest() throws Exception
{
new UpdateMsg(
}
/**
* Test that ServerStartMsg encoding and decoding works
* by checking that : msg == new ServerStartMsg(msg.getBytes()).
*/
{
}
/**
* Test StartSessionMsg encoding and decoding.
*/
@Test()
public void startECLSessionMsgTest()
throws Exception
{
// data
short mode = 3;
int firstDraftChangeNumber = 13;
int lastDraftChangeNumber = 14;
// create original
// create copy
// test equality between the two copies
{
}
}
int perfRep = 100000;
throws Exception
{
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
long getbytes = 0;
long alld = 0;
long setentryattr = 0;
long buildnew = 0;
"organization");
HashMap<AttributeType, List<Attribute>> userAttList = new HashMap<AttributeType, List<Attribute>>();
for (int i=1;i<perfRep;i++)
{
// create op
"parentUniqueId");
// create msg from op
// set entry attr
// encode msg
// getBytes
// getBytes
}
"addMsgPerfs "
+ "createop\t"
+ "createmsgfromop\t"
+ "setentryattr\t"
+ "encodemsg\t"
+ "getbytes\t"
+ "buildnew\t");
"addMsgPerfs "
}
throws Exception
{
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
long getbytes = 0;
long alld = 0;
long setentryattr = 0;
long buildnew = 0;
for (int i=1;i<perfRep;i++)
{
// create op
// create msg from op
// set entry attr
// generatedMsg.setEntryAttributes(entryAttrList);
// encode msg
// getBytes
// getBytes
}
"modMsgPerfs "
+ "createop\t"
+ "createmsgfromop\t"
+ "setentryattr\t"
+ "encodemsg\t"
+ "getbytes\t"
+ "buildnew\t");
"modMsgPerfs "
}
throws Exception
{
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
long getbytes = 0;
long alld = 0;
long setentryattr = 0;
long buildnew = 0;
for (int i=1;i<perfRep;i++)
{
// create op
// create msg from op
// set entry attr
//generatedMsg.setEntryAttributes(entryAttrList);
// encode msg
// getBytes
// getBytes
}
"deleteMsgPerfs "
+ "createop\t"
+ "createmsgfromop\t"
+ "setentryattr\t"
+ "encodemsg\t"
+ "getbytes\t"
+ "buildnew\t");
"deleteMsgPerfs "
}
}