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.laxser.blitz.lama.core.LamaOperationFactoryImpl.java
@Override public LamaOperation getOperation(DataAccess dataAccess, Modifier modifier) { // Annotation SQL sql = modifier.getAnnotation(SQL.class); Assert.notNull(sql, "@SQL is required for method " + modifier); String sqlString = sql.value(); SQLType sqlType = sql.type(); if (sqlType == SQLType.AUTO_DETECT) { for (int i = 0; i < SELECT_PATTERNS.length; i++) { // ?? SELECT ? if (SELECT_PATTERNS[i].matcher(sqlString).find()) { sqlType = SQLType.READ; break; }/*from w w w .ja v a 2 s. com*/ } if (sqlType == SQLType.AUTO_DETECT) { sqlType = SQLType.WRITE; } } // if (SQLType.READ == sqlType) { // RowMapper RowMapper rowMapper = rowMapperFactory.getRowMapper(modifier); // SELECT return new SelectOperation(dataAccess, sqlString, modifier, rowMapper); } else if (SQLType.WRITE == sqlType) { // INSERT / UPDATE / DELETE return new UpdateOperation(dataAccess, sqlString, modifier); } // throw new AssertionError("Unknown SQL type: " + sqlType); }
From source file:org.brutusin.json.impl.JacksonSchema.java
@Override public final void validate(JsonNode node) throws ValidationException { if (node instanceof LazyJsonNode) { validate(((LazyJsonNode) node).getJsonNode()); return;//from w ww . java 2 s .c o m } if (!(node instanceof JacksonNode)) { try { node = JsonCodec.getInstance().parse(node.toString()); } catch (ParseException ex) { throw new AssertionError(ex); } } JacksonNode nodeImpl = (JacksonNode) node; ProcessingReport report = null; try { report = getValidator().validate(nodeImpl.getNode()); } catch (ProcessingException ex) { ex.printStackTrace(); List<String> messages = new ArrayList(); messages.add(ex.getProcessingMessage().getMessage()); throw new ValidationException(messages); } if (!report.isSuccess()) { Iterator<ProcessingMessage> iterator = report.iterator(); List<String> messages = new ArrayList(); while (iterator.hasNext()) { ProcessingMessage processingMessage = iterator.next(); messages.add(processingMessage.getMessage()); } throw new ValidationException(messages); } }
From source file:com.datatorrent.stram.FSRecoveryHandler.java
@Override public DataOutputStream rotateLog() throws IOException { if (fs.exists(logBackupPath)) { // log backup is purged on snapshot/restore throw new AssertionError("Snapshot state prior to log rotation: " + logBackupPath); }// w w w . j ava 2 s. c o m if (fs.exists(logPath)) { LOG.debug("Creating log backup {}", logBackupPath); if (!fs.rename(logPath, logBackupPath)) { throw new IOException("Failed to rotate log: " + logPath); } } LOG.info("Creating {}", logPath); final FSDataOutputStream fsOutputStream; String scheme = null; try { scheme = fs.getScheme(); } catch (UnsupportedOperationException e) { LOG.warn("{} doesn't implement getScheme() method", fs.getClass().getName()); } if ("file".equals(scheme)) { // local FS does not support hflush and does not flush native stream FSUtil.mkdirs(fs, logPath.getParent()); fsOutputStream = new FSDataOutputStream( new FileOutputStream(Path.getPathWithoutSchemeAndAuthority(logPath).toString()), null); } else { fsOutputStream = fs.create(logPath); } DataOutputStream osWrapper = new DataOutputStream(fsOutputStream) { @Override public void flush() throws IOException { super.flush(); fsOutputStream.hflush(); } @Override public void close() throws IOException { LOG.debug("Closing {}", logPath); super.close(); } }; return osWrapper; }
From source file:jp.co.nemuzuka.core.controller.JsonController.java
/** * ?./* ww w. j a v a2 s . c om*/ * ?commit??ThreadLocal???? * @see org.slim3.controller.Controller#run() */ @Override protected Navigation run() throws Exception { //????????????? String setUpError = requestScope(SETUP_ERROR); if (StringUtils.isNotEmpty(setUpError)) { return null; } Object obj = null; try { obj = execute(); if (obj == null) { throw new AssertionError("execute() must not be null."); } executeCommit(); } catch (ConcurrentModificationException e) { //????????Json???? super.tearDown(); JsonResult result = new JsonResult(); result.setStatus(JsonResult.VERSION_ERR); result.getErrorMsg().add(ApplicationMessage.get("errors.version")); obj = result; } catch (AlreadyExistKeyException e) { //?????????Json???? super.tearDown(); JsonResult result = new JsonResult(); result.setStatus(JsonResult.DUPLICATE_ERR); result.getErrorMsg().add(ApplicationMessage.get("errors.duplicate")); obj = result; } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); throw e; } return writeJsonObj(obj); }
From source file:mulavito.gui.control.CountingPickedState.java
@Override public void clear() { List<T> unpicks = new ArrayList<T>(picked); for (T v : unpicks) pick(v, false);/*from www .ja v a2 s .co m*/ if (!picked.isEmpty()) throw new AssertionError("BUG"); }
From source file:edu.rit.csh.androidwebnews.WebnewsHttpClient.java
/** * Makes the SSL cert work correctly./*from ww w . j a va2 s. com*/ * * @return SSLSocketFactory - provides the SSLFactory for communicating * with the scheme */ private SSLSocketFactory newSslSocketFactory() { try { // Get an instance of the Bouncy Castle KeyStore format KeyStore trusted = KeyStore.getInstance(KeyStore.getDefaultType()); trusted.load(null, null); // Pass the keystore to the SSLSocketFactory. The factory is responsible // for the verification of the server certificate. SSLSocketFactory sf = new WebnewsSocketFactory(trusted); // Hostname verification from certificate // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506 sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); return sf; } catch (Exception e) { throw new AssertionError(e); } }
From source file:io.neba.spring.web.WebApplicationContextAdapterTest.java
private Object[] mockArgs(Method method) { return stream(method.getParameterTypes()).map(type -> { if (!type.isPrimitive()) { return null; }/*from w w w .j a v a 2 s . c o m*/ if (type == boolean.class) { return false; } throw new AssertionError("Unable to mock type " + type + "."); }).toArray(); }
From source file:com.discovery.darchrow.tools.jsonlib.JsonUtil.java
/** Don't let anyone instantiate this class. */ private JsonUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:general.Main.java
/** * Since this is a utility class, it should not be instantiated. *///from www. ja v a 2 s. c om private Main() { throw new AssertionError("Instantiating utility class Main"); }