本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
}
};
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
};
}
示例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);
}
};
}
示例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();
}
};
}
示例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();
}
};
}