Java Code Examples for org.junit.Before

The following are top voted examples for showing how to use org.junit.Before. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: springboot-shiro-cas-mybatis   File: PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.action = new PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction();

    final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<>();
    idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator());


    final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager(
            Collections.<AuthenticationHandler, PrincipalResolver>singletonMap(
                    new PrincipalBearingCredentialsAuthenticationHandler(),
                    new PrincipalBearingPrincipalResolver()));
    final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl(
            new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(),
            idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(),
            mock(ServicesManager.class), mock(LogoutManager.class));
    this.action.setCentralAuthenticationService(centralAuthenticationService);
}
 
Example 2
Project: weex-3d-map   File: AG_Border_Text_Border_Left_Color.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws InterruptedException {
	super.setUp();
	HashMap testMap = new <String, Object> HashMap();
	testMap.put("testComponet", "AG_Border");
	testMap.put("testChildCaseInit", "AG_Border_Text_Border_Left_Color");
	testMap.put("step1",new HashMap(){
		{
			put("click", "#FF0000");
			put("screenshot", "AG_Border_Text_Border_Left_Color_01_#FF0000");
		}
	});
	testMap.put("step2",new HashMap(){
		{
			put("click", "#00FFFF");
			put("screenshot", "AG_Border_Text_Border_Left_Color_02_#00FFFF");
		}
	});
	super.setTestMap(testMap);
}
 
Example 3
Project: android-mobile-engage-sdk   File: MobileEngageTest.java   View source code 6 votes vote down vote up
@Before
public void init() throws Exception {
    MobileEngageExperimental.enableFeature(MobileEngageFeature.IN_APP_MESSAGING);

    application = (Application) InstrumentationRegistry.getTargetContext().getApplicationContext();
    coreCompletionHandler = mock(MobileEngageCoreCompletionHandler.class);
    mobileEngageInternal = mock(MobileEngageInternal.class);
    inboxInternal = mock(InboxInternal.class);
    baseConfig = new MobileEngageConfig.Builder()
            .application(application)
            .credentials(appID, appSecret)
            .disableDefaultChannel()
            .build();
    MobileEngage.inboxInstance = inboxInternal;
    MobileEngage.instance = mobileEngageInternal;
    MobileEngage.completionHandler = coreCompletionHandler;

    ConnectivityWatchdogTestUtils.resetCurrentActivityWatchdog();
}
 
Example 4
Project: Webcheckers   File: PostSigninRouteTest.java   View source code 6 votes vote down vote up
@Before
public void setup() {
    // set up mock objects
    request = mock(Request.class);
    session = mock(Session.class);
    when(request.session()).thenReturn(session);
    engine = mock(TemplateEngine.class);

    // set up friendly objects
    playerLobby = new PlayerLobby();
    playerLobby.addPlayer(new Player("inuse"));
    gameLobby = new GameLobby();
    gameCenter = new GameCenter(playerLobby, gameLobby);

    CuT = new PostSigninRoute(engine, gameCenter);
}
 
Example 5
Project: ditb   File: TestSplitLogWorker.java   View source code 6 votes vote down vote up
@Before
public void setup() throws Exception {
  TEST_UTIL.startMiniZKCluster();
  Configuration conf = TEST_UTIL.getConfiguration();
  zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      "split-log-worker-tests", null);
  ds = new DummyServer(zkw, conf);
  ZKUtil.deleteChildrenRecursively(zkw, zkw.baseZNode);
  ZKUtil.createAndFailSilent(zkw, zkw.baseZNode);
  assertThat(ZKUtil.checkExists(zkw, zkw.baseZNode), not (is(-1)));
  LOG.debug(zkw.baseZNode + " created");
  ZKUtil.createAndFailSilent(zkw, zkw.splitLogZNode);
  assertThat(ZKUtil.checkExists(zkw, zkw.splitLogZNode), not (is(-1)));

  LOG.debug(zkw.splitLogZNode + " created");
  ZKUtil.createAndFailSilent(zkw, zkw.rsZNode);
  assertThat(ZKUtil.checkExists(zkw, zkw.rsZNode), not (is(-1)));

  SplitLogCounters.resetCounters();
  executorService = new ExecutorService("TestSplitLogWorker");
  executorService.startExecutorService(ExecutorType.RS_LOG_REPLAY_OPS, 10);
  this.mode = (conf.getBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false) ?
      RecoveryMode.LOG_REPLAY : RecoveryMode.LOG_SPLITTING);
}
 
