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:clear.cdb.support.test.AnnotationProcessorTestCompiler.java
/** * Avoid instantiation. */ private AnnotationProcessorTestCompiler() { throw new AssertionError("Not instantiable."); }
From source file:com.google.code.simplestuff.bean.BusinessObjectContext.java
/** * Private so that this class cannot be instantiated. *///from w w w. j a v a2 s . co m private BusinessObjectContext() { throw new AssertionError("Don't instantiate me."); }
From source file:com.gatf.executor.dataprovider.MongoDBTestDataSource.java
public void init() { if (args == null || args.length == 0) { throw new AssertionError("No arguments passed to the MongoDBTestDataProvider"); }//w ww .j ava 2 s . c om if (args.length < 3) { throw new AssertionError("The arguments, namely mongodb-host, mongodb-port, mongodb-database are " + " mandatory for MongoDBTestDataProvider"); } Assert.assertNotNull("mongodb-host cannot be empty", args[0]); Assert.assertNotNull("mongodb-port cannot be empty", args[1]); Assert.assertNotNull("mongodb-database cannot be empty", args[2]); String host = args[0].trim(); String port = args[1].trim(); String dbName = args[2].trim(); Assert.assertFalse("mongodb-host cannot be empty", host.isEmpty()); Assert.assertFalse("mongodb-port cannot be empty", port.isEmpty()); Assert.assertFalse("mongodb-database cannot be empty", dbName.isEmpty()); String username = null, password = ""; if (args.length > 3) { Assert.assertNotNull("mongodb-user cannot be empty", args[3]); Assert.assertFalse("mongodb-user cannot be empty", args[3].isEmpty()); username = args[3].trim(); if (args.length > 4 && args[4] != null) password = args[4].trim(); } StringBuilder build = new StringBuilder(); build.append("MongoDBTestDataSource configuration [\n"); build.append(String.format("mongodb-host is %s\n", host)); build.append(String.format("mongodb-port is %s\n", port)); build.append(String.format("mongodb-database is %s\n", dbName)); if (username != null) { build.append(String.format("mongodb-user is %s\n", username)); build.append(String.format("mongodb-password is %s\n", password)); } logger.info(build.toString()); try { String[] hosts = host.split(","); String[] ports = port.split(","); if (hosts.length > ports.length) { Assert.assertEquals(String.format("Port missing for host %s", hosts[ports.length - 1]), hosts.length, ports.length); } else { Assert.assertEquals(String.format("Host missing for port %s", ports[hosts.length - 1]), hosts.length, ports.length); } for (String portVal : ports) { try { Integer.valueOf(portVal); } catch (Exception e) { throw new AssertionError(String.format("Port value invalid - %s", portVal)); } } for (int i = 0; i < hosts.length; i++) { ServerAddress address = new ServerAddress(hosts[i], Integer.valueOf(ports[i])); addresses.add(address); } for (int i = 0; i < poolSize; i++) { MongoClient mongoClient = null; //Now try connecting to the Database try { mongoClient = new MongoClient(addresses); } catch (Exception e) { throw new AssertionError(String.format("Connection to MongoDB failed with the error %s", ExceptionUtils.getStackTrace(e))); } DB db = null; try { db = mongoClient.getDB(dbName); if (username != null && password != null) { Assert.assertTrue(String.format("Authentication to the Mongo database %s failed with %s/%s", dbName, username, password), db.authenticate(username, password.toCharArray())); } } catch (Exception e) { throw new AssertionError(String.format("Error during initialization of MongoDB connection %s", ExceptionUtils.getStackTrace(e))); } addToPool(mongoClient, false); } } catch (Exception e) { throw new AssertionError(String.format("Error during initialization of MongoDB connection %s", ExceptionUtils.getStackTrace(e))); } finally { } }
From source file:edu.stanford.junction.provider.irc.JunctionProvider.java
@Override public URI generateSessionUri() { try {/*from ww w. j a va 2s . c o m*/ String sessionName = UUID.randomUUID().toString(); return new URI("junction://sb/" + sessionName + "#irc"); } catch (URISyntaxException e) { throw new AssertionError("Invalid URI"); } }
From source file:gmc.hotplate.logic.LocalDataManager.java
@Override public List<Recipe> getRecipes(int offset, int limit) { throw new AssertionError("Not implemented yet!"); }
From source file:com.discovery.darchrow.io.SerializableUtil.java
/** Don't let anyone instantiate this class. */ private SerializableUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:com.mgmtp.perfload.core.client.util.concurrent.DelayingExecutorServiceTest.java
@Test public void testWithoutDelay() throws InterruptedException, BrokenBarrierException { DelayingExecutorService execSrv = new DelayingExecutorService(); final StopWatch sw = new StopWatch(); final CyclicBarrier stopBarrier = new CyclicBarrier(11, new Runnable() { @Override/*from w ww. ja v a2 s .c om*/ public void run() { sw.stop(); } }); sw.start(); for (int i = 0; i < 10; ++i) { Runnable r = new Runnable() { @Override public void run() { try { Thread.sleep(1L); stopBarrier.await(); } catch (Exception ex) { throw new AssertionError(ex); } } }; ScheduledFuture<?> future = execSrv.schedule(r, 0L, TimeUnit.NANOSECONDS); // compare with epsilon to make up for bad accuracy assertTrue(abs(future.getDelay(TimeUnit.MILLISECONDS)) < EPSILON); } stopBarrier.await(); assertTrue(sw.getTime() < EPSILON); }
From source file:de.fau.cs.osr.hddiff.tree.DiffNode.java
public final void setOverride(DiffNode partner, int common) { if (!isSameNodeType(partner)) throw new AssertionError("!isSameNodeType(partner): " + String.valueOf(this.getType()) + " vs. " + String.valueOf(partner.getType())); this.partner = partner; this.common = common; }
From source file:com.feilong.core.text.DateFormatUtilTemp.java
/** Don't let anyone instantiate this class. */ private DateFormatUtilTemp() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:com.pinterest.jbender.JBenderHttpBenchmark.java
@Benchmark public Histogram loadtestHttpThroughput() throws SuspendExecution, InterruptedException, ExecutionException, IOException { final IntervalGenerator intervalGenerator = new ConstantIntervalGenerator(10000000); try (final FiberApacheHttpClientRequestExecutor requestExecutor = new FiberApacheHttpClientRequestExecutor<>( (res) -> {/*from ww w .jav a 2 s.co m*/ if (res == null) { throw new AssertionError("Response is null"); } final int status = res.getStatusLine().getStatusCode(); if (status != 200) { throw new AssertionError("Status is " + status); } }, 1000000)) { final Channel<HttpGet> requestCh = Channels.newChannel(1000); final Channel<TimingEvent<CloseableHttpResponse>> eventCh = Channels.newChannel(1000); // Requests generator new Fiber<Void>("req-gen", () -> { // Bench handling 1k reqs for (int i = 0; i < 1000; ++i) { requestCh.send(new HttpGet("http://localhost:8080/hello-world")); } requestCh.close(); }).start(); final Histogram histogram = new Histogram(3600000000L, 3); // Event recording, both HistHDR and logging record(eventCh, new HdrHistogramRecorder(histogram, 1000000)); // Main new Fiber<Void>("jbender", () -> { JBender.loadTestThroughput(intervalGenerator, 0, requestCh, requestExecutor, eventCh); eventCh.close(); }).start().join(); // Avoid code elimination return histogram; } }