当前位置: 首页>>代码示例>>Java>>正文


Java TestModel类代码示例

本文整理汇总了Java中org.opendaylight.controller.md.cluster.datastore.model.TestModel的典型用法代码示例。如果您正苦于以下问题:Java TestModel类的具体用法?Java TestModel怎么用?Java TestModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestModel类属于org.opendaylight.controller.md.cluster.datastore.model包,在下文中一共展示了TestModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testApply

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testApply() throws Exception {
    //TODO : Need to write a better test for this

    //Write something into the datastore
    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
    MergeModification writeModification = new MergeModification(TestModel.TEST_PATH,
            ImmutableNodes.containerNode(TestModel.TEST_QNAME));
    writeModification.apply(writeTransaction);
    commitTransaction(writeTransaction);

    //Check if it's in the datastore
    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
    Assert.assertTrue(data.isPresent());

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:MergeModificationTest.java

示例2: testTransactionAbort

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testTransactionAbort() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "transactionAbortIntegrationTest", "test-1")) {

                final DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
                assertNotNull("newWriteOnlyTransaction returned null", writeTx);

                writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));

                final DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();

                cohort.canCommit().get(5, TimeUnit.SECONDS);

                cohort.abort().get(5, TimeUnit.SECONDS);

                testWriteTransaction(dataStore, TestModel.TEST_PATH,
                        ImmutableNodes.containerNode(TestModel.TEST_QNAME));
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:DistributedDataStoreIntegrationTest.java

示例3: testCreateChainedTransactionAfterEmptyTxReadied

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testCreateChainedTransactionAfterEmptyTxReadied() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testCreateChainedTransactionAfterEmptyTxReadied", "test-1")) {

                final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();

                final DOMStoreReadWriteTransaction rwTx1 = txChain.newReadWriteTransaction();

                rwTx1.ready();

                final DOMStoreReadWriteTransaction rwTx2 = txChain.newReadWriteTransaction();

                final Optional<NormalizedNode<?, ?>> optional = rwTx2.read(TestModel.TEST_PATH).get(
                        5, TimeUnit.SECONDS);
                assertEquals("isPresent", false, optional.isPresent());

                txChain.close();
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:DistributedDataStoreIntegrationTest.java

示例4: testCreateChainedTransactionWhenPreviousNotReady

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testCreateChainedTransactionWhenPreviousNotReady() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testCreateChainedTransactionWhenPreviousNotReady", "test-1")) {

                final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();

                final DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
                assertNotNull("newWriteOnlyTransaction returned null", writeTx);

                writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));

                // Try to create another Tx of each type - each should fail
                // b/c the previous Tx wasn't
                // readied.
                assertExceptionOnTxChainCreates(txChain, IllegalStateException.class);
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DistributedDataStoreIntegrationTest.java

示例5: testMergeWithInvalidChildNodeNames

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testMergeWithInvalidChildNodeNames() throws DataValidationFailedException {
    ContainerNode augContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(AUG_CONTAINER)).withChild(
                    ImmutableNodes.containerNode(AUG_INNER_CONTAINER)).build();

    DataContainerChild<?, ?> outerNode = outerNode(outerNodeEntry(1, innerNode("one", "two")));
    ContainerNode normalizedNode = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode)
            .withChild(augContainer).withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug")).build();

    YangInstanceIdentifier path = TestModel.TEST_PATH;

    pruningDataTreeModification.merge(path, normalizedNode);

    dataTree.commit(getCandidate());

    ContainerNode prunedNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode).build();

    Optional<NormalizedNode<?, ?>> actual = dataTree.takeSnapshot().readNode(path);
    assertEquals("After pruning present", true, actual.isPresent());
    assertEquals("After pruning", prunedNode, actual.get());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:PruningDataTreeModificationTest.java

