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:net.bluehornreader.misc.Utils.java
public static void cbAssert(boolean cond, String message) { if (!cond) {/* w w w .jav a 2 s. c o m*/ AssertionError e = new AssertionError(message); LOG.fatal("Assertion failure", e); exit("Assertion failure", 1); } }
From source file:cn.edu.zjnu.acm.judge.security.password.MessageDigestPasswordEncoder.java
private static MessageDigest getMessageDigest(String algorithmName) { try {//ww w. j a va 2 s . c o m return MessageDigest.getInstance(algorithmName); } catch (NoSuchAlgorithmException e) { throw new AssertionError(e); } }
From source file:Main.java
/** Evaluates an XPath. */ private static synchronized Object evalXPath(String expression, Object item, QName type) { if (xPath == null) xPath = XPathFactory.newInstance().newXPath(); try {/*w w w . j a v a 2s .c om*/ XPathExpression exp = xPath.compile(expression); Object node = exp.evaluate(item, XPathConstants.NODE); return (node == null) ? null : exp.evaluate(item, type); } catch (XPathExpressionException e) { throw new AssertionError("Error initializing XPath instance for '" + expression + "': " + e); } }
From source file:com.payu.ratel.proxy.BroadcastingInvocationHandler.java
private static Method getReceiveEventHandler() { try {/*from w ww .j av a 2 s . co m*/ return EVENT_RECEIVER_CLASS.getDeclaredMethod("receiveEvent", Serializable.class); } catch (NoSuchMethodException e) { throw new AssertionError(e); } }
From source file:com.anhth12.util.WeightInitUtil.java
public static INDArray initWeight(int[] shape, WeightInit initScheme, ActivationFunction act, RealDistribution dist) {/* ww w . j a v a 2 s . c o m*/ INDArray ret; switch (initScheme) { case VI: //Rand .* 2 .*r - r ret = Nd4j.rand(shape); int len = 0; for (int i = 0; i < shape.length; i++) { len += shape[i]; } double r = Math.sqrt(6) / Math.sqrt(len + 1); ret.muli(2).muli(r).subi(r); return ret; case ZERO: return Nd4j.create(shape); case SIZE: return uniformBasedOnInAndOut(shape, shape[0], shape[1]); case DISTRIBUTION: ret = Nd4j.rand(shape); for (int i = 0; i < ret.slices(); i++) { ret.putSlice(i, Nd4j.create(dist.sample(ret.columns()))); } case NORMALIZED: ret = Nd4j.rand(shape); return ret.subi(0.5).divi(shape[0]); case UNIFORM: double a = 1 / shape[0]; return Nd4j.rand(shape, -a, a, new MersenneTwister(123)); default: throw new AssertionError(initScheme.name()); } }
From source file:com.callidusrobotics.object.ItemFactory.java
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel") public static synchronized void initializeFactory(final String xmlFile) throws IOException { final XmlMarshaller xmlMarshaller = new XmlMarshaller(ItemList.class); final ItemList itemList = (ItemList) xmlMarshaller .unMarshal(IOUtils.toString(ItemFactory.class.getResourceAsStream(xmlFile))); for (final ItemData itemData : itemList.items) { if (ITEM_MAP.containsKey(itemData.getId())) { throw new AssertionError( "Encountered duplicate ItemData ID (" + itemData.getId() + ") in " + xmlFile); }/* w ww.ja v a2s .c om*/ ITEM_MAP.put(itemData.getId(), itemData); } }
From source file:com.opentable.etcd.EtcdServerRule.java
private static EtcdServerRule makeNode(EtcdConfiguration config) { Path dir;/* w ww .j av a2 s . com*/ try { dir = Files.createTempDirectory("etcd"); } catch (IOException e) { throw new AssertionError(e); } config.setDataDirectory(dir); config.setDestroyNodeOnExit(true); return new EtcdServerRule(new EtcdInstance(config)); }
From source file:com.tc.process.Exec.java
public static String getJavaExecutable() { String javaHome = System.getProperty("java.home"); if (javaHome == null) { throw new IllegalStateException("java.home system property not set"); }/* w ww.j ava 2s . c o m*/ File home = new File(javaHome); ensureDir(home); File bin = new File(home, "bin"); ensureDir(bin); File java = new File(bin, "java" + (System.getProperty("os.name").contains("win") ? ".exe" : "")); if (java.exists() && java.canRead()) { return java.getAbsolutePath(); } throw new AssertionError(java.getAbsolutePath() + " cannot be read or does not exist"); }
From source file:be.i8c.codequality.sonar.plugins.sag.webmethods.flow.sslr.FlowParser.java
public static AstNode parseFile(String filePath) { AstNode astNode;// w w w . j a v a 2 s . com File file = FileUtils.getFile(filePath); if (file == null || !file.exists()) { throw new AssertionError("The file \"" + filePath + "\" does not exist."); } astNode = P.parse(file); return astNode; }
From source file:com.zxy.commons.memcache.MemcacheFactory.java
private static MemcachedClient getObjectJava() { String servers = MemcachePropUtils.getServers(); if (StringUtils.isBlank(servers)) { throw new AssertionError("Parameter servers must not be empty."); }//from w w w . ja v a2 s . c o m MemcachedClientBuilder builder = new XMemcachedClientBuilder(servers); builder.setConnectionPoolSize(MemcachePropUtils.getConnectPoolSize()); builder.setConnectTimeout(MemcachePropUtils.getInstance().getLong("connectTimeout")); try { return builder.build(); } catch (IOException e) { throw new AssertionError(e); } }