List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:crawlercommons.fetcher.file.SimpleFileFetcherTest.java
@Test public void testMissingFile() throws Exception { String url = new File("src/main/resources/bogus-name").toURI().toURL().toExternalForm(); SimpleFileFetcher fetcher = new SimpleFileFetcher(); try {/*w ww .j a va2s. c o m*/ fetcher.get(url); Assert.fail("No exception throw"); } catch (HttpFetchException e) { // valid } }
From source file:fll.web.WebTestUtils.java
private static void checkForServerError(final Page page) throws IOException { final com.gargoylesoftware.htmlunit.WebResponse response = page.getWebResponse(); final int code = response.getStatusCode(); final boolean error; if (code >= 400) { error = true;/*from ww w . j a v a 2 s.co m*/ } else { error = false; } if (error) { final String responseMessage = response.getStatusMessage(); final String text = getPageSource(page); final File output = File.createTempFile("server-error", ".html", new File("screenshots")); final FileWriter writer = new FileWriter(output); writer.write(text); writer.close(); Assert.fail("Error loading page: " + page.getUrl() + " code: " + code + " message: " + responseMessage + " Contents of error page written to: " + output.getAbsolutePath()); } }
From source file:br.com.sicoob.cro.cop.batch.core.BatchProcessingTests.java
@Test public void taskletExample() { try {/* ww w.j a va2s. c o m*/ Properties jobParameters = new Properties(); jobParameters.put("nomeArquivo", "OpLm.csv"); BatchProcess launcher = BatchApplication.createExecutionProcess("taskletExample", jobParameters); BatchExecution execution = launcher.start(); while (execution.getStatus() != Status.COMPLETED) { Thread.sleep(5000); LOG.info(execution.toString()); } LOG.info(execution.toString()); assertEquals(Result.Type.SUCCESS, execution.getResult().getType()); } catch (BatchStartException excecao) { Assert.fail(excecao.getMessage()); } catch (InterruptedException ex) { Assert.fail(ex.getMessage()); Logger.getLogger(BatchProcessingTests.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.atlassian.jira.rest.client.TestUtil.java
@SuppressWarnings("unused") public static <T extends Throwable> void assertThrows(Class<T> clazz, String regexp, Runnable runnable) { try {/*ww w . j a v a 2 s . c o m*/ runnable.run(); Assert.fail(clazz.getName() + " exception expected"); } catch (Throwable e) { Assert.assertTrue( "Expected exception of class " + clazz.getName() + " but was caught " + e.getClass().getName(), clazz.isInstance(e)); if (e.getMessage() == null && regexp != null) { Assert.fail("Exception with no message caught, while expected regexp [" + regexp + "]"); } if (regexp != null && e.getMessage() != null) { Assert.assertTrue("Message [" + e.getMessage() + "] does not match regexp [" + regexp + "]", e.getMessage().matches(regexp)); } } }
From source file:de.tudarmstadt.ukp.dkpro.tc.integrationtest.ExtremeConfiguratonSettingsTest.java
@Test public void testExtremeValues_emptyFeatureExtractorSet() throws Exception { try {// w w w. jav a2 s . co m new ExtremeConfigurationSettingsExperiment().runEmptyFeatureExtractorSet(); } catch (ExecutionException e) { if (!ExceptionUtils.getRootCauseMessage(e) .contains("No feature extractors have been added to the experiment.")) { Assert.fail("Unexpected exception"); } } }
From source file:it.geosolutions.tools.compress.file.test.ExtractorTest.java
@Test public void extractorGZip() throws FileNotFoundException, IOException { try {/*from ww w . j ava2 s.c om*/ Extractor.extractGzip(compressed, tar); if (!tar.exists()) { Assert.fail("Failed to uncompress the gzip file"); } else if (tar.length() != tarCompare.length()) { Assert.fail("Failed to compare the resulting tar file"); } } catch (CompressorException e) { LOGGER.log(Level.ERROR, e.getMessage(), e); Assert.fail(e.getLocalizedMessage()); } }
From source file:de.hybris.vjdbc.VirtualDriverTest.java
@Test public void testConnectWithInvalidUrl() throws Exception { try {//from w w w . j a v a 2 s .c o m driver.connect("foobar", null); Assert.fail("should have failed"); } catch (SQLException e) { assertFirstLineOfSQLException( "Unsupported url format. Expected 'jdbc:hybris:[flexiblesearch:|sql:]<some url>' but got :foobar. Refer to documentation for details", e); } Mockito.verifyZeroInteractions(virtualConnectionBuilder); }
From source file:com.googlecode.ehcache.annotations.integration.ConfigurationFailureTest.java
/** * Test verifies behavior when no {@link Ehcache} is defined for * the cacheName attribute on the {@link Cacheable} annotated method AND * 'createMissingCaches' is false./* w w w . j a v a 2 s .c om*/ */ @Test public void testNoCache() { try { new ClassPathXmlApplicationContext("/noCacheTestContext.xml"); Assert.fail("Test should have failed with no Cache defined"); } catch (BeanCreationException bce) { Assert.assertEquals("missingCacheNameImpl", bce.getBeanName()); final CacheNotFoundException cnfe = (CacheNotFoundException) bce.getCause(); Assert.assertEquals("nonexistent", cnfe.getCacheName()); } }
From source file:eu.stratosphere.pact.runtime.task.TempTaskExternalITCase.java
@Test public void testTempTask() { int keyCnt = 16384; int valCnt = 32; super.initEnvironment(1024 * 1024 * 1); super.addInput(new UniformPactRecordGenerator(keyCnt, valCnt, false), 1); super.addOutput(this.outList); TempTask<PactRecord> testTask = new TempTask<PactRecord>(); super.getTaskConfig().setMemorySize(1 * 1024 * 1024); super.registerTask(testTask, PrevStub.class); try {//from ww w.j a va 2 s. co m testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } Assert.assertTrue(this.outList.size() == keyCnt * valCnt); }
From source file:azkaban.crypto.DecryptionTest.java
@Test public void testV1() throws IOException { BasicConfigurator.configure();/*from ww w. j av a 2 s .c o m*/ Logger.getRootLogger().setLevel(Level.DEBUG); String expected = "test"; String ciphered = "eyJ2ZXIiOiIxLjAiLCJ2YWwiOiJOd1hRejdOMjBXUU05SXEzaE94RVZnPT0ifQ=="; String passphrase = "test1234"; Crypto crypto = new Crypto(); String actual = crypto.decrypt(ciphered, passphrase); Assert.assertEquals(expected, actual); try { new CryptoV1_1().decrypt(ciphered, passphrase); Assert.fail("Should have failed when decrypt v1 ciphered text with v1.1 decryption."); } catch (Exception e) { Assert.assertTrue(e instanceof RuntimeException); } }