示例6: testWriteWithInvalidChildNodeNames

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testWriteWithInvalidChildNodeNames() throws DataValidationFailedException {
    ContainerNode augContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(AUG_CONTAINER)).withChild(
                    ImmutableNodes.containerNode(AUG_INNER_CONTAINER)).build();

    DataContainerChild<?, ?> outerNode = outerNode(outerNodeEntry(1, innerNode("one", "two")));
    ContainerNode normalizedNode = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode)
            .withChild(augContainer).withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug"))
            .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")).build();

    YangInstanceIdentifier path = TestModel.TEST_PATH;

    pruningDataTreeModification.write(path, normalizedNode);

    dataTree.commit(getCandidate());

    ContainerNode prunedNode = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode)
            .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")).build();

    Optional<NormalizedNode<?, ?>> actual = dataTree.takeSnapshot().readNode(path);
    assertEquals("After pruning present", true, actual.isPresent());
    assertEquals("After pruning", prunedNode, actual.get());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:PruningDataTreeModificationTest.java

示例7: testShardDataTreeSnapshotWithNoMetadata

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testShardDataTreeSnapshotWithNoMetadata() throws Exception {
    NormalizedNode<?, ?> expectedNode = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(expectedNode);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try (ObjectOutputStream out = new ObjectOutputStream(bos)) {
        snapshot.serialize(out);
    }

    ShardDataTreeSnapshot deserialized;
    try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
        deserialized = ShardDataTreeSnapshot.deserialize(in);
    }

    Optional<NormalizedNode<?, ?>> actualNode = deserialized.getRootNode();
    assertEquals("rootNode present", true, actualNode.isPresent());
    assertEquals("rootNode", expectedNode, actualNode.get());
    assertEquals("Deserialized type", MetadataShardDataTreeSnapshot.class, deserialized.getClass());
    assertEquals("Metadata size", 0, ((MetadataShardDataTreeSnapshot)deserialized).getMetadata().size());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:ShardDataTreeSnapshotTest.java

示例8: testShardDataTreeSnapshotWithMetadata

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testShardDataTreeSnapshotWithMetadata() throws Exception {
    NormalizedNode<?, ?> expectedNode = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    Map<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>> expMetadata =
            ImmutableMap.of(TestShardDataTreeSnapshotMetadata.class, new TestShardDataTreeSnapshotMetadata("test"));
    MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(expectedNode, expMetadata);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try (ObjectOutputStream out = new ObjectOutputStream(bos)) {
        snapshot.serialize(out);
    }

    ShardDataTreeSnapshot deserialized;
    try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
        deserialized = ShardDataTreeSnapshot.deserialize(in);
    }

    Optional<NormalizedNode<?, ?>> actualNode = deserialized.getRootNode();
    assertEquals("rootNode present", true, actualNode.isPresent());
    assertEquals("rootNode", expectedNode, actualNode.get());
    assertEquals("Deserialized type", MetadataShardDataTreeSnapshot.class, deserialized.getClass());
    assertEquals("Metadata", expMetadata, ((MetadataShardDataTreeSnapshot)deserialized).getMetadata());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ShardDataTreeSnapshotTest.java

