org.junit.Before Java Examples

The following examples show how to use org.junit.Before. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterTestHarness.java    From kareldb with Apache License 2.0 7 votes vote down vote up
@Before
public void setUp() throws Exception {
    zookeeper = new EmbeddedZookeeper();
    zkConnect = String.format("localhost:%d", zookeeper.port());

    configs = new Vector<>();
    servers = new Vector<>();
    for (int i = 0; i < numBrokers; i++) {
        KafkaConfig config = getKafkaConfig(i);
        configs.add(config);

        KafkaServer server = TestUtils.createServer(config, Time.SYSTEM);
        servers.add(server);
    }

    String[] serverUrls = new String[servers.size()];
    ListenerName listenerType = ListenerName.forSecurityProtocol(getSecurityProtocol());
    for (int i = 0; i < servers.size(); i++) {
        serverUrls[i] =
            Utils.formatAddress(
                servers.get(i).config().advertisedListeners().head().host(),
                servers.get(i).boundPort(listenerType)
            );
    }
    bootstrapServers = Utils.join(serverUrls, ",");
}
 
Example #2
Source File: RequestPartIntegrationTests.java    From spring-analysis-note with MIT License 7 votes vote down vote up
@Before
public void setup() {
	ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter();
	emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));

	List<HttpMessageConverter<?>> converters = new ArrayList<>(3);
	converters.add(emptyBodyConverter);
	converters.add(new ByteArrayHttpMessageConverter());
	converters.add(new ResourceHttpMessageConverter());
	converters.add(new MappingJackson2HttpMessageConverter());

	AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter();
	converter.setPartConverters(converters);

	restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
	restTemplate.setMessageConverters(Collections.singletonList(converter));
}
 
Example #3
Source File: TableDaoShardByDbTest.java    From das with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
    for (int i = 0; i < DB_MODE; i++) {
        String[] statements = new String[TABLE_MODE];
        for (int j = 0; j < TABLE_MODE; j++) {
            statements[j] = String.format("INSERT INTO person(PeopleID, Name, CountryID, CityID, ProvinceID) VALUES(%d, 'test', %d, %d, 1)", j + 1, i, j);
        }

        if(!allowInsertWithId())
            statements = DbSetupUtil.handle("Person", statements);

        BatchUpdateBuilder builder = new BatchUpdateBuilder(statements);
        builder.hints().inShard(i);
        super.dao.batchUpdate(builder);
    }
}
 
Example #4
Source File: DatabaseJoinTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {

  TransformMeta mockTransformMeta = mock( TransformMeta.class );
  PipelineMeta mockPipelineMeta = mock( PipelineMeta.class );
  Pipeline mockPipeline = mock( Pipeline.class );
  TransformPartitioningMeta mockTransformPartitioningMeta = mock( TransformPartitioningMeta.class );

  when( mockTransformMeta.getName() ).thenReturn( "MockTransform" );
  when( mockPipelineMeta.findTransform( anyString() ) ).thenReturn( mockTransformMeta );
  when( mockTransformMeta.getTargetTransformPartitioningMeta() ).thenReturn( mockTransformPartitioningMeta );

  mockITransform = mock( DatabaseJoinMeta.class, withSettings().extraInterfaces( ITransform.class ) );
  mockTransformDataInterface = mock( DatabaseJoinData.class, withSettings().extraInterfaces( ITransform.class ) );
  mockTransformDataInterface.db = mock( Database.class );
  mockTransformDataInterface.pstmt = mock( PreparedStatement.class );
  mockDatabaseJoin = spy( new DatabaseJoin( mockTransformMeta, mockTransformDataInterface, 1, mockPipelineMeta, mockPipeline ) );
}
 
Example #5
Source File: TlsTcpChannelInitializerTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception {
    MockitoAnnotations.initMocks(this);

    pipeline = new FakeChannelPipeline();

    when(tlsTcpListener.getTls()).thenReturn(tls);
    when(ssl.getSslHandler(any(SocketChannel.class), any(Tls.class))).thenReturn(sslHandler);
    when(sslHandler.handshakeFuture()).thenReturn(future);
    when(socketChannel.pipeline()).thenReturn(pipeline);
    when(socketChannel.attr(any(AttributeKey.class))).thenReturn(attribute);
    when(channelDependencies.getConfigurationService()).thenReturn(fullConfigurationService);

    tlstcpChannelInitializer = new TlsTcpChannelInitializer(channelDependencies, tlsTcpListener, ssl, eventLog);

}
 
