SDN Controller Programming Guide
123
MAC_ADDRESS,
FRIENDLY_NAME,
ACTIVE_STATE
}
Switch Sort Specification Usage Example:
SortSpecification<SwitchSortKey> sort =
new SortSpecification<SwitchSortKey>();
sort.addSortComponent(SwitchSortKey.MAC_ADDRESS, SortOrder.ASCENDING);
sort.addSortComponent(SwitchSortKey.ACTIVE_STATE, SortOrder.DESCENDING);
sort.addSortComponent(SwitchSortKey.FRIENDLY_NAME, SortOrder.ASCENDING);
Model Objects Unit Test
The HP VAN SDN Controller Framework offers some utilities to facilitate writing unit tests.
Even though The Data Transfer Object [32] is a pattern while a JavaBean [33] is a specification,
consider a Data Transfer Object as a java bean which is transported across tiers. The Data
Transfer Object pattern is used as a light-weight method of transferring data between layers. Thus,
use the Bean Test utilities provided by the HP VAN SDN Controller Framework to test the transfer
objects. The following listing illustrates the utility classes provided by the HP VAN SDN Controller
Framework that can be used to test model objects. For the complete test code see the sample
application source code included with the HP VAN SDN Controller SDK. SwitchTest should be
located under hm-model/src/test/java/com/hp/hm/model directory.
SwitchTest.java:
package com.hp.hm.model;
import com.hp.test.BeanTest;
import com.hp.test.EqualityTester;
import com.hp.test.SerializabilityTester;
public class SwitchTest {
...
@Test
public void testGettersAndSetters() throws Exception {
Switch device = //... create an instance
BeanTest.testGettersAndSetters(device);
}
@Test
public void testEqualsAndHashcode() {
Switch base = //... create the base object
Switch equals1 = //... create an object equal to the base
Switch equals2 = //... create an object equal to the base
Switch unequal = //... create an object unequal to the base
EqualityTester.testEqualsAndHashCode(base, equals1,