List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:BQJDBC.QueryResultTest.QueryResultTest.java
@Test public void QueryResultTest09() { final String sql = "SELECT corpus, corpus_date FROM publicdata:samples.shakespeare GROUP BY corpus, corpus_date ORDER BY corpus_date DESC LIMIT 3;"; final String description = "Shakespeare's 3 latest"; String[][] expectation = new String[][] { { "kinghenryviii", "tempest", "winterstale" }, { "1612", "1611", "1610" } }; this.logger.info("Test number: 09"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {/*from w ww .j a va 2s. c o m*/ Result = QueryResultTest.con.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { Assert.assertTrue("Comparing failed in the String[][] array", this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java
@Test public void TestResultSetAbsolute() { try {//from ww w . ja v a 2 s . c o m Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(1)); Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(2)); Assert.assertEquals("yet", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(3)); Assert.assertEquals("would", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(4)); Assert.assertEquals("world", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(5)); Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(6)); Assert.assertEquals("with", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(7)); Assert.assertEquals("your", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(8)); Assert.assertEquals("young", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(9)); Assert.assertEquals("words", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(10)); Assert.assertEquals("word", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQResultSetFunctionTest.Result.absolute(0)); Assert.assertEquals("", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } try { Assert.assertFalse(BQResultSetFunctionTest.Result.absolute(11)); Assert.assertEquals("", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } }
From source file:com.github.magicsky.sya.checkers.TestSourceReader.java
public static IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException { ICElement elem = project.findElement(file.getFullPath()); if (elem instanceof ITranslationUnit) { ITranslationUnit tu = (ITranslationUnit) elem; return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); }// w w w.ja va2s . c om Assert.fail("Could not create AST for " + file.getFullPath()); return null; }
From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testParserServeConfigurationWithArrayHavingAnXMLDocPortEmpty() { try {//from w w w . j a va 2s. c o m byte[] test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ptest-server><hostname>test</hostname><port></port></ptest-server>" .getBytes(); new PTestServerConfigurationParser().parseServerConfiguration(test); Assert.fail("Invalid file contents"); } catch (ServerConfigurationFailedException e) { } }
From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
@Test public void TestResultSetAbsolute() { try {/*ww w . ja va 2 s. c om*/ Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(1)); Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(2)); Assert.assertEquals("yet", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(3)); Assert.assertEquals("would", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(4)); Assert.assertEquals("world", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(5)); Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(6)); Assert.assertEquals("with", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(7)); Assert.assertEquals("your", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(8)); Assert.assertEquals("young", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(9)); Assert.assertEquals("words", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(10)); Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.absolute(0)); Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } try { Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.absolute(11)); Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } }
From source file:eu.stratosphere.pact.runtime.task.util.OutputEmitterTest.java
@Test public void testWrongKeyClass() { // Test for IntValue @SuppressWarnings("unchecked") final TypeComparator<Record> doubleComp = new RecordComparatorFactory(new int[] { 0 }, new Class[] { DoubleValue.class }).createComparator(); final ChannelSelector<SerializationDelegate<Record>> oe1 = new OutputEmitter<Record>( ShipStrategyType.PARTITION_HASH, doubleComp); final SerializationDelegate<Record> delegate = new SerializationDelegate<Record>( new RecordSerializerFactory().getSerializer()); PipedInputStream pipedInput = new PipedInputStream(1024 * 1024); DataInputStream in = new DataInputStream(pipedInput); DataOutputStream out;//from www.jav a 2 s.c o m Record rec = null; try { out = new DataOutputStream(new PipedOutputStream(pipedInput)); rec = new Record(1); rec.setField(0, new IntValue()); rec.write(out); rec = new Record(); rec.read(in); } catch (IOException e) { fail("Test erroneous"); } try { delegate.setInstance(rec); oe1.selectChannels(delegate, 100); } catch (DeserializationException re) { return; } Assert.fail("Expected a NullKeyFieldException."); }
From source file:com.verisign.epp.interfaces.EPPLaunchTst.java
/** * Unit test of using using the <code>EPPLaunchInfo</code> Extension with * <code>EPPDomain</code> info command with the following tests:<br> * <br>//from w w w .ja va 2 s . co m * <ol> * <li>Info command for sunrise application "abc123" * <li>Info command for sunrise registration * <li>Info command for landrush application * <li>Info command for unsupported landrush registration * <li>Info command for unsupported phase "CLAIMS" * </ol> */ public void launchInfo() { printStart("launchInfo"); // Try Successful Info try { EPPDomainInfoResp domainResponse; System.out.println("launchInfo: Info command for Sunrise Application \"abc123\""); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE), "abc123")); domainResponse = domain.sendInfo(); // -- Output all of the domain info response attributes System.out.println("launchInfo: Sunrise Application Response = [" + domainResponse + "]\n\n"); if (domainResponse.hasExtension(EPPLaunchInfData.class)) { EPPLaunchInfData infData = (EPPLaunchInfData) domainResponse.getExtension(EPPLaunchInfData.class); if (!infData.getPhase().getPhase().equals(EPPLaunchPhase.PHASE_SUNRISE)) { Assert.fail("launchInfo: phase " + infData.getPhase().getPhase() + " != " + EPPLaunchPhase.PHASE_SUNRISE); } System.out.println("Sunrise Application Id = " + infData.getApplicationId()); System.out.println("Sunrise Application Status = " + infData.getStatus().getStatus()); System.out.println("Sunrise Application Mark = " + infData.getMark()); } System.out.println("launchInfo: Info command for Sunrise Registration"); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE))); domainResponse = domain.sendInfo(); // -- Output all of the domain info response attributes System.out.println("launchInfo: Sunrise Registration Response = [" + domainResponse + "]\n\n"); if (domainResponse.hasExtension(EPPLaunchInfData.class)) { EPPLaunchInfData infData = (EPPLaunchInfData) domainResponse.getExtension(EPPLaunchInfData.class); if (!infData.getPhase().getPhase().equals(EPPLaunchPhase.PHASE_SUNRISE)) { Assert.fail("launchInfo: phase " + infData.getPhase().getPhase() + " != " + EPPLaunchPhase.PHASE_SUNRISE); } if (infData.getApplicationId() != null) { Assert.fail("launchInfo: applicationId should be null for sunrise registration"); } if (infData.getStatus() != null) { Assert.fail("launchInfo: status should be null for sunrise registration"); } if (infData.getMark() != null) { Assert.fail("launchInfo: Mark should be null with includeMark = false"); } } System.out.println("launchInfo: Info command for Sunrise Registration with includeMark = true"); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension EPPLaunchInfo theExt = new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE)); theExt.setIncludeMark(true); domain.addExtension(theExt); domainResponse = domain.sendInfo(); // -- Output all of the domain info response attributes System.out.println("launchInfo: Sunrise Registration with includeMark=true Response = [" + domainResponse + "]\n\n"); if (domainResponse.hasExtension(EPPLaunchInfData.class)) { EPPLaunchInfData infData = (EPPLaunchInfData) domainResponse.getExtension(EPPLaunchInfData.class); if (!infData.getPhase().getPhase().equals(EPPLaunchPhase.PHASE_SUNRISE)) { Assert.fail("launchInfo: phase " + infData.getPhase().getPhase() + " != " + EPPLaunchPhase.PHASE_SUNRISE); } if (infData.getApplicationId() != null) { Assert.fail("launchInfo: applicationId should be null for sunrise registration"); } if (infData.getStatus() != null) { Assert.fail("launchInfo: status should be null for sunrise registration"); } if (infData.getMark() == null) { Assert.fail("launchInfo: mark should not be null"); } System.out.println("Sunrise Registration Mark = " + infData.getMark()); } System.out.println("launchInfo: Info command for landrush application \"abc123\""); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_LANDRUSH), "abc123")); domainResponse = domain.sendInfo(); // -- Output all of the domain info response attributes System.out.println("launchInfo: Landrush Application Response = [" + domainResponse + "]\n\n"); if (domainResponse.hasExtension(EPPLaunchInfData.class)) { EPPLaunchInfData infData = (EPPLaunchInfData) domainResponse.getExtension(EPPLaunchInfData.class); if (!infData.getPhase().getPhase().equals(EPPLaunchPhase.PHASE_LANDRUSH)) { Assert.fail("EPPLaunchInfData phase " + infData.getPhase().getPhase() + " != " + EPPLaunchPhase.PHASE_LANDRUSH); } System.out.println("Landrush Application Id = " + infData.getApplicationId()); System.out.println("Landrush Application Status = " + infData.getStatus().getStatus()); if (infData.getMark() != null) { Assert.fail("launchInfo: mark should be null for landrush application"); } } System.out.println("launchInfo: Info command for unsupported landrush registration"); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_LANDRUSH))); domainResponse = null; try { domainResponse = domain.sendInfo(); } catch (EPPCommandException ex) { EPPResponse response = ex.getResponse(); System.out.println( "launchInfo: Landrush Registration Expected Error Response = [" + response + "]\n\n"); } if (domainResponse != null) { Assert.fail("launchInfo: landrush registration info should have failed"); } System.out.println("launchInfo: Info command for unsupported phase \"CLAIMS\""); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_CLAIMS))); domainResponse = null; try { domainResponse = domain.sendInfo(); } catch (EPPCommandException ex) { EPPResponse response = ex.getResponse(); System.out.println( "launchInfo: Info with Unsupported Phase Expected Error Response = [" + response + "]\n\n"); } if (domainResponse != null) { Assert.fail("launchInfo: Info with unsupported Phase should have failed"); } System.out.println("launchInfo: Info command for unsupported phase \"CLAIMS\""); domain.setTransId("ABC-12345"); domain.addDomainName("example.tld"); // Add extension domain.addExtension(new EPPLaunchInfo(new EPPLaunchPhase(EPPLaunchPhase.PHASE_CLAIMS))); domainResponse = null; try { domainResponse = domain.sendInfo(); } catch (EPPCommandException ex) { EPPResponse response = ex.getResponse(); System.out.println( "launchInfo: Info with Unsupported Phase Expected Error Response = [" + response + "]\n\n"); } if (domainResponse != null) { Assert.fail("launchInfo: Info with unsupported Phase should have failed"); } } catch (EPPCommandException e) { handleException(e); } printEnd("launchInfo"); }
From source file:com.imaginary.home.cloud.CloudTest.java
private void setupToken() throws Exception { if (relayKeyId == null) { setupRelay();//from w ww. j a v a 2 s . c om } HttpClient client = getClient(); HttpPost method = new HttpPost(cloudAPI + "/token"); long timestamp = System.currentTimeMillis(); method.addHeader("Content-Type", "application/json"); method.addHeader("x-imaginary-version", VERSION); method.addHeader("x-imaginary-timestamp", String.valueOf(timestamp)); method.addHeader("x-imaginary-api-key", relayKeyId); method.addHeader("x-imaginary-signature", CloudService.sign(relayKeyId.getBytes("utf-8"), "post:/token:" + relayKeySecret + ":" + timestamp + ":" + VERSION)); HttpResponse response; StatusLine status; try { response = client.execute(method); status = response.getStatusLine(); } catch (IOException e) { e.printStackTrace(); throw new CommunicationException(e); } if (status.getStatusCode() == HttpServletResponse.SC_CREATED) { String json = EntityUtils.toString(response.getEntity()); JSONObject t = new JSONObject(json); token = (t.has("token") && !t.isNull("token")) ? t.getString("token") : null; } else { Assert.fail("Failed to generate token (" + status.getStatusCode() + ": " + EntityUtils.toString(response.getEntity())); } }
From source file:org.sakaiproject.crudplus.logic.test.CrudPlusLogicImplTest.java
/** * Test method for {@link org.sakaiproject.crudplus.logic.impl.CrudPlusLogicImpl#removeItem(org.sakaiproject.crudplus.model.CrudPlusItem)}. *//*from w ww.ja v a 2 s . com*/ public void testRemoveItem() { // set up mock objects with return values userDirectoryService.getCurrentUser(); // expect this to be called userDirectoryServiceControl.setReturnValue(new TestUser(USER_ID)); userDirectoryServiceControl.setReturnValue(new TestUser(MAINT_USER_ID)); userDirectoryServiceControl.setReturnValue(new TestUser(ADMIN_USER_ID)); userDirectoryServiceControl.setReturnValue(new TestUser(MAINT_USER_ID)); userDirectoryServiceControl.setReturnValue(new TestUser(USER_ID)); securityService.unlock(new TestUser(USER_ID), CrudPlusLogicImpl.ITEM_WRITE_ANY, SITE_REF); securityServiceControl.setReturnValue(false, MockControl.ZERO_OR_MORE); securityService.unlock(new TestUser(MAINT_USER_ID), CrudPlusLogicImpl.ITEM_WRITE_ANY, SITE_REF); securityServiceControl.setReturnValue(true, MockControl.ZERO_OR_MORE); // activate the mock objects userDirectoryServiceControl.replay(); securityServiceControl.replay(); toolManagerControl.replay(); siteServiceControl.replay(); // mock object is needed here try { logicImpl.removeItem(adminitem); // user cannot delete this Assert.fail("Should have thrown SecurityException"); } catch (SecurityException e) { Assert.assertNotNull(e.getMessage()); log.info("Could not remove item (this is correct)"); } try { logicImpl.removeItem(adminitem); // permed user cannot delete this Assert.fail("Should have thrown SecurityException"); } catch (SecurityException e) { Assert.assertNotNull(e.getMessage()); log.info("Could not remove item (this is correct)"); } CrudPlusItem item; logicImpl.removeItem(adminitem); // admin can delete this item = logicImpl.getItemById(adminitem.getId()); Assert.assertNull(item); logicImpl.removeItem(maintitem); // permed user can delete this item = logicImpl.getItemById(maintitem.getId()); Assert.assertNull(item); logicImpl.removeItem(item1); // user can delete this item = logicImpl.getItemById(item1.getId()); Assert.assertNull(item); // verify the mock objects were used userDirectoryServiceControl.verify(); securityServiceControl.verify(); toolManagerControl.verify(); siteServiceControl.verify(); }