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


Java TestModel.createTestContext方法代码示例

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


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

示例1: setUp

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入方法依赖的package包/类
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    schemaContext = TestModel.createTestContext();

    doReturn(getSystem()).when(mockActorContext).getActorSystem();
    doReturn(getSystem().dispatchers().defaultGlobalDispatcher()).when(mockActorContext).getClientDispatcher();
    doReturn(MemberName.forName(memberName)).when(mockActorContext).getCurrentMemberName();
    doReturn(new ShardStrategyFactory(configuration,
            LogicalDatastoreType.CONFIGURATION)).when(mockActorContext).getShardStrategyFactory();
    doReturn(schemaContext).when(mockActorContext).getSchemaContext();
    doReturn(new Timeout(operationTimeoutInSeconds, TimeUnit.SECONDS)).when(mockActorContext).getOperationTimeout();
    doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();
    doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();
    doReturn(dataStoreContextBuilder.build()).when(mockActorContext).getDatastoreContext();

    final ClientIdentifier mockClientId = MockIdentifiers.clientIdentifier(getClass(), memberName);
    mockComponentFactory = new TransactionContextFactory(mockActorContext, mockClientId);

    Timer timer = new MetricRegistry().timer("test");
    doReturn(timer).when(mockActorContext).getOperationTimer(any(String.class));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:AbstractTransactionProxyTest.java

示例2: setUp

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    final SchemaContext schemaContext = TestModel.createTestContext();

    Mockito.when(actorContext.getSchemaContext()).thenReturn(schemaContext);
    Mockito.when(actorContext.getDatastoreContext()).thenReturn(DatastoreContext.newBuilder().build());
    Mockito.when(clientTransaction.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
    Mockito.when(clientSnapshot.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);

    Mockito.when(clientActor.getIdentifier()).thenReturn(CLIENT_IDENTIFIER);
    Mockito.when(clientActor.createTransaction()).thenReturn(clientTransaction);
    Mockito.when(clientActor.createLocalHistory()).thenReturn(clientLocalHistory);
    Mockito.when(clientActor.createSnapshot()).thenReturn(clientSnapshot);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ClientBackedDataStoreTest.java

示例3: setUp

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    schemaContext = TestModel.createTestContext();

    doReturn(schemaContext).when(actorContext).getSchemaContext();
    doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:DistributedDataStoreTest.java

示例4: testOnCreateShardWithNoInitialSchemaContext

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入方法依赖的package包/类
@Test
public void testOnCreateShardWithNoInitialSchemaContext() {
    LOG.info("testOnCreateShardWithNoInitialSchemaContext starting");
    new JavaTestKit(getSystem()) {
        {
            ActorRef shardManager = actorFactory
                    .createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider()))
                            .withDispatcher(Dispatchers.DefaultDispatcherId()));

            Shard.Builder shardBuilder = Shard.builder();

            ModuleShardConfiguration config = new ModuleShardConfiguration(URI.create("foo-ns"), "foo-module",
                    "foo", null, members("member-1"));
            shardManager.tell(new CreateShard(config, shardBuilder, null), getRef());

            expectMsgClass(duration("5 seconds"), Success.class);

            SchemaContext schemaContext = TestModel.createTestContext();
            shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());

            shardManager.tell(new FindLocalShard("foo", true), getRef());

            expectMsgClass(duration("5 seconds"), LocalShardFound.class);

            assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
            assertNotNull("schemaContext is null", shardBuilder.getDatastoreContext());
        }
    };

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

示例5: testOnCreateShard

import org.opendaylight.controller.md.cluster.datastore.model.TestModel; //导入方法依赖的package包/类
@Test
public void testOnCreateShard() {
    LOG.info("testOnCreateShard starting");
    new JavaTestKit(getSystem()) {
        {
            datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true);

            ActorRef shardManager = actorFactory
                    .createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider()))
                            .withDispatcher(Dispatchers.DefaultDispatcherId()));

            SchemaContext schemaContext = TestModel.createTestContext();
            shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());

            DatastoreContext datastoreContext = DatastoreContext.newBuilder().shardElectionTimeoutFactor(100)
                    .persistent(false).build();
            Shard.Builder shardBuilder = Shard.builder();

            ModuleShardConfiguration config = new ModuleShardConfiguration(URI.create("foo-ns"), "foo-module",
                    "foo", null, members("member-1", "member-5", "member-6"));
            shardManager.tell(new CreateShard(config, shardBuilder, datastoreContext), getRef());

            expectMsgClass(duration("5 seconds"), Success.class);

            shardManager.tell(new FindLocalShard("foo", true), getRef());

            expectMsgClass(duration("5 seconds"), LocalShardFound.class);

            assertEquals("isRecoveryApplicable", false, shardBuilder.getDatastoreContext().isPersistent());
            assertTrue("Epxected ShardPeerAddressResolver", shardBuilder.getDatastoreContext().getShardRaftConfig()
                    .getPeerAddressResolver() instanceof ShardPeerAddressResolver);
            assertEquals("peerMembers", Sets.newHashSet(
                    ShardIdentifier.create("foo", MemberName.forName("member-5"), shardMrgIDSuffix).toString(),
                    ShardIdentifier.create("foo", MemberName.forName("member-6"), shardMrgIDSuffix).toString()),
                    shardBuilder.getPeerAddresses().keySet());
            assertEquals("ShardIdentifier", ShardIdentifier.create("foo", MEMBER_1, shardMrgIDSuffix),
                    shardBuilder.getId());
            assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());

            // Send CreateShard with same name - should return Success with
            // a message.

            shardManager.tell(new CreateShard(config, shardBuilder, null), getRef());

            Success success = expectMsgClass(duration("5 seconds"), Success.class);
            assertNotNull("Success status is null", success.status());
        }
    };

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


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