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(Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:org.openmrs.module.formfilter.web.controller.AddFormFilterPropertyControllerTest.java

/**
 * @see {@link AddFormFilterPropertyController#onSubmit(FormFilterProperty, org.springframework.validation.BindingResult, org.springframework.web.bind.support.SessionStatus, javax.servlet.http.HttpServletRequest) }
 *///ww  w. jav  a2 s.  c  om
@Test
@Verifies(value = "should add new FormFilterProperty", method = "onSubmit(FormFilterProperty, org.springframework.validation.BindingResult, org.springframework.web.bind.support.SessionStatus, javax.servlet.http.HttpServletRequest)")
public void onSubmit_shouldAddNewFormFilterProperty() {

    AddFormFilterPropertyController controller = new AddFormFilterPropertyController();

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("formFilterId", "1");
    request.addParameter("propertyType", "AgeProperty");
    request.addParameter("minimumAge", "10");
    request.addParameter("maximumAge", "30");

    FormFilterProperty formFilterProperty = new FormFilterProperty();
    formFilterProperty.setFilterName("Test Filter");
    formFilterProperty.setFilterDescription("This filter used for testing.");

    controller.onSubmit(formFilterProperty, null, null, request);

    FormFilterService formFilterService = Context.getService(FormFilterService.class);

    FormFilterProperty temp = new FormFilterProperty();
    Set<FormFilterProperty> assignedFilters = formFilterService.getFormFilter(1).getFormFilterProperties();
    for (FormFilterProperty filterProperty : assignedFilters) {
        if (filterProperty.getFilterName() == "Test Filter")
            temp = filterProperty;
    }

    Assert.assertNotNull(temp);
}

From source file:de.hybris.platform.integration.cis.payment.strategies.impl.CisPaymentResponseInterpretationStrategyIntegrationTest.java

@Test
public void testMissingPaymentDetailsResponseInterpretation() throws Exception {
    try {/*ww  w .  j a v  a 2  s .  c  o m*/
        TestUtils.disableFileAnalyzer("expected stacktrace from hystrix");
        final Map<String, PaymentErrorField> errors = new HashMap<String, PaymentErrorField>();

        final RestResponse hpfUrl = this.paymentClient.pspUrl("test");
        final String testClientRef = "JUNIT-TEST-CLIENT";
        final List<BasicNameValuePair> formDataMissingDetails = CisPaymentIntegrationTestHelper
                .getFormDataMapMissingDetails();
        final Map<String, String> profileCreationResponse = CisPaymentIntegrationTestHelper
                .createNewProfile(hpfUrl.getLocation().toASCIIString(), formDataMissingDetails);

        final CreateSubscriptionResult subscriptionResult = cisPaymentResponseInterpretation
                .interpretResponse(profileCreationResponse, testClientRef, errors);
        Assert.assertNotNull(subscriptionResult);
        Assert.assertNotNull(subscriptionResult.getDecision());
        Assert.assertNotNull(subscriptionResult.getReasonCode());

        if (!subscriptionResult.getReasonCode().equals(CispaymentConstants.HYSTRIX_FALLBACK_ERR_CODE)) {
            Assert.assertEquals(DecisionsEnum.REJECT.name(), subscriptionResult.getDecision());
        } else
        // Hystrix fallback unexpectedly executed. Assert Decision was set to ERROR
        {
            Assert.assertEquals(DecisionsEnum.ERROR.name(), subscriptionResult.getDecision());
        }
    } finally {
        TestUtils.enableFileAnalyzer();
    }
}

From source file:io.cloudslang.engine.node.services.WorkerNodeServiceTest.java

@Test
public void createNode() throws Exception {
    workerNodeService.create("H3", "H3", "amit.levin", "c:/dir");
    verify(workerLockService).create("H3");
    WorkerNode worker = workerNodeService.readByUUID("H3");
    Assert.assertNotNull(worker);
}

From source file:io.cloudslang.engine.queue.repositories.ExecutionQueueRepositoryTest.java

@Test
public void testGetFinishedExecStateIds() {
    List<ExecutionMessage> msg = new ArrayList<>();
    msg.add(generateFinishedMessage(1L, 1));
    msg.add(generateFinishedMessage(1L, 2));
    msg.add(generateFinishedMessage(2L, 3));
    msg.add(generateFinishedMessage(3L, 4));
    executionQueueRepository.insertExecutionQueue(msg, 1L);

    Set<Long> result = executionQueueRepository.getFinishedExecStateIds();
    Assert.assertNotNull(result);
    Assert.assertEquals(3, result.size());
}

From source file:de.akquinet.chameria.activation.ActivationTest.java

@Test
public void startChameriaWithTwoActivations() throws Exception {

    ChameRIA chameleon = new ChameRIA("target/core", true, null, APP_2_DIRECTORY, null, null);
    Framework framework = chameleon.start(new String[] { "-open", "bla" });

    ServiceReference[] refs = framework.getBundleContext()
            .getServiceReferences(ActivationService.class.getName(), null);
    Assert.assertNotNull(refs);

    for (ServiceReference ref : refs) {
        ActivationService svc = (ActivationService) framework.getBundleContext().getService(ref);
        count = svc.getClass().getField("activation_count");
        args = svc.getClass().getField("last_args");
        open = svc.getClass().getField("open");

        Assert.assertEquals(1, count.get(svc));
        Assert.assertEquals(2, ((String[]) args.get(svc)).length);
        Assert.assertEquals("bla", open.get(svc));
    }//from   w  w  w .j  av a  2  s .c  om

    chameleon.stop();

}

From source file:org.callimachusproject.test.WebResource.java

public WebResource create(Map<String, String> headers, String type, byte[] body) throws IOException {
    HttpURLConnection con = (HttpURLConnection) new URL(uri).openConnection();
    con.setRequestMethod("POST");
    for (Map.Entry<String, String> e : headers.entrySet()) {
        con.setRequestProperty(e.getKey(), e.getValue());
    }//from  ww  w  . j a  va2  s .co m
    con.setRequestProperty("Content-Type", type);
    con.setDoOutput(true);
    OutputStream out = con.getOutputStream();
    try {
        out.write(body);
    } finally {
        out.close();
    }
    Assert.assertEquals(con.getResponseMessage(), 201, con.getResponseCode());
    String header = con.getHeaderField("Location");
    Assert.assertNotNull(header);
    return ref(header);
}

From source file:ejportal.webapp.action.UserActionTest.java

/**
 * Test save conflicting user./*from ww  w  . ja  v a  2 s.  com*/
 * 
 * @throws Exception
 *             the exception
 */
public void testSaveConflictingUser() throws Exception {
    final UserManager userManager = (UserManager) this.applicationContext.getBean("userManager");
    final User user = userManager.getUserByUsername("user");
    user.setPassword("user");
    user.setConfirmPassword("user");
    // e-mail address from existing user
    // User existingUser = (User) userManager.getUsers().get(0);
    final User existingUser = userManager.getUserByUsername("admin");
    user.setEmail(existingUser.getEmail());
    this.action.setUser(user);
    this.action.setFrom("list");

    final Integer originalVersionNumber = user.getVersion();
    this.log.debug("original version #: " + originalVersionNumber);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("encryptPass", "true");
    ServletActionContext.setRequest(request);

    Assert.assertEquals("input", this.action.save());
    Assert.assertNotNull(this.action.getUser());
    Assert.assertEquals(originalVersionNumber, user.getVersion());
    Assert.assertTrue(this.action.hasActionErrors());
}

From source file:com.taobao.ad.jpa.test.RepeatAlarmTest.java

@Test
public void tesUpdateRepeatAlarmStatus() {
    RepeatAlarmDO repeatAlarm = new RepeatAlarmDO();
    repeatAlarm.setJobName("11");
    repeatAlarm.setJobGroup("11");
    repeatAlarm.setStatus(0);/*from   w ww .ja  v a  2 s .  co m*/
    repeatAlarmBO.updateRepeatAlarmStatus(repeatAlarm);

    repeatAlarm = repeatAlarmBO.findRepeatAlarms(repeatAlarm).get(0);
    Assert.assertNotNull(repeatAlarm);
    Assert.assertEquals(1, repeatAlarm.getId().intValue());
    Assert.assertEquals("11", repeatAlarm.getJobName());
    Assert.assertEquals("11", repeatAlarm.getJobGroup());
    Assert.assertEquals(0, repeatAlarm.getStatus().intValue());
}

From source file:org.netxilia.spi.impl.formula.TestFindAndFilter.java

@Test
public void testFilterValueWrongFormula() throws NetxiliaResourceException, NetxiliaBusinessException {
    ISheet sheet = SheetUtils.sheetWithCell("A1", 200, "A2", "200", "A3", 200.0);
    List<Integer> rows = operations.filter(sheet, new Formula("=A1=300+")).getNonBlocking();
    Assert.assertNotNull(rows);
    Assert.assertEquals(rows.size(), 0);

}

From source file:org.opencastproject.remotetest.server.LtiAuthenticationTest.java

@Test
public void testLtiLaunch() throws Exception {
    // Construct a POST message with the oauth parameters
    String nonce = UUID.randomUUID().toString();
    String timestamp = Long.toString(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
    OAuthMessage oauthMessage = new OAuthMessage(OAuthMessage.POST, Main.BASE_URL + "/lti", null);
    oauthMessage.addParameter(OAuth.OAUTH_CONSUMER_KEY, CONSUMER_KEY);
    oauthMessage.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
    oauthMessage.addParameter(OAuth.OAUTH_NONCE, nonce);
    oauthMessage.addParameter(OAuth.OAUTH_TIMESTAMP, timestamp);

    // Add some LTI parameters
    oauthMessage.addParameter("user_id", LTI_CONSUMER_USER);
    oauthMessage.addParameter("context_id", LTI_CONSUMER_CONTEXT);
    oauthMessage.addParameter("consumer_gui", LTI_CONSUMER_GUID);
    oauthMessage.addParameter("custom_test", "true");

    // Sign the request
    OAuthConsumer consumer = new OAuthConsumer(null, CONSUMER_KEY, CONSUMER_SECRET, null);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    oauthMessage.sign(accessor);//from   w  ww  .j ava2 s  . c o m

    // Get the response
    OAuthResponseMessage oauthResponse = (OAuthResponseMessage) oauthClient.invoke(oauthMessage,
            ParameterStyle.BODY);

    // Make sure we got what we wanted
    Assert.assertEquals(HttpStatus.SC_OK, oauthResponse.getHttpResponse().getStatusCode());
    String cookie = oauthResponse.getHttpResponse().getHeader("Set-Cookie");
    Assert.assertNotNull(cookie);

    String sessionId = cookie.substring(0, cookie.lastIndexOf(";"));

    // Send a GET request to "/info/me.json" using this cookie
    HttpGet get = new HttpGet(Main.BASE_URL + "/info/me.json");
    get.setHeader("Cookie", sessionId);
    HttpResponse httpResponse = httpClient.execute(get);
    String me = EntityUtils.toString(httpResponse.getEntity());
    JSONObject meJson = (JSONObject) new JSONParser().parse(me);

    // Ensure that the "current user" was set by the LTI consumer
    Assert.assertEquals(LTI_USER_PREFIX + LTI_CONSUMER_NAME + LTI_CONSUMER_USER, meJson.get("username"));

    // Send a GET request to "/lti" using this cookie
    get = new HttpGet(Main.BASE_URL + "/lti");
    get.setHeader("Cookie", sessionId);
    httpResponse = httpClient.execute(get);
    String lti = EntityUtils.toString(httpResponse.getEntity());
    JSONObject ltiJson = (JSONObject) new JSONParser().parse(lti);

    // Ensure that the LTI information sent by the tool consumer is available
    Assert.assertEquals(LTI_CONSUMER_CONTEXT, ltiJson.get("context_id"));

    // Make sure we can't use the same nonce twice
    try {
        oauthResponse = (OAuthResponseMessage) oauthClient.invoke(oauthMessage, ParameterStyle.BODY);
        Assert.fail();
    } catch (OAuthProblemException e) {
        // expected
    }
}