Example 6
Project: weex-3d-map   File: AG_Border_Image_Border_Right_Color.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws InterruptedException {
	super.setUp();
	HashMap testMap = new <String, Object> HashMap();
	testMap.put("testComponet", "AG_Border");
	testMap.put("testChildCaseInit", "AG_Border_Image_Border_Right_Color");
	testMap.put("step1",new HashMap(){
		{
			put("click", "#FF0000");
			put("screenshot", "AG_Border_Image_Border_Right_Color_01_#FF0000");
		}
	});
	testMap.put("step2",new HashMap(){
		{
			put("click", "#00FFFF");
			put("screenshot", "AG_Border_Image_Border_Right_Color_02_#00FFFF");
		}
	});
	super.setTestMap(testMap);
}
 
Example 7
Project: kafka-0.11.0.0-src-with-comment   File: AbstractCoordinatorTest.java   View source code 6 votes vote down vote up
@Before
public void setupCoordinator() {
    this.mockTime = new MockTime();
    this.mockClient = new MockClient(mockTime);

    Metadata metadata = new Metadata(100L, 60 * 60 * 1000L, true);
    this.consumerClient = new ConsumerNetworkClient(mockClient, metadata, mockTime,
            RETRY_BACKOFF_MS, REQUEST_TIMEOUT_MS);
    Metrics metrics = new Metrics();

    Cluster cluster = TestUtils.singletonCluster("topic", 1);
    metadata.update(cluster, Collections.<String>emptySet(), mockTime.milliseconds());
    this.node = cluster.nodes().get(0);
    mockClient.setNode(node);

    this.coordinatorNode = new Node(Integer.MAX_VALUE - node.id(), node.host(), node.port());
    this.coordinator = new DummyCoordinator(consumerClient, metrics, mockTime);
}
 
Example 8
Project: DijkstraAlgorithm-Java   File: testDijkstraGraph.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	points = new Point[6][2];
	graph = new DijkstraGraph();
	for(int y = 0; y < 2; y++) {
		for(int x = 0; x < 6; x++) {
			points[x][y] = new Point(1.0);
			graph.addPoint(points[x][y]);
			if(y != 0) {
				graph.addConnection(points[x][y], points[x][y - 1]);
			}
			if(x != 0) {
				graph.addConnection(points[x][y], points[x - 1][y]);
			}
		}
	}
	points[0][1].entryCost = 2.0;
	points[2][0].entryCost = 4.0;
	points[4][1].entryCost = 4.0;
}
 
Example 9
Project: kafka-0.11.0.0-src-with-comment   File: CompositeReadOnlyWindowStoreTest.java   View source code 6 votes vote down vote up
@Before
public void before() {
    stubProviderOne = new StateStoreProviderStub(false);
    stubProviderTwo = new StateStoreProviderStub(false);
    underlyingWindowStore = new ReadOnlyWindowStoreStub<>(WINDOW_SIZE);
    stubProviderOne.addStore(storeName, underlyingWindowStore);

    otherUnderlyingStore = new ReadOnlyWindowStoreStub<>(WINDOW_SIZE);
    stubProviderOne.addStore("other-window-store", otherUnderlyingStore);


    windowStore = new CompositeReadOnlyWindowStore<>(
        new WrappingStoreProvider(Arrays.<StateStoreProvider>asList(stubProviderOne, stubProviderTwo)),
            QueryableStoreTypes.<String, String>windowStore(),
            storeName);
}
 
Example 10
Project: weex-3d-map   File: AG_Input_Input_Font_Style.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws InterruptedException {
	super.setUp();
	HashMap testMap = new <String, Object> HashMap();
	testMap.put("testComponet", "AG_Input");
	testMap.put("testChildCaseInit", "AG_Input_Input_Font_Style");
	testMap.put("step1",new HashMap(){
		{
			put("click", "normal");
			put("screenshot", "AG_Input_Input_Font_Style_01_normal");
		}
	});
	testMap.put("step2",new HashMap(){
		{
			put("click", "italic");
			put("screenshot", "AG_Input_Input_Font_Style_02_italic");
		}
	});
	super.setTestMap(testMap);
}
 
Example 11
Project: GitHub   File: FutureTest.java   View source code 5 votes vote down vote up
@Before public void setUp() {
  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(new StringConverterFactory())
      .addCallAdapterFactory(ScalaCallAdapterFactory.create())
      .build();
  service = retrofit.create(Service.class);
}
 
