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.googlecode.vfsjfilechooser2.utils.VFSUtils.java
private VFSUtils() { throw new AssertionError("Trying to create a VFSUtils object"); }
From source file:edu.oregonstate.eecs.mcplan.experiments.MultipleInstanceMultipleWorldGenerator.java
@Override public ExperimentalSetup<P, W> next() { if (first_) { pdir_ = new File(master_.root_directory, "p" + pidx_ + "_" + pval_.toString()); pdir_.mkdir();/*w ww . j av a2s . c o m*/ first_ = false; } if (!witr_.hasNext()) { if (pitr_.hasNext()) { pval_ = pitr_.next(); ++pidx_; pdir_ = new File(master_.root_directory, "p" + pidx_ + "_" + pval_.toString()); pdir_.mkdir(); witr_ = ws_.listIterator(); widx_ = 0; } else { throw new AssertionError("No such element"); } } final Environment env = makeEnvironment(); env.root_directory.mkdir(); ++widx_; return new ExperimentalSetup<P, W>(env, pval_, witr_.next().copy()); }
From source file:com.yoncabt.ebr.executor.sql.SQLReport.java
@Override public void exportTo(ReportRequest request, ReportOutputFormat outputFormat, EBRConnection con, ReportDefinition reportDefinition) throws ReportException, IOException { JDBCNamedParameters p = new JDBCNamedParameters(request.getReportQuery()); for (ReportParam reportParam : reportDefinition.getReportParams()) { if (reportParam.isRaw()) { ///*from w w w. j a va2s.co m*/ } else { FieldType type = reportParam.getFieldType(); switch (type) { case STRING: { String value = Convert.to(request.getReportParams().get(reportParam.getName()), String.class); p.set(reportParam.getName(), value); break; } case INTEGER: { Integer value = Convert.to(request.getReportParams().get(reportParam.getName()), Integer.class); p.set(reportParam.getName(), value); break; } case LONG: { Long value = Convert.to(request.getReportParams().get(reportParam.getName()), Long.class); p.set(reportParam.getName(), value); break; } case DOUBLE: { Double value = Convert.to(request.getReportParams().get(reportParam.getName()), Double.class); p.set(reportParam.getName(), value); break; } case DATE: { Date value = (Date) request.getReportParams().get(reportParam.getName()); p.set(reportParam.getName(), value); break; } default: throw new AssertionError( reportParam.getName() + " in tipi tannmyor :" + reportParam.getFieldType()); } } } try (PreparedStatement st = p.prepare(con); ResultSet res = st.executeQuery()) { File tempFile = File.createTempFile(request.getUuid(), ".json"); ResultSetSerializer ser = new ResultSetSerializer(res, tempFile); ser.serialize(); try (FileInputStream fis = new FileInputStream(tempFile)) { reportLogger.logReport(request, outputFormat, fis); } tempFile.delete(); } catch (SQLException ex) { throw new ReportException(ex); } }
From source file:edu.teco.smartlambda.container.docker.HttpHijackingWorkaround.java
/** * Get a output stream that can be used to write into the standard input stream of docker container's running process * * @param stream the docker container's log stream * @param uri the URI to the docker socket * * @return a writable byte channel that can be used to write into the http web-socket output stream * * @throws Exception on any docker or reflection exception *///from w ww.j a v a2s . c o m static OutputStream getOutputStream(final LogStream stream, final String uri) throws Exception { // @formatter:off final String[] fields = new String[] { "reader", "stream", "original", "input", "in", "in", "in", "eofWatcher", "wrappedEntity", "content", "in", "instream" }; final String[] containingClasses = new String[] { "com.spotify.docker.client.DefaultLogStream", LogReader.class.getName(), "org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream", EntityInputStream.class.getName(), FilterInputStream.class.getName(), FilterInputStream.class.getName(), FilterInputStream.class.getName(), EofSensorInputStream.class.getName(), HttpEntityWrapper.class.getName(), BasicHttpEntity.class.getName(), IdentityInputStream.class.getName(), SessionInputBufferImpl.class.getName() }; // @formatter:on final List<String[]> fieldClassTuples = new LinkedList<>(); for (int i = 0; i < fields.length; i++) { fieldClassTuples.add(new String[] { containingClasses[i], fields[i] }); } if (uri.startsWith("unix:")) { fieldClassTuples.add(new String[] { ChannelInputStream.class.getName(), "ch" }); } else if (uri.startsWith("https:")) { final float jvmVersion = Float.parseFloat(System.getProperty("java.specification.version")); fieldClassTuples .add(new String[] { "sun.security.ssl.AppInputStream", jvmVersion < 1.9f ? "c" : "socket" }); } else { fieldClassTuples.add(new String[] { "java.net.SocketInputStream", "socket" }); } final Object res = getInternalField(stream, fieldClassTuples); if (res instanceof WritableByteChannel) { return Channels.newOutputStream((WritableByteChannel) res); } else if (res instanceof Socket) { return ((Socket) res).getOutputStream(); } else { throw new AssertionError("Expected " + WritableByteChannel.class.getName() + " or " + Socket.class.getName() + " but found: " + res.getClass().getName()); } }
From source file:com.joyent.manta.client.crypto.MantaEncryptedObjectInputStreamTest.java
public MantaEncryptedObjectInputStreamTest() { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); this.testURL = classLoader.getResource("test-data/chaucer.txt"); try {/*from w w w .j a va2s .co m*/ 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.wickettasks.business.services.task.TestTaskService.java
@Test public void testCompleteTask() { try {//w w w . ja v a 2s .c o m Task task = this.taskService.add("adadadadad", this.taskList.getId(), this.user.getId()); this.taskService.complete(task.getId(), this.user.getId()); Task foundTask = this.taskService.findByTaskIdAndUserId(task.getId(), this.user.getId()); assertEquals(task, foundTask); assertEquals(Boolean.TRUE, foundTask.getCompleted()); assertEquals(Boolean.TRUE, task.getCompleted()); } catch (AccessRestrictionException e) { throw new AssertionError(e); } }
From source file:org.everit.osgi.webconsole.tests.GetConfigurationTest.java
public void assertContainsAll(final List<DisplayedAttribute> actual, final List<DisplayedAttribute> expected) { for (DisplayedAttribute exp : expected) { if (!actual.contains(exp)) { String exception = actual.stream().filter((act) -> act.getId().equals(exp.getId())).findFirst() .map((act) -> act + "\nis not equal to\n" + exp) .orElseGet(() -> "failed to assert that " + actual + " contains " + exp); throw new AssertionError(exception); }//from w ww . j a va 2s .com } }
From source file:org.silverpeas.components.blankApp.rest.BlankAppRESTTest.java
protected void close(Statement stmt) { if (stmt != null) { try {//from w w w.j av a2s. c om stmt.close(); } catch (SQLException ex) { throw new AssertionError(ex); } } }
From source file:org.thoughtcrime.ssl.pinning.util.PinningHelper.java
/** * Constructs an HttpsURLConnection that will validate HTTPS connections against a set of * specified pins./*from w ww. j a va 2s .c o m*/ * * @param pins An array of encoded pins to match a seen certificate * chain against. A pin is a hex-encoded hash of a X.509 certificate's * SubjectPublicKeyInfo. A pin can be generated using the provided pin.py * script: python ./tools/pin.py certificate_file.pem * */ public static HttpsURLConnection getPinnedHttpsURLConnection(Context context, String[] pins, URL url) throws IOException { try { if (!url.getProtocol().equals("https")) { throw new IllegalArgumentException("Attempt to construct pinned non-https connection!"); } TrustManager[] trustManagers = new TrustManager[1]; trustManagers[0] = new PinningTrustManager(SystemKeyStore.getInstance(context), pins, 0); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustManagers, null); HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); return urlConnection; } catch (NoSuchAlgorithmException nsae) { throw new AssertionError(nsae); } catch (KeyManagementException e) { throw new AssertionError(e); } }
From source file:com.collective.celos.FileSystemStateDatabaseTest.java
/** * Write slot states returned by getStates to file system and diff * the temporary dir against the src/test/resources one. *///from w w w .j a v a2 s .co m @Test public void canWriteToFileSystem() throws Exception { StateDatabaseConnection db = getStateDatabaseConnection(); for (SlotState state : getStates()) { db.putSlotState(state); } if (diff(getDatabaseDir(), getResourceDir())) { throw new AssertionError("Database differs from resource database."); } }