List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:org.opencastproject.remotetest.server.RetryStrategiesTest.java
@Test public void testRetry() throws Exception { // ------------------------------------------------- // FIRST WORKFLOW (RETRY) // ------------------------------------------------- // Start a workflow instance via the rest endpoint HttpPost postStart = new HttpPost(BASE_URL + "/workflow/start"); List<NameValuePair> formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("definition", getSampleWorkflowDefinition("workflow-retry.xml"))); formParams.add(new BasicNameValuePair("mediapackage", getSampleMediaPackage())); formParams.add(new BasicNameValuePair("properties", "this=that")); postStart.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8")); // Grab the new workflow instance from the response String postResponse = EntityUtils.toString(client.execute(postStart).getEntity()); String id = getWorkflowInstanceId(postResponse); // Ensure that the workflow finishes successfully int attempts = 0; while (true) { if (++attempts == 20) Assert.fail("workflow rest endpoint test has hung"); HttpGet getWorkflowMethod = new HttpGet(BASE_URL + "/workflow/instance/" + id + ".xml"); String getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); String state = getWorkflowInstanceStatus(getResponse); if ("FAILED".equals(state)) break; if ("SUCCEEDED".equals(state)) Assert.fail("workflow instance " + id + " succeeded"); if ("PAUSED".equals(state)) Assert.fail("workflow instance " + id + " paused"); System.out.println("workflow " + id + " is " + state); Thread.sleep(5000);//www . j ava 2 s. c o m } // Get Ingest service state // Should be WARNING HttpGet getWorkflowMethod = new HttpGet( BASE_URL + "/services/services.json?serviceType=org.opencastproject.inspection&host=" + BASE_URL); String jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); String state = new JSONObject(jsonResponse).getJSONObject("services").getJSONObject("service") .getString("service_state"); Assert.assertEquals("WARNING", state); // Get the number of failed on Ingest service, // Should be 1 getWorkflowMethod = new HttpGet(BASE_URL + "/services/count?serviceType=org.opencastproject.inspection"); String getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); logger.debug("Job count response: {}", getResponse); Assert.assertEquals(2, Integer.parseInt(getResponse) - initCount); // ------------------------------------------------- // SECOND WORKFLOW (NONE) // ------------------------------------------------- // Start a workflow instance via the rest endpoint postStart = new HttpPost(BASE_URL + "/workflow/start"); formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("definition", getSampleWorkflowDefinition("workflow-none.xml"))); formParams.add(new BasicNameValuePair("mediapackage", getSecondSampleMediaPackage())); formParams.add(new BasicNameValuePair("properties", "this=that")); postStart.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8")); // Grab the new workflow instance from the response postResponse = EntityUtils.toString(client.execute(postStart).getEntity()); id = getWorkflowInstanceId(postResponse); // Ensure that the workflow finishes successfully attempts = 0; while (true) { if (++attempts == 20) Assert.fail("workflow rest endpoint test has hung"); getWorkflowMethod = new HttpGet(BASE_URL + "/workflow/instance/" + id + ".xml"); getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); state = getWorkflowInstanceStatus(getResponse); if ("FAILED".equals(state)) break; if ("SUCCEEDED".equals(state)) Assert.fail("workflow instance " + id + " succeeded"); if ("PAUSED".equals(state)) Assert.fail("workflow instance " + id + " paused"); System.out.println("workflow " + id + " is " + state); Thread.sleep(5000); } // Get Ingest service state // Should be WARNING getWorkflowMethod = new HttpGet( BASE_URL + "/services/services.json?serviceType=org.opencastproject.inspection&host=" + BASE_URL); jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); state = new JSONObject(jsonResponse).getJSONObject("services").getJSONObject("service") .getString("service_state"); Assert.assertEquals("ERROR", state); // Get available ingest service, because ingest service is in ERROR mode he is not returned getWorkflowMethod = new HttpGet( BASE_URL + "/services/available.json?serviceType=org.opencastproject.inspection"); jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); Assert.assertNull(new JSONObject(jsonResponse).optJSONObject("services")); // Get the number of failed on Ingest service, // Should be 1 getWorkflowMethod = new HttpGet(BASE_URL + "/services/count?serviceType=org.opencastproject.inspection"); getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); logger.debug("Job count response: {}", getResponse); Assert.assertEquals(3, Integer.parseInt(getResponse) - initCount); }
From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.EnhancedPushTests.java
@SuppressWarnings("deprecation") public void testRegisterUnregisterNativeCallback() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); Context context = getInstrumentation().getTargetContext(); final SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()); final Container container = new Container(); final String handle = "handle"; String registrationId = "registrationId"; MobileServiceClient client = new MobileServiceClient(appUrl, appKey, context); client = client.withFilter(getUpsertTestFilter(registrationId)); final MobileServicePush push = client.getPush(); forceRefreshSync(push, handle);//from w w w .ja v a 2 s . com push.register(handle, new String[] { "tag1" }, new RegistrationCallback() { @Override public void onRegister(Registration registration, Exception exception) { if (exception != null) { container.exception = exception; latch.countDown(); } else { container.registrationId = registration.getRegistrationId(); container.storedRegistrationId = sharedPreferences.getString( STORAGE_PREFIX + REGISTRATION_NAME_STORAGE_KEY + DEFAULT_REGISTRATION_NAME, null); push.unregister(new UnregisterCallback() { @Override public void onUnregister(Exception exception) { if (exception != null) { container.exception = exception; } else { container.unregister = sharedPreferences.getString( STORAGE_PREFIX + REGISTRATION_NAME_STORAGE_KEY + DEFAULT_REGISTRATION_NAME, null); } latch.countDown(); } }); } } }); latch.await(); // Asserts Exception exception = container.exception; if (exception != null) { fail(exception.getMessage()); } else { Assert.assertEquals(registrationId, container.storedRegistrationId); Assert.assertEquals(registrationId, container.registrationId); Assert.assertNull(container.unregister); } }
From source file:com.netflix.curator.framework.recipes.locks.TestReaper.java
private void testWithEphemerals(String namespace) throws Exception { Timing timing = new Timing(); Reaper reaper = null;//from w ww .jav a 2 s .co m CuratorFramework client2 = null; CuratorFramework client = makeClient(timing, namespace); try { client.start(); client.create().creatingParentsIfNeeded().forPath("/one/two/three"); Assert.assertNotNull(client.checkExists().forPath("/one/two/three")); client2 = makeClient(timing, namespace); client2.start(); for (int i = 0; i < 10; ++i) { client2.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/one/two/three/foo-"); } reaper = new Reaper(client, 100); reaper.start(); reaper.addPath("/one/two/three"); timing.sleepABit(); Assert.assertNotNull(client.checkExists().forPath("/one/two/three")); client2.close(); // should clear ephemerals client2 = null; Thread.sleep(timing.session()); timing.sleepABit(); Assert.assertNull(client.checkExists().forPath("/one/two/three")); } finally { IOUtils.closeQuietly(reaper); IOUtils.closeQuietly(client2); IOUtils.closeQuietly(client); } }
From source file:org.obiba.onyx.core.etl.participant.impl.ParticipantReaderTest.java
/** * Tests processing of an appointment list where a mandatory attribute (Enrollment ID, at line 4) has not been * assigned a value. Reader should not return an error as it is a validation done in the ParticipantProcessor. * // w w w . ja v a2s. c o m * @throws IOException if the appointment list could not be read */ @Test public void testProcessWithMissingMandatoryAttributeValue() throws IOException { ParticipantReaderForTest reader = createParticipantReaderForTest(1, 2, 3, false, TEST_RESOURCES_DIR + "/appointmentList_missingMandatoryAttributeValue.xls"); reader.open(context); List<Participant> participants = new ArrayList<Participant>(); try { while (reader.getRow() != null) { Participant participant = reader.read(); if (participant != null) participants.add(participant); } } catch (Exception e) { throw new RuntimeException(e); } Assert.assertEquals(3, participants.size()); Assert.assertEquals("Tremblay", participants.get(0).getLastName()); Assert.assertEquals("100001", participants.get(0).getEnrollmentId()); Assert.assertEquals("Smith", participants.get(1).getLastName()); Assert.assertNull(participants.get(1).getEnrollmentId()); Assert.assertEquals("Casserly", participants.get(2).getLastName()); Assert.assertEquals("100003", participants.get(2).getEnrollmentId()); }
From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java
protected boolean containsServiceConfig(BeanFactory beanFactory, Collection<RemoteServiceConfig> serviceConfigs, Class<?> serviceClass) { for (RemoteServiceConfig serviceConfig : serviceConfigs) { if (serviceClass.equals(beanFactory.getType(serviceConfig.getServiceName()))) { Assert.assertNull(serviceConfig.getResponseCompressionEnabled()); Assert.assertNull(serviceConfig.getRpcTokenProtectionEnabled()); Assert.assertNull(serviceConfig.getRpcTokenValidatorName()); Assert.assertNull(serviceConfig.getServiceInterface()); Assert.assertNull(serviceConfig.getRelativePath()); return true; }/* w w w .j a va 2 s .c om*/ } return false; }
From source file:org.openmrs.module.printer.PrinterServiceComponentTest.java
@Test public void shouldReturnNullIfNoHandlerMatchingName() { PrintHandler printHandler = printerService.getRegisteredPrintHandlerByName("bogus name"); Assert.assertNull(printHandler); }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
@Test public void testUnsubcribeShouldMakeRegIdNullToIdsAvailable() throws Exception { GetIdsAvailable();//w w w. j av a 2 s . c o m OneSignalInit(); threadAndTaskWait(); Assert.assertEquals(ShadowPushRegistratorGPS.regId, ShadowOneSignalRestClient.lastPost.getString("identifier")); Robolectric.getForegroundThreadScheduler().runOneTask(); Assert.assertEquals(ShadowPushRegistratorGPS.regId, getCallBackRegId); OneSignal.setSubscription(false); GetIdsAvailable(); threadAndTaskWait(); Assert.assertNull(getCallBackRegId); }
From source file:com.netflix.curator.framework.recipes.locks.TestReaper.java
private void testBasic(String namespace) throws Exception { Timing timing = new Timing(); Reaper reaper = null;/*from ww w . j a va 2s . co m*/ CuratorFramework client = makeClient(timing, namespace); try { client.start(); client.create().creatingParentsIfNeeded().forPath("/one/two/three"); Assert.assertNotNull(client.checkExists().forPath("/one/two/three")); reaper = new Reaper(client, 100); reaper.start(); reaper.addPath("/one/two/three"); timing.sleepABit(); Assert.assertNull(client.checkExists().forPath("/one/two/three")); } finally { IOUtils.closeQuietly(reaper); IOUtils.closeQuietly(client); } }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
@Test public void testSetSubscriptionShouldNotOverrideSubscribeError() throws Exception { OneSignalInitWithBadProjectNum();/*www .java2 s . co m*/ threadAndTaskWait(); // Should not try to update server ShadowOneSignalRestClient.lastPost = null; OneSignal.setSubscription(true); Assert.assertNull(ShadowOneSignalRestClient.lastPost); // Restart app - Should omit notification_types StaticResetHelper.restSetStaticFields(); OneSignalInitWithBadProjectNum(); threadAndTaskWait(); Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("notification_types")); }
From source file:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java
@Test public void testGetPaperRecordRequestById() { PaperRecordRequest request = paperRecordService.getPaperRecordRequestById(1); Assert.assertNotNull(request);/* ww w . j a v a 2 s . c o m*/ Assert.assertEquals(new Integer(7), request.getPaperRecord().getPatientIdentifier().getPatient().getId()); Assert.assertEquals(new Integer(1), request.getPaperRecord().getRecordLocation().getId()); Assert.assertEquals(new Integer(2), request.getRequestLocation().getId()); Assert.assertEquals("CATBALL", request.getPaperRecord().getPatientIdentifier().getIdentifier()); Assert.assertEquals(PaperRecordRequest.Status.SENT, request.getStatus()); Assert.assertNull(request.getAssignee()); }