Search in sources :

Example 6 with MockResourceService

use of org.onosproject.net.resource.MockResourceService in project onos by opennetworkinglab.

the class PointToPointIntentCompilerTest method makeCompiler.

/**
 * Creates a point to point intent compiler for a three switch linear
 * topology.
 *
 * @param resourceService service to use for resource allocation requests
 * @return point to point compiler
 */
private PointToPointIntentCompiler makeCompiler(String[] hops, ResourceService resourceService) {
    final PointToPointIntentCompiler compiler = new PointToPointIntentCompiler();
    compiler.pathService = new IntentTestsMocks.MockPathService(hops);
    if (resourceService == null) {
        compiler.resourceService = new MockResourceService();
    } else {
        compiler.resourceService = resourceService;
    }
    return compiler;
}
Also used : MockResourceService(org.onosproject.net.resource.MockResourceService) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks)

Example 7 with MockResourceService

use of org.onosproject.net.resource.MockResourceService in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method makeCompiler.

/**
 * Creates a compiler for SinglePointToMultiPoint intents.
 *
 * @param hops hops to use while computing paths for this intent
 * @param pathService the path service
 * @param resourceService the resource service
 * @return a single point to multi point intent compiler
 */
private SinglePointToMultiPointIntentCompiler makeCompiler(String[] hops, PathService pathService, ResourceService resourceService) {
    SinglePointToMultiPointIntentCompiler compiler = new SinglePointToMultiPointIntentCompiler();
    compiler.deviceService = new IntentTestsMocks.MockDeviceService();
    if (pathService == null) {
        compiler.pathService = new IntentTestsMocks.Mp2MpMockPathService(hops);
    } else {
        compiler.pathService = pathService;
    }
    if (resourceService == null) {
        compiler.resourceService = new MockResourceService();
    } else {
        compiler.resourceService = resourceService;
    }
    return compiler;
}
Also used : MockResourceService(org.onosproject.net.resource.MockResourceService) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks)

Example 8 with MockResourceService

use of org.onosproject.net.resource.MockResourceService in project onos by opennetworkinglab.

the class LinkCollectionEncapIntentCompilerTest method setUp.

@Before
public void setUp() {
    sut = new LinkCollectionIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
    sut.coreService = coreService;
    domainService = createMock(DomainService.class);
    expect(domainService.getDomain(anyObject(DeviceId.class))).andReturn(LOCAL).anyTimes();
    sut.domainService = domainService;
    super.setUp();
    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut);
    intentExtensionService.unregisterCompiler(LinkCollectionIntent.class);
    registrator = new IntentConfigurableRegistrator();
    registrator.extensionService = intentExtensionService;
    registrator.cfgService = new ComponentConfigAdapter();
    registrator.activate();
    sut.registrator = registrator;
    sut.resourceService = new MockResourceService();
    LinkCollectionCompiler.optimizeInstructions = false;
    LinkCollectionCompiler.copyTtl = false;
    replay(coreService, domainService, intentExtensionService);
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) MockResourceService(org.onosproject.net.resource.MockResourceService) DomainService(org.onosproject.net.domain.DomainService) CoreService(org.onosproject.core.CoreService) Before(org.junit.Before)

Example 9 with MockResourceService

use of org.onosproject.net.resource.MockResourceService in project onos by opennetworkinglab.

the class HostToHostIntentCompilerTest method makeCompiler.

/**
 * Creates a compiler for HostToHost intents.
 *
 * @param hops string array describing the path hops to use when compiling
 * @param resourceService the resource service
 * @return HostToHost intent compiler
 */
private HostToHostIntentCompiler makeCompiler(String[] hops, ResourceService resourceService) {
    HostToHostIntentCompiler compiler = new HostToHostIntentCompiler();
    compiler.pathService = new IntentTestsMocks.MockPathService(hops);
    compiler.hostService = mockHostService;
    if (resourceService == null) {
        compiler.resourceService = new MockResourceService();
    } else {
        compiler.resourceService = resourceService;
    }
    return compiler;
}
Also used : MockResourceService(org.onosproject.net.resource.MockResourceService) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks)

Example 10 with MockResourceService

use of org.onosproject.net.resource.MockResourceService in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerDomainP2PTest method setUp.

@Before
public void setUp() {
    sut = new LinkCollectionIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
    sut.coreService = coreService;
    // defining the domain assignments
    domainService = createMock(DomainService.class);
    expect(domainService.getDomain(d1Id)).andReturn(LOCAL).anyTimes();
    expect(domainService.getDomain(d2Id)).andReturn(domain).anyTimes();
    expect(domainService.getDomain(d4Id)).andReturn(domain).anyTimes();
    expect(domainService.getDomain(d3Id)).andReturn(LOCAL).anyTimes();
    sut.domainService = domainService;
    super.setUp();
    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut);
    intentExtensionService.unregisterCompiler(LinkCollectionIntent.class);
    registrator = new IntentConfigurableRegistrator();
    registrator.extensionService = intentExtensionService;
    registrator.cfgService = new ComponentConfigAdapter();
    registrator.activate();
    sut.registrator = registrator;
    sut.resourceService = new MockResourceService();
    LinkCollectionCompiler.optimizeInstructions = false;
    LinkCollectionCompiler.copyTtl = false;
    replay(coreService, domainService, intentExtensionService);
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) MockResourceService(org.onosproject.net.resource.MockResourceService) DomainService(org.onosproject.net.domain.DomainService) CoreService(org.onosproject.core.CoreService) Before(org.junit.Before)

Aggregations

MockResourceService (org.onosproject.net.resource.MockResourceService)15 Before (org.junit.Before)10 CoreService (org.onosproject.core.CoreService)9 IntentExtensionService (org.onosproject.net.intent.IntentExtensionService)9 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)7 DomainService (org.onosproject.net.domain.DomainService)6 IntentTestsMocks (org.onosproject.net.intent.IntentTestsMocks)5 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 DefaultPath (org.onosproject.net.DefaultPath)1 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)1 FlowObjectiveServiceAdapter (org.onosproject.net.flowobjective.FlowObjectiveServiceAdapter)1 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)1