當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。