本文整理汇总了Java中org.junit.experimental.theories.DataPoints类的典型用法代码示例。如果您正苦于以下问题:Java DataPoints类的具体用法?Java DataPoints怎么用?Java DataPoints使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataPoints类属于org.junit.experimental.theories包,在下文中一共展示了DataPoints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFixture
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
/**
* 正常系テストデータ. 正常なレンジヘッダフィールドが指定された場合のテスト
* @return テストデータ
*/
@DataPoints
public static Fixture[] getFixture() {
Fixture[] datas = {
// ※前提 first-byte-pos:a last-byte-pos:b suffix-length:c entitylength:Z
// a = 0 < b
new Fixture(1, "bytes=0-26", 100, 0, 26, 27, "bytes 0-26/100"),
// a ≠ 0 < b
new Fixture(2, "bytes=3-7", 100, 3, 7, 5, "bytes 3-7/100"),
// bがない場合は、entitybodyの最後までを終端として扱う
new Fixture(3, "bytes=10-", 100, 10, 99, 90, "bytes 10-99/100"),
// Z<bの場合は、entitybodyの最後までを終端として扱う
new Fixture(4, "bytes=10-150", 100, 10, 99, 90, "bytes 10-99/100"),
// c<Zの場合(開始が省略)は、ファイルの終端からc分を扱う
new Fixture(5, "bytes=-10", 100, 90, 99, 10, "bytes 90-99/100"),
// c>Zの場合(開始が省略かつファイルサイズより指定が大きい)は、ファイル全体を扱う
new Fixture(6, "bytes=-150", 100, 0, 99, 100, "bytes 0-99/100"),
// a=b場合
new Fixture(7, "bytes=10-10", 100, 10, 10, 1, "bytes 10-10/100"),
// a=b=Zの場合
new Fixture(8, "bytes=99-99", 100, 99, 99, 1, "bytes 99-99/100") };
return datas;
}
示例2: guilds
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static Card[] guilds() {
BonusPerBoardElement bonus = new BonusPerBoardElement();
bonus.setType(BoardElementType.CARD);
bonus.setColors(Arrays.asList(Color.GREY, Color.BROWN));
bonus.setBoards(Arrays.asList(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT));
bonus.setPoints(1);
BonusPerBoardElement bonus2 = new BonusPerBoardElement();
bonus2.setType(BoardElementType.BUILT_WONDER_STAGES);
bonus2.setBoards(
Arrays.asList(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT));
bonus2.setPoints(1);
return new Card[] {TestUtils.createGuildCard(1, bonus), TestUtils.createGuildCard(2, bonus2)};
}
示例3: getSampleData
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static String[][] getSampleData() {
return new String[][]{
{"lineA", "lineA"},
{"lineB\n", "lineB\n"},
{"\nlineC\n", "lineC\n"},
{"\n\n\nlineD\n", "lineD\n"},
{"firstA\n\n\nlast", "firstA\nlast"},
{"firstB\n\n\nsecond\n\n\n\n\n\nlast", "firstB\nsecond\nlast"},
{"firstC\n\n\nlast\n\n", "firstC\nlast\n"},
// CRLF
{"Crlf lineA\r\n\r\nsecond line", "Crlf lineA\r\nsecond line"},
{"Crlf lineB\r\n\r\nsecond line\r\n\r\n", "Crlf lineB\r\nsecond line\r\n"},
// mixed
{"Crlf lineC\n\n\nsecond line\r\n\r\n", "Crlf lineC\nsecond line\r\n"},
};
}
示例4: getBatches
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static BatchTest[] getBatches() {
List<BatchTest> result = new ArrayList<BatchTest>();
BatchTest test = new BatchTest();
test.contentType = ContentType.XML;
test.stream = BulkApiBatchIntegrationTest.class.getResourceAsStream(TEST_REQUEST_XML);
result.add(test);
test = new BatchTest();
test.contentType = ContentType.CSV;
test.stream = BulkApiBatchIntegrationTest.class.getResourceAsStream(TEST_REQUEST_CSV);
result.add(test);
// TODO test ZIP_XML and ZIP_CSV
return result.toArray(new BatchTest[result.size()]);
}
示例5: valuesAndLengths
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static int[][] valuesAndLengths()
{
return new int[][]
{
{1, 1},
{10, 2},
{100, 3},
{1000, 4},
{12, 2},
{123, 3},
{2345, 4},
{9, 1},
{99, 2},
{999, 3},
{9999, 4},
};
}
示例6: urls
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static String[] urls() throws Exception {
// Load examples
try (InputStream in = OEmbedExamplesTest.class.getResourceAsStream("examples.json")) {
ObjectMapper mapper = new ObjectMapper();
TypeFactory tf = mapper.getTypeFactory();
examples = mapper.readValue(in, tf.constructMapType(Map.class, tf.constructType(String.class),
tf.constructCollectionType(List.class, String.class)));
}
List<String> result = new ArrayList<>();
urlToProviderName = new HashMap<>();
for (Map.Entry<String, List<String>> e : examples.entrySet()) {
for (String url : e.getValue()) {
HttpUrl b = HttpUrl.parse(url);
String v = b.queryParameter("url");
if (v != null) {
urlToProviderName.put(v, e.getKey());
result.add(v);
}
}
}
return result.toArray(new String[result.size()]);
}
示例7: data
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static TestPair[] data() {
int counter = 1;
return new TestPair[] {
new TestPair(counter++, atom("foo")),
new TestPair(counter++, list("foo")),
new TestPair(counter++, list("foo", list("bar", atom("baz")), atom("foof"))),
new TestPair(counter++, list("foo", atom("baz"))),
new TestPair(counter++, list("fo\"o", atom("baz"))),
new TestPair(counter++, list("fo-o", atom("baz"))),
new TestPair(counter++, list("foo bar", atom("baz"))),
new TestPair(counter++, list("\0x80fsssssssssssssoo bar", atom("baz"))),
new TestPair(counter++, atom("foo-bar")),
new TestPair(counter++, atom("-")),
new TestPair(counter++, atom("includes ~ tilde")),
};
}
示例8: addMultiPointMethods
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
private void addMultiPointMethods(ParameterSignature sig, List<PotentialAssignment> list) throws Throwable {
for (FrameworkMethod dataPointsMethod : getDataPointsMethods(sig)) {
Class<?> returnType = dataPointsMethod.getReturnType();
if ((returnType.isArray() && sig.canPotentiallyAcceptType(returnType.getComponentType())) ||
Iterable.class.isAssignableFrom(returnType)) {
try {
addDataPointsValues(returnType, sig, dataPointsMethod.getName(), list,
dataPointsMethod.invokeExplosively(null));
} catch (Throwable throwable) {
DataPoints annotation = dataPointsMethod.getAnnotation(DataPoints.class);
if (annotation != null && isAssignableToAnyOf(annotation.ignoredExceptions(), throwable)) {
return;
} else {
throw throwable;
}
}
}
}
}
示例9: getDataPointsFields
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@Override
protected Collection<Field> getDataPointsFields(ParameterSignature sig) {
Collection<Field> fields = super.getDataPointsFields(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<Field> fieldsWithMatchingNames = new ArrayList<Field>();
for (Field field : fields) {
String[] fieldNames = field.getAnnotation(DataPoints.class).value();
if (Arrays.asList(fieldNames).contains(requestedName)) {
fieldsWithMatchingNames.add(field);
}
}
return fieldsWithMatchingNames;
}
示例10: getDataPointsMethods
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@Override
protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {
Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
for (FrameworkMethod method : methods) {
String[] methodNames = method.getAnnotation(DataPoints.class).value();
if (Arrays.asList(methodNames).contains(requestedName)) {
methodsWithMatchingNames.add(method);
}
}
return methodsWithMatchingNames;
}
示例11: cipherTexts
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static List<TestCyphertext> cipherTexts() throws
URISyntaxException, FileNotFoundException, IOException {
JsonObject json = Utils.loadJsonResource("/wallet_ciphertexts.json");
JsonArray jsonCiphertexts = json.getAsJsonArray("ciphertexts");
ArrayList<TestCyphertext> ciphertexts = new ArrayList<>();
for (JsonElement e : jsonCiphertexts) {
JsonObject obj = e.getAsJsonObject();
TestCyphertext ciphertext = new TestCyphertext();
ciphertext.passphrase = obj.get("passphrase").getAsString();
ciphertext.cleartext = obj.get("cleartext").getAsString();
ciphertext.encrypted = EncryptedMessage.fromJson(obj.get("encrypted").getAsJsonObject());
ciphertexts.add(ciphertext);
}
return ciphertexts;
}
示例12: globs
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints({"globs"})
public static MatchData[] globs() {
final ImmutableList.Builder<MatchData> builder = ImmutableList.<MatchData>builder()
.add(MatchData.of("glob:*", false, false, false, true,
assertNonNull(hasItems("dir1", "dir2"))))
.add(MatchData.of("glob:*", false, false, true, false,
assertNonNull(hasItems(subFiles.toArray(new String[0])))))
.add(MatchData.of("glob:dir2", false, false, true, true,
assertNonNull(everyItem(equalTo("dir2")))))
.add(MatchData.of("glob:dir2/**/dir22?/dir*/*.*", false, false, true, false,
assertNonNull(everyItem(allOf(
startsWith(toFileSystemSpecific("dir2/dir22/dir222/dir2221")),
anyOf(endsWith("file2.txt"), endsWith("file3.ok"), endsWith("file4")),
not(anyOf(endsWith("file4"), endsWith("file1")))
)))));
return assertNonNull(builder.build().toArray(new MatchData[0]));
}
示例13: addFields
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
private void addFields(ParameterSignature sig,
List<PotentialAssignment> list) {
for (final Field field : fClass.getJavaClass().getFields()) {
if (Modifier.isStatic(field.getModifiers())) {
Class<?> type = field.getType();
if (sig.canAcceptArrayType(type)
&& field.getAnnotation(DataPoints.class) != null) {
try {
addArrayValues(field.getName(), list, getStaticFieldValue(field));
} catch (Throwable e) {
// ignore and move on
}
} else if (sig.canAcceptType(type)
&& field.getAnnotation(DataPoint.class) != null) {
list.add(PotentialAssignment
.forValue(field.getName(), getStaticFieldValue(field)));
}
}
}
}
示例14: getFullyCompatibleData
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static DataPair[] getFullyCompatibleData() {
return new DataPair[]{
DataPair.pair(XS_INTEGER, NUMERIC_VALUE),
DataPair.pair(XS_INT, NUMERIC_VALUE),
DataPair.pair(XS_SHORT, NUMERIC_VALUE),
DataPair.pair(XS_LONG, NUMERIC_VALUE),
DataPair.pair(XS_DECIMAL, FLOATING_POINT_VALUE),
DataPair.pair(XS_DOUBLE, FLOATING_POINT_VALUE),
DataPair.pair(XS_FLOAT, FLOATING_POINT_VALUE),
DataPair.pair(XS_BOOLEAN, "true"),
DataPair.pair(XS_STRING, VALUE),
DataPair.pair(XS_HEX_BINARY, "FFFF"),
DataPair.pair(XS_DAY_TIME_DURATION, "P4DT12H30M5S"),
DataPair.pair(XS_YEAR_MONTH_DURATION, "P3Y6M"),
DataPair.pair(XS_DATE, "2013-12-31"),
DataPair.pair(XS_DATE_TIME, "2013-12-31T23:59:59"),
DataPair.pair(XS_TIME, "23:59:59"),
DataPair.pair(XS_G_DAY, "---01"),
DataPair.pair(XS_G_MONTH, "--01"),
DataPair.pair(XS_G_MONTH_DAY, "--01-01"),
DataPair.pair(XS_G_YEAR, "0001"),
DataPair.pair(XS_G_YEAR_MONTH, "0001-01"),
DataPair.pair(XS_ANY_URI, VALUE),
};
}
示例15: getSaxonCompatibleData
import org.junit.experimental.theories.DataPoints; //导入依赖的package包/类
@DataPoints
public static DataPair[] getSaxonCompatibleData() {
return new DataPair[]{
DataPair.pair(XS_NON_NEGATIVE_INTEGER, NUMERIC_VALUE),
DataPair.pair(XS_POSITIVE_INTEGER, NUMERIC_VALUE),
DataPair.pair(XS_NON_POSITIVE_INTEGER, NEGATIVE_NUMERIC_VALUE),
DataPair.pair(XS_NEGATIVE_INTEGER, NEGATIVE_NUMERIC_VALUE),
DataPair.pair(XS_UNSIGNED_INT, NUMERIC_VALUE),
DataPair.pair(XS_UNSIGNED_SHORT, NUMERIC_VALUE),
DataPair.pair(XS_UNSIGNED_LONG, NUMERIC_VALUE),
DataPair.pair(XS_UNSIGNED_BYTE, "10"),
DataPair.pair(XS_DURATION, "P3Y6M4DT12H30M5S"),
DataPair.pair(XS_BYTE, "32"),
DataPair.pair(XS_NORMALIZED_STRING, VALUE),
DataPair.pair(XS_TOKEN, VALUE),
DataPair.pair(XS_LANGUAGE, VALUE),
DataPair.pair(XS_UNTYPED_ATOMIC, VALUE),
DataPair.pair(TEXT, VALUE),
};
}