本文整理汇总了Java中com.indeed.proctor.common.ProctorUtils类的典型用法代码示例。如果您正苦于以下问题:Java ProctorUtils类的具体用法?Java ProctorUtils怎么用?Java ProctorUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProctorUtils类属于com.indeed.proctor.common包,在下文中一共展示了ProctorUtils类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSpecificationGet
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
@RequestMapping(value= "/{testName}/specification")
public View doSpecificationGet(
@PathVariable String testName,
@RequestParam(required = false) final String branch
) {
final Environment theEnvironment = determineEnvironmentFromParameter(branch);
final ProctorStore store = determineStoreFromEnvironment(theEnvironment);
final TestDefinition definition = getTestDefinition(store, testName);
if (definition == null) {
LOGGER.info("Unknown test definition : " + testName);
// unknown testdefinition
throw new NullPointerException("Unknown test definition");
}
JsonView view;
try {
final TestSpecification specification = ProctorUtils.generateSpecification(definition);
view = new JsonView(specification);
} catch (IllegalArgumentException e) {
LOGGER.error("Could not generate Test Specification", e);
view = new JsonView(new JsonResponse(e.getMessage(), false, "Could not generate Test Specification"));
}
return view;
}
示例2: generateArtifact
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
static void generateArtifact(final ProctorReader proctorPersister, final Writer outputSink,
final String authorOverride, final String versionOverride
) throws IOException, IncompatibleTestMatrixException, StoreException {
final TestMatrixVersion currentTestMatrix = proctorPersister.getCurrentTestMatrix();
if(currentTestMatrix == null) {
throw new RuntimeException("Failed to load current test matrix for " + proctorPersister);
}
// I'm not sure if it's better for the LocalDirectoryPersister to be aware of this svn info, or for all the overrides to happen here.
if(!CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(authorOverride))) {
currentTestMatrix.setAuthor(authorOverride);
}
if(!Strings.isNullOrEmpty(versionOverride)) {
currentTestMatrix.setVersion(versionOverride);
}
final TestMatrixArtifact artifact = ProctorUtils.convertToConsumableArtifact(currentTestMatrix);
// For each test, verify that it's internally consistent (buckets sum to 1.0, final null allocation)
final String matrixSource = artifact.getAudit().getUpdatedBy() + "@" + artifact.getAudit().getVersion();
for(final Map.Entry<String, ConsumableTestDefinition> td : artifact.getTests().entrySet()) {
ProctorUtils.verifyInternallyConsistentDefinition(td.getKey(), matrixSource, td.getValue());
}
ProctorUtils.serializeArtifact(outputSink, artifact);
}
示例3: testNestedClasses
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
@Test
public void testNestedClasses() throws Exception {
final Map<String, String> declaredContext = getProctorSpecification().getProvidedContext();
final Map<String, String> innerClassTypes = Maps.filterValues(declaredContext, new Predicate<String>() {
@Override
public boolean apply(final String subfrom) {
return subfrom.contains("$");
}
});
assertTrue(
"Sample groups need to contain at least one inner class type",
!innerClassTypes.isEmpty());
final ProvidedContext providedContext = ProctorUtils.convertContextToTestableMap(declaredContext);
assertTrue(
"Expected the provided context to be populated since no class-not-found-error should have been thrown",
!providedContext.getContext().isEmpty());
}
示例4: recursiveSpecificationsFinder
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private void recursiveSpecificationsFinder(final File dir, final String packageNamePrefix) throws CodeGenException {
if (dir.equals(null)) {
throw new CodeGenException("recursiveSpecificationsFinder called with null pointer");
}
final File[] files = dir.listFiles();
if (files == null) {
return;
}
for(final File entry : files) {
try {
if (entry.isDirectory()) {
recursiveSpecificationsFinder(entry, (packageNamePrefix == null) ? entry.getName() : packageNamePrefix + "/" + entry.getName());
} else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) {
processFile(
entry,
packageNamePrefix == null ? "" : packageNamePrefix.replace("/", "."),
entry.getName().substring(0, entry.getName().lastIndexOf(".json")));
}
} catch (IOException e) {
throw new CodeGenException("Could not read from file " + entry.getName(),e);
}
}
}
示例5: addNonPartialsToResources
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private void addNonPartialsToResources(final File dir, final Resource resource) throws CodeGenException {
if (dir.equals(null)) {
throw new CodeGenException("Could not read from directory " + dir.getPath());
}
final File[] files = dir.listFiles();
if (files == null) {
return;
}
for(File entry : files) {
try {
if (entry.isDirectory()) {
addNonPartialsToResources(entry, resource);
} else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) {
resource.addInclude(entry.getPath().substring(getTopDirectory().getPath().length() + 1));
}
} catch (IOException e) {
throw new CodeGenException("Could not read from file " + entry.getName(),e);
}
}
}
示例6: load
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
public Proctor load(String definitionUrl, boolean forceReload) {
Proctor proctor = proctorCache.get(definitionUrl);
if (proctor != null && !forceReload) {
System.out.println("reusing cached " + definitionUrl);
return proctor;
}
try {
HttpURLConnection.setFollowRedirects(true); // for demo purposes, allow Java to follow redirects
ProctorSpecification spec = ProctorUtils.readSpecification(DefinitionManager.class.getResourceAsStream(DEFAULT_SPEC));
UrlProctorLoader loader = new UrlProctorLoader(spec, definitionUrl + "?r=" + random.nextInt());
proctor = loader.doLoad();
System.out.println("loaded definition from " + definitionUrl);
proctorCache.put(definitionUrl, proctor);
} catch (Throwable t) {
logger.error("Failed to load test spec/definition", t);
t.printStackTrace();
}
return proctor;
}
示例7: verify
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private ProctorLoadResult verify(final ProctorSpecification spec,
final TestMatrixArtifact testMatrix,
final String testName,
final String matrixSource) {
final Map<String, TestSpecification> requiredTests;
if (spec.getTests().containsKey(testName)) {
requiredTests = ImmutableMap.of(testName, spec.getTests().get(testName));
} else {
requiredTests = Collections.emptyMap();
}
return ProctorUtils.verify(testMatrix, matrixSource, requiredTests);
}
示例8: viewRawTestMatrix
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
@RequestMapping(value="/matrix/raw", method=RequestMethod.GET)
public JsonView viewRawTestMatrix(final String branch, final Model model) {
final Environment which = determineEnvironmentFromParameter(branch);
final TestMatrixVersion testMatrixVersion = getCurrentMatrix(which);
final TestMatrixArtifact testMatrixArtifact = ProctorUtils.convertToConsumableArtifact(testMatrixVersion);
return new JsonView(testMatrixArtifact);
}
示例9: populateCompabilityRow
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private void populateCompabilityRow(final Map<Environment, CompatibilityRow> rows, final Environment rowEnv) {
final CompatibilityRow row = new CompatibilityRow();
rows.put(rowEnv, row);
final TestMatrixVersion matrix = getCurrentMatrix(rowEnv);
final TestMatrixArtifact artifact = ProctorUtils.convertToConsumableArtifact(matrix);
populateSingleCompabilityColumn(rowEnv, artifact, row, Environment.WORKING);
populateSingleCompabilityColumn(rowEnv, artifact, row, Environment.QA);
populateSingleCompabilityColumn(rowEnv, artifact, row, Environment.PRODUCTION);
}
示例10: populateRootMap
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
@Override
protected Map<String, Object> populateRootMap(final String input, final Map<String, Object> baseContext, final String packageName, final String className) {
final File inputFile = new File(input);
final ProctorSpecification spec = ProctorUtils.readSpecification(inputFile);
return populateRootMap(spec, baseContext, packageName, className);
}
示例11: getProctorSpecification
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private ProctorSpecification getProctorSpecification() throws IOException {
final InputStream specificationStream = getClass().getResourceAsStream(SPECIFICATION_RESOURCE);
try {
return ProctorUtils.readSpecification(specificationStream);
} finally {
specificationStream.close();
}
}
示例12: getProctorSpecification
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
private ProctorSpecification getProctorSpecification() throws IOException {
final InputStream specicationStream = getClass().getResourceAsStream(SPECIFICATION_RESOURCE);
try {
return ProctorUtils.readSpecification(specicationStream);
} finally {
specicationStream.close();
}
}
示例13: populateSingleCompabilityColumn
import com.indeed.proctor.common.ProctorUtils; //导入依赖的package包/类
/**
* We want a compatibility matrix of
*
* TRUNK-MATRIX:
* [DEV-WEBAPPS]:
* (web-app-1): compatible?
* [QA-WEBAPPS]:
* (web-app-1): compatible?
* [PRODUCTION-WEBAPPS]:
* (web-app-1): compatible?
*
* QA-MATRIX:
* [DEV-WEBAPPS]:
* (web-app-1): compatible?
* [QA-WEBAPPS]:
* (web-app-1): compatible?
* [PRODUCTION-WEBAPPS]:
* (web-app-1): compatible?
*
* PRODUCTION-MATRIX:
* [DEV-WEBAPPS]:
* (web-app-1): compatible?
* [QA-WEBAPPS]:
* (web-app-1): compatible?
* [PRODUCTION-WEBAPPS]:
* (web-app-1): compatible?
*
* @param artifact
* @param row
* @param webappEnvironment
*/
private void populateSingleCompabilityColumn(
final Environment artifactEnvironment,
final TestMatrixArtifact artifact,
final CompatibilityRow row,
final Environment webappEnvironment) {
final Map<AppVersion, RemoteSpecificationResult> clients = specificationSource.loadAllSpecifications(webappEnvironment);
// sort the apps (probably should sort the Map.Entry, but this is good enough for now
final SortedSet<AppVersion> versions = Sets.newTreeSet(clients.keySet());
for(final AppVersion version : versions) {
final RemoteSpecificationResult remoteResult = clients.get(version);
final boolean compatible;
final String error;
if (remoteResult.isSkipped()) {
continue;
} else if (remoteResult.isSuccess()) {
// use all the required tests from the specification
final String matrixSource = artifactEnvironment.getName() + " r" + artifact.getAudit().getVersion();
final ProctorLoadResult plr = ProctorUtils.verify(artifact, matrixSource, remoteResult.getSpecificationResult().getSpecification().getTests());
compatible = !plr.hasInvalidTests();
error = String.format("Incompatible: Tests Missing: %s Invalid Tests: %s for %s", plr.getMissingTests(), plr.getTestsWithErrors(), matrixSource);
} else {
compatible = false;
error = "Failed to load a proctor specification from " + Joiner.on(", ").join(Iterables.transform(remoteResult.getFailures().keySet(), Functions.toStringFunction()));
}
row.addVersion(webappEnvironment, new CompatibleSpecificationResult(version, compatible, error));
}
}