本文整理匯總了Java中org.junit.BeforeClass類的典型用法代碼示例。如果您正苦於以下問題:Java BeforeClass類的具體用法?Java BeforeClass怎麽用?Java BeforeClass使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BeforeClass類屬於org.junit包,在下文中一共展示了BeforeClass類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateTestDataAndQueries
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void generateTestDataAndQueries() throws Exception {
// Table consists of two columns "emp_id", "emp_name" and "dept_id"
empTableLocation = testTempFolder.newFolder().getAbsolutePath();
// Write 100 records for each new file
final int empNumRecsPerFile = 100;
for(int fileIndex=0; fileIndex<NUM_EMPLOYEES/empNumRecsPerFile; fileIndex++) {
File file = new File(empTableLocation + File.separator + fileIndex + ".json");
PrintWriter printWriter = new PrintWriter(file);
for (int recordIndex = fileIndex*empNumRecsPerFile; recordIndex < (fileIndex+1)*empNumRecsPerFile; recordIndex++) {
String record = String.format("{ \"emp_id\" : %d, \"emp_name\" : \"Employee %d\", \"dept_id\" : %d }",
recordIndex, recordIndex, recordIndex % NUM_DEPTS);
printWriter.println(record);
}
printWriter.close();
}
// Initialize test queries
groupByQuery = String.format("SELECT dept_id, count(*) as numEmployees FROM dfs.`%s` GROUP BY dept_id", empTableLocation);
}
示例2: setup
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setup() throws Exception
{
workingDirectory = System.getProperty( "workingDirectory" );
if ( workingDirectory == null )
{
String path = SchemaManagerAddTest.class.getResource( "" ).getPath();
int targetPos = path.indexOf( "target" );
workingDirectory = path.substring( 0, targetPos + 6 );
}
// Make sure every test class has its own schema directory
workingDirectory = new File( workingDirectory, "SchemaManagerAddTest" ).getAbsolutePath();
schemaRepository = new File( workingDirectory, "schema" );
// Cleanup the target directory
FileUtils.deleteDirectory( schemaRepository );
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
extractor.extractOrCopy();
}
示例3: beforeClassSetup
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void beforeClassSetup() throws InterruptedException {
network =
(NeatNetwork) NetworkBuilder
.create(NetworkType.EVOLUTION)
.setInputLayer(
LayerBuilder
.create()
.addNodes(1, Activations.sigmoid))
.addHiddenLayer(
LayerBuilder
.create()
.addNodes(4, Activations.sigmoid))
.setOutputLayer(
LayerBuilder
.create()
.addNodes(1, Activations.sigmoid)
)
.withBiasNode()
.withSettings(
NeatSettings
.create()
.setRandomSeed(3000))
.build();
}
示例4: createTempFile
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void createTempFile() throws Exception {
File tempFile;
while (true) {
tempFile = File.createTempFile("drillFSTest", ".txt");
if (tempFile.exists()) {
boolean success = tempFile.delete();
if (success) {
break;
}
}
}
// Write some data
PrintWriter printWriter = new PrintWriter(tempFile);
for (int i=1; i<=200000; i++) {
printWriter.println (String.format("%d, key_%d", i, i));
}
printWriter.close();
tempFilePath = tempFile.getPath();
}
示例5: setup
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setup() throws Exception {
SharesDataRetrievalServiceLocal billingRetrievalService = mock(SharesDataRetrievalServiceLocal.class);
when(
billingRetrievalService.loadOrganizationHistoryRoles(anyLong(),
anyLong())).thenReturn(
Arrays.asList(new OrganizationRole(
OrganizationRoleType.SUPPLIER)));
supplierShareAssembler = spy(new SupplierShareResultAssembler(
billingRetrievalService));
createBillingResults();
mockOrganizationData();
mockOrganizationHistoryRoles();
mockGetMarketplaceRevenueSharePercentage();
mockGetOperatorRevenueSharePercentage();
mockGetSellerRevenueSharePercentage();
mockGetProductHistoryData();
mockGetSubscriptionHistoryData();
mockGetBillingResults();
mockFindMarketplaceHistory();
mockGetOrgData(CUSTOMER);
mockXmlSearch();
datatypeFactory = DatatypeFactory.newInstance();
}
示例6: setUp
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
server.start();
server.addReference(REF_BIO_ID, REF_ID, REFERENCE_NAME, PATH_TO_REFERENCE);
//register vcf, no name, no index
server.addFeatureIndexedFileRegistration(REF_ID, PATH_TO_VCF, null, VCF_ID,
VCF_BIO_ID, BiologicalDataItemFormat.VCF, true);
// add another without feature index
server.addFeatureIndexedFileRegistration(REF_ID, PATH_TO_VCF, null, VCF_ID,
VCF_BIO_ID, BiologicalDataItemFormat.VCF, false);
//register BAM with name
server.addFileRegistration(REF_ID, PATH_TO_BAM, PATH_TO_BAI, BAM_NAME, BAM_ID, BAM_BIO_ID,
BiologicalDataItemFormat.BAM);
//register BAM without name
server.addFileRegistration(REF_ID, PATH_TO_BAM, PATH_TO_BAI, null, BAM_ID, BAM_BIO_ID,
BiologicalDataItemFormat.BAM);
serverParameters = getDefaultServerOptions(server.getPort());
}
示例7: setUp
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
WebserviceTestBase.getMailReader().deleteMails();
WebserviceTestBase.getOperator().addCurrency("EUR");
setup = new WebserviceTestSetup();
supplier1 = setup.createSupplier("Supplier1");
is = ServiceFactory.getDefault().getIdentityService(
WebserviceTestBase.getPlatformOperatorKey(),
WebserviceTestBase.getPlatformOperatorPassword());
VOUserDetails userDetails = is.getCurrentUserDetails();
userDetails.setEMail(WebserviceTestBase.getMailReader()
.getMailAddress());
is.updateUser(userDetails);
WebserviceTestBase.getMailReader().deleteMails();
}
示例8: setUpFixture
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setUpFixture() {
StringBuilder sb = new StringBuilder();
sb.append("Lorem ipsum dolor sit amet, eam no tale solet patrioque, est ")
.append("ne dico veri. Copiosae petentium no eum, has at wisi dicunt causae. Duo ea ")
.append("animal eligendi honestatis, dico fastidii officiis sit ne. At oblique ")
.append("docendi verterem ius, te vide cibo gloriatur nam. Ad has possit delicata. ")
.append("Sit vocibus accusamus an.");
loremIpsum = sb.toString();
sb = new StringBuilder();
for (int i = 0; i < 10000; i++) {
sb.append(loremIpsum);
}
repeatedLoremIpsum = sb.toString();
}
示例9: initializeJiraDataBase
import org.junit.BeforeClass; //導入依賴的package包/類
/**
* Initialize data base with 'MDA' JIRA project.
*/
@BeforeClass
public static void initializeJiraDataBase() throws SQLException {
datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
final Connection connection = datasource.getConnection();
final JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
try {
ScriptUtils.executeSqlScript(connection,
new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
ScriptUtils.executeSqlScript(connection,
new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
jdbcTemplate.queryForList("SELECT * FROM pluginversion WHERE ID = 10075");
} finally {
connection.close();
}
}
示例10: setupConfigsAndUtils
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setupConfigsAndUtils() throws Exception {
PRODUCER_CONFIG.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
PRODUCER_CONFIG.put(ProducerConfig.ACKS_CONFIG, "all");
PRODUCER_CONFIG.put(ProducerConfig.RETRIES_CONFIG, 0);
PRODUCER_CONFIG.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class);
PRODUCER_CONFIG.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
RESULT_CONSUMER_CONFIG.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
RESULT_CONSUMER_CONFIG.put(ConsumerConfig.GROUP_ID_CONFIG, APP_ID + "-result-consumer");
RESULT_CONSUMER_CONFIG.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
RESULT_CONSUMER_CONFIG.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class);
RESULT_CONSUMER_CONFIG.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
STREAMS_CONFIG.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
STREAMS_CONFIG.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
STREAMS_CONFIG.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getPath());
STREAMS_CONFIG.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.Long().getClass());
STREAMS_CONFIG.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
STREAMS_CONFIG.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 0);
STREAMS_CONFIG.put(IntegrationTestUtils.INTERNAL_LEAVE_GROUP_ON_CLOSE, true);
STREAMS_CONFIG.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 100);
}
示例11: init
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
mQClientAPIImpl = mock(MQClientAPIImpl.class);
defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
field.setAccessible(true);
field.set(defaultMQAdminExtImpl, mqClientInstance);
field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
field.setAccessible(true);
field.set(mqClientInstance, mQClientAPIImpl);
field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
field.setAccessible(true);
field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
Properties properties = new Properties();
properties.setProperty("maxMessageSize", "5000000");
properties.setProperty("flushDelayOffsetInterval", "15000");
properties.setProperty("serverSocketRcvBufSize", "655350");
when(mQClientAPIImpl.getBrokerConfig(anyString(), anyLong())).thenReturn(properties);
}
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:23,代碼來源:GetBrokerConfigCommandTest.java
示例12: beforeClass
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void beforeClass() {
String queueName = "DEMO.CONTRACT.MOCK";
System.setProperty("karate.env", "contract");
File file = FileUtils.getFileRelativeTo(PaymentServiceContractUsingMockTest.class, "payment-service-mock.feature");
server = FeatureServer.start(file, 0, false, Collections.singletonMap("queueName", queueName));
String paymentServiceUrl = "http://localhost:" + server.getPort();
System.setProperty("payment.service.url", paymentServiceUrl);
System.setProperty("shipping.queue.name", queueName);
}
示例13: checkAvailability
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void checkAvailability() {
try {
new Hmac();
} catch (WolfCryptException e) {
if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
System.out.println("Hmac test skipped: " + e.getError());
Assume.assumeNoException(e);
}
}
示例14: setupDefaultTestCluster
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void setupDefaultTestCluster() throws Exception {
// Create a test implementation of UserService
// and inject it in SabotNode.
BINDER_RULE.bind(UserService.class, new UserServiceTestImpl());
BaseTestQuery.setupDefaultTestCluster();
}
示例15: init
import org.junit.BeforeClass; //導入依賴的package包/類
@BeforeClass
public static void init() {
Calendar c = Calendar.getInstance();
c.set(1979, 2, 9, 11, 30);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
DATE_VALUE = c.getTime();
builder = GsonConfiguration.builder();
}