List of usage examples for junit.framework Assert fail
static public void fail()
From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformObjectFacadeStrategyTest.java
@Test public void testDeleteSuccess() throws ObjectNotFoundException { final ModelService modelService = Mockito.mock(ModelService.class); final LabelService labelService = Mockito.mock(LabelService.class); final UserModel user = new UserModel(); user.setName("Test User"); Mockito.doNothing().when(modelService).remove(user); Mockito.when(labelService.getObjectLabel(Mockito.any())).thenReturn(StringUtils.EMPTY); final DefaultPlatformObjectFacadeStrategy strategy = new DefaultPlatformObjectFacadeStrategy(); strategy.setModelService(modelService); strategy.setLabelService(labelService); try {/*from w w w .j a v a2s .c o m*/ strategy.delete(user, null); } catch (final ObjectDeletionException ex) { Assert.fail(); } Mockito.verify(modelService).remove(user); // Assert.assertEquals(user, strategy.delete(user, null)); }
From source file:at.ac.tuwien.ifs.tita.test.service.project.TiTAProjectServiceTest.java
/** * Prepare test./*from ww w . java 2s. c o m*/ */ @Before public void setUp() { p1 = new TiTAProject(); p2 = new TiTAProject(); p3 = new TiTAProject(); try { service.saveProject(p1); service.saveProject(p2); service.saveProject(p3); } catch (Exception e) { Assert.fail(); } }
From source file:com.onesite.sdk.test.api.SessionApiTest.java
@Test public void testCreateActive() { SessionApi api = new SessionApi(); try {/*from w w w . j a v a2 s . c o m*/ User testUser = new User(); testUser.setId(userID); Session testSession = new Session(); testSession.setUser(testUser); testSession.setIp(ip); testSession.setAgent(agent); Map<String, String> data = new HashMap<String, String>(); data.put("alpha", "abc"); data.put("numeric", "123"); data.put("other", "#$%.-"); testSession.setSessionData(data); Session session = api.create(testSession); System.out.println("Active Session"); System.out.println("coreU: " + session.getCoreU()); System.out.println("coreX: " + session.getCoreU()); System.out.println("Data: " + session.getSessionDataSize()); Assert.assertFalse(StringUtils.isEmpty(session.getCoreU())); } catch (Exception e) { Assert.fail(); } }
From source file:com.inmobi.grill.driver.impala.TestImpalaDriver.java
@Test public void testConfigure() { try {/* www. ja v a2 s . c o m*/ Configuration config = new Configuration(); config.set("PORT", "123"); config.set("HOST", "test.com"); TSocket mockSocket = PowerMockito.mock(TSocket.class); TBinaryProtocol mockTProtocol = mock(TBinaryProtocol.class); ImpalaService.Client mockClient = mock(ImpalaService.Client.class); whenNew(TSocket.class).withArguments(config.get("HOST"), config.getInt("PORT", 9999)) .thenReturn(mockSocket); whenNew(TBinaryProtocol.class).withArguments(mockSocket).thenReturn(mockTProtocol); whenNew(ImpalaService.Client.class).withArguments(mockTProtocol).thenReturn(mockClient); this.testInst.configure(config); verifyNew(TSocket.class).withArguments("test.com", 123); verifyNew(TBinaryProtocol.class).withArguments(mockSocket); verifyNew(ImpalaService.Client.class).withArguments(mockTProtocol); Mockito.verify(mockSocket, Mockito.times(1)).open(); } catch (Exception e) { Assert.fail(); } }
From source file:org.jrecruiter.service.UserServiceTest.java
@Test public void testLoadUserByUsername() { final User user = getUser(); try {/* w w w . ja v a 2 s.c o m*/ userService.addUser(user); entityManager.flush(); } catch (DuplicateUserException e) { Assert.fail(); } final UserDetails user2 = userService.loadUserByUsername(user.getUsername()); Assert.assertNotNull(user2); }
From source file:com.brienwheeler.lib.test.stepper.SteppableThreadTest.java
@Test public void testReleaseBrokenBarrier() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); SteppableThread latchStepper = new SteppableWaitForLatch(latch); interruptInWait(latchStepper, TestMode.RELEASE); try {//from ww w . j a v a2 s. c om latchStepper.release(); Assert.fail(); } catch (RuntimeException e) { Assert.assertEquals(BrokenBarrierException.class, e.getCause().getClass()); } ((CyclicBarrier) ReflectionTestUtils.getField(latchStepper, "stepStart")).reset(); latchStepper.start(); latch.countDown(); latchStepper.releaseAndJoin(); }
From source file:com.dianping.dpsf.centralstat.test.CentralStatTestCase.java
@Test public void testFutureTimeout() throws Exception { log.info("$$$$$$$$$$testFutureTimeout"); String ret = null;/*from w w w . j a v a 2 s.com*/ try { CentralStatTestService service = (CentralStatTestService) context .getBean("centralStatTestServiceFuture"); service.invokeFutureTimeOut("testFutureTimeout"); ret = (String) ServiceFutureFactory.getFuture()._get(); Assert.fail(); } catch (Throwable e) { Assert.assertNull(ret); } }
From source file:com.liferay.mobile.push.DeviceRegistrationTest.java
@Test public void unregister() throws Exception { final String registrationId = "123"; register(registrationId);/* ww w . ja v a2 s . c om*/ push.onSuccess(new Push.OnSuccess() { @Override public void onSuccess(JSONObject device) { try { Assert.assertNotNull(device); Assert.assertEquals(registrationId, device.getString("token")); } catch (JSONException je) { Assert.fail(); } } }).unregister(registrationId); Robolectric.runBackgroundTasks(); }
From source file:com.oneops.util.SearchSenderTest.java
@Test public void testQueueFailure() { BrokerService searchBroker = context.getBean("searchBroker", BrokerService.class); try {/*w ww. j a va 2 s . c o m*/ searchBroker.stop(); } catch (Exception e) { Assert.fail(); } try { searchBroker.waitUntilStopped(); if (searchBroker.isStopped()) { MessageData[] dataList = getMessages(); for (MessageData data : dataList) { searchPublisher.publish(data); } Thread.sleep(2000); consumer.startRecording(); searchBroker.start(true); searchBroker.waitUntilStarted(5000); if (searchBroker.isStarted()) { await().atMost(10, TimeUnit.SECONDS).until(() -> (consumer.getCounter() == 3)); LinkedList<MessageData> list = consumer.getMessages(); assertMessages(dataList, list.toArray(new MessageData[] {})); } consumer.reset(); // send messages again for (MessageData data : dataList) { searchPublisher.publish(data); } await().atMost(10, TimeUnit.SECONDS).until(() -> (consumer.getCounter() == 3)); LinkedList<MessageData> list = consumer.getMessages(); assertMessages(dataList, list.toArray(new MessageData[] {})); } } catch (Exception e) { Assert.fail(e.getMessage()); } }
From source file:com.siberhus.tdfl.DflSimpleTest.java
@Test public void testStopLoadingFile() throws DataFileLoaderException { Runnable dfl = new Runnable() { public void run() { employeeDfl.setDataFileProcessor(longRunningDfp); employeeDfl.setResource(new FileSystemResource(XLS_FILE_IN_NAME)); try { employeeDfl.load();//from ww w .j a v a2 s . com Assert.fail(); } catch (DataFileLoaderException e) { Assert.assertEquals(2, longRunningDfp.getSuccessCounter()); Assert.assertEquals("Interrupt exception", "STOP", e.getMessage()); } } }; Thread thread = new Thread(dfl); thread.start(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } thread.interrupt(); }