return topologyManager;
}
@Test
public void testClusters() throws Exception {
TopologyManager tm = getTopologyManager();
{
int [][] linkArray = {
{1, 1, 2, 1, DIRECT_LINK},
{2, 2, 3, 2, DIRECT_LINK},
{3, 1, 1, 2, DIRECT_LINK},
{2, 3, 4, 2, DIRECT_LINK},
{3, 3, 4, 1, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3},
{4}
};
//tm.recompute();
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
{
int [][] linkArray = {
{5, 3, 6, 1, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3},
{4},
{5},
{6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
{
int [][] linkArray = {
{6, 1, 5, 3, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3},
{4},
{5,6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
{
int [][] linkArray = {
{4, 2, 2, 3, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3,4},
{5,6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
{
int [][] linkArray = {
{4, 3, 5, 1, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3,4},
{5,6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
{
int [][] linkArray = {
{5, 2, 2, 4, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3,4,5,6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
//Test 2.
{
int [][] linkArray = {
{3, 2, 2, 2, DIRECT_LINK},
{2, 1, 1, 1, DIRECT_LINK},
{1, 2, 3, 1, DIRECT_LINK},
{4, 1, 3, 3, DIRECT_LINK},
{5, 1, 4, 3, DIRECT_LINK},
{2, 4, 5, 2, DIRECT_LINK}
};
int [][] expectedClusters = {
{1,2,3,4,5,6}
};
createTopologyFromLinks(linkArray);
verifyClusters(expectedClusters);
}
// Test 3. Remove links
{
tm.removeLink((long)5,(short)3,(long)6,(short)1);
tm.removeLink((long)6,(short)1,(long)5,(short)3);
int [][] expectedClusters = {
{1,2,3,4,5},
};
topologyManager.createNewInstance();
verifyClusters(expectedClusters);
}
// Remove Switch
{
tm.removeSwitch(4);
int [][] expectedClusters = {
{1,2,3,5},
};
topologyManager.createNewInstance();
verifyClusters(expectedClusters);