Example 12
Project: empiria.player   File: GroupAnswersControllerModelTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
    groupAnswersControllerModel = new GroupAnswersControllerModel(identifiableAnswersByTypeFinder, model);
    groupController1 = mock(GroupAnswersController.class);
    groupController2 = mock(GroupAnswersController.class);

    groupControllers = Lists.newArrayList(groupController1, groupController2);

    groupAnswersControllerModel.setGroupChoicesControllers(groupControllers);
}
 
Example 13
Project: verify-hub   File: SessionResourceIntegrationTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    idpEntityId = "idpEntityId";
    rpEntityId = "rpEntityId";
    translatedAuthnRequest = SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto().withIssuer(rpEntityId).build();
    rpSamlRequest = SamlAuthnRequestContainerDtoBuilder.aSamlAuthnRequestContainerDto().build();
    idpSsoUri = UriBuilder.fromPath("idpSsoUri").build();

    configStub.reset();
    configStub.setupStubForEnabledIdps(asList(idpEntityId));
    configStub.setUpStubForLevelsOfAssurance(rpEntityId);
    configStub.setUpStubForMatchingServiceEntityId(rpEntityId, msEntityId);
    configStub.setupStubForEidasEnabledForTransaction(rpEntityId, false);
    eventSinkStub.setupStubForLogging();
}
 
Example 14
Project: oscm   File: LoggerInitListenerTest.java   View source code 5 votes vote down vote up
@Before
public void setup() throws Exception {
    emptyLogsFolder();

    configServiceMock = setupConfigurationMockForLogging();
    listener = new LoggerInitListener() {
        @Override
        ConfigurationService getConfigurationService() {
            return configServiceMock;
        }
    };

    logger = LoggerFactory.getLogger(this.getClass());
}
 
Example 15
Project: Learning-Spring-Boot-2.0-Second-Edition   File: ImageServiceTests.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
	operations.dropCollection(Image.class);

	operations.insert(new Image("1",
		"learning-spring-boot-cover.jpg"));
	operations.insert(new Image("2",
		"learning-spring-boot-2nd-edition-cover.jpg"));
	operations.insert(new Image("3",
		"bazinga.png"));
}
 
Example 16
Project: hadoop   File: TestYARNRunner.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  resourceMgrDelegate = mock(ResourceMgrDelegate.class);
  conf = new YarnConfiguration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/[email protected]");
  clientCache = new ClientCache(conf, resourceMgrDelegate);
  clientCache = spy(clientCache);
  yarnRunner = new YARNRunner(conf, resourceMgrDelegate, clientCache);
  yarnRunner = spy(yarnRunner);
  submissionContext = mock(ApplicationSubmissionContext.class);
  doAnswer(
      new Answer<ApplicationSubmissionContext>() {
        @Override
        public ApplicationSubmissionContext answer(InvocationOnMock invocation)
            throws Throwable {
          return submissionContext;
        }
      }
      ).when(yarnRunner).createApplicationSubmissionContext(any(Configuration.class),
          any(String.class), any(Credentials.class));

  appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
  jobId = TypeConverter.fromYarn(appId);
  if (testWorkDir.exists()) {
    FileContext.getLocalFSFileContext().delete(new Path(testWorkDir.toString()), true);
  }
  testWorkDir.mkdirs();
}
 
Example 17
Project: java-debug   File: BaseJdiTestCase.java   View source code 5 votes vote down vote up
@Before
public void setup() throws Exception {
    debugSession = DebugSessionFactory.getDebugSession(PROJECT_NAME, "VariableTest");
    if (staticBreakpointEvent == null) {
        staticBreakpointEvent = waitForBreakPointEvent("VariableTest", 60);
    }
}
 
Example 18
Project: verify-hub   File: EidasSessionResourceIntegrationTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    stubSamlEngineTranslationLOAForCountry(LevelOfAssurance.LEVEL_2, NETHERLANDS);
    stubSamlEngineGenerationOfAQR();
    configStub.reset();
    configStub.setUpStubForMatchingServiceRequest(RP_ENTITY_ID, MS_ENTITY_ID, true);
    configStub.setupStubForEnabledIdps(asList(IDP_ENTITY_ID));
    configStub.setUpStubForLevelsOfAssurance(RP_ENTITY_ID);
    configStub.setupStubForEidasEnabledForTransaction(RP_ENTITY_ID, false);
    enableCountriesForRp(RP_ENTITY_ID, NETHERLANDS, SPAIN);
    configStub.setupStubForEidasCountries(EIDAS_COUNTRIES);
    eventSinkStub.reset();
    eventSinkStub.setupStubForLogging();
}
 
