/** * This test require the dirty model, since the checkParams method would check there's a * GreTunnelService in the model. * * @throws CapabilityException * @throws ProtocolException */ @Test @Ignore public void testDeleteUnexistingTunnelAction() throws CapabilityException, ProtocolException { log.info("TEST GRE TUNNEL ACTION"); IGRETunnelCapability greCapability = (IGRETunnelCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE)); greCapability.deleteGRETunnel( ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, null, null, null, null)); IQueueManagerCapability queueCapability = (IQueueManagerCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation( TestsConstants.QUEUE_CAPABILIY_TYPE)); List<IAction> queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 1); QueueResponse queueResponse = (QueueResponse) queueCapability.execute(); Assert.assertEquals(queueResponse.getResponses().size(), 1); Assert.assertFalse(queueResponse.isOk()); queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 0); }
@Test public void testGRECreateTunnelAction() throws CapabilityException, ProtocolException { log.info("TEST GRE TUNNEL ACTION"); IGRETunnelCapability greCapability = (IGRETunnelCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE)); greCapability.createGRETunnel( ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv4_ADDRESS, IP_SOURCE, IP_DESTINY)); IQueueManagerCapability queueCapability = (IQueueManagerCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation( TestsConstants.QUEUE_CAPABILIY_TYPE)); List<IAction> queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 1); QueueResponse queueResponse = (QueueResponse) queueCapability.execute(); Assert.assertEquals(queueResponse.getResponses().size(), 1); Assert.assertEquals(queueResponse.getPrepareResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals(queueResponse.getConfirmResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals(queueResponse.getRefreshResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals( queueResponse.getRestoreResponse().getStatus(), ActionResponse.STATUS.PENDING); Assert.assertTrue(queueResponse.isOk()); queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 0); }
@Test public void testGREDeleteTunnelAction() throws CapabilityException, ProtocolException { log.info("TEST GRE TUNNEL ACTION"); IGRETunnelCapability greCapability = (IGRETunnelCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE)); // add gre tunnel service to the router model. GRETunnelService greTunnelService = new GRETunnelService(); greTunnelService.setName(TUNNEL_NAME); ComputerSystem model = (ComputerSystem) routerResource.getModel(); model.addHostedService(greTunnelService); routerResource.setModel(model); greCapability.deleteGRETunnel( ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, null, null, null, null)); IQueueManagerCapability queueCapability = (IQueueManagerCapability) routerResource.getCapability( InitializerTestHelper.getCapabilityInformation( TestsConstants.QUEUE_CAPABILIY_TYPE)); List<IAction> queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 1); QueueResponse queueResponse = (QueueResponse) queueCapability.execute(); Assert.assertEquals(queueResponse.getResponses().size(), 1); Assert.assertEquals(queueResponse.getPrepareResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals(queueResponse.getConfirmResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals(queueResponse.getRefreshResponse().getStatus(), ActionResponse.STATUS.OK); Assert.assertEquals( queueResponse.getRestoreResponse().getStatus(), ActionResponse.STATUS.PENDING); Assert.assertTrue(queueResponse.isOk()); queue = (List<IAction>) queueCapability.getActions(); Assert.assertEquals(queue.size(), 0); }
@Test public void MakeRemoveConnectionsResourceTest() throws Exception { ResourceDescriptor resourceDescriptor = ResourceHelper.newResourceDescriptorProteus("roadm"); /* create resource */ Resource resource = (Resource) repository.createResource(resourceDescriptor); Assert.assertNotNull(resource.getResourceIdentifier()); Assert.assertNotNull(resource.getResourceDescriptor()); Assert.assertTrue(resource.getCapabilities().isEmpty()); Assert.assertNull(resource.getModel()); Assert.assertNull(resource.getProfile()); Assert.assertFalse(repository.listResources().isEmpty()); // add protocol for resource createProtocolForResource(resource.getResourceIdentifier().getId()); /* start resource */ repository.startResource(resource.getResourceIdentifier().getId()); Assert.assertFalse(resource.getCapabilities().isEmpty()); Assert.assertNotNull(resource.getModel()); // Assert.assertNotNull(resource.getProfile()); IConnectionsCapability connections = (IConnectionsCapability) resource.getCapabilityByInterface(IConnectionsCapability.class); if (connections == null) Assert.fail("Capability not found"); IQueueManagerCapability queueCapability = (IQueueManagerCapability) resource.getCapabilityByInterface(IQueueManagerCapability.class); if (queueCapability == null) Assert.fail("Capability not found"); /* checking model */ // TODO CHECK NEW MODEL CONFIG /* refresh connection */ // Response resp = (Response) connections.sendMessage(ActionConstants.REFRESHCONNECTIONS, null); // List<ActionResponse> responses = (List<ActionResponse>) // queueCapability.sendMessage(QueueManagerConstants.EXECUTE, null); // // Assert.assertTrue(responses.size() == 2); // ActionResponse actionResponse = responses.get(0); // Assert.assertEquals(ActionConstants.REFRESHCONNECTIONS, actionResponse.getActionID()); // for (Response response : actionResponse.getResponses()) { // Assert.assertTrue(response.getStatus() == Response.Status.OK); // } // // List<IAction> queue = (List<IAction>) // queueCapability.sendMessage(QueueManagerConstants.GETQUEUE, null); // Assert.assertTrue(queue.size() == 0); OpticalSwitchFactory opticalSwitchFactory = new OpticalSwitchFactory(); resource.setModel(opticalSwitchFactory.newPedrosaProteusOpticalSwitch()); /* make connection */ FiberConnection connectionRequest = newMakeConnectionParams((ProteusOpticalSwitch) resource.getModel()); connections.makeConnection(connectionRequest); QueueResponse queueResponse = queueCapability.execute(); Assert.assertTrue(queueResponse.isOk()); boolean foundAndOk = false; for (ActionResponse response : queueResponse.getResponses()) { if (response.getActionID().equals(ActionConstants.MAKECONNECTION)) { if (response.getStatus() == STATUS.OK) { foundAndOk = true; for (Response subresponse : response.getResponses()) { Assert.assertTrue(subresponse.getStatus() == Response.Status.OK); } } } } Assert.assertTrue(foundAndOk); List<IAction> queue = (List<IAction>) queueCapability.getActions(); Assert.assertTrue(queue.size() == 0); /* checking model */ Assert.assertNotNull( getFiberConnection(connectionRequest, (ProteusOpticalSwitch) resource.getModel())); // checking for model intern details is in action tests /* remove connection */ connections.removeConnection(connectionRequest); queueResponse = (QueueResponse) queueCapability.execute(); Assert.assertTrue(queueResponse.isOk()); foundAndOk = false; for (ActionResponse response : queueResponse.getResponses()) { if (response.getActionID().equals(ActionConstants.REMOVECONNECTION)) { if (response.getStatus() == STATUS.OK) { foundAndOk = true; for (Response subresponse : response.getResponses()) { Assert.assertTrue(subresponse.getStatus() == Response.Status.OK); } } } } Assert.assertTrue(foundAndOk); queue = (List<IAction>) queueCapability.getActions(); Assert.assertTrue(queue.size() == 0); /* checking model */ Assert.assertNull( getFiberConnection(connectionRequest, (ProteusOpticalSwitch) resource.getModel())); /* stop resource */ repository.stopResource(resource.getResourceIdentifier().getId()); Assert.assertNotNull(resource.getResourceIdentifier()); Assert.assertNotNull(resource.getResourceDescriptor()); Assert.assertTrue(resource.getCapabilities().isEmpty()); Assert.assertNull(resource.getModel()); // Assert.assertNull(resource.getProfile()); Assert.assertFalse(repository.listResources().isEmpty()); /* remove resource */ createProtocolForResource(resource.getResourceIdentifier().getId()); repository.removeResource(resource.getResourceIdentifier().getId()); Assert.assertTrue(resource.getCapabilities().isEmpty()); Assert.assertNull(resource.getModel()); Assert.assertNull(resource.getProfile()); // Assert.assertTrue(repository.listResources().isEmpty()); }