示例9: testSerialization

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testSerialization() {
    NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    ReadDataReply expected = new ReadDataReply(data, DataStoreVersions.CURRENT_VERSION);

    Object serialized = expected.toSerializable();
    assertEquals("Serialized type", ReadDataReply.class, serialized.getClass());

    ReadDataReply actual = ReadDataReply.fromSerializable(SerializationUtils.clone(
            (Serializable) serialized));
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
    assertEquals("getNormalizedNode", expected.getNormalizedNode(), actual.getNormalizedNode());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ReadDataReplyTest.java

示例10: testCreateTransaction

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testCreateTransaction() {
    new ShardTestKit(getSystem()) {
        {
            final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransaction");

            waitUntilLeader(shard);

            shard.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());

            shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
                    DataStoreVersions.CURRENT_VERSION).toSerializable(), getRef());

            final CreateTransactionReply reply = expectMsgClass(duration("3 seconds"),
                    CreateTransactionReply.class);

            final String path = reply.getTransactionPath().toString();
            assertTrue("Unexpected transaction path " + path, path.startsWith(String.format(
                    "akka://test/user/testCreateTransaction/shard-%s-%s:[email protected]:",
                        shardID.getShardName(), shardID.getMemberName().getName())));
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:ShardTest.java

示例11: testOnReceiveReadDataWhenDataNotFound

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testOnReceiveReadDataWhenDataNotFound() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            testOnReceiveReadDataWhenDataNotFound(
                    newTransactionActor(RO, readOnlyTransaction(), "testReadDataWhenDataNotFoundRO"));

            testOnReceiveReadDataWhenDataNotFound(
                    newTransactionActor(RW, readWriteTransaction(), "testReadDataWhenDataNotFoundRW"));
        }

        private void testOnReceiveReadDataWhenDataNotFound(final ActorRef transaction) {
            transaction.tell(new ReadData(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION), getRef());

            ReadDataReply reply = expectMsgClass(duration("5 seconds"), ReadDataReply.class);

            assertTrue(reply.getNormalizedNode() == null);
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:ShardTransactionTest.java

示例12: testOnReceiveDataExistsNegative

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testOnReceiveDataExistsNegative() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            testOnReceiveDataExistsNegative(
                    newTransactionActor(RO, readOnlyTransaction(), "testDataExistsNegativeRO"));

            testOnReceiveDataExistsNegative(
                    newTransactionActor(RW, readWriteTransaction(), "testDataExistsNegativeRW"));
        }

        private void testOnReceiveDataExistsNegative(final ActorRef transaction) {
            transaction.tell(new DataExists(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION), getRef());

            DataExistsReply reply = expectMsgClass(duration("5 seconds"), DataExistsReply.class);

            assertFalse(reply.exists());
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:ShardTransactionTest.java

示例13: testInvalidCreateTransactionReply

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testInvalidCreateTransactionReply() throws Exception {
    ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));

    doReturn(getSystem().actorSelection(actorRef.path())).when(mockActorContext)
            .actorSelection(actorRef.path().toString());

    doReturn(primaryShardInfoReply(getSystem(), actorRef)).when(mockActorContext)
            .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));

    doReturn(Futures.successful(new Object())).when(mockActorContext).executeOperationAsync(
        eq(getSystem().actorSelection(actorRef.path())), eqCreateTransaction(memberName, READ_ONLY),
        any(Timeout.class));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY);

    propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:TransactionProxyTest.java

示例14: testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard() throws Exception {
    LOG.info("testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard starting");
    new JavaTestKit(getSystem()) {
        {
            final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());

            shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            shardManager.tell(new ActorInitialized(), mockShardActor);
            shardManager.tell(new RoleChangeNotification("member-1-shard-default-" + shardMrgIDSuffix, null,
                    RaftState.IsolatedLeader.name()), mockShardActor);

            shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), getRef());

            expectMsgClass(duration("2 seconds"), NoShardLeaderException.class);
        }
    };

    LOG.info("testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard ending");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:ShardManagerTest.java

示例15: testMultipleRegistrationsAtOnePrefix

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入依赖的package包/类
@Test
public void testMultipleRegistrationsAtOnePrefix() throws Exception {
    initEmptyDatastores();

    for (int i = 0; i < 10; i++) {
        LOG.debug("Round {}", i);
        final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard(
                TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
                DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);

        leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
                ClusterUtils.getCleanShardName(TestModel.TEST_PATH));

        assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(),
                ClusterUtils.getCleanShardName(TestModel.TEST_PATH)));

        waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);

        waitUntilShardIsDown(leaderDistributedDataStore.getActorContext(),
                ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DistributedShardedDOMDataTreeTest.java


注:本文中的org.opendaylight.controller.md.cluster.datastore.model.TestModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。