code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void doHttpFilePost(String url, HttpResponse result, Map<String, Object> headers, File file) {
httpClient.post(url, result, headers, file);
} | java |
public void doHttpFilePut(String url, HttpResponse result, Map<String, Object> headers, File file) {
httpClient.put(url, result, headers, file);
} | java |
public void doHttpPut(String url, String templateName, Object model, HttpResponse result) {
doHttpPut(url, templateName, model, result, null, XmlHttpResponse.CONTENT_TYPE_XML_TEXT_UTF8);
} | java |
public void doHttpPut(String url, HttpResponse result, Map<String, Object> headers, String contentType) {
httpClient.put(url, result, headers, contentType);
} | java |
public XmlHttpResponse doHttpGetXml(String url) {
XmlHttpResponse response = new XmlHttpResponse();
doGet(url, response);
setContext(response);
return response;
} | java |
public void doHead(String url, HttpResponse response, Map<String, Object> headers) {
response.setRequest(url);
httpClient.head(url, response, headers);
} | java |
public void doDelete(String url, HttpResponse response, Map<String, Object> headers) {
response.setRequest(url);
httpClient.delete(url, response, headers);
} | java |
public void doDelete(String url, HttpResponse result, Map<String, Object> headers, String contentType) {
httpClient.delete(url, result, headers, contentType);
} | java |
public String getHtml(Formatter formatter, String value) {
String result = null;
if (value != null) {
if ("".equals(value)) {
result = "";
} else {
String formattedResponse = formatter.format(value);
result = "<pre>" + StringEscapeU... | java |
public static void handleErrorResponse(String msg, String responseText) {
String responseHtml;
Environment instance = getInstance();
try {
responseHtml = instance.getHtmlForXml(responseText);
} catch (Exception e) {
responseHtml = instance.getHtml(value -> value, ... | java |
public ProgramResponse invokeProgram(int timeout, String directory, String command,
String... arguments) {
ProgramResponse result = new ProgramResponse();
result.setDirectory(directory);
result.setCommand(command);
result.setArguments(arguments);
... | java |
public String getWikiUrl(String filePath) {
String wikiUrl = null;
String filesDir = getFitNesseFilesSectionDir();
if (filePath.startsWith(filesDir)) {
String relativeFile = filePath.substring(filesDir.length());
relativeFile = relativeFile.replace('\\', '/');
... | java |
public String getFilePathFromWikiUrl(String wikiUrl) {
String url = getHtmlCleaner().getUrl(wikiUrl);
File file;
if (url.startsWith("files/")) {
String relativeFile = url.substring("files".length());
relativeFile = relativeFile.replace('/', File.separatorChar);
... | java |
public void addSeleniumCookies(HttpResponse response) {
CookieStore cookieStore = ensureResponseHasCookieStore(response);
CookieConverter converter = getCookieConverter();
Set<Cookie> browserCookies = getSeleniumHelper().getCookies();
converter.copySeleniumCookies(browserCookies, cookieS... | java |
public long stopTimer(String name) {
StopWatch sw = getStopWatch(name);
sw.stop();
STOP_WATCHES.remove(name);
return sw.getTime();
} | java |
public Map<String, Long> stopAllTimers() {
Map<String, Long> result = allTimerTimes();
STOP_WATCHES.clear();
return result;
} | java |
public String createContainingValue(String filename, String key) {
Object data = value(key);
if (data == null) {
throw new SlimFixtureException(false, "No value for key: " + key);
}
return createContaining(filename, data);
} | java |
public String encode(String fileUrl) {
String file = getFilePathFromWikiUrl(fileUrl);
try {
byte[] content = IOUtils.toByteArray(new FileInputStream(file));
return base64Encode(content);
} catch (IOException e) {
throw new SlimFixtureException("Unable to read:... | java |
public String createFrom(String fileName, String base64String) {
String result;
String baseName = FilenameUtils.getBaseName(fileName);
String target = saveBase + baseName;
String ext = FilenameUtils.getExtension(fileName);
byte[] content = base64Decode(base64String);
Stri... | java |
public void addValueToIn(Object value, String name, Map<String, Object> map) {
Object val = getValue(map, name);
if (val instanceof Collection) {
Object cleanValue = getCleanValue(value);
((Collection) val).add(cleanValue);
} else if (val == null) {
setVa... | java |
public void copyValuesFromTo(Map<String, Object> otherMap, Map<String, Object> map) {
map.putAll(otherMap);
} | java |
public String applyTemplate(String aTemplate) {
String result = getEnvironment().processTemplate(aTemplate, getCurrentValues());
result = postProcess(result);
result = formatResult(aTemplate, result);
return result;
} | java |
@Override
public boolean loadValuesFrom(String filename) {
String yamlStr = textIn(filename);
Object y = yaml.load(yamlStr);
if (y instanceof Map) {
getCurrentValues().putAll((Map) y);
} else {
getCurrentValues().put("elements", y);
}
return tr... | java |
@Override
public T apply(T webElement) {
if (firstFound == null) {
firstFound = webElement;
}
return mayPass(webElement) ? webElement : null;
} | java |
private HttpEntity buildBodyWithFile(File file) {
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", file,
ContentType.APPLICATION_OCTET_STREAM, file.getName());
HttpEntity multipart = builder.build();
return multipart;
} | java |
protected static org.apache.http.client.HttpClient buildHttpClient(boolean contentCompression, boolean sslVerification) {
RequestConfig rc = RequestConfig.custom()
.setCookieSpec(CookieSpecs.STANDARD)
.build();
HttpClientBuilder builder = HttpClients.custom()
... | java |
public static <T, K, U> Collector<T, ?, LinkedHashMap<K, U>> toLinkedMap(Function<? super T, ? extends K> keyMapper,
Function<? super T, ? extends U> valueMapper) {
BinaryOperator<U> mergeFunction = throwingMerger();
return ... | java |
public static <T, K, U> Collector<T, ?, LinkedHashMap<K, U>> toLinkedMap(
Function<? super T, ? extends K> keyMapper,
Function<? super T, ? extends U> valueMapper,
BinaryOperator<U> mergeFunction) {
return Collectors.toMap(keyMapper, valueMapper, mergeFunction, LinkedHash... | java |
public static <T> BinaryOperator<T> throwingMerger() {
return (u, v) -> {
throw new IllegalArgumentException(String.format("Duplicate key: value %s was already present now %s is added", u, v));
};
} | java |
public boolean validateAgainst(String xmlContent, String xsdContent) {
try {
Source xsd = new SAXSource(new InputSource(new StringReader(xsdContent)));
Source xml = new SAXSource(new InputSource(new StringReader(xmlContent)));
SchemaFactory schemaFactory = SchemaFactory
... | java |
@Override
public boolean loadValuesFrom(String filename) {
String propContent = textIn(filename);
PropertiesHelper propHelper = getEnvironment().getPropertiesHelper();
Properties properties = propHelper.parsePropertiesString(propContent);
Map<String, Object> propAsMap = propHelper.co... | java |
public boolean startDriver(String driverClassName, final Map<String, Object> profile) throws Exception {
if (OVERRIDE_ACTIVE) {
return true;
}
DriverFactory driverFactory = new LocalDriverFactory(driverClassName, profile);
WebDriver driver = setAndUseDriverFactory(driverFact... | java |
public boolean connectToDriverForVersionOnAt(String browser, String version, String platformName, String url)
throws MalformedURLException {
Platform platform = Platform.valueOf(platformName);
DesiredCapabilities desiredCapabilities = new DesiredCapabilities(browser, version, platform);
... | java |
public static Integer getFileSizeOnFTPServer(String hostName, Integer port,
String userName, String password, String filePath) {
Integer result = null;
// get file size
String replyString = executeCommandOnFTPServer(hostName, port, userName, password, "SIZE", filePath);
if ... | java |
public static String executeCommandOnFTPServer(String hostName, Integer port,
String userName, String password, String command, String commandArgs) {
String result = null;
if (StringUtils.isNotBlank(command)) {
FTPClient ftpClient = new FTPClient();
String errorMessa... | java |
public static String uploadFileToFTPServer(String hostName, Integer port, String userName,
String password, String localFileFullName, String remotePath) {
String result = null;
FTPClient ftpClient = new FTPClient();
String errorMessage = "Unable to ... | java |
public static String loadFileFromFTPServer(String hostName, Integer port,
String userName, String password, String filePath, int numberOfLines) {
String result = null;
FTPClient ftpClient = new FTPClient();
InputStream inputStream = null;
String errorMessage = "Unable to con... | java |
public static void connectAndLoginOnFTPServer(FTPClient ftpClient,
String hostName, Integer port, String userName, String password) {
try {
if (port != null && port.intValue() > 0) {
ftpClient.connect(hostName, port);
} else {
ftpClient.connect... | java |
public static void disconnectAndLogoutFromFTPServer(FTPClient ftpClient, String hostName) {
try {
// logout and disconnect
if (ftpClient != null && ftpClient.isConnected()) {
ftpClient.logout();
ftpClient.disconnect();
}
} catch (IOExce... | java |
public void addDerivedDates(Map<String, Object> values) {
Map<String, Object> valuesToAdd = new HashMap<String, Object>();
for (Map.Entry<String, Object> entry : values.entrySet()) {
String key = entry.getKey();
Object object = entry.getValue();
if (object != null) {... | java |
public void setIntValueForIn(int value, String name, Map<String, Object> map) {
setValueForIn(Integer.valueOf(value), name, map);
} | java |
public void setDoubleValueForIn(double value, String name, Map<String, Object> map) {
setValueForIn(Double.valueOf(value), name, map);
} | java |
public void setBooleanValueForIn(boolean value, String name, Map<String, Object> map) {
setValueForIn(Boolean.valueOf(value), name, map);
} | java |
public void addValueToIn(Object value, String name, Map<String, Object> map) {
getMapHelper().addValueToIn(value, name, map);
} | java |
public void copyValuesFromTo(Map<String, Object> otherMap, Map<String, Object> map) {
getMapHelper().copyValuesFromTo(otherMap, map);
} | java |
public String getXPath(NamespaceContext context, String xml, String xPathExpr) {
return (String) evaluateXpath(context, xml, xPathExpr, null);
} | java |
public List<String> getAllXPath(NamespaceContext context, String xml, String xPathExpr) {
List<String> result = null;
NodeList nodes = (NodeList) evaluateXpath(context, xml, xPathExpr, XPathConstants.NODESET);
if (nodes != null) {
result = new ArrayList<String>(nodes.getLeng... | java |
@SafeVarargs
public static <T> T firstNonNull(Supplier<T>... suppliers) {
return firstNonNull(Supplier::get, suppliers);
} | java |
public static <T, R> R firstNonNull(T input, Function<T, R> function, Function<T, R>... functions) {
return firstNonNull(f -> f.apply(input), Stream.concat(Stream.of(function), Stream.of(functions)));
} | java |
public static <T, R> R firstNonNull(Function<T, R> function, Stream<T> values) {
return values
.map(function)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
} | java |
public static XPathCheckResult parse(String value) {
XPathCheckResult parsed = new XPathCheckResult();
parsed.result = value;
return parsed;
} | java |
public void addMisMatch(String name, String expected, String actual) {
result = "NOK";
Mismatch mismatch = new Mismatch();
mismatch.name = name;
mismatch.expected = expected;
mismatch.actual = actual;
mismatches.add(mismatch);
} | java |
public Properties parsePropertiesString(String propertiesAsString) {
final Properties p = new Properties();
try (StringReader reader = new StringReader(propertiesAsString)) {
p.load(reader);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to pars... | java |
public Map<String, Object> convertPropertiesToMap(Properties properties) {
return properties.entrySet().stream()
.collect(toLinkedMap(
e -> e.getKey().toString(),
e -> e.getValue()));
} | java |
protected String createFile(String dir, String fileName, byte[] content) {
String baseName = FilenameUtils.getBaseName(fileName);
String ext = FilenameUtils.getExtension(fileName);
String downloadedFile = FileUtil.saveToFile(dir + baseName, ext, content);
return linkToFile(downloadedFile... | java |
protected String linkToFile(File f) {
String url = getWikiUrl(f.getAbsolutePath());
if (url == null) {
url = f.toURI().toString();
}
return String.format("<a href=\"%s\" target=\"_blank\">%s</a>", url, f.getName());
} | java |
public void add(String prefix, String uri) {
if (uri == null) {
namespaces.remove(prefix);
} else {
if (namespaces.containsKey(prefix)) {
String currentUri = namespaces.get(prefix);
if (!currentUri.equals(uri)) {
throw new FitFa... | java |
public String html(String htmlSource) {
String cleanSource = htmlCleaner.cleanupPreFormatted(htmlSource);
return "<div>" + StringEscapeUtils.unescapeHtml4(cleanSource) + "</div>";
} | java |
protected String generateResultXml(String testName, Throwable exception, double executionTime) {
int errors = 0;
int failures = 0;
String failureXml = "";
if (exception != null) {
failureXml = "<failure type=\"" + exception.getClass().getName()
+ "\" mess... | java |
protected void writeResult(String testName, String resultXml) throws IOException {
String finalPath = getXmlFileName(testName);
Writer fw = null;
try {
fw = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(finalPath),
... | java |
public static String getData(String dataUrl) {
int indexOfComma = dataUrl.indexOf(',');
return dataUrl.substring(indexOfComma + 1);
} | java |
public Object getJsonPath(String json, String jsonPath) {
if (!JsonPath.isPathDefinite(jsonPath)) {
throw new RuntimeException(jsonPath + " returns a list of results, not a single.");
}
return parseJson(json).read(jsonPath);
} | java |
public List<Object> getAllJsonPath(String json, String jsonPath) {
List<Object> result;
if (JsonPath.isPathDefinite(jsonPath)) {
Object val = getJsonPath(json, jsonPath);
if (val == null) {
result = Collections.emptyList();
} else {
res... | java |
public String differenceBetweenAnd(String first, String second) {
Formatter whitespaceFormatter = new Formatter() {
@Override
public String format(String value) {
return ensureWhitespaceVisible(value);
}
};
return getDifferencesHtml(first, seco... | java |
public String differenceBetweenExplicitWhitespaceAnd(String first, String second) {
Formatter whitespaceFormatter = new Formatter() {
@Override
public String format(String value) {
return explicitWhitespace(value);
}
};
return getDifferencesHtm... | java |
public String differenceBetweenIgnoreWhitespaceAnd(String first, String second) {
String cleanFirst = allWhitespaceToSingleSpace(first);
String cleanSecond = allWhitespaceToSingleSpace(second);
String cleanDiff = differenceBetweenAnd(cleanFirst, cleanSecond);
if (cleanDiff != null) {
... | java |
protected static void registerNs(String prefix, String url) {
Environment.getInstance().registerNamespace(prefix, url);
} | java |
protected Response callServiceImpl(String urlSymbolKey, String soapAction) {
String url = getSymbol(urlSymbolKey).toString();
Response response = getEnvironment().createInstance(getResponseClass());
callSoapService(url, getTemplateName(), soapAction, response);
return response;
} | java |
protected XmlHttpResponse callCheckServiceImpl(String urlSymbolKey, String soapAction) {
String url = getSymbol(urlSymbolKey).toString();
XmlHttpResponse response = getEnvironment().createInstance(getCheckResponseClass());
callSoapService(url, getCheckTemplateName(), soapAction, response);
... | java |
protected void callSoapService(String url, String templateName, String soapAction, XmlHttpResponse response) {
Map<String, Object> headers = soapAction != null ? Collections.singletonMap("SOAPAction", (Object) soapAction) : null;
getEnvironment().callService(url, templateName, getCurrentRowValues(), res... | java |
public String getUrl(String htmlLink) {
String result = htmlLink;
if (htmlLink != null) {
Matcher linkMatcher = LINKPATTERN.matcher(htmlLink);
Matcher imgMatcher = IMAGEPATTERN.matcher(htmlLink);
if (linkMatcher.matches()) {
String href = linkMatcher.g... | java |
public static String getXPathForRowByValueInOtherColumn(String selectIndex, String value) {
return String.format("/tr[td[%1$s]/descendant-or-self::text()[normalized(.)='%2$s']]", selectIndex, value);
} | java |
public static String getXPathForColumnIndex(String columnName) {
// determine how many columns are before the column with the requested name
// the column with the requested name will have an index of the value +1 (since XPath indexes are 1 based)
String headerXPath = getXPathForHeaderCellWithTe... | java |
public static String getXPathForHeaderRowByHeaders(String columnName, String... extraColumnNames) {
String allHeadersPresent;
if (extraColumnNames != null && extraColumnNames.length > 0) {
int extraCount = extraColumnNames.length;
String[] columnNames = new String[extraCount + 1]... | java |
private <T> T doWithLock(LockCallback<T> callback) throws JobPersistenceException {
return doWithLock(callback, null);
} | java |
private <T> T doWithLock(LockCallback<T> callback, String errorMessage) throws JobPersistenceException {
JedisCommands jedis = null;
try {
jedis = getResource();
try {
storage.waitForLock(jedis);
return callback.doWithLock(jedis);
} cat... | java |
public boolean lock(T jedis){
UUID lockId = UUID.randomUUID();
final String setResponse = jedis.set(redisSchema.lockKey(), lockId.toString(), "NX", "PX", lockTimeout);
boolean lockAcquired = !isNullOrEmpty(setResponse) && setResponse.equals("OK");
if(lockAcquired){
// save th... | java |
public void waitForLock(T jedis){
while(!lock(jedis)){
try {
logger.debug("Waiting for Redis lock.");
Thread.sleep(randomInt(75, 125));
} catch (InterruptedException e) {
logger.error("Interrupted while waiting for lock.", e);
}... | java |
public boolean unlock(T jedis){
final String currentLock = jedis.get(redisSchema.lockKey());
if(!isNullOrEmpty(currentLock) && UUID.fromString(currentLock).equals(lockValue)){
// This is our lock. We can remove it.
jedis.del(redisSchema.lockKey());
return true;
... | java |
public JobDetail retrieveJob(JobKey jobKey, T jedis) throws JobPersistenceException, ClassNotFoundException{
final String jobHashKey = redisSchema.jobHashKey(jobKey);
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobKey);
final Map<String, String> jobDetailMap = jedis.hgetAll(j... | java |
public OperableTrigger retrieveTrigger(TriggerKey triggerKey, T jedis) throws JobPersistenceException{
final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
Map<String, String> triggerMap = jedis.hgetAll(triggerHashKey);
if(triggerMap == null || triggerMap.isEmpty()){
... | java |
public List<OperableTrigger> getTriggersForJob(JobKey jobKey, T jedis) throws JobPersistenceException {
final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(jobKey);
final Set<String> triggerHashKeys = jedis.smembers(jobTriggerSetKey);
List<OperableTrigger> triggers = new ArrayList<>();... | java |
public boolean setTriggerState(final RedisTriggerState state, final double score, final String triggerHashKey, T jedis) throws JobPersistenceException{
boolean success = false;
if(state != null){
unsetTriggerState(triggerHashKey, jedis);
success = jedis.zadd(redisSchema.triggerSt... | java |
public boolean checkExists(JobKey jobKey, T jedis){
return jedis.exists(redisSchema.jobHashKey(jobKey));
} | java |
public boolean checkExists(TriggerKey triggerKey, T jedis){
return jedis.exists(redisSchema.triggerHashKey(triggerKey));
} | java |
public Calendar retrieveCalendar(String name, T jedis) throws JobPersistenceException{
final String calendarHashKey = redisSchema.calendarHashKey(name);
Calendar calendar;
try{
final Map<String, String> calendarMap = jedis.hgetAll(calendarHashKey);
if(calendarMap == null ... | java |
public void pauseJob(JobKey jobKey, T jedis) throws JobPersistenceException {
for (OperableTrigger trigger : getTriggersForJob(jobKey, jedis)) {
pauseTrigger(trigger.getKey(), jedis);
}
} | java |
public Set<String> getPausedTriggerGroups(T jedis){
final Set<String> triggerGroupSetKeys = jedis.smembers(redisSchema.pausedTriggerGroupsSet());
Set<String> names = new HashSet<>(triggerGroupSetKeys.size());
for (String triggerGroupSetKey : triggerGroupSetKeys) {
names.add(redisSche... | java |
protected boolean isActiveInstance(String instanceId, T jedis) {
boolean isActive = ( System.currentTimeMillis() - getLastInstanceActiveTime(instanceId, jedis) < clusterCheckInterval);
if (!isActive) {
removeLastInstanceActiveTime(instanceId, jedis);
}
return isActive;
} | java |
protected void releaseOrphanedTriggers(RedisTriggerState currentState, RedisTriggerState newState, T jedis) throws JobPersistenceException {
for (Tuple triggerTuple : jedis.zrangeWithScores(redisSchema.triggerStateKey(currentState), 0, -1)) {
final String lockId = jedis.get(redisSchema.triggerLockKe... | java |
protected void releaseTriggersCron(T jedis) throws JobPersistenceException {
// has it been more than 10 minutes since we last released orphaned triggers
// or is this the first check upon initialization
if(isTriggerLockTimeoutExceeded(jedis) || !isActiveInstance(schedulerInstanceId, jedis)){
... | java |
protected void settLastTriggerReleaseTime(long time, T jedis){
jedis.set(redisSchema.lastTriggerReleaseTime(), Long.toString(time));
} | java |
protected void setLastInstanceActiveTime(String instanceId, long time, T jedis){
jedis.hset(redisSchema.lastInstanceActiveTime(), instanceId, Long.toString(time));
} | java |
protected void removeLastInstanceActiveTime(String instanceId, T jedis){
jedis.hdel(redisSchema.lastInstanceActiveTime(), instanceId);
} | java |
protected boolean isBlockedJob(String jobHashKey, T jedis) {
JobKey jobKey = redisSchema.jobKey(jobHashKey);
return jedis.sismember(redisSchema.blockedJobsSet(), jobHashKey) &&
isActiveInstance(jedis.get(redisSchema.jobBlockedKey(jobKey)), jedis);
} | java |
protected boolean lockTrigger(TriggerKey triggerKey, T jedis){
return jedis.set(redisSchema.triggerLockKey(triggerKey), schedulerInstanceId, "NX", "PX", TRIGGER_LOCK_TIMEOUT).equals("OK");
} | java |
protected List<String> split(final String string){
if (null!=prefix){
//remove prefix before split
return Arrays.asList(string.substring(prefix.length()).split(delimiter));
}else{
return Arrays.asList(string.split(delimiter));
}
} | java |
@Override
public void storeTrigger(OperableTrigger trigger, boolean replaceExisting, JedisCluster jedis) throws JobPersistenceException {
final String triggerHashKey = redisSchema.triggerHashKey(trigger.getKey());
final String triggerGroupSetKey = redisSchema.triggerGroupSetKey(trigger.getKey());
... | java |
@Override
public boolean removeJob(JobKey jobKey, Jedis jedis) throws JobPersistenceException {
final String jobHashKey = redisSchema.jobHashKey(jobKey);
final String jobBlockedKey = redisSchema.jobBlockedKey(jobKey);
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobKey);
... | java |
@Override
@SuppressWarnings("unchecked")
public void storeJob(JobDetail jobDetail, boolean replaceExisting, Jedis jedis) throws ObjectAlreadyExistsException {
final String jobHashKey = redisSchema.jobHashKey(jobDetail.getKey());
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobD... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.