當前位置: 首頁>>代碼示例>>Java>>正文


Java TestModel.TEST_PATH屬性代碼示例

本文整理匯總了Java中org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_PATH屬性的典型用法代碼示例。如果您正苦於以下問題:Java TestModel.TEST_PATH屬性的具體用法?Java TestModel.TEST_PATH怎麽用?Java TestModel.TEST_PATH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.opendaylight.controller.md.cluster.datastore.model.TestModel的用法示例。


在下文中一共展示了TestModel.TEST_PATH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testApply

@Test
public void testApply() throws Exception {
    // Write something into the datastore
    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
    WriteModification writeModification = new WriteModification(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());

    // Delete stuff from the datastore
    DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
    DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
    deleteModification.apply(deleteTransaction);
    commitTransaction(deleteTransaction);

    data = readData(TestModel.TEST_PATH);
    Assert.assertFalse(data.isPresent());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:22,代碼來源:DeleteModificationTest.java

示例2: testWriteWithInvalidChildNodeNames

@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,代碼行數:26,代碼來源:PruningDataTreeModificationTest.java

示例3: testSerialization

@Test
public void testSerialization() {
    YangInstanceIdentifier path = TestModel.TEST_PATH;
    NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    MergeModification expected = new MergeModification(path, data);

    MergeModification clone = (MergeModification) SerializationUtils.clone(expected);
    assertEquals("getPath", expected.getPath(), clone.getPath());
    assertEquals("getData", expected.getData(), clone.getData());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:13,代碼來源:MergeModificationTest.java

示例4: testSerialization

@Test
public void testSerialization() {
    YangInstanceIdentifier writePath = TestModel.TEST_PATH;
    NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH;
    NormalizedNode<?, ?> mergeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build();

    YangInstanceIdentifier deletePath = TestModel.TEST_PATH;

    MutableCompositeModification compositeModification = new MutableCompositeModification();
    compositeModification.addModification(new WriteModification(writePath, writeData));
    compositeModification.addModification(new MergeModification(mergePath, mergeData));
    compositeModification.addModification(new DeleteModification(deletePath));

    MutableCompositeModification clone = (MutableCompositeModification)
            SerializationUtils.clone(compositeModification);

    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, clone.getVersion());

    assertEquals("getModifications size", 3, clone.getModifications().size());

    WriteModification write = (WriteModification)clone.getModifications().get(0);
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, write.getVersion());
    assertEquals("getPath", writePath, write.getPath());
    assertEquals("getData", writeData, write.getData());

    MergeModification merge = (MergeModification)clone.getModifications().get(1);
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, merge.getVersion());
    assertEquals("getPath", mergePath, merge.getPath());
    assertEquals("getData", mergeData, merge.getData());

    DeleteModification delete = (DeleteModification)clone.getModifications().get(2);
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, delete.getVersion());
    assertEquals("getPath", deletePath, delete.getPath());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:39,代碼來源:MutableCompositeModificationTest.java

示例5: testSerialization

