List of usage examples for junit.framework Assert fail
static public void fail()
From source file:com.onesite.sdk.test.api.SessionApiTest.java
@Test public void testJoinCrossDomain() { String callbackUrl = "http://example.com"; String domain = "twilight-fans.net"; SessionApi api = new SessionApi(); try {/*from w w w . ja v a2 s . c o m*/ URL redirectUrl = api.joinCrossDomain(callbackUrl, domain, ip, agent); System.out.println("Join Cross Domain Redirect Url"); System.out.println(redirectUrl.toString()); Assert.assertFalse(StringUtils.isEmpty(redirectUrl.toString())); } catch (Exception e) { Assert.fail(); } }
From source file:org.opencastproject.remotetest.server.ComposerRestEndpointTest.java
@Test public void testEncodeVideoTracks() throws Exception { // Start an encoding job via the rest endpoint HttpPost postEncode = new HttpPost(ComposerResources.getServiceUrl() + "encode"); List<NameValuePair> formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("sourceTrack", SampleUtils.generateVideoTrack(BASE_URL))); formParams.add(new BasicNameValuePair("profileId", "flash.http")); postEncode.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8")); // Grab the job from the response HttpResponse postResponse = client.execute(postEncode); Assert.assertEquals(200, postResponse.getStatusLine().getStatusCode()); String postResponseXml = EntityUtils.toString(postResponse.getEntity()); String jobId = getJobId(postResponseXml); // Poll the service for the status of the job. while (!JobUtils.isJobInState(jobId, "FINISHED")) { Thread.sleep(2000); // wait and try again System.out.println("Waiting for encoding job " + jobId + " to finish"); if (JobUtils.isJobInState(jobId, "FAILED")) { Assert.fail(); }/*from w w w .j a v a2s. c o m*/ } }
From source file:de.unentscheidbar.validation.swing.trigger.DocumentChangeTriggerTest.java
@Override protected void provokeTrigger(Iterable<JTextComponent> components) { for (final JTextComponent c : components) { runInEdt(new Callable<Void>() { @Override/* w w w. j a v a 2 s . c o m*/ public Void call() throws Exception { Document doc = c.getDocument(); switch (rnd.nextInt(3)) { case 0: doc.remove(doc.getStartPosition().getOffset(), doc.getLength() / 2); break; case 1: doc.insertString(rnd.nextInt(Math.max(1, doc.getStartPosition().getOffset())), RandomStringUtils.randomAlphanumeric(1 + rnd.nextInt(10)), null); break; case 2: c.setText(UUID.randomUUID().toString()); break; default: Assert.fail(); } return null; } }); } drainEventQueue(); }
From source file:com.nestlabs.sdk.StructureAndroidTest.java
@Test public void testStructureToParcel() { try {//from ww w.j a v a 2 s . c om String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_STRUCTURE_JSON), "utf-8"); Structure structure = mapper.readValue(json, Structure.class); Parcel parcel = Parcel.obtain(); structure.writeToParcel(parcel, 0); parcel.setDataPosition(0); Structure structureFromParcel = Structure.CREATOR.createFromParcel(parcel); assertEquals(structure, structureFromParcel); assertEquals(structureFromParcel.getStructureId(), "VqFabWH21nwVyd4RWgJgNb292wa7hG"); assertEquals(structureFromParcel.getThermostats().size(), 1); assertEquals(structureFromParcel.getThermostats().get(0), "peyiJNo0IldT2YlIVtYaGQ"); assertEquals(structureFromParcel.getSmokeCoAlarms().size(), 1); assertEquals(structureFromParcel.getSmokeCoAlarms().get(0), "RTMTKxsQTCxzVcsySOHPxKoF4OyCifrs"); assertEquals(structureFromParcel.getCameras().size(), 1); assertEquals(structureFromParcel.getCameras().get(0), "awJo6rHX"); assertEquals(structureFromParcel.getDevices().size(), 1); assertEquals(structureFromParcel.getAway(), "home"); assertEquals(structureFromParcel.getName(), "Home"); assertEquals(structureFromParcel.getCountryCode(), "US"); assertEquals(structureFromParcel.getPostalCode(), "94304"); assertEquals(structureFromParcel.getPeakPeriodStartTime(), "2015-10-31T23:59:59.000Z"); assertEquals(structureFromParcel.getPeakPeriodEndTime(), "2015-10-31T23:59:59.000Z"); assertEquals(structureFromParcel.getTimeZone(), "America/Los_Angeles"); assertNotNull(structureFromParcel.getEta()); Structure.ETA eta = structureFromParcel.getEta(); assertEquals(eta.getTripId(), "myTripHome1024"); assertEquals(eta.getEstimatedArrivalWindowBegin(), "2015-10-31T22:42:59.000Z"); assertEquals(eta.getEstimatedArrivalWindowEnd(), "2015-10-31T23:59:59.000Z"); assertEquals(structureFromParcel.getRhrEnrollment(), true); assertNotNull(structureFromParcel.getWheres()); assertEquals(structureFromParcel.getWheres().size(), 1); Structure.Where where = structureFromParcel.getWheres().get("Fqp6wJIX"); assertNotNull(where); assertEquals(where.getWhereId(), "Fqp6wJIX"); assertEquals(where.getName(), "Bedroom"); } catch (IOException e) { e.printStackTrace(); Assert.fail(); } }
From source file:edu.cuny.cat.market.FourHeapTest.java
public void testRandom() { System.out.println("\n>>>>>>>>>\t " + "testRandom() \n"); int matches = 0; try {//from w w w . ja v a 2 s. c om Shout testRemoveShout = null, testRemoveShout2 = null; for (int round = 0; round < 700; round++) { if (testRemoveShout != null) { shoutEngine.removeShout(testRemoveShout); shoutEngine.removeShout(testRemoveShout2); } for (int shout = 0; shout < 200; shout++) { shoutEngine.newShout(randomShout()); } shoutEngine.newShout(testRemoveShout = randomShout()); testRemoveShout2 = (Shout) testRemoveShout.clone(); testRemoveShout2 = new Shout(testRemoveShout.getQuantity(), testRemoveShout.getPrice(), !testRemoveShout.isBid()); shoutEngine.newShout(testRemoveShout2); if ((round & 0x01) > 0) { continue; } final List<Shout> matched = shoutEngine.getMatchedShouts(); final Iterator<Shout> i = matched.iterator(); while (i.hasNext()) { matches++; final Shout bid = i.next(); final Shout ask = i.next(); Assert.assertTrue(bid.isBid()); Assert.assertTrue(ask.isAsk()); Assert.assertTrue(bid.getPrice() >= ask.getPrice()); // System.out.print(bid + "/" + ask + " "); } // System.out.println(""); } } catch (final Exception e) { shoutEngine.printState(); e.printStackTrace(); Assert.fail(); } System.out.println("Matches = " + matches); }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void databaseMetaDataGetTables() { //clouddb,ARTICLE_LOOKUP,starschema.net,[Ljava.lang.String;@9e8424 ResultSet result = null;/*from w ww .j a v a 2 s .c om*/ try { //Function call getColumns //catalog:null, //schemaPattern: starschema_net__clouddb, //tableNamePattern:OUTLET_LOOKUP, columnNamePattern: null //result = con.getMetaData().getTables("OUTLET_LOOKUP", null, "starschema_net__clouddb", null ); result = con.getMetaData().getColumns(null, "starschema_net__clouddb", "OUTLET_LOOKUP", null); //Function call getTables(catalog: ARTICLE_COLOR_LOOKUP, schemaPattern: null, tableNamePattern: starschema_net__clouddb, types: TABLE , VIEW , SYSTEM TABLE , SYNONYM , ALIAS , ) } catch (SQLException e) { e.printStackTrace(); Assert.fail(); } try { Assert.assertTrue(result.first()); while (!result.isAfterLast()) { String toprint = ""; toprint += result.getString(1) + " , "; toprint += result.getString(2) + " , "; toprint += result.getString(3) + " , "; toprint += result.getString(4) + " , "; toprint += result.getString(5) + " , "; toprint += result.getString(6) + " , "; toprint += result.getString(7) + " , "; toprint += result.getString(8) + " , "; toprint += result.getString(9) + " , "; toprint += result.getString(10); System.err.println(toprint); result.next(); } } catch (SQLException e) { e.printStackTrace(); Assert.fail(); } }
From source file:interactivespaces.util.web.HttpClientHttpContentCopierTest.java
/** * Test having a failure copying from the remote and then attempting to read * again./*from w ww .j av a 2 s . c om*/ * * @throws Exception */ @Test public void testCopyFromFailure() throws Exception { File destination = getTempFile(); String sourceUri = getUrlPrefix(); try { copier.copy(sourceUri + "error", destination); Assert.fail(); } catch (Exception e) { // Expected } testCopyFromSuccessfulTransfer(destination, sourceUri); }
From source file:misc.TestUtils.java
public static void assertEqualFields(Object expected, Object actual) { if (expected == actual) return;/*from w ww. j a va2s.c om*/ if (expected == null ^ actual == null) Assert.fail(); Assert.assertEquals(fieldsToString(expected), fieldsToString(actual)); }
From source file:com.brienwheeler.lib.test.stepper.SteppableThreadTest.java
@Test public void testWaitDoneBrokenBarrier() throws InterruptedException { SteppableThread stepper = new SteppableOneStep(); interruptInWait(stepper, TestMode.WAITDONE); try {// w ww . j a v a 2 s.com stepper.waitDone(); Assert.fail(); } catch (RuntimeException e) { Assert.assertEquals(BrokenBarrierException.class, e.getCause().getClass()); } ((CyclicBarrier) ReflectionTestUtils.getField(stepper, "stepDone")).reset(); stepper.start(); stepper.releaseAndWaitDone(); stepper.releaseAndJoin(); }
From source file:misc.TestUtils.java
public static void assertToStringEquals(Object a, Object b) { if (a == null ^ b == null) Assert.fail(); if (a == null && b == null) return;/*from ww w. ja v a 2 s . co m*/ Assert.assertEquals(a.toString(), b.toString()); }