List of usage examples for junit.framework AssertionFailedError printStackTrace
public void printStackTrace()
From source file:org.apache.hadoop.dfs.ClusterTestDFSNamespaceLogging.java
private void testFsPseudoDistributed(int datanodeNum) throws Exception { try {/*from w w w .j a v a 2 s . co m*/ prepareTempFileSpace(); configureDFS(); startDFS(datanodeNum); if (logfh == null) try { logfh = new BufferedReader(new FileReader(logFile)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block throw new AssertionFailedError("Log file does not exist: " + logFile); } // create a directory try { assertTrue(dfsClient.mkdirs("/data")); assertMkdirs("/data", false); } catch (IOException ioe) { ioe.printStackTrace(); } try { assertTrue(dfsClient.mkdirs("data")); assertMkdirs("data", true); } catch (IOException ioe) { ioe.printStackTrace(); } // // create a file with 1 data block try { createFile("/data/xx", 1); assertCreate("/data/xx", 1, false); } catch (IOException ioe) { assertCreate("/data/xx", 1, true); } // create a file with 2 data blocks try { createFile("/data/yy", BLOCK_SIZE + 1); assertCreate("/data/yy", BLOCK_SIZE + 1, false); } catch (IOException ioe) { assertCreate("/data/yy", BLOCK_SIZE + 1, true); } // create an existing file try { createFile("/data/xx", 2); assertCreate("/data/xx", 2, false); } catch (IOException ioe) { assertCreate("/data/xx", 2, true); } // delete the file try { dfsClient.delete("/data/yy", true); assertDelete("/data/yy", false); } catch (IOException ioe) { ioe.printStackTrace(); } // rename the file try { dfsClient.rename("/data/xx", "/data/yy"); assertRename("/data/xx", "/data/yy", false); } catch (IOException ioe) { ioe.printStackTrace(); } try { dfsClient.delete("/data/xx", true); assertDelete("/data/xx", true); } catch (IOException ioe) { ioe.printStackTrace(); } try { dfsClient.rename("/data/xx", "/data/yy"); assertRename("/data/xx", "/data/yy", true); } catch (IOException ioe) { ioe.printStackTrace(); } } catch (AssertionFailedError afe) { afe.printStackTrace(); throw afe; } catch (Throwable t) { msg("Unexpected exception_a: " + t); t.printStackTrace(); } finally { shutdownDFS(); } }
From source file:org.iavante.sling.initialconfig.services.impl.JCROperations.java
/** * Check if the user already exists. If doesn't, tries to create it with a * generated password. If error, throws IOException. * //from w ww . ja va 2 s . com * @param user * @throws IOException */ private void createUserInJCR(String user) throws IOException { if (log.isInfoEnabled()) log.info("createUserInJCR, ini"); boolean createUser = false; Credentials creds = new UsernamePasswordCredentials(adminUser, adminPasswd); String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + user + ".html"; Node slingConf = null; try { if (log.isInfoEnabled()) log.info("rootNode=" + rootNode); slingConf = rootNode.getNode("content/config/sling"); if (log.isInfoEnabled()) log.info("slingConf=" + slingConf.getPath()); } catch (PathNotFoundException e2) { e2.printStackTrace(); } catch (RepositoryException e2) { e2.printStackTrace(); } try { // Checking if user already exists assertAuthenticatedHttpStatus(creds, postUrl, HttpServletResponse.SC_OK, null); if (log.isInfoEnabled()) log.info("createUserInJCR, " + user + " already exists"); //if 'gaduser' property doesn't exits in '/content/config/sling' node, then // generate a new password if (!slingConf.hasProperty("gaduser")) { if (log.isInfoEnabled()) log.info("createUserInJCR, " + user + " already exists, but prop '" + user + "' doesn't exits in " + slingConf.getPath()); //In order to update pwd, we need to delete and create 'gaduser' postUrl = HTTP_BASE_URL + "/system/userManager/user/" + user + ".delete.html"; List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new NameValuePair("go", "" + 1)); assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); if (log.isInfoEnabled()) log.info("createUserInJCR, user deleted: " + user); createUser = true; } } catch (AssertionFailedError e) { // Not exists, needs to create the user createUser = true; } catch (RepositoryException e) { e.printStackTrace(); } if (createUser) { postUrl = HTTP_BASE_URL + "/system/userManager/user.create.html"; String pwd = generatePassword(10); List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new NameValuePair(":name", user)); postParams.add(new NameValuePair("pwd", pwd)); postParams.add(new NameValuePair("pwdConfirm", pwd)); assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); if (log.isInfoEnabled()) log.info("createUserInJCR, user created " + user + ":" + pwd); // Setting gaduser and gaduserpwd in /content/config/sling node try { if (log.isInfoEnabled()) log.info("saving..."); slingConf.setProperty("gad_user", user); slingConf.setProperty("gad_pass", pwd); slingConf.save(); if (log.isInfoEnabled()) log.info("saved"); } catch (PathNotFoundException e1) { e1.printStackTrace(); } catch (RepositoryException e1) { e1.printStackTrace(); } } if (log.isInfoEnabled()) log.info("createUserInJCR, end"); }
From source file:org.jitsi.meet.test.FailureListener.java
/** * Creates a screenshot named by the class and name of the failure. * @param test the test//w w w . jav a 2s.com * @param t the assertion error */ @Override public void addFailure(Test test, AssertionFailedError t) { if (t != null) { System.err.println("Failure:"); t.printStackTrace(); } try { String fileNamePrefix = JUnitVersionHelper.getTestCaseClassName(test) + "." + JUnitVersionHelper.getTestCaseName(test); takeScreenshots(test); saveHtmlSources(test); saveMeetDebugLog(fileNamePrefix); saveBrowserLogs(fileNamePrefix); saveThreadDump(fileNamePrefix); } catch (Throwable ex) { ex.printStackTrace(); } super.addFailure(test, t); }