use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class SimpleGroupStoreTest method testGroupOperationFailure.
@Test
public void testGroupOperationFailure() {
simpleGroupStore.deviceInitialAuditCompleted(D1, true);
ApplicationId appId = new DefaultApplicationId(2, "org.groupstore.test");
GroupKey key = new DefaultGroupKey("group1".getBytes());
PortNumber[] ports = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
List<PortNumber> outPorts = new ArrayList<>();
outPorts.add(ports[0]);
outPorts.add(ports[1]);
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
GroupDescription groupDesc = new DefaultGroupDescription(D1, Group.Type.SELECT, groupBuckets, key, null, appId);
InternalGroupStoreDelegate checkStoreGroupDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_REQUESTED);
simpleGroupStore.setDelegate(checkStoreGroupDelegate);
// Testing storeGroup operation
simpleGroupStore.storeGroupDescription(groupDesc);
simpleGroupStore.unsetDelegate(checkStoreGroupDelegate);
// Testing Group add operation failure
Group createdGroup = simpleGroupStore.getGroup(D1, key);
checkStoreGroupDelegate.verifyGroupId(createdGroup.id());
GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
InternalGroupStoreDelegate checkGroupAddFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_FAILED);
simpleGroupStore.setDelegate(checkGroupAddFailureDelegate);
simpleGroupStore.groupOperationFailed(D1, groupAddOp);
// Testing Group modify operation failure
simpleGroupStore.unsetDelegate(checkGroupAddFailureDelegate);
GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
InternalGroupStoreDelegate checkGroupModFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_UPDATE_FAILED);
simpleGroupStore.setDelegate(checkGroupModFailureDelegate);
simpleGroupStore.groupOperationFailed(D1, groupModOp);
// Testing Group modify operation failure
simpleGroupStore.unsetDelegate(checkGroupModFailureDelegate);
GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
InternalGroupStoreDelegate checkGroupDelFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_REMOVE_FAILED);
simpleGroupStore.setDelegate(checkGroupDelFailureDelegate);
simpleGroupStore.groupOperationFailed(D1, groupDelOp);
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class DistributedSecurityModeStoreTest method setUp.
@Before
public void setUp() throws Exception {
appId = new DefaultApplicationId(1, "test");
testPermissions = new HashSet<Permission>();
testPermission = new Permission("testClass", "testName");
testPermissions.add(testPermission);
testFeatures = new ArrayList<String>();
testFeatures.add("testFeature");
testRequiredApps = new ArrayList<String>();
testRequiredApps.add("testRequiredApp");
app = DefaultApplication.builder().withAppId(appId).withVersion(Version.version(1, 1, "patch", "build")).withTitle("testTitle").withDescription("testDes").withOrigin("testOri").withCategory("testCT").withUrl("testurl").withReadme("test").withIcon(null).withRole(ApplicationRole.ADMIN).withPermissions(testPermissions).withFeaturesRepo(Optional.ofNullable(null)).withFeatures(testFeatures).withRequiredApps(testRequiredApps).build();
testLocations = new HashSet<String>();
testLocations.add("locationA");
testLocations.add("locationB");
Set<ApplicationId> appIdSet = new HashSet<ApplicationId>();
appIdSet.add(appId);
localBundleAppDirectory = new ConcurrentHashMap<>();
localBundleAppDirectory.put("testLocation", appIdSet);
localAppBundleDirectory = new ConcurrentHashMap<>();
localAppBundleDirectory.put(appId, testLocations);
violations = new ConcurrentHashMap<ApplicationId, Set<Permission>>();
violations.put(appId, testPermissions);
testSecInfo = new SecurityInfo(testPermissions, SECURED);
states = new ConcurrentHashMap<ApplicationId, SecurityInfo>();
states.put(appId, testSecInfo);
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class SecurityModeManagerTest method testGetPrintableRequestedPermissions.
@Test
public void testGetPrintableRequestedPermissions() {
DefaultApplicationId appIdViolation;
appIdViolation = new DefaultApplicationId(2, "violation");
Map<Integer, List<Permission>> result = getPrintablePermissionMap(store.getRequestedPermissions(appIdViolation));
assertNotNull(result.get(2).get(0));
assertTrue(result.get(2).size() > 0);
assertEquals("testNameViolation", result.get(2).get(0).getName());
}
Aggregations