junit.framework.AssertionFailedError Java Examples
The following examples show how to use
junit.framework.AssertionFailedError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EncStatefulBean.java From tomee with Apache License 2.0 | 8 votes |
public void lookupBooleanEntry() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final Boolean expected = Boolean.TRUE; final Boolean actual = (Boolean) ctx.lookup("java:comp/env/stateful/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #2
Source File: EncMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupPersistenceContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/TestContext"); Assert.assertNotNull("The EntityManager is null", em); // call a do nothing method to assure entity manager actually exists em.getFlushMode(); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #3
Source File: AbstractGTest.java From ghidra with Apache License 2.0 | 6 votes |
private static void waitForCondition(BooleanSupplier condition, boolean failOnTimeout, Supplier<String> failureMessageSupplier) throws AssertionFailedError { int totalTime = 0; while (totalTime <= DEFAULT_WAIT_TIMEOUT) { if (condition.getAsBoolean()) { return; // success } totalTime += sleep(DEFAULT_WAIT_DELAY); } if (!failOnTimeout) { return; } String failureMessage = "Timed-out waiting for condition"; if (failureMessageSupplier != null) { failureMessage = failureMessageSupplier.get(); } throw new AssertionFailedError(failureMessage); }
Example #4
Source File: TestUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Fails iff values does not contain a number within epsilon of z. * * @param msg message to return with failure * @param values complex array to search * @param z value sought * @param epsilon tolerance */ public static void assertContains(String msg, Complex[] values, Complex z, double epsilon) { int i = 0; boolean found = false; while (!found && i < values.length) { try { assertEquals(values[i], z, epsilon); found = true; } catch (AssertionFailedError er) { // no match } i++; } if (!found) { Assert.fail(msg + " Unable to find " + ComplexFormat.formatComplex(z)); } }
Example #5
Source File: OracleExportTest.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 6 votes |
@Override public void testDatesAndTimes() throws IOException, SQLException { final int TOTAL_RECORDS = 10; ColumnGenerator genDate = getDateColumnGenerator(); ColumnGenerator genTime = getTimeColumnGenerator(); try { createTextFile(0, TOTAL_RECORDS, false, genDate, genTime); createTable(genDate, genTime); runExport(getArgv(true, 10, 10)); verifyExport(TOTAL_RECORDS); assertColMinAndMax(forIdx(0), genDate); assertColMinAndMax(forIdx(1), genTime); } catch (AssertionFailedError afe) { genDate = getNewDateColGenerator(); genTime = getNewTimeColGenerator(); createTextFile(0, TOTAL_RECORDS, false, genDate, genTime); createTable(genDate, genTime); runExport(getArgv(true, 10, 10)); verifyExport(TOTAL_RECORDS); assertColMinAndMax(forIdx(0), genDate); assertColMinAndMax(forIdx(1), genTime); } }
Example #6
Source File: ContextLookupStatefulPojoBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupLongEntry() throws TestFailureException { try { try { final Long expected = new Long(1L); final Long actual = (Long) ejbContext.lookup("stateful/references/Long"); Assert.assertNotNull("The Long looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #7
Source File: XmlUtilsTest.java From pipeline-maven-plugin with MIT License | 6 votes |
@Test public void test_listGeneratedArtifacts_including_generated_artifacts() throws Exception { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jenkinsci/plugins/pipeline/maven/maven-spy-deploy-jar.xml"); in.getClass(); // check non null Element mavenSpyLogs = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in).getDocumentElement(); List<MavenArtifact> generatedArtifacts = XmlUtils.listGeneratedArtifacts(mavenSpyLogs, true); System.out.println(generatedArtifacts); Assert.assertThat(generatedArtifacts.size(), Matchers.is(3)); // a jar file and a pom file are generated for (MavenArtifact mavenArtifact:generatedArtifacts) { Assert.assertThat(mavenArtifact.getGroupId(), Matchers.is("com.example")); Assert.assertThat(mavenArtifact.getArtifactId(), Matchers.is("my-jar")); if("pom".equals(mavenArtifact.getType())) { Assert.assertThat(mavenArtifact.getExtension(), Matchers.is("pom")); Assert.assertThat(mavenArtifact.getClassifier(), Matchers.isEmptyOrNullString()); } else if ("jar".equals(mavenArtifact.getType())) { Assert.assertThat(mavenArtifact.getExtension(), Matchers.is("jar")); Assert.assertThat(mavenArtifact.getClassifier(), Matchers.isEmptyOrNullString()); } else if ("java-source".equals(mavenArtifact.getType())) { Assert.assertThat(mavenArtifact.getExtension(), Matchers.is("jar")); Assert.assertThat(mavenArtifact.getClassifier(), Matchers.is("sources")); } else { throw new AssertionFailedError("Unsupported type for " + mavenArtifact); } } }
Example #8
Source File: AbstractToolSavingTest.java From ghidra with Apache License 2.0 | 6 votes |
protected void closeAndReopenProject() { executeOnSwingWithoutBlocking(() -> { try { // we want to trigger the saving of tools to the toolchest for our tests // just closing the project doesn't save anything. testEnv.getProject().saveSessionTools(); testEnv.getProject().save(); testEnv.closeAndReopenProject(); } catch (IOException e) { AssertionFailedError afe = new AssertionFailedError(); afe.initCause(e); throw afe; } }); waitForPostedSwingRunnables(); }
Example #9
Source File: ContextLookupSingletonPojoBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupFloatEntry() throws TestFailureException { try { try { final Float expected = new Float(1.0F); final Float actual = (Float) getSessionContext().lookup("singleton/references/Float"); Assert.assertNotNull("The Float looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #10
Source File: JSR166TestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void assertThrows(Class<? extends Throwable> expectedExceptionClass, Runnable... throwingActions) { for (Runnable throwingAction : throwingActions) { boolean threw = false; try { throwingAction.run(); } catch (Throwable t) { threw = true; if (!expectedExceptionClass.isInstance(t)) { AssertionFailedError afe = new AssertionFailedError ("Expected " + expectedExceptionClass.getName() + ", got " + t.getClass().getName()); afe.initCause(t); threadUnexpectedException(afe); } } if (!threw) shouldThrow(expectedExceptionClass.getName()); } }
Example #11
Source File: ContextLookupMdbPojoBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupBooleanEntry() throws TestFailureException { try { try { final Boolean expected = true; final Boolean actual = (Boolean) getMessageDrivenContext().lookup("stateless/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #12
Source File: EncMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupShortEntry() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final Short expected = (short) 1; final Short actual = (Short) ctx.lookup("java:comp/env/stateless/references/Short"); Assert.assertNotNull("The Short looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #13
Source File: EncMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupMessageDrivenContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc final MessageDrivenContext messageDrivenContext = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext"); Assert.assertNotNull("The SessionContext got from java:comp/env/mdbcontext is null", messageDrivenContext); // lookup using global name final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); // verify context was set via legacy set method Assert.assertNotNull("The MdbContext is null from setter method", mdbContext); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #14
Source File: EncMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupCharacterEntry() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final Character expected = 'D'; final Character actual = (Character) ctx.lookup("java:comp/env/stateless/references/Character"); Assert.assertNotNull("The Character looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #15
Source File: ContextLookupMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupBooleanEntry() throws TestFailureException { try { try { final Boolean expected = true; final Boolean actual = (Boolean) mdbContext.lookup("stateless/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #16
Source File: EncCmpBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupFloatEntry() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final Float expected = new Float(1.0F); final Float actual = (Float) ctx.lookup("java:comp/env/entity/cmp/references/Float"); Assert.assertNotNull("The Float looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #17
Source File: ContextLookupSingletonBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupStringEntry() throws TestFailureException { try { try { final String expected = new String("1"); final String actual = (String) ejbContext.lookup("singleton/references/String"); Assert.assertNotNull("The String looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #18
Source File: EncBmpBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupPersistenceContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/TestContext"); Assert.assertNotNull("The EntityManager is null", em); // call a do nothing method to assure entity manager actually exists em.getFlushMode(); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #19
Source File: ContextLookupSingletonPojoBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupBooleanEntry() throws TestFailureException { try { try { final Boolean expected = Boolean.TRUE; final Boolean actual = (Boolean) getSessionContext().lookup("singleton/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #20
Source File: AbstractDockingTest.java From ghidra with Apache License 2.0 | 6 votes |
public static Window waitForWindow(Class<?> windowClass) { if ((!Dialog.class.isAssignableFrom(windowClass)) && (!Frame.class.isAssignableFrom(windowClass))) { throw new IllegalArgumentException( windowClass.getName() + " does not extend Dialog or Frame."); } int timeout = DEFAULT_WAIT_TIMEOUT; int totalTime = 0; while (totalTime <= timeout) { Set<Window> winList = getAllWindows(); Iterator<Window> it = winList.iterator(); while (it.hasNext()) { Window w = it.next(); if (windowClass.isAssignableFrom(w.getClass()) && w.isVisible()) { return w; } } totalTime += sleep(DEFAULT_WAIT_DELAY); } throw new AssertionFailedError("Timed-out waiting for window of class: " + windowClass); }
Example #21
Source File: EncCmpBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupByteEntry() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); final Byte expected = new Byte((byte) 1); final Byte actual = (Byte) ctx.lookup("java:comp/env/entity/cmp/references/Byte"); Assert.assertNotNull("The Byte looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #22
Source File: ContextLookupMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@Override public void lookupDoubleEntry() throws TestFailureException { try { try { final Double expected = 1.0D; final Double actual = (Double) mdbContext.lookup("stateless/references/Double"); Assert.assertNotNull("The Double looked up is null", actual); Assert.assertEquals(expected, actual); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #23
Source File: JSR166TestCase.java From j2objc with Apache License 2.0 | 6 votes |
/** * Extra checks that get done for all test cases. * * Triggers test case failure if any thread assertions have failed, * by rethrowing, in the test harness thread, any exception recorded * earlier by threadRecordFailure. * * Triggers test case failure if interrupt status is set in the main thread. */ public void tearDown() throws Exception { Throwable t = threadFailure.getAndSet(null); if (t != null) { if (t instanceof Error) throw (Error) t; else if (t instanceof RuntimeException) throw (RuntimeException) t; else if (t instanceof Exception) throw (Exception) t; else { AssertionFailedError afe = new AssertionFailedError(t.toString()); afe.initCause(t); throw afe; } } if (Thread.interrupted()) tearDownFail("interrupt status set in main thread"); checkForkJoinPoolThreadLeaks(); }
Example #24
Source File: SetterInjectionSingletonBean.java From tomee with Apache License 2.0 | 5 votes |
public void lookupResource() throws TestFailureException { try { Assert.assertNotNull("The DataSource is null", daataSourceField); } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #25
Source File: JSR166TestCase.java From j2objc with Apache License 2.0 | 5 votes |
/** * Just like assertEquals(x, y), but additionally recording (using * threadRecordFailure) any AssertionFailedError thrown, so that * the current testcase will fail. */ public void threadAssertEquals(long x, long y) { try { assertEquals(x, y); } catch (AssertionFailedError t) { threadRecordFailure(t); throw t; } }
Example #26
Source File: OneLinerFormatter.java From pxf with Apache License 2.0 | 5 votes |
@Override public void addFailure(Test test, AssertionFailedError error) { if (test != null) { if (!failedTests.containsKey(test)) { failedTests.put(test, error); } } }
Example #27
Source File: DashTest.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
@Override protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) { if (fullPlaybackNoSeeking) { // We shouldn't have skipped any output buffers. DecoderCountersUtil.assertSkippedOutputBufferCount(AUDIO_TAG, audioCounters, 0); DecoderCountersUtil.assertSkippedOutputBufferCount(VIDEO_TAG, videoCounters, 0); // We allow one fewer output buffer due to the way that MediaCodecRenderer and the // underlying decoders handle the end of stream. This should be tightened up in the future. DecoderCountersUtil.assertTotalOutputBufferCount(AUDIO_TAG, audioCounters, audioCounters.inputBufferCount - 1, audioCounters.inputBufferCount); DecoderCountersUtil.assertTotalOutputBufferCount(VIDEO_TAG, videoCounters, videoCounters.inputBufferCount - 1, videoCounters.inputBufferCount); } try { int droppedFrameLimit = (int) Math.ceil(MAX_DROPPED_VIDEO_FRAME_FRACTION * DecoderCountersUtil.getTotalOutputBuffers(videoCounters)); // Assert that performance is acceptable. // Assert that total dropped frames were within limit. DecoderCountersUtil.assertDroppedOutputBufferLimit(VIDEO_TAG, videoCounters, droppedFrameLimit); // Assert that consecutive dropped frames were within limit. DecoderCountersUtil.assertConsecutiveDroppedOutputBufferLimit(VIDEO_TAG, videoCounters, MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES); } catch (AssertionFailedError e) { if (trackSelector.includedAdditionalVideoFormats) { // Retry limiting to CDD mandated formats (b/28220076). Log.e(TAG, "Too many dropped or consecutive dropped frames.", e); needsCddLimitedRetry = true; } else { throw e; } } }
Example #28
Source File: GridCommonAbstractTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param res Response. */ protected void assertPartitionsSame(IdleVerifyResultV2 res) throws AssertionFailedError { if (res.hasConflicts()) { StringBuilder b = new StringBuilder(); res.print(b::append); fail(b.toString()); } }
Example #29
Source File: MultipleStreamTest.java From exificient with MIT License | 5 votes |
protected void _test(EXIFactory exiFactory, byte[] isBytes, int numberOfEXIDocuments) throws AssertionFailedError, Exception { // output stream ByteArrayOutputStream osEXI = new ByteArrayOutputStream(); _testEncode(exiFactory, isBytes, numberOfEXIDocuments, osEXI); InputStream isEXI = new ByteArrayInputStream(osEXI.toByteArray()); _testDecode(exiFactory, isBytes, numberOfEXIDocuments, new PushbackInputStream(isEXI, DecodingOptions.PUSHBACK_BUFFER_SIZE)); }
Example #30
Source File: SetterInjectionStatefulBean.java From tomee with Apache License 2.0 | 5 votes |
public void lookupStatelessBean() throws TestFailureException { try { Assert.assertNotNull("The EJBObject is null", statelessHomeField); } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }