Example usage for junit.framework Assert assertNotNull

List of usage examples for junit.framework Assert assertNotNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNotNull.

Prototype

static public void assertNotNull(String message, Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:org.apache.synapse.transport.passthru.config.SourceConfigurationTest.java

@Test
public void testGetHttpParams() throws Exception {
    HttpParams httpParams = sourceConfiguration.getHttpParams();
    Assert.assertNotNull("HTTP Parameters are null.", httpParams);
    String originServer = (String) httpParams.getParameter(HttpProtocolParams.ORIGIN_SERVER);
    Assert.assertEquals("Origin Server isn't correct.", "WSO2-PassThrough-HTTP", originServer);

}

From source file:com.redblackit.war.AppSecurityHttpTest.java

/**
 * Test GET using supplied URL, expectedTitle (to identify login or welcome page), and an indication of whether we
 * should authenticate OK, or not.//w ww. j a  v  a 2  s.  c o m
 *
 * @param url
 * @param expectedTitle
 * @param badClientCertificate
 * @throws Exception
 */
private void testGetUrl(final String url, final String expectedTitle, final boolean badClientCertificate)
        throws Exception {
    StringBuilder sb = new StringBuilder();
    sb.append(":url=").append(url).append(":expectedTitle=").append(expectedTitle)
            .append(":badClientCertificate=").append(badClientCertificate).append(":clientAuthMandatory=")
            .append(clientAuthMandatory);
    final String[] spropkeys = { "user.name", "clientAuthMandatory", "javax.net.ssl.keyStore",
            "javax.net.ssl.keyStorePassword", "javax.net.ssl.trustStore", "javax.net.ssl.trustStorePassword" };
    for (String spropkey : spropkeys) {
        sb.append("\n  [").append(spropkey).append("]=").append(System.getProperty(spropkey));
    }

    WebConversation conversation = new WebConversation();
    WebResponse response = null;
    try {
        response = conversation.getResponse(url);
        if (clientAuthMandatory && badClientCertificate) {
            Assert.fail("expected exception for bad certificate:but got response=" + response + sb);
        } else {
            Assert.assertNotNull("response" + sb, response);
            logger.info(response);

            String respUrl = response.getURL().toString();

            Assert.assertTrue("URL should start with '" + baseHttpsUrl + "' ... but was '" + respUrl + "'",
                    respUrl.startsWith(baseHttpsUrl));
            Assert.assertEquals("Title for response page" + sb, expectedTitle, response.getTitle().trim());
        }

    } catch (IOException se) {
        if (clientAuthMandatory && se instanceof SocketException) {
            logger.debug("expected exception" + sb, se);
            Throwable t = se.getCause();
            while (t instanceof SocketException) {
                t = t.getCause();
            }

            if (t != null) {
                logger.debug("root cause exception" + sb, t);
            }
        } else {
            logger.fatal("unexpected exception:" + sb, se);
            throw new RuntimeException("unexpected exception" + sb, se);
        }

    }
}

From source file:org.thingsplode.server.executors.ExecutorTest.java

@Test
public void testBootNotificationRequest() throws UnknownHostException, InterruptedException, ExecutionException,
        TimeoutException, MessageConversionException {
    Device d = TestFactory.createDevice("test_device_2", "987654321", "1");
    Future<Response> rspHandle = requestGw.execute(
            new BootNotificationRequest(d.getIdentification(), Calendar.getInstance().getTimeInMillis(), d));
    Response rsp = rspHandle.get(30, TimeUnit.SECONDS);
    Assert.assertNotNull("The resposne message cannot be null.", rsp);
    Assert.assertFalse(rsp.isErrorType());
    Assert.assertTrue(rsp.isAcknowledged());
    Assert.assertNotNull("The registration id cannot be null",
            rsp.expectMessageByType(BootNotificationResponse.class).getRegistrationID());
    System.out.println("\n\n RESPONSE");
    System.out.println(rsp.toString());
    System.out.println("\n\n ========");
}

From source file:org.deviceconnect.android.profile.restful.test.NormalPhoneProfileTestCase.java

/**
 * ??()??./*from  w ww  .  j a v  a  2 s . c  om*/
 * <pre>
 * ?HTTP
 * Method: PUT
 * Path: /phone/set?deviceid=xxxx&mode=1
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * </pre>
 */
public void testPutSet002() {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + PhoneProfileConstants.PROFILE_NAME);
    builder.append("/" + PhoneProfileConstants.ATTRIBUTE_SET);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(PhoneProfileConstants.PARAM_MODE + "=1");
    builder.append("&");
    builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken());
    try {
        HttpUriRequest request = new HttpPut(builder.toString());
        JSONObject root = sendRequest(request);
        Assert.assertNotNull("root is null.", root);
        Assert.assertEquals(DConnectMessage.RESULT_OK, root.getInt(DConnectMessage.EXTRA_RESULT));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testEvaluateIntegerWithPortExpression()
        throws ParserConfigurationException, XPathExpressionException, SAXException, IOException {
    PTestServerConfigurationParser p = new PTestServerConfigurationParser();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
            .parse(new ByteArrayInputStream("<ptest-server><port>123</port></ptest-server>".getBytes()));
    Integer result = p.evaluateInteger(p.xpathExpressionPort, document);
    Assert.assertNotNull("The result must not be null", result);
    Assert.assertEquals("The result must be '123'", 123, result.intValue());
}

From source file:org.apache.synapse.transport.passthru.config.BaseConfigurationTest.java

@Test
public void testBuildIOReactorConfig() throws Exception {
    IOReactorConfig config = baseConfiguration.buildIOReactorConfig();
    int expectedIOThreadCount = Runtime.getRuntime().availableProcessors();
    Assert.assertNotNull("I/O Reactor hasn't been initialized.", config);
    Assert.assertEquals("I/O reactor thread count isn't correct.", expectedIOThreadCount,
            config.getIoThreadCount());/*from   w w w.ja va2 s. co  m*/
}

From source file:org.openxdata.server.service.impl.FormDownloadServiceTest.java

@Test
public void testGetFormList_forUserStudy2() throws Exception {
    User user = userService.findUserByUsername("user");
    // user has only one form permission for study2
    List<String> forms = formDownloadService.getFormsDefaultVersionXml(user, 2, null);
    Assert.assertNotNull("There are forms for user user", forms);
    Assert.assertEquals("There is 1 forms under study 2", 1, forms.size());
}