List of usage examples for java.lang AssertionError AssertionError
public AssertionError(double detailMessage)
double
, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification. From source file:com.brightcove.com.zartan.verifier.rendition.IOSRenditionVerifier.java
@ZartanCheck(value = "The video has the expected IOS renditions") public ResultEnum assertRenditionListCorrect(UploadData upData) throws Throwable { List<Throwable> throwables = new ArrayList<Throwable>(); for (JsonNode jsonRend : upData.getIosResponseJson().get("IOSRenditions")) { Rendition rend = new Rendition(jsonRend, upData.getmIngestFile().getFileInfo()); boolean match = false; for (TranscodingOptions req : renditions) { if (rend.equalsOption(req)) { mLog.info("Found Match: \n" + req + " \n" + rend); renditions.remove(req);// w w w.j a v a 2 s . com match = true; break; } } if (!match) { throwables.add(new AssertionError( "Rendition with id " + jsonRend.get("id").getLongValue() + " has no matching request.")); } } if (!renditions.isEmpty()) { throwables.add(new AssertionError( "Renditions " + renditions + " were requested and have no matching renditions.")); } MultipleFailureException.assertEmpty(throwables); return ResultEnum.PASS; }
From source file:com.baidu.qa.service.test.verify.VerifyMysqlDataImpl.java
public void verifyMysqlDataByCsvFile(File file, Config config) { FileCharsetDetector det = new FileCharsetDetector(); try {/*from ww w.java 2s . c o m*/ String oldcharset = det.guestFileEncoding(file); if (oldcharset.equalsIgnoreCase("UTF-8") == false) FileUtil.transferFile(file, oldcharset, "UTF-8"); } catch (Exception ex) { log.error("[change expect file charset error]:" + ex); } boolean isdelete = false; if (file == null) { return; } String[] name = file.getName().trim().split("\\."); String table = ""; String dbname = ""; List<String[]> datalist = FileUtil.getSplitedListFromFile(file, Constant.FILE_REGEX_DB); if (datalist == null || datalist.size() <= 1) { log.info("[no available Expect dbfile]"); return; } try { if (FileUtil.getPrefixTag(file) != null && FileUtil.getPrefixTag(file).equalsIgnoreCase("delete")) { isdelete = true; Assert.assertEquals("[get db name error]:from" + file.getName(), 4, name.length); table = name[1].trim() + "." + name[2].trim(); dbname = name[1].trim(); } else { Assert.assertEquals("[get db name error]:from" + file.getName(), 3, name.length); table = name[0].trim() + "." + name[1].trim(); dbname = name[0].trim(); } List<String> sqlList = new ArrayList<String>(); for (int i = 1; i < datalist.size(); i++) { StringBuilder sb = new StringBuilder(); sb.append("select * from "); sb.append(table); sb.append(" where "); sb.append(datalist.get(0)[0] + "="); sb.append(datalist.get(i)[0]); for (int j = 1; j < datalist.get(i).length; j++) { sb.append(" and "); sb.append(datalist.get(0)[j] + "="); sb.append(datalist.get(i)[j]); } sqlList.add(sb.toString()); log.info(sb.toString()); } if (isdelete) { JdbcUtil.excuteVerifyDeleteSqls(sqlList, dbname, config.getReplace_time()); } else { JdbcUtil.excuteVerifySqls(sqlList, dbname, config.getReplace_time()); } } catch (Exception e) { log.error("[the file " + file + " data verify fail]:", e); throw new AssertionError("the file " + file + " data verify fail: " + e.getMessage()); } }
From source file:org.fedoraproject.jenkins.plugins.copr.CoprClient.java
String doGet(String username, String url) throws CoprException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpget = new HttpGet(this.apiurl + url); try {/*from www . j av a 2 s.c om*/ httpget.setHeader("Authorization", "Basic " + Base64.encodeBase64String(String.format("%s:%s", apilogin, apitoken).getBytes("UTF-8"))); } catch (UnsupportedEncodingException e) { // here goes trouble throw new AssertionError(e); } String result; try { CloseableHttpResponse response = httpclient.execute(httpget); result = EntityUtils.toString(response.getEntity()); response.close(); httpclient.close(); } catch (IOException e) { throw new CoprException("Error while processing HTTP request", e); } return result; }
From source file:com.joyent.manta.client.crypto.AbstractMantaEncryptedObjectInputStreamTest.java
AbstractMantaEncryptedObjectInputStreamTest() { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); this.testURL = classLoader.getResource("test-data/chaucer.txt"); try {/* w w w .j a v a2 s .c om*/ testFile = Paths.get(testURL.toURI()); } catch (URISyntaxException e) { throw new AssertionError(e); } this.plaintextSize = (int) testFile.toFile().length(); try (InputStream in = this.testURL.openStream()) { this.plaintextBytes = IOUtils.readFully(in, plaintextSize); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.moilioncircle.redis.replicator.rdb.AbstractRdbParser.java
/** * read bytes 1 or 2 or 5/* ww w.j ava2 s. c o m*/ * 1. |00xxxxxx| remaining 6 bits represent the length * 2. |01xxxxxx|xxxxxxxx| the combined 14 bits represent the length * 3. |10xxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx| the remaining 6 bits are discarded.Additional 4 bytes represent the length(big endian in version6) * 4. |11xxxxxx| the remaining 6 bits are read.and then the next object is encoded in a special format.so we set isencoded = true * * @return tuple(len, isencoded) * @throws IOException when read timeout * @see #rdbLoadIntegerObject * @see #rdbLoadLzfStringObject */ protected Len rdbLoadLen() throws IOException { boolean isencoded = false; int rawByte = in.read(); int type = (rawByte & 0xc0) >> 6; int value; switch (type) { case REDIS_RDB_ENCVAL: isencoded = true; value = rawByte & 0x3f; break; case REDIS_RDB_6BITLEN: value = rawByte & 0x3f; break; case REDIS_RDB_14BITLEN: value = ((rawByte & 0x3F) << 8) | in.read(); break; case REDIS_RDB_32BITLEN: value = in.readInt(4, false); break; default: throw new AssertionError("Un-except len-type:" + type); } return new Len(value, isencoded); }
From source file:com.wwpass.wwpassauth.WwpassSecurityRealm.java
@DataBoundConstructor public WwpassSecurityRealm(String certFile, String keyFile, String name, boolean allowsSignup) { this.disableSignup = !allowsSignup; this.name = name; if (certFile != null && !certFile.isEmpty() && keyFile != null && !keyFile.isEmpty()) { this.certFile = certFile; this.keyFile = keyFile; } else {//from ww w . ja v a2s . c om if (System.getProperty("os.name").startsWith("Windows")) { this.certFile = DEFAULT_CERT_FILE_WINDOWS; this.keyFile = DEFAULT_KEY_FILE_WINDOWS; } else if (System.getProperty("os.name").startsWith("Linux")) { this.certFile = DEFAULT_CERT_FILE_LINUX; this.keyFile = DEFAULT_KEY_FILE_LINUX; } else { LOGGER.severe(Messages.WwpassSession_UnsupportedOsError()); throw new Failure(Messages.WwpassSession_AuthError()); } } if (!hasSomeUser()) { // if Hudson is newly set up with the security realm and there's no user account created yet, // insert a filter that asks the user to create one try { PluginServletFilter.addFilter(CREATE_FIRST_USER_FILTER); } catch (ServletException e) { throw new AssertionError(e); // never happen because our Filter.init is no-op } } }
From source file:facebook4j.json.DataObjectFactory.java
private DataObjectFactory() { throw new AssertionError("not intended to be instantiated."); }
From source file:com.niyo.network.NetworkUtilities.java
/** * Connects to the Voiper server, authenticates the provided username and * password./*w ww . java2 s . c o m*/ * * @param username The user's username * @param password The user's password * @param handler The hander instance from the calling UI thread. * @param context The context of the calling Activity. * @return boolean The boolean result indicating whether the user was * successfully authenticated. */ public static boolean authenticate(String username, String password, Handler handler, final Context context) { final HttpResponse resp; final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(PARAM_USERNAME, username)); params.add(new BasicNameValuePair(PARAM_PASSWORD, password)); HttpEntity entity = null; try { entity = new UrlEncodedFormEntity(params); } catch (final UnsupportedEncodingException e) { // this should never happen. throw new AssertionError(e); } final HttpPost post = new HttpPost(AUTH_URI); post.addHeader(entity.getContentType()); post.setEntity(entity); maybeCreateHttpClient(); sendResult(true, handler, context); return true; // try { // resp = mHttpClient.execute(post); // if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { // if (Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, "Successful authentication"); // } // sendResult(true, handler, context); // return true; // } else { // if (Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, "Error authenticating" + resp.getStatusLine()); // } // sendResult(false, handler, context); // return false; // } // } catch (final IOException e) { // if (Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, "IOException when getting authtoken", e); // } // sendResult(false, handler, context); // return false; // } finally { // if (Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, "getAuthtoken completing"); // } // } }
From source file:com.brightcove.com.zartan.verifier.video.CustomFieldVerifier.java
private void assertCustomFieldsMatch(UploadData upData) { JsonNode actual = upData.getHttpResponseJson().get("customFields"); if (actual.isNull()) { throwables.add(new AssertionError("The custom Field list should not be null / empty.")); }/*from ww w . jav a 2 s .c om*/ Iterator<String> i = actual.getFieldNames(); while (i.hasNext()) { String key = i.next(); JsonNode value = actual.get(key); if (!expected.keySet().contains(key)) { throwables.add(new AssertionError( "The custom field " + key + " was not expected to have a value but has value of " + value)); } if (value != null) { String expValue = expected.get(key); if (!expValue.equals(value.getTextValue())) { throwables.add(new ComparisonFailure("The custom field " + key + " has the wrong value", expValue, value.getTextValue())); } } else if (expected.get(key) != null) { throwables.add(new AssertionError("The custom field " + key + " was expected to have a value of " + expected.get(key) + " but has value of null")); } expected.remove(key); } if (!expected.isEmpty()) { throwables.add(new AssertionError("The custom fields " + expected.keySet() + " were not returned.")); } }
From source file:de.damdi.fitness.db.parser.ExerciseTagJSONParser.java
/** * Parses the JSON-String to a list of {@link ExerciseTag}s. * /*from www . j a va2 s.c om*/ * * @param jsonString The String to parse. * * @return A list of {@link ExerciseTag}s, null if an error occurs. * */ @Override public List<ExerciseTag> parse(String jsonString) { List<ExerciseTag> exerciseTagList = new ArrayList<ExerciseTag>(); JSONArray jsonArray; try { jsonArray = new JSONArray(jsonString); for (int i = 0; i < jsonArray.length(); i++) { JSONObject SportsEquipmentObject = jsonArray.getJSONObject(i); ExerciseTag exerciseTag = null; for (String locale : TAG_LOCALES) { if (SportsEquipmentObject.has(locale)) { JSONObject languageObject = SportsEquipmentObject.getJSONObject(locale); // name String name = languageObject.getString(TAG_NAME); List<String> nameList = new ArrayList<String>(); nameList.add(name); String description = null; // description if (languageObject.has(TAG_DESCRIPTION)) { //JSONObject descriptionJSONObject = languageObject.getJSONObject(TAG_DESCRIPTION); // description description = languageObject.getString(TAG_DESCRIPTION); } if (exerciseTag == null) { exerciseTag = new ExerciseTag(new Locale(locale), nameList, description); } else { exerciseTag.addNames(new Locale(locale), nameList, description); } } } // Log.d(TAG, "Finished parsing ExerciseTag: \n" + exerciseTag.toDebugString()); exerciseTagList.add(exerciseTag); } } catch (JSONException e) { Log.e(TAG, "Error during parsing JSON File.", e); return null; } if (exerciseTagList.isEmpty()) throw new AssertionError("JSON parsing failed: no ExerciseTag parsed."); return exerciseTagList; }