use of com.google.cloud.conformance.storage.v1.PostPolicyV4Test in project java-storage by googleapis.
the class V4PostPolicyTest method testCases.
/**
* Loads all of the tests and return a {@code Collection<Object[]>} representing the set of tests.
* Each entry in the returned collection is the set of parameters to the constructor of this test
* class.
*
* <p>The results of this method will then be run by JUnit's Parameterized test runner
*/
@Parameters(name = "{2}")
public static Collection<Object[]> testCases() throws IOException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream credentialsStream = cl.getResourceAsStream(SERVICE_ACCOUNT_JSON_RESOURCE);
assertNotNull(String.format("Unable to load service account json: %s", SERVICE_ACCOUNT_JSON_RESOURCE), credentialsStream);
InputStream dataJson = cl.getResourceAsStream(TEST_DATA_JSON_RESOURCE);
assertNotNull(String.format("Unable to load test definition: %s", TEST_DATA_JSON_RESOURCE), dataJson);
ServiceAccountCredentials serviceAccountCredentials = ServiceAccountCredentials.fromStream(credentialsStream);
InputStreamReader reader = new InputStreamReader(dataJson, Charsets.UTF_8);
TestFile.Builder testBuilder = TestFile.newBuilder();
JsonFormat.parser().merge(reader, testBuilder);
TestFile testFile = testBuilder.build();
List<PostPolicyV4Test> tests = testFile.getPostPolicyV4TestsList();
ArrayList<Object[]> data = new ArrayList<>(tests.size());
for (PostPolicyV4Test test : tests) {
data.add(new Object[] { test, serviceAccountCredentials, test.getDescription() });
}
return data;
}
Aggregations