Search in sources :

Example 1 with IntentCompiler

use of org.onosproject.net.intent.IntentCompiler in project onos by opennetworkinglab.

the class IntentManagerTest method intentSubclassCompile.

/**
 * Tests that a compiler for a subclass of an intent that already has a
 * compiler is automatically added.
 */
@Test
public void intentSubclassCompile() {
    class MockIntentSubclass extends MockIntent {

        public MockIntentSubclass(Long number) {
            super(number);
        }
    }
    flowRuleService.setFuture(true);
    listener.setLatch(1, Type.INSTALL_REQ);
    listener.setLatch(1, Type.INSTALLED);
    Intent intent = new MockIntentSubclass(MockIntent.nextId());
    service.submit(intent);
    listener.await(Type.INSTALL_REQ);
    listener.await(Type.INSTALLED);
    assertEquals(1L, service.getIntentCount());
    assertEquals(1L, flowRuleService.getFlowRuleCount());
    final Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> compilers = extensionService.getCompilers();
    assertEquals(2, compilers.size());
    assertNotNull(compilers.get(MockIntentSubclass.class));
    assertNotNull(compilers.get(MockIntent.class));
    verifyState();
}
Also used : IntentCompiler(org.onosproject.net.intent.IntentCompiler) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)1 Intent (org.onosproject.net.intent.Intent)1 IntentCompiler (org.onosproject.net.intent.IntentCompiler)1 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)1 PathIntent (org.onosproject.net.intent.PathIntent)1