List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:com.karriem.tp.tddassignment.TDDTestNGTest.java
@Test public void failTest() { Assert.fail("This is a deliberate fail"); }
From source file:org.geomajas.gwt.server.mvc.GeomajasControllerTest.java
@Test public void testNonWebContext() throws ServletException, IOException { // create mock context that loads from the classpath MockServletConfig config = new MockServletConfig(); MockHttpServletRequest request = new MockHttpServletRequest(config.getServletContext()); MockHttpServletResponse response = new MockHttpServletResponse(); GeomajasController c = new GeomajasController(); c.init(config);//from ww w . j a va 2 s .co m try { c.doPost(request, response); Assert.fail("Should fail outside web context"); } catch (RuntimeException e) { } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void ChainedCursorFunctionTest() { this.logger.info("ChainedFunctionTest"); try {/*w w w .j a v a 2 s . c o m*/ Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("you", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { BQForwardOnlyResultSetFunctionTest.Result.absolute(10); } catch (SQLException e) { Assert.assertTrue(true); } try { for (int i = 0; i < 9; i++) { Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); } Assert.assertFalse(BQForwardOnlyResultSetFunctionTest.Result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { Assert.assertTrue(true); } QueryLoad(); try { Result.next(); Assert.assertEquals("you", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } this.logger.info("chainedfunctiontest end"); }
From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformObjectFacadeStrategyTest.java
@Test public void testLoad() throws ObjectNotFoundException { final ModelService modelService = Mockito.mock(ModelService.class); final UserModel user = new UserModel(); user.setName("Test User"); Mockito.when(modelService.get(PK.parse("1234"))).thenReturn(user); final LabelService labelService = Mockito.mock(LabelService.class); Mockito.when(labelService.getObjectLabel(Mockito.any())).thenReturn(StringUtils.EMPTY); final DefaultPlatformObjectFacadeStrategy strategy = new DefaultPlatformObjectFacadeStrategy(); strategy.setModelService(modelService); strategy.setLabelService(labelService); // Test we get the same user Assert.assertEquals(user, strategy.load("1234", null)); // Test that an unknown pk will return null Assert.assertNull(strategy.load("9999", null)); Assert.assertNull(strategy.load(null, null)); try {/*from w ww. j av a2 s .c o m*/ strategy.load("", null); Assert.fail("load method should have thrown an exception"); } catch (final ObjectNotFoundException ex) // NOPMD { // expected behavior } }
From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testEvaluateStringWithNullInput() { try {// w w w . j a v a 2 s .c om (new PTestServerConfigurationParser()).evaluateString(null, null); Assert.fail("Invalid input, both parameters contain null values"); } catch (XPathExpressionException e) { // } }
From source file:com.ibm.team.build.internal.hjplugin.tests.RTCFacadeFactoryIT.java
public void testGetFacadeSwitch() throws IOException { if (Config.DEFAULT.isConfigured()) { RTCFacadeWrapper facade = null;/*w ww .j ava2 s .c om*/ try { facade = RTCFacadeFactory.getFacade(Config.DEFAULT.getToolkit(), null); // ask again for the same one, should get the same one back RTCFacadeWrapper facade2 = RTCFacadeFactory.getFacade(Config.DEFAULT.getToolkit(), null); if (facade != facade2) { Assert.fail("Cached toolkit was not reused " + facade + " second requested facade " + facade2); } } catch (Exception e) { Assert.fail("Toolkit not found at " + Config.DEFAULT.getToolkit()); } File srcDir = new File(Config.DEFAULT.getToolkit()); File destDir = null; try { // create a build toolkit copy destDir = Files.createTempDir(); FileUtils.copyDirectory(srcDir, destDir); try { // create a new facade with the build toolkit copy RTCFacadeWrapper facade3 = RTCFacadeFactory.getFacade(destDir.getAbsolutePath(), null); if (facade == facade3) { Assert.fail("Cached toolkit re-used for different toolkit path " + facade + " new toolkit facade " + facade3); } // get the new facade with the build toolkit copy and make sure it is the cached version RTCFacadeWrapper facade4 = RTCFacadeFactory.getFacade(destDir.getAbsolutePath(), null); if (facade3 != facade4) { Assert.fail( "Cached toolkit was not reused " + facade3 + " second requested facade " + facade4); } // get the new facade with the build toolkit copy with a trailing slash and make sure it is the cached version facade4 = RTCFacadeFactory.getFacade(destDir.getAbsolutePath() + File.separator, null); if (facade3 != facade4) { Assert.fail( "Cached toolkit was not reused " + facade3 + " second requested facade " + facade4); } } catch (Exception e) { Assert.fail("Failed swtiching to toolkit " + destDir); } } finally { if (destDir != null) { try { // delete the build toolkit copy FileUtils.deleteDirectory(destDir); } catch (Exception e) { // don't let the cleanup fail the build e.printStackTrace(System.out); } } } try { // ask for the original toolkit - it should still be cached since default size is 3 RTCFacadeWrapper facade2 = RTCFacadeFactory.getFacade(Config.DEFAULT.getToolkit(), null); if (facade != facade2) { Assert.fail("Cached toolkit was not reused " + facade + " second requested facade " + facade2); } } catch (Exception e) { Assert.fail("Toolkit not found at " + Config.DEFAULT.getToolkit()); } } }
From source file:amqp.spring.camel.component.SpringAMQPProducerTest.java
@Test public void sendAsyncCallbackMessage() throws Exception { context().createProducerTemplate().asyncCallbackSendBody("direct:test.w", "HELLO WORLD", new Synchronization() { @Override/*from ww w .ja v a2 s . c om*/ public void onComplete(Exchange exchange) { Assert.assertNull(exchange.getException()); } @Override public void onFailure(Exchange exchange) { Assert.fail(exchange.getException() != null ? exchange.getException().getMessage() : "Failure on async callback"); } }); }
From source file:eagle.log.entity.TestHBaseWriteEntitiesPerformance.java
@Before public void setUp() throws IllegalAccessException, InstantiationException, IOException { EntityDefinition entityDefinition = EntityDefinitionManager .getEntityDefinitionByEntityClass(TestLogAPIEntity.class); hbase.createTable(entityDefinition.getTable(), entityDefinition.getColumnFamily()); EntityDefinitionManager.registerEntity(TestLogAPIEntity.class); try {//from w w w .jav a 2 s .c o m ed = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestLogAPIEntity.class); ed.setTimeSeries(true); } catch (InstantiationException | IllegalAccessException e) { Assert.fail(e.getMessage()); } }
From source file:org.jongo.AnnotationsMisusedTest.java
@Test public void savingAPojoWithAnEmptyCustomIntegerId() throws Exception { WithIntegerId custom = new WithIntegerId(); collection.withWriteConcern(WriteConcern.SAFE).save(custom); try {/*from w w w .j a v a 2 s. com*/ collection.findOne().as(WithIntegerId.class); Assert.fail("Should not be able to unmarshall an ObjectId into an Integer"); } catch (Exception e) { } }
From source file:org.sonatype.nexus.kenai.internal.KenaiRealmTest.java
@Test public void testAuthFail() throws Exception { KenaiRealm kenaiRealm = this.getRealm(); try {//from w ww . ja va 2 s.com kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken("random", "JUNK-PASS")); Assert.fail("Expected: AccountException to be thrown"); } catch (AccountException e) { // expected } }