List of usage examples for junit.framework AssertionFailedError AssertionFailedError
public AssertionFailedError(String message)
From source file:org.apache.hadoop.hbase.client.TestMetaMigrationRemovingHTD.java
public static void assertEquals(boolean expected, boolean actual) { if (expected != actual) { throw new AssertionFailedError("expected:<" + expected + "> but was:<" + actual + ">"); }/*from w w w .java 2 s . c om*/ }
From source file:org.apache.hadoop.hbase.HBaseTestCase.java
public static void assertByteEquals(byte[] expected, byte[] actual) { if (Bytes.compareTo(expected, actual) != 0) { throw new AssertionFailedError( "expected:<" + Bytes.toString(expected) + "> but was:<" + Bytes.toString(actual) + ">"); }//w ww. j a v a 2 s . c om }
From source file:org.apache.hadoop.hbase.HBaseTestCase.java
public static void assertEquals(byte[] expected, byte[] actual) { if (Bytes.compareTo(expected, actual) != 0) { throw new AssertionFailedError("expected:<" + Bytes.toStringBinary(expected) + "> but was:<" + Bytes.toStringBinary(actual) + ">"); }// www.ja v a 2s. c o m }
From source file:org.apache.hama.HamaTestCase.java
public void assertByteEquals(byte[] expected, byte[] actual) { if (Bytes.compareTo(expected, actual) != 0) { throw new AssertionFailedError( "expected:<" + Bytes.toString(expected) + "> but was:<" + Bytes.toString(actual) + ">"); }//from w ww . ja v a 2s.c om }
From source file:org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad.java
private void assertTimeout(long cutoff) throws AssertionFailedError { if (System.currentTimeMillis() > cutoff) { throw new AssertionFailedError( "Sling launchpad did not start within " + MAX_WAIT_TIME_MS + " milliseconds"); }/*w w w . j ava2 s. c o m*/ }
From source file:org.auraframework.test.util.WebDriverTestCase.java
/** * Gather up useful info to add to a test failure. try to get * <ul>// w w w .j av a 2s .c o m * <li>any client js errors</li> * <li>last known js test function</li> * <li>running/waiting</li> * <li>a screenshot</li> * </ul> * * @param originalErr the test failure * @throws Throwable a new AssertionFailedError or UnexpectedError with the original and additional info */ private Throwable addAuraInfoToTestFailure(Throwable originalErr) { StringBuffer description = new StringBuffer(); if (originalErr != null) { String msg = originalErr.getMessage(); if (msg != null) { description.append(msg); } } description.append(String.format("\nBrowser: %s", currentBrowserType)); if (auraUITestingUtil != null) { description.append("\nUser-Agent: " + auraUITestingUtil.getUserAgent()); } if (currentDriver == null) { description.append("\nTest failed before WebDriver was initialized"); } else { if (this instanceof PerfExecutorTest) { JSONArray json = this.getLastCollectedMetrics(); description.append("\nPerfMetrics: " + json + ';'); } description.append("\nWebDriver: " + currentDriver); description.append("\nJS state: "); try { String dump = (String) auraUITestingUtil .getRawEval("return (window.$A && $A.test && $A.test.getDump())||'';"); if (dump.isEmpty()) { description.append("no errors detected"); } else { description.append(dump); } } catch (Throwable t) { description.append(t.getMessage()); } String screenshotsDirectory = System.getProperty("screenshots.directory"); if (screenshotsDirectory != null) { String img = getBase64EncodedScreenshot(originalErr, true); if (img == null) { description.append("\nScreenshot: {not available}"); } else { String fileName = getClass().getName() + "." + getName() + "_" + currentBrowserType + ".png"; File path = new File(screenshotsDirectory + "/" + fileName); try { path.getParentFile().mkdirs(); byte[] bytes = Base64.decodeBase64(img.getBytes()); FileOutputStream fos = new FileOutputStream(path); fos.write(bytes); fos.close(); String baseUrl = System.getProperty("screenshots.baseurl"); description.append(String.format("%nScreenshot: %s/%s", baseUrl, fileName)); } catch (Throwable t) { description.append(String.format("%nScreenshot: {save error: %s}", t.getMessage())); } } } try { description.append("\nApplication cache status: "); description.append(auraUITestingUtil.getRawEval( "var cache=window.applicationCache;return (cache===undefined || cache===null)?'undefined':cache.status;") .toString()); } catch (Exception ex) { description.append("error calculating status: " + ex); } description.append("\n"); if (SauceUtil.areTestsRunningOnSauce()) { String linkToJob = SauceUtil.getLinkToPublicJobInSauce(currentDriver); description.append("\nSauceLabs-recording: "); description.append((linkToJob != null) ? linkToJob : "{not available}"); } } // replace original exception with new exception with additional info Throwable newFailure; if (originalErr instanceof AssertionFailedError) { newFailure = new AssertionFailedError(description.toString()); } else { description.insert(0, originalErr.getClass() + ": "); newFailure = new UnexpectedError(description.toString(), originalErr.getCause()); } newFailure.setStackTrace(originalErr.getStackTrace()); return newFailure; }
From source file:org.auraframework.test.WebDriverTestCase.java
/** * Gather up useful info to add to a test failure. try to get * <ul>//w w w . ja va 2 s. c o m * <li>any client js errors</li> * <li>last known js test function</li> * <li>running/waiting</li> * <li>a screenshot</li> * </ul> * * @param originalErr the test failure * @throws Throwable a new AssertionFailedError or UnexpectedError with the original and additional info */ private Throwable addAuraInfoToTestFailure(Throwable originalErr) { StringBuffer description = new StringBuffer(); if (originalErr != null) { String msg = originalErr.getMessage(); if (msg != null) { description.append(msg); } } description.append(String.format("\nBrowser: %s", currentBrowserType)); if (auraUITestingUtil != null) { description.append("\nUser-Agent: " + auraUITestingUtil.getUserAgent()); } if (currentDriver == null) { description.append("\nTest failed before WebDriver was initialized"); } else { description.append("\nWebDriver: " + currentDriver); description.append("\nJS state: "); try { String dump = (String) auraUITestingUtil .getRawEval("return (window.$A && $A.test && $A.test.getDump())||'';"); if (dump.isEmpty()) { description.append("no errors detected"); } else { description.append(dump); } } catch (Throwable t) { description.append(t.getMessage()); } String screenshotsDirectory = System.getProperty("screenshots.directory"); if (screenshotsDirectory != null) { String img = getBase64EncodedScreenshot(originalErr, true); if (img == null) { description.append("\nScreenshot: {not available}"); } else { String fileName = getClass().getName() + "." + getName() + "_" + currentBrowserType + ".png"; File path = new File(screenshotsDirectory + "/" + fileName); try { path.getParentFile().mkdirs(); byte[] bytes = Base64.decodeBase64(img.getBytes()); FileOutputStream fos = new FileOutputStream(path); fos.write(bytes); fos.close(); String baseUrl = System.getProperty("screenshots.baseurl"); description.append(String.format("%nScreenshot: %s/%s", baseUrl, fileName)); } catch (Throwable t) { description.append(String.format("%nScreenshot: {save error: %s}", t.getMessage())); } } } try { description.append("\nApplication cache status: "); description.append(auraUITestingUtil.getRawEval( "var cache=window.applicationCache;return (cache===undefined || cache===null)?'undefined':cache.status;") .toString()); } catch (Exception ex) { description.append("error calculating status: " + ex); } description.append("\n"); if (SauceUtil.areTestsRunningOnSauce()) { String linkToJob = SauceUtil.getLinkToPublicJobInSauce(currentDriver); description.append("\nSauceLabs-recording: "); description.append((linkToJob != null) ? linkToJob : "{not available}"); } } // replace original exception with new exception with additional info Throwable newFailure; if (originalErr instanceof AssertionFailedError) { newFailure = new AssertionFailedError(description.toString()); } else { description.insert(0, originalErr.getClass() + ": "); newFailure = new UnexpectedError(description.toString(), originalErr.getCause()); } newFailure.setStackTrace(originalErr.getStackTrace()); return newFailure; }
From source file:org.cellprofiler.subimager.TestImageJHandlerBase.java
protected static Parameter getParameterByName(RunModuleResponse rmr, String name) { for (Parameter p : rmr.getRunModuleResponseTypeSequence().getParameter()) { if (p.getName().equals(name)) { return p; }//from w ww. j a v a2s.c o m } throw new AssertionFailedError(String.format("Could not find parameter, \"%s\".", name)); }
From source file:org.csc.phynixx.connection.PooledManagedConnectionIntegrationScenariosIT.java
public void testRecovery() throws Exception { ITestConnection con = factory.getConnection(); con.setInitialCounter(43);//from w ww . j a va 2 s . c om // expection when act is called the 3rd time con.setInterruptFlag(TestInterruptionPoint.ACT, 3); con.act(6); con.act(-3); try { con.act(7); throw new AssertionFailedError("ActionInterrupted expected"); } catch (Exception e) { } // increments are performed during commit -- act(7) is not registered in con Assert.assertEquals(46, con.getCounter()); // connection is not closed ... // close the factory and leave the connection in a recoverable state // rollback the connection .... factory.close(); // instanciate a new connection pool TestConnectionStatusManager.clear(); PhynixxRecovery<ITestConnection> recovery = new PhynixxRecovery<ITestConnection>( new TestConnectionFactory()); IPhynixxLoggerSystemStrategy<ITestConnection> loggerStrategy = factory.getLoggerSystemStrategy(); loggerStrategy.close(); recovery.setLoggerSystemStrategy(loggerStrategy); recovery.addConnectionProxyDecorator(new TestConnectionStatusListener()); recovery.recover(null); LOG.info(TestConnectionStatusManager.toDebugString()); Set<TestStatusStack> statusStacks = TestConnectionStatusManager.getStatusStacks(); Assert.assertEquals(1, statusStacks.size()); TestStatusStack statusStack = statusStacks.iterator().next(); Assert.assertTrue(statusStack.isRecoverd()); Assert.assertTrue(!statusStack.isCommitted()); // recovering closes the recovered connection Assert.assertTrue(statusStack.isFreed()); }
From source file:org.csc.phynixx.connection.recovery.RecoveryIT.java
@Test public void testInterruptedCommit() throws Exception { ITestConnection con = RecoveryIT.this.factory.getConnection(); con.setInitialCounter(3);/*from w w w.ja v a 2 s . c o m*/ con.act(2); con.act(7); con.setInterruptFlag(TestInterruptionPoint.COMMIT); try { con.commit(); throw new AssertionFailedError("ActionInterruptedException expected"); } catch (Exception e) { } // close on an incomplete connections does not destroy the restore data con.close(); LOG.info(TestConnectionStatusManager.toDebugString()); TestStatusStack statusStack = TestConnectionStatusManager.getStatusStack(con.getConnectionId()); Assert.assertTrue(!statusStack.isCommitted()); final ITestConnection[] recoveredConnection = new ITestConnection[1]; PhynixxRecovery<ITestConnection> recovery = new PhynixxRecovery<ITestConnection>( new TestConnectionFactory()); IPhynixxLoggerSystemStrategy<ITestConnection> loggerStrategy = this.factory.getLoggerSystemStrategy(); loggerStrategy.close(); recovery.addConnectionProxyDecorator(new TestConnectionStatusListener()); recovery.setLoggerSystemStrategy(loggerStrategy); recovery.recover(new IPhynixxRecovery.IRecoveredManagedConnection<ITestConnection>() { @Override public void managedConnectionRecovered(ITestConnection con) { recoveredConnection[0] = con; Assert.assertEquals(12, con.getCounter()); } }); LOG.info(TestConnectionStatusManager.toDebugString()); TestStatusStack recoveredStatusStack = TestConnectionStatusManager .getStatusStack(recoveredConnection[0].getConnectionId()); Assert.assertTrue(recoveredStatusStack.isRecoverd()); Assert.assertTrue(recoveredStatusStack.isFreed()); }