Example #6
Source File: AG_Switch_Switch_Checked.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws InterruptedException {
	super.setUp();
	TreeMap testMap = new <String, Object> TreeMap();
	testMap.put("testComponet", "AG_Switch");
	testMap.put("testChildCaseInit", "AG_Switch_Switch_Checked");
	testMap.put("step1",new TreeMap(){
		{
			put("click", "true");
			put("screenshot", "AG_Switch_Switch_Checked_01_true");
		}
	});
	testMap.put("step2",new TreeMap(){
		{
			put("click", "false");
			put("screenshot", "AG_Switch_Switch_Checked_02_false");
		}
	});
	super.setTestMap(testMap);
}
 
Example #7
Source File: IncrementalSSSPITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception {
	resultPath = tempFolder.newFile().toURI().toString();
	File verticesFile = tempFolder.newFile();
	FileUtils.writeFileUtf8(verticesFile, IncrementalSSSPData.VERTICES);

	File edgesFile = tempFolder.newFile();
	FileUtils.writeFileUtf8(edgesFile, IncrementalSSSPData.EDGES);

	File edgesInSSSPFile = tempFolder.newFile();
	FileUtils.writeFileUtf8(edgesInSSSPFile, IncrementalSSSPData.EDGES_IN_SSSP);

	verticesPath = verticesFile.toURI().toString();
	edgesPath = edgesFile.toURI().toString();
	edgesInSSSPPath = edgesInSSSPFile.toURI().toString();
}
 
Example #8
Source File: TestContextName.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    cn1 = new ContextName(null, null);
    cn2 = new ContextName("", null);
    cn3 = new ContextName("/", null);
    cn4 = new ContextName("/foo", null);
    cn5 = new ContextName("/foo/bar", null);
    cn6 = new ContextName(null, "A");
    cn7 = new ContextName("", "B");
    cn8 = new ContextName("/", "C");
    cn9 = new ContextName("/foo", "D");
    cn10 = new ContextName("/foo/bar", "E");
    cn11 = new ContextName("ROOT", false);
    cn12 = new ContextName("foo", false);
    cn13 = new ContextName("foo#bar", false);
    cn14 = new ContextName("ROOT##A", false);
    cn15 = new ContextName("foo##D", false);
    cn16 = new ContextName("foo#bar##E", false);
    cn17 = new ContextName("/ROOT", null);
    cn18 = new ContextName("/ROOT#bar", false);
    cn19 = new ContextName("/ROOT#bar##A", false);
    cn20 = new ContextName("/ROOT##A", false);
    cn21 = new ContextName("foo.war", false);
    cn22 = new ContextName("foo.war", true);
}
 
Example #9
Source File: SpringJpaXmlTest.java    From hypersistence-optimizer with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    try {
        transactionTemplate.execute((TransactionCallback<Void>) transactionStatus -> {
            Tag hibernate = new Tag();
            hibernate.setName("hibernate");
            entityManager.persist(hibernate);

            Tag jpa = new Tag();
            jpa.setName("jpa");
            entityManager.persist(jpa);
            return null;
        });
    } catch (TransactionException e) {
        LOGGER.error("Failure", e);
    }

}
 
Example #10
Source File: AndTest.java    From NeurophFramework with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    instance = new And();
    inputNeurons = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        inputNeurons.add(new InputNeuron());
    }
           
    Neuron toNeuron = new Neuron();

    inputConnections = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        inputConnections.add(new Connection(inputNeurons.get(i), toNeuron, 1));
        toNeuron.addInputConnection(inputConnections.get(i));
    }
}
 
Example #11
Source File: PaverServiceImplTest.java    From data-highway with Apache License 2.0 6 votes vote down vote up
@Before
public void before() {
  road.setName(ROAD_NAME);
  road.setContactEmail("[email protected]");
  road.setDescription("road description");
  road.setTeamName("awesome team");
  road.setAuthorisation(new Authorisation());
  road.getAuthorisation().setOnramp(new Onramp());
  road.getAuthorisation().getOnramp().setCidrBlocks(emptyList());
  road.getAuthorisation().getOnramp().setAuthorities(emptyList());
  road.getAuthorisation().setOfframp(new Offramp());
  road.getAuthorisation().getOfframp().setAuthorities(emptyMap());
  road.setDeleted(false);
  underTest = new PaverServiceImpl(roadAdminClient, schemaStoreClient, cidrBlockValidator, mappings,
      notificationHandler, true, clock);
}
 
