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


Java TestModel类代码示例

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


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

示例1: createTestContainer

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
private static NormalizedNode<?, ?> createTestContainer() {
    byte[] bytes1 = {1,2,3};
    LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build();

    byte[] bytes2 = {};
    LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build();

    LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, null)).withValue(null).build();

    return TestModel.createBaseTestContainerBuilder()
            .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
                    new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
                    .withChild(entry1).withChild(entry2).withChild(entry3).build())
            .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1,2,3,4}))
            .withChild(Builders.orderedMapBuilder()
                  .withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
                  .withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
                          TestModel.ID_QNAME, 11)).build()).build();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例2: testYangInstanceIdentifierStreaming

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testYangInstanceIdentifierStreaming() throws IOException  {
    YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.TEST_PATH)
            .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(
                    TestModel.INNER_LIST_QNAME, TestModel.ID_QNAME, 10).build();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));

    nnout.writeYangInstanceIdentifier(path);

    NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
        bos.toByteArray()));

    YangInstanceIdentifier newPath = nnin.readYangInstanceIdentifier();
    Assert.assertEquals(path, newPath);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例3: testInnerContainerNodeWithParentPathPrunedWhenSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testInnerContainerNodeWithParentPathPrunedWhenSchemaMissing() throws IOException {
    YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
            .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
            .build();
    NormalizedNodePruner pruner = prunerFullSchema(path);

    MapNode innerList = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
            TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild(
                    ImmutableNodes.containerNode(TestModel.INVALID_QNAME)).build()).build();
    NormalizedNode<?, ?> input = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
            .withChild(innerList).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> expected = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
                TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").build()).build()).build();
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", expected, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:NormalizedNodePrunerTest.java

示例4: testInnerListNodeWithParentPathPrunedWhenSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testInnerListNodeWithParentPathPrunedWhenSchemaMissing() throws IOException {
    YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
            .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
            .build();
    NormalizedNodePruner pruner = prunerFullSchema(path);

    MapNode innerList = mapNodeBuilder(TestModel.INVALID_QNAME).withChild(mapEntryBuilder(
            TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one").withChild(
                    ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
    NormalizedNode<?, ?> input = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
            .withChild(innerList).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> expected = mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", expected, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:NormalizedNodePrunerTest.java

示例5: createTestContainer

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
private static NormalizedNode<?, ?> createTestContainer() {
    byte[] bytes1 = {1,2,3};
    LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build();

    byte[] bytes2 = {};
    LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build();

    LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
            new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, null)).withValue(null).build();


    return TestModel.createBaseTestContainerBuilder()
            .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
                    new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
                    .withChild(entry1).withChild(entry2).withChild(entry3).build())
            .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
            .build();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:NormalizedNodePrunerTest.java

示例6: testWithSerializable

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testWithSerializable() {
    NormalizedNode<?, ?> input = TestModel.createTestContainer();
    SampleNormalizedNodeSerializable serializable = new SampleNormalizedNodeSerializable(input);
    SampleNormalizedNodeSerializable clone =
            (SampleNormalizedNodeSerializable)SerializationUtils.clone(serializable);

    Assert.assertEquals(input, clone.getInput());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例7: testAnyXmlStreaming

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testAnyXmlStreaming() throws Exception {
    String xml = "<foo xmlns=\"http://www.w3.org/TR/html4/\" x=\"123\"><bar>one</bar><bar>two</bar></foo>";
    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    Node xmlNode = factory.newDocumentBuilder().parse(
            new InputSource(new StringReader(xml))).getDocumentElement();

    assertEquals("http://www.w3.org/TR/html4/", xmlNode.getNamespaceURI());

    NormalizedNode<?, ?> anyXmlContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(
                    Builders.anyXmlBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME))
                        .withValue(new DOMSource(xmlNode)).build()).build();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));

    nnout.writeNormalizedNode(anyXmlContainer);

    NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
        bos.toByteArray()));

    ContainerNode deserialized = (ContainerNode)nnin.readNormalizedNode();

    Optional<DataContainerChild<? extends PathArgument, ?>> child =
            deserialized.getChild(new NodeIdentifier(TestModel.ANY_XML_QNAME));
    assertEquals("AnyXml child present", true, child.isPresent());

    StreamResult xmlOutput = new StreamResult(new StringWriter());
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    transformer.transform(((AnyXmlNode)child.get()).getValue(), xmlOutput);

    assertEquals("XML", xml, xmlOutput.getWriter().toString());
    assertEquals("http://www.w3.org/TR/html4/", ((AnyXmlNode)child.get()).getValue().getNode().getNamespaceURI());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:39,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例8: testSchemaPathSerialization

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testSchemaPathSerialization() throws Exception {
    final SchemaPath expected = SchemaPath.create(true, TestModel.ANY_XML_QNAME);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));
    nnout.writeSchemaPath(expected);

    NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
        bos.toByteArray()));
    SchemaPath actual = nnin.readSchemaPath();
    assertEquals(expected, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例9: testLeafNodeNotPrunedWhenHasNoParent

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafNodeNotPrunedWhenHasNoParent() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.DESC_QNAME));
    NormalizedNode<?, ?> input = Builders.leafBuilder().withNodeIdentifier(
            new NodeIdentifier(TestModel.DESC_QNAME)).withValue("test").build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", input, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:NormalizedNodePrunerTest.java

