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:AIR.Common.Web.HttpWebHelperTest.java
@Test public void SendXmlTest() throws IOException, InterruptedException, XMLStreamException { MockData data = new MockData("This is a test"); IdiotServer server = new IdiotServer(8888); server.start();/*from w ww . j a va2 s . c o m*/ _httpWebHelper.sendXml("http://localhost:8888/", data); server.join(1000); if (server.isAlive()) { server.interrupt(); throw new AssertionError("Server did not receive request"); } assertTrue(server.isSucceeded()); assertNull(server.getError()); String response = server.getResponse(); _logger.info(response); ByteArrayOutputStream databytes = new ByteArrayOutputStream(); XMLOutputFactory factory = TdsXmlOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(databytes); data.writeXML(writer); assertEquals(response, databytes.toString()); assertTrue(server.getHeaders().get(0).startsWith("POST")); boolean foundContentType = false; for (String header : server.getHeaders()) { _logger.info(header); if (header.equals("Content-Type: text/xml")) { foundContentType = true; } } assertTrue(foundContentType); }
From source file:net.lmxm.ute.utils.HttpUtils.java
/** * Prevent instantiation. */ private HttpUtils() { throw new AssertionError("Cannot be instantiated"); }
From source file:es.udc.gii.common.eaf.stoptest.WallTimeStopTest.java
@Override public void configure(Configuration conf) { this.maxWallTime = conf.getLong("MaxWallTime"); if (this.maxWallTime < 0) { throw new AssertionError("Maximum wall time must greather than cero."); }/*from w w w. ja v a 2 s . co m*/ }
From source file:de.tud.kom.p2psim.impl.network.modular.st.ploss.PingErPacketLoss.java
@Override public boolean shallDrop(ModularNetMessage msg, ModularNetLayer nlSender, ModularNetLayer nlReceiver, NetMeasurementDB db) {/*from ww w . j a v a 2s .c om*/ if (db == null) throw new IllegalArgumentException("The PingER packet loss strategy can not access any network " + "measurement database. You may not have loaded it in the config file."); SummaryRelation sumRel = db.getMostAccurateSummaryRelation(nlSender.getDBHostMeta(), nlReceiver.getDBHostMeta()); if (sumRel == null) throw new AssertionError("No summary relation could be found for " + nlSender + " - " + nlReceiver); // If the message consists of multiple fragments, the loss probability // will be the probability that all fragments have arrived, and // every fragment itself has the probability of "sumRel.getpLoss()" to // be dropped double prob = 1d - Math.pow(1d - sumRel.getpLoss() * 0.01, msg.getNoOfFragments()); log.debug("Dropping with probability " + prob + ", fragments " + msg.getNoOfFragments()); return rand.nextDouble() < prob; }
From source file:bi.meteorite.pages.SaikuTable.java
public WebElement findFirstRowWhere(final BeanMatcher... matchers) { List<WebElement> rows = getRowElementsWhere(matchers); if (rows.isEmpty()) { throw new AssertionError( "Expecting a table with at least one row where: " + Arrays.deepToString(matchers)); }//from ww w. j a va 2 s. com return rows.get(0); }
From source file:com.feilong.servlet.http.ResponseDownloadUtil.java
/** Don't let anyone instantiate this class. */ private ResponseDownloadUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:org.stem.ClusterManagerDaemon.java
public static Config loadConfig() { URL url = getConfigUrl();/*from w w w . j a v a2 s .co m*/ logger.info("Loading settings from " + url); InputStream stream; try { stream = url.openStream(); } catch (IOException e) { throw new AssertionError(e); } Constructor constructor = new Constructor(Config.class); Yaml yaml = new Yaml(constructor); config = (Config) yaml.load(stream); return config; }
From source file:com.wormsim.animals.AnimalZoo2Instance.java
public AnimalStage2Instance getAnimalStage(String key) { if (!this.stages.containsKey(key)) { System.out.println("Input: " + key); stages.forEach((k, v) -> {/*from w ww . j ava 2s . c o m*/ System.out.println(k); }); throw new AssertionError("Should match!"); } return this.stages.get(key); }
From source file:com.feilong.commons.core.lang.reflect.FieldUtil.java
/** Don't let anyone instantiate this class. */ private FieldUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:com.squarespace.template.TestCaseParser.java
/** * Parses a source file into a valid test case instance. *///from w ww . j a v a 2 s . com public TestCase parseTest(String source) { Map<String, String> sections = parseSections(source); String json = sections.get(TYPE_JSON); String template = sections.get(TYPE_TEMPLATE); String partials = sections.get(TYPE_PARTIALS); if (sections.containsKey(TYPE_OUTPUT)) { return new OutputTestCase(json, template, partials, sections.get(TYPE_OUTPUT)); } else if (sections.containsKey(TYPE_ERROR)) { // TBD: return new ErrorCase(json, template, sections.get(TYPE_ERROR)); } throw new AssertionError("Expected one of: " + TYPE_ERROR + ", " + TYPE_OUTPUT); }