@Override protected boolean matchesSafely(final Value item, final Description mismatchDescription) { Value actualValue = item.get(key); if (actualValue == null) { mismatchDescription.appendText("no property with key '" + key + "'"); return false; } if (actualValue.getValueType() != Value.TYPE.STRING) { mismatchDescription.appendText("property with key '" + key + "' is '" + actualValue.getValueType() + "'"); return false; } if (!value.equals(actualValue.getString())) { mismatchDescription.appendText("property with key '" + key + "' had value of '" + actualValue.getString() + "'"); return false; } return true; }
public void install(String registerUrl, boolean checkStatus) throws Exception { //get a upm token String token = getUpmToken(); HttpPost post = new HttpPost(baseUrl + UPM_URL_PATH + "?token=" + token); post.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); final ObjectNode installRequest = JsonNodeFactory.instance.objectNode(); installRequest.put("pluginUri", registerUrl); installRequest.put("pluginName", "the plugin name"); post.setEntity(new StringEntity(installRequest.toString(), ContentType.create("application/vnd.atl.plugins.install.uri+json"))); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(post, responseHandler, defaultUsername, defaultPassword); if (Strings.isNullOrEmpty(response) || (!response.startsWith("{") && !response.endsWith("}"))) { install(registerUrl); } else { JSON json = JSON.parse(response); if (null == json.get("enabled")) { URI uri = new URI(baseUrl); final String statusUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + json.get("links").get("self").getString(); // JCE-635 the timeout here used to be 1 minute but needed to be bumped - it should be changed back if possible InstallStatusChecker statusChecker = checkStatus ? new InstallStatusChecker(userRequestSender, statusUrl, 4, TimeUnit.MINUTES, 500, TimeUnit.MILLISECONDS) : new InstallStatusChecker(userRequestSender, statusUrl, 5, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS); statusChecker.run(defaultUsername, defaultPassword); } } }
private String getDescriptorValue(String key) { String value; try { value = JPath.evaluate(descriptor.get(), key).getString(); } catch (ParserException | IOException e) { throw new RuntimeException(e); } return value; }
@Override public String find(String expression) throws Exception { JPath path = JPath.parse(expression); Value value = path.evaluate(body); if (value == null) { log.warn("Can't find expression '" + expression + "' in\n" + body.toJSON()); return null; } else { return value.toString(); } }
@Override protected final boolean matchesSafely(final Value value, final Description mismatchDescription) { if (value.getValueType() != Value.TYPE.ARRAY) { mismatchDescription.appendText("was of type " + value.getValueType()); return false; } @SuppressWarnings("unchecked") // this cast is safe - see the implementation fo value.getValueType() List<Value> list = (List<Value>) value; if (!matcher.matches(list)) { matcher.describeMismatch(list, mismatchDescription); return false; } return true; }
public void assertAddonIsEnabled(String addonKey) { assertTrue(getPluginJson(addonKey).get("enabled").getBoolean()); }
private static PerformanceResultsPublisherClient.PerformanceTestResult runPerformanceTest(TestPluginModuleStorageClient testPluginModuleStorageClient, PluginModulePerformanceTest performanceTest) throws Exception { final DescriptiveStatistics statistics = new DescriptiveStatistics(); final String deserializerIdentifier = performanceTest.getDeserializerIdentifier(); for (int i = 0; i < ITERATIONS; i++) { statistics.addValue(testPluginModuleStorageClient.testDeserializerByIdentifier(deserializerIdentifier).get("totalElapsedTimeMs").getDouble()); log.info("Moving median " + i + ": " + statistics.getPercentile(50)); } final double medianTimeMs = statistics.getPercentile(50); log.info("Median time for " + deserializerIdentifier + " with " + PLUGIN_MODULES + " modules: " + medianTimeMs + "ms"); final String assertionReason = "Deserializing " + deserializerIdentifier + " took too much time. More than " + performanceTest.maximumTimeMsForOneHundredModules() + "ms."; Assert.assertThat(assertionReason, medianTimeMs, Matchers.lessThanOrEqualTo(performanceTest.maximumTimeMsForOneHundredModules())); return new PerformanceResultsPublisherClient.PerformanceTestResult(deserializerIdentifier, medianTimeMs, statistics.getPercentile(99)); }
private String getDescriptorValue(String key) { String value; try { value = JPath.evaluate(descriptor.get(), key).getString(); } catch (ParserException | IOException e) { throw new RuntimeException(e); } return value; }
@Override public String find(String expression) throws Exception { JPath path = JPath.parse(expression); Value value = path.evaluate(body); if (value == null) { log.warn("Can't find expression '" + expression + "' in\n" + body.toJSON()); return null; } else { return value.toString(); } }
@Override protected final boolean matchesSafely(final Value value, final Description mismatchDescription) { if (value.getValueType() != Value.TYPE.ARRAY) { mismatchDescription.appendText("was of type " + value.getValueType()); return false; } @SuppressWarnings("unchecked") // this cast is safe - see the implementation fo value.getValueType() List<Value> list = (List<Value>) value; if (!matcher.matches(list)) { matcher.describeMismatch(list, mismatchDescription); return false; } return true; }
public void assertAddonIsDisabled(String addonKey) { assertFalse(getPluginJson(addonKey).get("enabled").getBoolean()); }
@Override protected boolean matchesSafely(final Value item, final Description mismatchDescription) { Value actualValue = item.get(key); if (actualValue == null) { mismatchDescription.appendText("no property with key '" + key + "'"); return false; } if (actualValue.getValueType() != Value.TYPE.STRING) { mismatchDescription.appendText("property with key '" + key + "' is '" + actualValue.getValueType() + "'"); return false; } if (!value.equals(actualValue.getString())) { mismatchDescription.appendText("property with key '" + key + "' had value of '" + actualValue.getString() + "'"); return false; } return true; }
public void install(String registerUrl, boolean checkStatus) throws Exception { //get a upm token String token = getUpmToken(); HttpPost post = new HttpPost(baseUrl + UPM_URL_PATH + "?token=" + token); post.addHeader("Accept", "application/json"); post.setEntity(new StringEntity("{ \"pluginUri\": \"" + registerUrl + "\", \"pluginName\": \"the plugin name\" }", ContentType.create("application/vnd.atl.plugins.install.uri+json"))); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(post, responseHandler, defaultUsername, defaultPassword); if (Strings.isNullOrEmpty(response) || (!response.startsWith("{") && !response.endsWith("}"))) { install(registerUrl); } else { JSON json = JSON.parse(response); if (null == json.get("enabled")) { URI uri = new URI(baseUrl); final String statusUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + json.get("links").get("self").getString(); if (checkStatus) { InstallStatusChecker statusChecker = new InstallStatusChecker(userRequestSender, statusUrl, 1, TimeUnit.MINUTES, 500, TimeUnit.MILLISECONDS); statusChecker.run(defaultUsername, defaultPassword); } else { InstallStatusChecker statusChecker = new InstallStatusChecker(userRequestSender, statusUrl, 5, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS); try { statusChecker.run(defaultUsername, defaultPassword); } catch (Exception e) { } } } } }