use of java.lang.RuntimeException in project camunda-bpm-platform by camunda.
the class TestConnector method execute.
public TestConnectorResponse execute(TestConnectorRequest req) {
// capture request parameters
requestParameters = req.getRequestParameters();
TestRequestInvocation testRequestInvocation = new TestRequestInvocation(null, req, requestInterceptors);
try {
testRequestInvocation.proceed();
// use response parameters
return new TestConnectorResponse(responseParameters);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of java.lang.RuntimeException in project sugar by satyan.
the class QueryBuilder method generatePlaceholders.
public static String generatePlaceholders(int numberOfArgs) {
if (numberOfArgs < 1) {
throw new RuntimeException("The number of arguments must be greater than or equal to 1.");
}
StringBuilder stringBuilder = new StringBuilder(numberOfArgs * 2 - 1);
stringBuilder.append("?");
for (int i = 1; i < numberOfArgs; i++) {
stringBuilder.append(",?");
}
return stringBuilder.toString();
}
use of java.lang.RuntimeException in project lucene-solr by apache.
the class TestWindowsFS method testOpenDeleteConcurrently.
public void testOpenDeleteConcurrently() throws IOException, Exception {
final Path dir = wrap(createTempDir());
final Path file = dir.resolve("thefile");
final CyclicBarrier barrier = new CyclicBarrier(2);
final AtomicBoolean stopped = new AtomicBoolean(false);
Thread t = new Thread() {
@Override
public void run() {
try {
barrier.await();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
while (stopped.get() == false) {
try {
if (random().nextBoolean()) {
Files.delete(file);
} else if (random().nextBoolean()) {
Files.deleteIfExists(file);
} else {
Path target = file.resolveSibling("other");
Files.move(file, target);
Files.delete(target);
}
} catch (IOException ex) {
// continue
}
}
}
};
t.start();
barrier.await();
try {
final int iters = 10 + random().nextInt(100);
for (int i = 0; i < iters; i++) {
boolean opened = false;
try (OutputStream stream = Files.newOutputStream(file)) {
opened = true;
stream.write(0);
// just create
} catch (FileNotFoundException | NoSuchFileException ex) {
assertEquals("File handle leaked - file is closed but still registered", 0, ((WindowsFS) dir.getFileSystem().provider()).openFiles.size());
assertFalse("caught FNF on close", opened);
}
assertEquals("File handle leaked - file is closed but still registered", 0, ((WindowsFS) dir.getFileSystem().provider()).openFiles.size());
Files.deleteIfExists(file);
}
} finally {
stopped.set(true);
t.join();
}
}
use of java.lang.RuntimeException in project jdk8u_jdk by JetBrains.
the class CipherInputStreamExceptions method cbc_shortStream.
/* Check that close() does not throw an exception with full message in
* CipherInputStream's ibuffer.
* This test:
* 1) Encrypts a 97 byte message with AES/CBC/PKCS5Padding
* 2) Create a stream that sends 96 bytes.
* 3) Read stream once,
* 4) Close and expect no exception
*/
static void cbc_shortStream() throws Exception {
Cipher c;
AlgorithmParameters params;
byte[] read = new byte[200];
System.out.println("Running cbc_shortStream");
// Encrypt 97 byte with AES/CBC/PKCS5Padding
byte[] ct = encryptedText("CBC", 97);
// Create stream with only 96 bytes of encrypted data
CipherInputStream in = getStream("CBC", ct, 96);
try {
int size = in.read(read);
in.close();
if (size != 80) {
throw new RuntimeException("Fail: CipherInputStream.read() " + "returned " + size + ". Should have been 80");
}
System.out.println(" Pass.");
} catch (IOException e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
use of java.lang.RuntimeException in project jdk8u_jdk by JetBrains.
the class CipherInputStreamExceptions method cbc_readAllIllegalBlockSize.
/* Check that exception is thrown when message is fully read
* This test:
* 1) Encrypts a 96 byte message with AES/CBC/PKCS5Padding
* 2) Create a stream that sends 95 bytes.
* 3) Read stream to the end
* 4) Expect IllegalBlockSizeException thrown
*/
static void cbc_readAllIllegalBlockSize() throws Exception {
byte[] read = new byte[200];
System.out.println("Running cbc_readAllIllegalBlockSize test");
// Encrypt 96 byte with AES/CBC/PKCS5Padding
byte[] ct = encryptedText("CBC", 96);
// Create a stream with only 95 bytes of encrypted data
CipherInputStream in = getStream("CBC", ct, 95);
try {
int s, size = 0;
while ((s = in.read(read)) != -1) {
size += s;
}
throw new RuntimeException("Fail: No IllegalBlockSizeException. " + "CipherInputStream.read() returned " + size);
} catch (IOException e) {
Throwable ec = e.getCause();
if (ec instanceof IllegalBlockSizeException) {
System.out.println(" Pass.");
} else {
System.out.println(" Fail: " + ec.getMessage());
throw new RuntimeException(ec);
}
}
}
Aggregations