示例10: testLeafNodePrunedWhenHasAugmentationParentAndSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafNodePrunedWhenHasAugmentationParentAndSchemaMissing() throws IOException {
    AugmentationIdentifier augId = new AugmentationIdentifier(Sets.newHashSet(TestModel.AUG_CONT_QNAME));
    NormalizedNodePruner pruner = prunerFullSchema(YangInstanceIdentifier.builder()
            .node(TestModel.TEST_QNAME).node(TestModel.AUGMENTED_LIST_QNAME)
                    .node(TestModel.AUGMENTED_LIST_QNAME).node(augId).build());
    LeafNode<Object> child = Builders.leafBuilder().withNodeIdentifier(
            new NodeIdentifier(TestModel.INVALID_QNAME)).withValue("test").build();
    NormalizedNode<?, ?> input = Builders.augmentationBuilder().withNodeIdentifier(augId).withChild(child).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", Builders.augmentationBuilder().withNodeIdentifier(augId).build(), actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:15,代码来源:NormalizedNodePrunerTest.java

示例11: testLeafNodePrunedWhenHasNoParentAndSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
    NormalizedNode<?, ?> input = Builders.leafBuilder().withNodeIdentifier(
            new NodeIdentifier(TestModel.INVALID_QNAME)).withValue("test").build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertNull(actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:NormalizedNodePrunerTest.java

示例12: testLeafSetEntryNodeNotPrunedWhenHasNoParent

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafSetEntryNodeNotPrunedWhenHasNoParent() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
    NormalizedNode<?, ?> input = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
            new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", input, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:NormalizedNodePrunerTest.java

示例13: testLeafSetEntryNodeNotPrunedWhenHasParent

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafSetEntryNodeNotPrunedWhenHasParent() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
    LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
            new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
    NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(
            new NodeIdentifier(TestModel.SHOE_QNAME)).withChild(child).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", input, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:NormalizedNodePrunerTest.java

示例14: testLeafSetEntryNodePrunedWhenHasNoParentAndSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafSetEntryNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
    NormalizedNode<?, ?> input = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
            new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertNull(actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:NormalizedNodePrunerTest.java

示例15: testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing

import org.opendaylight.controller.cluster.datastore.util.TestModel; //导入依赖的package包/类
@Test
public void testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
    LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
            new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
    NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(
            new NodeIdentifier(TestModel.INVALID_QNAME)).withChild(child).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);

    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertNull(actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:NormalizedNodePrunerTest.java


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