List of usage examples for junit.framework AssertionFailedError AssertionFailedError
public AssertionFailedError(String message)
From source file:my.FileBasedTestCase.java
protected void checkWrite(Writer output) throws Exception { try {//from w ww .ja v a 2 s .c om new java.io.PrintWriter(output).write('a'); } catch (Throwable t) { throw new AssertionFailedError( "The copy() method closed the stream " + "when it shouldn't have. " + t.getMessage()); } }
From source file:net.sourceforge.vulcan.web.struts.MockApplicationContextStrutsTestCase.java
@Override public final void verifyForward(String forwardName) throws AssertionFailedError { if (resultForward == null) { throw new AssertionFailedError("actionForward is null"); }/*w ww . j a va 2 s. c o m*/ assertEquals(forwardName, resultForward.getName()); }
From source file:net.sourceforge.vulcan.web.struts.MockApplicationContextStrutsTestCase.java
@Override public final void verifyForwardPath(String forwardPath) throws AssertionFailedError { if (resultForward == null) { throw new AssertionFailedError("actionForward is null"); }/*w ww . jav a 2s.com*/ assertEquals(forwardPath, resultForward.getPath()); }
From source file:com.owncloud.android.lib.test_project.test.GetShareesTest.java
/** * Test get federated sharees//from w w w. j av a 2s. c o m * * Requires OC server 8.2 or later */ public void testGetFederatedShareesOperation() { Log.v(LOG_TAG, "testGetFederatedSharees in"); /// successful cases // search for sharees including "@" GetRemoteShareesOperation getShareesOperation = new GetRemoteShareesOperation("@", 1, 50); RemoteOperationResult result = getShareesOperation.execute(mClient); JSONObject resultItem; JSONObject value; int type; int fedCount = 0; assertTrue(result.isSuccess() && result.getData().size() > 0); try { for (int i = 0; i < result.getData().size(); i++) { resultItem = (JSONObject) result.getData().get(i); value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); if (type == ShareType.FEDERATED.getValue()) { fedCount++; } } assertTrue(fedCount > 0); } catch (JSONException e) { AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); afe.setStackTrace(e.getStackTrace()); throw afe; } // search for 'admin' sharee from external server - expecting at least 1 result String remoteSharee = "admin@" + mServerUri2.split("//")[1]; getShareesOperation = new GetRemoteShareesOperation(remoteSharee, 1, 50); result = getShareesOperation.execute(mClient); assertTrue(result.isSuccess() && result.getData().size() > 0); /// failed cases // search for sharees including wrong page values getShareesOperation = new GetRemoteShareesOperation("@", 0, 50); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); getShareesOperation = new GetRemoteShareesOperation("@", 1, 0); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); }
From source file:org.opennms.core.test.MockLogAppender.java
/** * <p>assertNotGreaterOrEqual</p> * * @throws junit.framework.AssertionFailedError if any. *//*from w ww . ja v a 2 s . c o m*/ public static void assertNotGreaterOrEqual(final Level level) throws AssertionFailedError { if (!isLoggingSetup()) { throw new AssertionFailedError("MockLogAppender has not been initialized"); } /* try { Thread.sleep(500); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } */ final LoggingEvent[] events = getEventsGreaterOrEqual(level); if (events.length == 0) { return; } StringBuffer message = new StringBuffer("Log messages at or greater than the log level ").append(level) .append(" received:"); for (final LoggingEvent event : events) { message.append("\n\t[").append(event.getLevel()).append("] ").append(event.getLoggerName()).append(": ") .append(event.getMessage()); } throw new AssertionFailedError(message.toString()); }
From source file:fi.hsl.parkandride.itest.AbstractReportingITest.java
protected void withWorkbook(Response response, Consumer<Workbook> workbookConsumer) { try (Workbook workbook = readWorkbookFrom(response)) { workbookConsumer.accept(workbook); } catch (IOException e) { e.printStackTrace();//from w ww. j a v a2 s . c om throw new AssertionFailedError(e.getMessage()); } }
From source file:com.mtgi.analytics.servlet.BehaviorTrackingFilterTest.java
/** test the graceful handling of various runtime errors by the filter */ @Test//from ww w .j a va 2 s . co m public void testExceptionHandling() throws Exception { TestServlet.servletException = new ServletException("servlet boom"); try { webClient.getPage(baseUrl + "/app/foo.ext?param1=SE"); fail("non-OK status should have been sent back by test servlet"); } catch (FailingHttpStatusCodeException expected) { assertNotNull("Servlet was hit", servlet); assertEquals("Server status code sent back", 500, expected.getStatusCode()); } TestServlet.ioException = new IOException("IO boom"); try { webClient.getPage(baseUrl + "/app/foo.ext?param1=IOE"); fail("non-OK status should have been sent back by test servlet"); } catch (FailingHttpStatusCodeException expected) { assertNotNull("Servlet was hit", servlet); assertEquals("Server status code sent back", 500, expected.getStatusCode()); } TestServlet.runtimeException = new NullPointerException("Should have written a unit test"); try { webClient.getPage(baseUrl + "/app/foo.ext?param1=RE"); fail("non-OK status should have been sent back by test servlet"); } catch (FailingHttpStatusCodeException expected) { assertNotNull("Servlet was hit", servlet); assertEquals("Server status code sent back", 500, expected.getStatusCode()); } TestServlet.error = new AssertionFailedError("Might as well try to trap these"); try { webClient.getPage(baseUrl + "/app/foo.ext?param1=E"); fail("non-OK status should have been sent back by test servlet"); } catch (FailingHttpStatusCodeException expected) { assertNotNull("Servlet was hit", servlet); assertEquals("Server status code sent back", 500, expected.getStatusCode()); } //verify correct event data written to the DB manager.flush(); assertEventDataMatches("BehaviorTrackingFilterTest.testExceptionHandling-result.xml"); }
From source file:com.owncloud.android.lib.test_project.test.MoveFileTest.java
public MoveFileTest() { super();//from w ww. ja va2s .c o m Protocol pr = Protocol.getProtocol("https"); if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) { try { ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory(); Protocol.registerProtocol("https", new Protocol("https", psf, 443)); } catch (GeneralSecurityException e) { throw new AssertionFailedError("Self-signed confident SSL context could not be loaded"); } } }
From source file:com.owncloud.android.lib.test_project.test.CopyFileTest.java
public CopyFileTest() { super(TestActivity.class); Protocol pr = Protocol.getProtocol("https"); if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) { try {//from ww w .j a v a 2 s . co m ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory(); Protocol.registerProtocol("https", new Protocol("https", psf, 443)); } catch (GeneralSecurityException e) { throw new AssertionFailedError("Self-signed confident SSL context could not be loaded"); } } }
From source file:fi.hsl.parkandride.itest.AbstractReportingITest.java
protected Workbook readWorkbookFrom(Response whenPostingToReportUrl) { try (ByteArrayInputStream bais = new ByteArrayInputStream(whenPostingToReportUrl.asByteArray())) { return WorkbookFactory.create(bais); } catch (IOException | InvalidFormatException e) { e.printStackTrace();//from w w w . j a v a 2s .co m throw new AssertionFailedError(e.getMessage()); } }