Example 19
Project: android-architecture-components   File: NetworkBoundResourceTest.java   View source code 5 votes vote down vote up
@Before
public void init() {
    AppExecutors appExecutors = useRealExecutors
            ? countingAppExecutors.getAppExecutors()
            : new InstantAppExecutors();
    networkBoundResource = new NetworkBoundResource<Foo, Foo>(appExecutors) {
        @Override
        protected void saveCallResult(@NonNull Foo item) {
            saveCallResult.apply(item);
        }

        @Override
        protected boolean shouldFetch(@Nullable Foo data) {
            // since test methods don't handle repetitive fetching, call it only once
            return shouldFetch.apply(data) && fetchedOnce.compareAndSet(false, true);
        }

        @NonNull
        @Override
        protected LiveData<Foo> loadFromDb() {
            return dbData;
        }

        @NonNull
        @Override
        protected LiveData<ApiResponse<Foo>> createCall() {
            return createCall.apply(null);
        }
    };
}
 
Example 20
Project: LocaleChanger   File: LocaleChangerDelegateTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
    localePersistor = mock(LocalePersistor.class);
    localeResolver = mock(LocaleResolver.class);
    defaultLocalePair = mock(DefaultResolvedLocalePair.class);
    doReturn(defaultLocalePair).when(localeResolver).resolveDefault();
    appLocaleChanger = mock(AppLocaleChanger.class);
    sut = new LocaleChangerDelegate(localePersistor, localeResolver, appLocaleChanger);
}
 
Example 21
Project: ats-framework   File: Test_ActionHandler.java   View source code 5 votes vote down vote up
@Before
public void setUp() {

    //init the test values
    ActionClassOne.ACTION_VALUE = 0;
    ActionClassTwo.ACTION_VALUE = 0;
}
 
Example 22
Project: 2017-StateFarm-CodingCompetitionProblem   File: PolyBlockTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    block1 = new PolyBlockImpl();
    block2 = new PolyBlockImpl();
    block3 = new PolyBlockImpl();
    block4 = new PolyBlockImpl();
    block5 = new PolyBlockImpl();
}
 
Example 23
Project: q-mail   File: WebDavStoreTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    HttpParams httpParams = new BasicHttpParams();
    when(mockHttpClientFactory.create()).thenReturn(mockHttpClient);
    when(mockHttpClient.getParams()).thenReturn(httpParams);
    when(mockHttpClient.getConnectionManager()).thenReturn(mockClientConnectionManager);
    when(mockClientConnectionManager.getSchemeRegistry()).thenReturn(mockSchemeRegistry);
}
 
Example 24
Project: loom   File: SwiftRealAdapterTestLocalOnly.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    LOG.info("Setup test");
    realAdapter = (RealAdapter) adapterLoader.getAdapter("helionSwiftReal.properties");
    prov = realAdapter.getProvider();
    session = new SessionImpl("sessionOne", sessionManager.getInterval());
    aggregationManager.createSession(session);
    stitcher.createSession(session);
    // this triggers the data collection
    adapterManager.userConnected(session, prov, creds);
}
 