Example #12
Source File: SimplifyTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
@Override
public void setup() throws Exception{
	super.setup();

	Object[][] edges = new Object[][]{
		new Object[]{0, 0},
		new Object[]{0, 1},
		new Object[]{0, 1},
		new Object[]{0, 2},
		new Object[]{0, 2},
		new Object[]{1, 0},
		new Object[]{2, 2},
	};

	List<Edge<IntValue, NullValue>> edgeList = new LinkedList<>();

	for (Object[] edge : edges) {
		edgeList.add(new Edge<>(new IntValue((int) edge[0]), new IntValue((int) edge[1]), NullValue.getInstance()));
	}

	graph = Graph.fromCollection(edgeList, env);
}
 
Example #13
Source File: RedisMetadataHandlerTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp()
        throws Exception
{
    logger.info("{}: enter", testName.getMethodName());

    when(mockFactory.getOrCreateConn(eq(decodedEndpoint))).thenReturn(mockClient);

    handler = new RedisMetadataHandler(mockGlue, new LocalKeyFactory(), mockSecretsManager, mockAthena, mockFactory, "bucket", "prefix");
    allocator = new BlockAllocatorImpl();

    when(mockSecretsManager.getSecretValue(any(GetSecretValueRequest.class)))
            .thenAnswer((InvocationOnMock invocation) -> {
                GetSecretValueRequest request = invocation.getArgumentAt(0, GetSecretValueRequest.class);
                if ("endpoint".equalsIgnoreCase(request.getSecretId())) {
                    return new GetSecretValueResult().withSecretString(decodedEndpoint);
                }
                throw new RuntimeException("Unknown secret " + request.getSecretId());
            });
}
 
Example #14
Source File: BlockUntilStepsFinishMetaTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  PluginRegistry.init( false );
  List<String> attributes =
    Arrays.asList( "transformName", "transformCopyNr" );

  Map<String, String> getterMap = new HashMap<>();
  Map<String, String> setterMap = new HashMap<>();
  FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
    new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 5 );

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "transformName", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "transformCopyNr", stringArrayLoadSaveValidator );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
    new LoadSaveTester<>( testMetaClass, attributes, new ArrayList<>(),
      getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #15
Source File: StatusServiceTestCase.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    doReturn(new MediaFile()).when(mediaFileService).getMediaFile(any(Path.class));
    doReturn(settings).when(settingsService).getUserSettings(any(String.class));
    doReturn(true).when(settings).getNowPlayingAllowed();
    service = new StatusService();
    service.setMessagingTemplate(messagingTemplate);
    service.setMediaFileService(mediaFileService);
    service.setSettingsService(settingsService);
    player1 = new Player();
    player1.setId(1);
    player1.setUsername("p1");
    player2 = new Player();
    player2.setId(2);
    player2.setUsername("p2");
}
 
Example #16
Source File: TestGetOpenOrders.java    From huobi_Java with Apache License 2.0 5 votes vote down vote up
@Before
public void Initialize() {
  impl = new RestApiRequestImpl("12345", "67890", new RequestOptions());
  testAccount1.setType(AccountType.SPOT);
  testAccount1.setId(123L);
  testAccount2.setType(AccountType.MARGIN);
  testAccount2.setId(456L);
  List<Account> accountList = new LinkedList<>();
  accountList.add(testAccount1);
  accountList.add(testAccount2);
  testUser.setAccounts(accountList);
}
 
Example #17
Source File: ExcelInputMetaTest.java    From hop with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  HopEnvironment.init();

  meta = new ExcelInputMeta();
  meta.setFileName( new String[] { "1", "2", "3" } );
  meta.setSheetName( new String[] { "1", "2", "3", "4" } );
  meta.setField( new ExcelInputField[] {
    new ExcelInputField( "1", 1, 1 ),
    new ExcelInputField( "2", 2, 2 ) } );
  meta.normilizeAllocation();
}
 
Example #18
Source File: NormalMsgTwoSameGroupConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    printSeperator();
    topic = initTopic();
    logger.info(String.format("use topic: %s;", topic));
    producer = getProducer(nsAddr, topic);
}
 