@Test
public void testSerialization() {
    YangInstanceIdentifier path = TestModel.TEST_PATH;

    DeleteModification expected = new DeleteModification(path);

    DeleteModification clone = (DeleteModification) SerializationUtils.clone(expected);
    assertEquals("getPath", expected.getPath(), clone.getPath());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:9,代碼來源:DeleteModificationTest.java

示例6: testApply

@Test
public void testApply() throws Exception {
    //Write something into the datastore
    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
    WriteModification writeModification = new WriteModification(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,代碼行數:13,代碼來源:WriteModificationTest.java

示例7: testSerialization

@Test
public void testSerialization() {
    YangInstanceIdentifier path = TestModel.TEST_PATH;
    NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    WriteModification expected = new WriteModification(path, data);

    WriteModification clone = (WriteModification) SerializationUtils.clone(expected);
    assertEquals("getPath", expected.getPath(), clone.getPath());
    assertEquals("getData", expected.getData(), clone.getData());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:13,代碼來源:WriteModificationTest.java

示例8: testReadWriteTransactionWithSingleShard

@Test
public void testReadWriteTransactionWithSingleShard() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testReadWriteTransactionWithSingleShard", "test-1")) {

                // 1. Create a read-write Tx
                final DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
                assertNotNull("newReadWriteTransaction returned null", readWriteTx);

                // 2. Write some data
                final YangInstanceIdentifier nodePath = TestModel.TEST_PATH;
                final NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
                readWriteTx.write(nodePath, nodeToWrite);

                // 3. Read the data from Tx
                final Boolean exists = readWriteTx.exists(nodePath).checkedGet(5, TimeUnit.SECONDS);
                assertEquals("exists", true, exists);

                Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(nodePath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", nodeToWrite, optional.get());

                // 4. Ready the Tx for commit
                final DOMStoreThreePhaseCommitCohort cohort = readWriteTx.ready();

                // 5. Commit the Tx
                doCommit(cohort);

                // 6. Verify the data in the store
                final DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();

                optional = readTx.read(nodePath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", nodeToWrite, optional.get());
            }
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:40,代碼來源:DistributedDataStoreIntegrationTest.java

示例9: setUp

@Before
public void setUp() {
    setUpStatic();
    final YangInstanceIdentifier writePath = TestModel.TEST_PATH;
    final NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
    candidate = DataTreeCandidates.fromNormalizedNode(writePath, writeData);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:9,代碼來源:CommitTransactionPayloadTest.java

示例10: testSerialization

@Test
public void testSerialization() {
    DataExists expected = new DataExists(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION);

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

    DataExists actual = DataExists.fromSerializable(SerializationUtils.clone((Serializable) serialized));
    assertEquals("getPath", expected.getPath(), actual.getPath());
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:11,代碼來源:DataExistsTest.java

示例11: testSerialization

@Test
public void testSerialization() {
    ReadData expected = new ReadData(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION);

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

    ReadData actual = ReadData.fromSerializable(SerializationUtils.clone((Serializable) serialized));
    assertEquals("getPath", expected.getPath(), actual.getPath());
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:11,代碼來源:ReadDataTest.java

示例12: testOnReceiveBatchedModificationsReadyWithoutImmediateCommit

@Test
public void testOnReceiveBatchedModificationsReadyWithoutImmediateCommit() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(),
                    "testOnReceiveBatchedModificationsReadyWithoutImmediateCommit");

            JavaTestKit watcher = new JavaTestKit(getSystem());
            watcher.watch(transaction);

            YangInstanceIdentifier writePath = TestModel.TEST_PATH;
            NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
                    .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
                    .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

            final TransactionIdentifier tx1 = nextTransactionId();
            BatchedModifications batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION);
            batched.addModification(new WriteModification(writePath, writeData));

            transaction.tell(batched, getRef());
            BatchedModificationsReply reply = expectMsgClass(duration("5 seconds"),
                    BatchedModificationsReply.class);
            assertEquals("getNumBatched", 1, reply.getNumBatched());

            batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION);
            batched.setReady(true);
            batched.setTotalMessagesSent(2);

            transaction.tell(batched, getRef());
            expectMsgClass(duration("5 seconds"), ReadyTransactionReply.class);
            watcher.expectMsgClass(duration("5 seconds"), Terminated.class);
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:34,代碼來源:ShardTransactionTest.java

示例13: testOnReceiveBatchedModificationsReadyWithImmediateCommit

@Test
public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(),
                    "testOnReceiveBatchedModificationsReadyWithImmediateCommit");

            JavaTestKit watcher = new JavaTestKit(getSystem());
            watcher.watch(transaction);

            YangInstanceIdentifier writePath = TestModel.TEST_PATH;
            NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
                    .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
                    .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

            BatchedModifications batched = new BatchedModifications(nextTransactionId(),
                    DataStoreVersions.CURRENT_VERSION);
            batched.addModification(new WriteModification(writePath, writeData));
            batched.setReady(true);
            batched.setDoCommitOnReady(true);
            batched.setTotalMessagesSent(1);

            transaction.tell(batched, getRef());
            expectMsgClass(duration("5 seconds"), CommitTransactionReply.class);
            watcher.expectMsgClass(duration("5 seconds"), Terminated.class);
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:28,代碼來源:ShardTransactionTest.java

示例14: testRegisterDataTreeChangeListener

@Test
public void testRegisterDataTreeChangeListener() throws Exception {
    new ShardTestKit(getSystem()) {
        {
            final TestActorRef<Shard> shard = actorFactory.createTestActor(
                    newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
                    "testRegisterDataTreeChangeListener");

            waitUntilLeader(shard);

            shard.tell(new UpdateSchemaContext(SchemaContextHelper.full()), ActorRef.noSender());

            final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1);
            final ActorRef dclActor = actorFactory.createActor(DataTreeChangeListenerActor.props(listener,
                    TestModel.TEST_PATH), "testRegisterDataTreeChangeListener-DataTreeChangeListener");

            shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, false), getRef());

            final RegisterDataTreeNotificationListenerReply reply = expectMsgClass(duration("3 seconds"),
                    RegisterDataTreeNotificationListenerReply.class);
            final String replyPath = reply.getListenerRegistrationPath().toString();
            assertTrue("Incorrect reply path: " + replyPath,
                    replyPath.matches("akka:\\/\\/test\\/user\\/testRegisterDataTreeChangeListener\\/\\$.*"));

            final YangInstanceIdentifier path = TestModel.TEST_PATH;
            writeToStore(shard, path, ImmutableNodes.containerNode(TestModel.TEST_QNAME));

            listener.waitForChangeEvents();
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:31,代碼來源:ShardTest.java

示例15: testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration

@SuppressWarnings("serial")
@Test
public void testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration() throws Exception {
    final CountDownLatch onFirstElectionTimeout = new CountDownLatch(1);
    final CountDownLatch onChangeListenerRegistered = new CountDownLatch(1);
    final Creator<Shard> creator = new Creator<Shard>() {
        boolean firstElectionTimeout = true;

        @Override
        public Shard create() throws Exception {
            return new Shard(newShardBuilder()) {
                @Override
                public void handleCommand(final Object message) {
                    if (message instanceof ElectionTimeout && firstElectionTimeout) {
                        firstElectionTimeout = false;
                        final ActorRef self = getSelf();
                        new Thread(() -> {
                            Uninterruptibles.awaitUninterruptibly(
                                    onChangeListenerRegistered, 5, TimeUnit.SECONDS);
                            self.tell(message, self);
                        }).start();

                        onFirstElectionTimeout.countDown();
                    } else {
                        super.handleCommand(message);
                    }
                }
            };
        }
    };

    setupInMemorySnapshotStore();

    final YangInstanceIdentifier path = TestModel.TEST_PATH;
    final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1);
    final ActorRef dclActor = actorFactory.createActor(DataTreeChangeListenerActor.props(listener, path),
            "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration-DataChangeListener");

    final TestActorRef<Shard> shard = actorFactory.createTestActor(
            Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
            "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration");

    new ShardTestKit(getSystem()) {
        {
            assertEquals("Got first ElectionTimeout", true, onFirstElectionTimeout.await(5, TimeUnit.SECONDS));

            shard.tell(new RegisterDataTreeChangeListener(path, dclActor, false), getRef());
            final RegisterDataTreeNotificationListenerReply reply = expectMsgClass(duration("5 seconds"),
                    RegisterDataTreeNotificationListenerReply.class);
            assertNotNull("getListenerRegistratioznPath", reply.getListenerRegistrationPath());

            shard.tell(FindLeader.INSTANCE, getRef());
            final FindLeaderReply findLeadeReply = expectMsgClass(duration("5 seconds"), FindLeaderReply.class);
            assertFalse("Expected the shard not to be the leader", findLeadeReply.getLeaderActor().isPresent());

            onChangeListenerRegistered.countDown();

            // TODO: investigate why we do not receive data chage events
            listener.waitForChangeEvents();
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:62,代碼來源:ShardTest.java


注:本文中的org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_PATH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。