Example 25
Project: spring-io   File: AuditResourceIntTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    AuditEventService auditEventService =
        new AuditEventService(auditEventRepository, auditEventConverter);
    AuditResource auditResource = new AuditResource(auditEventService);
    this.restAuditMockMvc = MockMvcBuilders.standaloneSetup(auditResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setConversionService(formattingConversionService)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
Example 26
Project: jarling   File: StarlingExceptionTests.java   View source code 5 votes vote down vote up
@Before
public void setUp(){
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("./cfg/sandbox.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.goodApiService = new ApiService(StarlingBankEnvironment.SANDBOX, properties.getProperty("starling.access.token"));
}
 
Example 27
Project: oscm   File: VServerProcessorBeanTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    vServerProcessor = spy(new VServerProcessorBean());
    vServerProcessor.vserverComm = mock(VServerCommunication.class);
    vServerProcessor.vsysComm = mock(VSystemCommunication.class);
    vServerProcessor.fwComm = mock(FWCommunication.class);
    vServerProcessor.vdiskInfo = mock(VDiskCommunication.class);
    platformService = mock(APPlatformService.class);
    doReturn("RUNNING").when(vServerProcessor.fwComm).getFirewallStatus(
            any(PropertyHandler.class));
    doReturn(Boolean.TRUE).when(platformService).lockServiceInstance(
            anyString(), anyString(), any(PasswordAuthentication.class));
    doNothing().when(platformService).unlockServiceInstance(anyString(),
            anyString(), any(PasswordAuthentication.class));
    doNothing().when(platformService).sendMail(anyListOf(String.class),
            subject.capture(), text.capture());
    User user = new User();
    user.setLocale("de");
    doReturn(user).when(platformService).authenticate(anyString(),
            any(PasswordAuthentication.class));
    vServerProcessor.setPlatformService(platformService);

    parameters = new HashMap<>();
    configSettings = new HashMap<>();
    settings = new ProvisioningSettings(parameters, configSettings, "en");
    settings.setSubscriptionId("subId");
    paramHandler = new PropertyHandler(settings);
}
 
Example 28
Project: incubator-ratis   File: TestRaftLogSegment.java   View source code 5 votes vote down vote up
@Before
public void setup() throws Exception {
  RaftProperties properties = new RaftProperties();
  storageDir = getTestDir();
  RaftServerConfigKeys.setStorageDir(properties, storageDir);
  this.segmentMaxSize =
      RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
  this.preallocatedSize =
      RaftServerConfigKeys.Log.preallocatedSize(properties).getSize();
  this.bufferSize =
      RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
}
 
Example 29
Project: GitHub   File: StatisticsScreenTest.java   View source code 5 votes vote down vote up
/**
 * Setup your test fixture with a fake task id. The {@link TaskDetailActivity} is started with
 * a particular task id, which is then loaded from the service API.
 *
 * <p>
 * Note that this test runs hermetically and is fully isolated using a fake implementation of
 * the service API. This is a great way to make your tests more reliable and faster at the same
 * time, since they are isolated from any outside dependencies.
 */
@Before
public void intentWithStubbedTaskId() {
    // Given some tasks
    TasksRepository.destroyInstance();
    TasksRepository repository = Injection.provideTasksRepository(InstrumentationRegistry.getContext());
    repository.saveTask(new Task("Title1", "", false));
    repository.saveTask(new Task("Title2", "", true));

    // Lazily start the Activity from the ActivityTestRule
    Intent startIntent = new Intent();
    mStatisticsActivityTestRule.launchActivity(startIntent);
}
 
Example 30
Project: FileDownloader-master   File: FileDownloadUrlConnectionTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    initMocks(this);

    Mockito.when(mURL.openConnection()).thenReturn(mConnection);
    Mockito.when(mURL.openConnection(mProxy)).thenReturn(mConnection);
}
 
Example 31
Project: spring-reactive-sample   File: IntegrationTests.java   View source code 5 votes vote down vote up
@Before
public void setup() {
    this.rest = WebTestClient
        .bindToServer()
        .responseTimeout(Duration.ofDays(1))
        .baseUrl("http://localhost:" + this.port)
        .build();
}
 
Example 32
Project: Pet-Supply-Store   File: TestStoreLargeImages.java   View source code 5 votes vote down vote up
@Before
public void initialize() {
	MockitoAnnotations.initMocks(this);
	when(mockedLargeImg.getSize()).thenReturn(ImageSizePreset.FULL.getSize());
	when(mockedIconImg.getSize()).thenReturn(ImageSizePreset.ICON.getSize());
	when(mockedMainImg.getSize()).thenReturn(ImageSizePreset.MAIN_IMAGE.getSize());
	when(mockedPreviewImg.getSize()).thenReturn(ImageSizePreset.PREVIEW.getSize());
}
 
Example 33
Project: hub-fortify-ssc-integration-service   File: VulnerabilityUtilTest.java   View source code 5 votes vote down vote up
@Override
@Before
public void setUp() throws JsonIOException, IOException, IntegrationException {
    final List<BlackDuckFortifyMapperGroup> blackDuckFortifyMappers = mappingParser
            .createMapping(propertyConstants.getMappingJsonPath());
    HUB_PROJECT_NAME_1 = blackDuckFortifyMappers.get(0).getHubProjectVersion().get(0).getHubProject();
    HUB_PROJECT_VERSION_NAME_1 = blackDuckFortifyMappers.get(0).getHubProjectVersion().get(0).getHubProjectVersion();
    HUB_PROJECT_NAME_2 = blackDuckFortifyMappers.get(1).getHubProjectVersion().get(0).getHubProject();
    HUB_PROJECT_VERSION_NAME_2 = blackDuckFortifyMappers.get(1).getHubProjectVersion().get(0).getHubProjectVersion();
}
 