Example #19
Source File: CompositeRequestConditionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.param1 = new ParamsRequestCondition("param1");
	this.param2 = new ParamsRequestCondition("param2");
	this.param3 = this.param1.combine(this.param2);

	this.header1 = new HeadersRequestCondition("header1");
	this.header2 = new HeadersRequestCondition("header2");
	this.header3 = this.header1.combine(this.header2);
}
 
Example #20
Source File: ProjectDaoTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    paging = new Paging<>();
    project = Project.builder().comment("project comment").app_id("10000000008").app_scene("aaa").dal_config_name("sasas").update_user_no("007").build();
    projectModel = ProjectModel.builder().name("das").build();
    paging.setData(projectModel);
}
 
Example #21
Source File: TestGroovyDriverPlatformHandlers.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();
   driver = factory.load(driverFile);
   context = new PlatformDeviceDriverContext(createDevice(driver), driver, mockPopulationCacheMgr);
}
 
Example #22
Source File: TestObjectHead.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException {
  //Create client stub and object store stub.
  OzoneClient clientStub = new OzoneClientStub();

  // Create volume and bucket
  clientStub.getObjectStore().createS3Bucket(bucketName);

  bucket = clientStub.getObjectStore().getS3Bucket(bucketName);

  // Create HeadBucket and setClient to OzoneClientStub
  keyEndpoint = new ObjectEndpoint();
  keyEndpoint.setClient(clientStub);
}
 
Example #23
Source File: TargetPointcutSelectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	ClassPathXmlApplicationContext ctx =
			new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
	testImpl1 = (TestInterface) ctx.getBean("testImpl1");
	testImpl2 = (TestInterface) ctx.getBean("testImpl2");
	testAspectForTestImpl1 = (TestAspect) ctx.getBean("testAspectForTestImpl1");
	testAspectForAbstractTestImpl = (TestAspect) ctx.getBean("testAspectForAbstractTestImpl");
	testInterceptor = (TestInterceptor) ctx.getBean("testInterceptor");

	testAspectForTestImpl1.count = 0;
	testAspectForAbstractTestImpl.count = 0;
	testInterceptor.count = 0;
}
 
Example #24
Source File: SchemaBuilderTest.java    From jsonschema-generator with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    this.config = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON)
            .with(Option.PLAIN_DEFINITION_KEYS)
            .build();
    this.typeContext = TypeContextFactory.createDefaultTypeContext();
}
 
Example #25
Source File: TestActivityEventProcessor.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
	processor = new ActivityEventProcessor(
			new Date(1000),
			new Date(10000),
			1000
	);
}
 
Example #26
Source File: DefaultHandshakeHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	super.setup();

	MockitoAnnotations.initMocks(this);
	this.handshakeHandler = new DefaultHandshakeHandler(this.upgradeStrategy);
}
 
Example #27
Source File: PassItselfBackViaContextTest.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
@Before
public void prepareSystem() {
    myObj = new MyObj();
    context = Context.newBuilder().allowPolyglotAccess(PolyglotAccess.ALL).build();
    context.getPolyglotBindings().putMember("myObj", myObj);
    context.eval("hashemi", "bebin azinja() {\n" + "  bede import(\"myObj\");\n" + "}\n");
    myObjWrapped = context.getBindings("hashemi").getMember("azinja").execute();
    assertFalse(myObjWrapped.isNull());
    myObjCall = myObjWrapped.as(CallWithValue.class);
}
 
Example #28
Source File: DeclarationOrderIndependenceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	ClassPathXmlApplicationContext ctx =
			new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
	aspect = (TopsyTurvyAspect) ctx.getBean("topsyTurvyAspect");
	target = (TopsyTurvyTarget) ctx.getBean("topsyTurvyTarget");
}
 
Example #29
Source File: DicomClientTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  clientAE = new ApplicationEntity(clientAET);
  Connection conn = new Connection();
  DeviceUtil.createClientDevice(clientAE, conn);
  clientAE.addConnection(conn);

  dicom = new DicomInputStream(TestUtils.streamTestFile(TestUtils.TEST_MR_FILE));
}
 
Example #30
Source File: CloneRowTest.java    From hop with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  transformMockHelper =
    new TransformMockHelper<CloneRowMeta, CloneRowData>( "Test CloneRow", CloneRowMeta.class, CloneRowData.class );
  when( transformMockHelper.logChannelFactory.create( any(), any( ILoggingObject.class ) ) )
    .thenReturn( transformMockHelper.logChannelInterface );
  when( transformMockHelper.pipeline.isRunning() ).thenReturn( true );
}