io.netty.channel.ChannelMetadata#junit.framework.AssertionFailedError源码实例Demo

下面列出了io.netty.channel.ChannelMetadata#junit.framework.AssertionFailedError 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tomee   文件: EncStatefulBean.java
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);
    }
}
 
源代码2 项目: ghidra   文件: AbstractDockingTest.java
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);
	}
 
源代码3 项目: tomee   文件: EncBmpBean.java
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);
    }
}
 
源代码4 项目: tomee   文件: ContextLookupMdbBean.java
@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);
    }
}
 
源代码5 项目: tomee   文件: ContextLookupMdbPojoBean.java
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);
    }
}
 
源代码6 项目: ghidra   文件: AbstractGTest.java
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);
}
 
源代码7 项目: astor   文件: TestUtils.java
/**
 * 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));
    }
}
 
源代码8 项目: ghidra   文件: AbstractToolSavingTest.java
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();
}
 
源代码9 项目: openjdk-jdk9   文件: JSR166TestCase.java
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());
    }
}
 
源代码10 项目: tomee   文件: EncMdbBean.java
@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);
    }
}
 
源代码11 项目: tomee   文件: ContextLookupSingletonBean.java
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);
    }
}
 
源代码12 项目: tomee   文件: ContextLookupMdbBean.java
@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);
    }
}
 
源代码13 项目: tomee   文件: EncMdbBean.java
@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);
    }
}
 
源代码14 项目: j2objc   文件: JSR166TestCase.java
/**
 * 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();
}
 
源代码15 项目: tomee   文件: ContextLookupSingletonPojoBean.java
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);
    }
}
 
源代码16 项目: tomee   文件: EncMdbBean.java
@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);
    }

}
 
源代码17 项目: tomee   文件: ContextLookupSingletonPojoBean.java
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);
    }
}
 
源代码18 项目: tomee   文件: ContextLookupStatefulPojoBean.java
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);
    }
}
 
@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);
  }
}
 
源代码20 项目: pipeline-maven-plugin   文件: XmlUtilsTest.java
@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);
        }
    }
}
 
源代码21 项目: tomee   文件: EncMdbBean.java
@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);
    }
}
 
源代码22 项目: tomee   文件: EncCmpBean.java
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);
    }
}
 
源代码23 项目: tomee   文件: EncCmpBean.java
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);
    }
}
 
源代码24 项目: swellrt   文件: DocOpValidatorTest.java
void doTest(TestData t) throws OperationException {
  DocOpBuffer d = new DocOpBuffer();
  DocOpBuffer m = new DocOpBuffer();
  boolean expected = t.build(d, m);

  BootstrapDocument doc = new BootstrapDocument();

  // initialize document
  doc.consume(d.finishUnchecked());

  // check whether m would apply
  ViolationCollector v = new ViolationCollector();
  ValidationResult result =
      DocOpValidator.validate(v, t.getSchemaConstraints(), doc, m.finishUnchecked());

  try {
    assertEquals(expected, v.isValid());
    assertEquals(result, v.getValidationResult());
  } catch (AssertionFailedError e) {
    System.err.println("test data:");
    System.err.println(DocOpUtil.toConciseString(d.finish()));
    System.err.println(DocOpUtil.toConciseString(m.finish()));
    System.err.println("violations:");
    v.printDescriptions(System.err);
    throw e;
  }
}
 
源代码25 项目: cacheonix-core   文件: AssertTest.java
public void testAssertNull() {
	assertNull(null);
	try {
		assertNull(new Object());
	} catch (AssertionFailedError e) {
		return;
	}
	fail();
}
 
源代码26 项目: tomee   文件: EncCmp2Bean.java
public void lookupPersistenceUnit() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            final EntityManagerFactory emf = (EntityManagerFactory) ctx.lookup("java:comp/env/persistence/TestUnit");
            Assert.assertNotNull("The EntityManagerFactory is null", emf);

        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
 
源代码27 项目: tomee   文件: InterceptorMdbBean.java
public void checkMethodLevelBusinessMethodInterception() throws TestFailureException {
    try {
        Assert.assertTrue("Method Level Business Method Interception failed for Mdb", methodLevelBusinessMethodInterception);
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
 
源代码28 项目: kubernetes-client   文件: WatchOverHTTP.java
@Test
public void testDeleted() throws InterruptedException {
  logger.info("testDeleted");
  KubernetesClient client = server.getClient().inNamespace("test");

  server.expect()
    .withPath(path)
    .andReturn(200, "Failed WebSocket Connection").once();
  server.expect().withPath(path).andReturnChunked(200,
    new WatchEvent(pod1, "DELETED"), "\n",
    new WatchEvent(pod1, "ADDED"), "\n").once();

  final CountDownLatch addLatch = new CountDownLatch(1);
  final CountDownLatch deleteLatch = new CountDownLatch(1);
  try (Watch watch = client.pods().withName("pod1").withResourceVersion("1").watch(new Watcher<Pod>() {
    @Override
    public void eventReceived(Action action, Pod resource) {
      switch (action) {
        case DELETED:
          deleteLatch.countDown();
          break;
        case ADDED:
          addLatch.countDown();
          break;
        default:
          throw new AssertionFailedError();
      }
    }

    @Override
    public void onClose(KubernetesClientException cause) {}
  })) /* autoclose */ {
    assertTrue(addLatch.await(10, TimeUnit.SECONDS));
    assertTrue(deleteLatch.await(10, TimeUnit.SECONDS));
  }
}
 
源代码29 项目: tomee   文件: FieldInjectionStatefulBean.java
public void lookupStatelessBusinessLocal() throws TestFailureException {
    try {
        Assert.assertNotNull("The EJB BusinessLocal is null", statelessBusinessLocal);
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
 
源代码30 项目: tomee   文件: SetterInjectionStatefulBean.java
public void lookupIntegerEntry() throws TestFailureException {
    try {
        final Integer expected = new Integer(1);

        Assert.assertNotNull("The Integer looked up is null", inteegerField);
        Assert.assertEquals(expected, inteegerField);

    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}