Example 34
Project: GitHub   File: SortDescriptorTests.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
    RealmConfiguration config = configFactory.createConfiguration();
    sharedRealm = OsSharedRealm.getInstance(config);
    sharedRealm.beginTransaction();
    table = sharedRealm.createTable("test_table");
}
 
Example 35
Project: etomica   File: EwaldSummationTest.java   View source code 5 votes vote down vote up
@Before
public void setup(){
    filenum = 4; // pick 1, 2, 3 or 4
    int numofmolecules = NIST_nmol[filenum-1];
    double boxlength = NIST_boxl[filenum -1];
    double kcut = Math.sqrt(26.999)*2*Math.PI/boxlength;
    double rCutRealES = 10;
    Space space = Space.getInstance(3);
    box = new Box(space);
    SpeciesWater3P species = new SpeciesWater3P(space,false);
    ChargeAgentSourceSPCE agentSource = new ChargeAgentSourceSPCE(species);
    AtomLeafAgentManager<EwaldSummation.MyCharge> atomAgentManager = new AtomLeafAgentManager<EwaldSummation.MyCharge>(agentSource, box);
    sim = new Simulation(space);

    sim.addSpecies(species);
    sim.addBox(box);
    box.setNMolecules(species,numofmolecules);
    box.getBoundary().setBoxSize(new Vector3D(boxlength,boxlength,boxlength));

    es = new EwaldSummation(box,atomAgentManager,space,kcut,rCutRealES);
    es.setAlpha(5.6/boxlength);

    Configuration config = new ConfigurationResourceFile(
            String.format("etomica/potential/spce"+String.valueOf(filenum)+".pos"),
            EwaldSummationTest.class
    );

    config.initializeCoordinates(box);



}
 
Example 36
Project: oscm   File: PropertyHandlerTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    parameters = new HashMap<>();
    configSettings = new HashMap<>();
    settings = new ProvisioningSettings(parameters, configSettings, "en");
    propertyHandler = new PropertyHandler(settings);
}
 
Example 37
Project: hadoop   File: TestAddBlock.java   View source code 5 votes vote down vote up
@Before
public void setup() throws IOException {
  conf = new Configuration();
  conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCKSIZE);
  cluster = new MiniDFSCluster.Builder(conf).numDataNodes(REPLICATION)
      .build();
  cluster.waitActive();
}
 
Example 38
Project: GitHub   File: LinkingObjectsManagedTests.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
    context = InstrumentationRegistry.getInstrumentation().getContext();

    RealmConfiguration realmConfig = configFactory.createConfiguration();
    realm = Realm.getInstance(realmConfig);
}
 
Example 39
Project: greycat   File: RobustnessTests.java   View source code 5 votes vote down vote up
@Before
public void initGraph() {
    _graph = new GraphBuilder().build();
    _graph.connect(new Callback<Boolean>() {
        @Override
        public void on(Boolean result) {
            Node root = _graph.newNode(0, 0);
            root.set("name", Type.STRING, "root");

            Node n1 = _graph.newNode(0, 0);
            n1.set("name", Type.STRING, "n1");

            Node n2 = _graph.newNode(0, 0);
            n2.set("name", Type.STRING, "n2");

            Node n3 = _graph.newNode(0, 0);
            n3.set("name", Type.STRING, "n3");

            root.addToRelation("child", n1);
            root.addToRelation("child", n2);
            root.addToRelation("child", n3);

            _graph.declareIndex(0, "rootIndex", rootIndex -> {
                rootIndex.update(root);
            }, "name");
        }
    });

}
 
Example 40
Project: monarch   File: LocatorServerStartupRule.java   View source code 5 votes vote down vote up
@Before
public void before() throws Throwable {
  restoreSystemProperties.before();
  temporaryFolder.create();
  Invoke.invokeInEveryVM("Stop each VM", this::stopServerOrLocatorInThisVM);
  members = new ArrayList<>(4);
}