Java Code Examples for junit.framework.Assert#assertNotNull()

The following examples show how to use junit.framework.Assert#assertNotNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SectionContainerBackendTest.java    From binnavi with Apache License 2.0 6 votes vote down vote up
@Test
public void deleteSectionTest2() throws CouldntLoadDataException, CouldntSaveDataException {
  final SectionContainerBackend sectionContainerBackend =
      new SectionContainerBackend(provider, module);

  Assert.assertNotNull(sectionContainerBackend);
  final int numberOfSections = sectionContainerBackend.loadSections().size();

  final Section section =
      sectionContainerBackend.createSection(".data2", new CAddress("100", 16), new CAddress(
          "200", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] {(byte) 0x90, (byte) 0xFF,
          (byte) 0x00});

  final int numberOfSections2 = sectionContainerBackend.loadSections().size();
  Assert.assertEquals(numberOfSections + 1, numberOfSections2);

  sectionContainerBackend.deleteSection(section);
  final int numberOfSections3 = sectionContainerBackend.loadSections().size();
  Assert.assertEquals(numberOfSections, numberOfSections3);
}
 
Example 2
Source File: GenericDataTSVTest.java    From iow-hadoop-streaming with Apache License 2.0 6 votes vote down vote up
@Test
public void testToString3() throws Exception {

    Schema s2 = p.parse(sc2);
    GenericData.Record r2 = new GenericData.Record(s2);
    r2.put("x",0.345621f);
    r2.put("y",Double.NaN);
    r2.put("x2", Float.POSITIVE_INFINITY);
    r2.put("y2", 1.0);
    r2.put("x3", Float.NaN);
    r2.put("y3", Double.POSITIVE_INFINITY);
    r2.put("x4", Float.NaN);
    r2.put("y4", Double.NEGATIVE_INFINITY);

    String tsv = gd.toString(r2,1,5);
    Assert.assertNotNull(tsv);
    Assert.assertEquals("NaN\tInfinity\t1.0\tNaN\tInfinity",tsv);
}
 
Example 3
Source File: ExecutionCompatibilityTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Executes the execution compatibility kit tests on the provided instance
 * of execution engine.
 */
public static Test suite(ExecutionEngine engine) {
    System.setProperty("org.openide.util.Lookup", ExecutionCompatibilityTest.class.getName() + "$Lkp");
    Object o = Lookup.getDefault();
    if (!(o instanceof Lkp)) {
        Assert.fail("Wrong lookup object: " + o);
    }
    
    Lkp l = (Lkp)o;
    l.assignExecutionEngine(engine);
    
    if (engine != null) {
        Assert.assertEquals("Same engine found", engine, ExecutionEngine.getDefault());
    } else {
        o = ExecutionEngine.getDefault();
        Assert.assertNotNull("Engine found", o);
        Assert.assertEquals(ExecutionEngine.Trivial.class, o.getClass());
    }
    
    TestSuite ts = new TestSuite();
    ts.addTestSuite(ExecutionEngineHid.class);
    
    return ts;
}
 
Example 4
Source File: TestSnapshotOnKvm8.java    From zstack with Apache License 2.0 6 votes vote down vote up
private void fullSnapshot(VolumeSnapshotInventory inv, int distance) {
    Assert.assertEquals(VolumeSnapshotState.Enabled.toString(), inv.getState());
    Assert.assertEquals(VolumeSnapshotStatus.Ready.toString(), inv.getStatus());
    VolumeVO vol = dbf.findByUuid(inv.getVolumeUuid(), VolumeVO.class);
    VolumeSnapshotVO svo = dbf.findByUuid(inv.getUuid(), VolumeSnapshotVO.class);
    Assert.assertNotNull(svo);
    Assert.assertFalse(svo.isFullSnapshot());
    Assert.assertTrue(svo.isLatest());
    Assert.assertNull(svo.getParentUuid());
    Assert.assertEquals(distance, svo.getDistance());
    Assert.assertEquals(vol.getPrimaryStorageUuid(), svo.getPrimaryStorageUuid());
    Assert.assertNotNull(svo.getPrimaryStorageInstallPath());
    VolumeSnapshotTreeVO cvo = dbf.findByUuid(svo.getTreeUuid(), VolumeSnapshotTreeVO.class);
    Assert.assertNotNull(cvo);
    Assert.assertTrue(cvo.isCurrent());
}
 
Example 5
Source File: ClientRPCStoreTest.java    From seldon-server with Apache License 2.0 6 votes vote down vote up
@Test 
public void testMissingCustomRequesToJSON() throws JsonParseException, IOException, NoSuchMethodException, SecurityException
{
	mockClientConfigHandler.addListener((ClientConfigUpdateListener) EasyMock.anyObject());
	EasyMock.expectLastCall().once();
	replay(mockClientConfigHandler);
	final String client = "test";
	ClientRpcStore store = new ClientRpcStore(mockClientConfigHandler);
	CustomPredictRequest customRequest =  CustomPredictRequest.newBuilder().addData(1.0f).build();
	store.add(client, customRequest.getClass(), null,customRequest.getClass().getMethod("newBuilder"),null);
	ClassificationRequestMeta meta = ClassificationRequestMeta.newBuilder().setPuid("1234").build();
	ClassificationRequest request = ClassificationRequest.newBuilder().setMeta(meta).build();
	JsonNode json = store.getJSONForRequest(client,request);
	Assert.assertNotNull(json);
	System.out.println(json);
	
}
 
Example 6
Source File: DnspodFreeTest.java    From happy-dns-android with MIT License 6 votes vote down vote up
public void testFound() throws IOException {
    DnspodFree resolver = new DnspodFree();
    try {
        Record[] records = resolver.resolve(new Domain("baidu.com"), null);
        Assert.assertNotNull(records);
        Assert.assertTrue(records.length > 0);
        for (Record r : records) {
            Assert.assertTrue(r.ttl >= 600);
            Assert.assertTrue(r.isA());
            Assert.assertFalse(r.isExpired());
        }

    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 7
Source File: RepresentationHandlerTests.java    From DDF with Apache License 2.0 6 votes vote down vote up
@Test
public void testNewRepHandler() throws DDFException {
  DDFManager manager = DDFManager.get(DDFManager.EngineType.BASIC);
  DDF ddf = manager.newDDF();

  IHandleRepresentations handler = new DummyRepresentationHandler(ddf);

  Double[] data = new Double[] { 0.0, 2.0, 1.0, 3.0, 4.0, 10.0, 11.0 };
  handler.add(data, Double[].class);
  Object[] obj1 = (Object[]) handler.get(Object[].class);
  Integer[] obj2 = (Integer[]) handler.get(Integer[].class);

  Assert.assertNotNull(obj1);
  Assert.assertNotNull(obj2);
  Assert.assertEquals(handler.getAllRepresentations().size(), 3);
  String[] obj3 = (String[]) handler.get(String[].class);
  Assert.assertNotNull(obj3);
  Assert.assertEquals(handler.getAllRepresentations().size(), 4);
}
 
Example 8
Source File: TestDeleteBackupStorageExtensionPoint.java    From zstack with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    SimulatorBackupStorageDetails ss = new SimulatorBackupStorageDetails();
    ss.setTotalCapacity(SizeUnit.GIGABYTE.toByte(100));
    ss.setUsedCapacity(0);
    ss.setUrl("nfs://simulator/backupstorage/");
    BackupStorageInventory inv = api.createSimulatorBackupStorage(1, ss).get(0);
    ext.setPreventDelete(true);
    try {
        api.deleteBackupStorage(inv.getUuid());
    } catch (ApiSenderException e) {
    }
    BackupStorageVO vo = dbf.findByUuid(inv.getUuid(), BackupStorageVO.class);
    Assert.assertNotNull(vo);

    ext.setExpectedBackupStorageUuid(inv.getUuid());
    ext.setPreventDelete(false);
    api.deleteBackupStorage(inv.getUuid());
    Assert.assertTrue(ext.isBeforeCalled());
    Assert.assertTrue(ext.isAfterCalled());
    vo = dbf.findByUuid(inv.getUuid(), BackupStorageVO.class);
    Assert.assertEquals(null, vo);
}
 
Example 9
Source File: DocumentMetadataServiceTest.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testStoreTemplate() throws Exception {
	SoapDocumentMetadataService docMetadataServiceImpl = new SoapDocumentMetadataService();
	docMetadataServiceImpl.setValidateSession(false);

	WSTemplate wsTemplateTest = new WSTemplate();
	wsTemplateTest.setName("template test");
	wsTemplateTest.setDescription("template test descr");

	Long templateId = docMetadataServiceImpl.storeTemplate("", wsTemplateTest);
	Assert.assertNotNull(templateId);

	Template createdTemplate = templateDao.findById(templateId);
	Assert.assertNotNull(createdTemplate);
	Assert.assertEquals("template test", createdTemplate.getName());
	Assert.assertEquals("template test descr", createdTemplate.getDescription());
}
 
Example 10
Source File: TestEagleQueryParser.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyString() {
	String query = "@name = \"\"";
	EagleQueryParser parser = new EagleQueryParser(query);
	ORExpression or = null;
	try{
		or = parser.parse();
	}catch(EagleQueryParseException ex){
		Assert.fail(ex.getMessage());
	}
	Assert.assertNotNull(or);
	Assert.assertEquals("@name", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey());
	Assert.assertEquals("", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue());
	Assert.assertEquals("=", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString());
	Assert.assertEquals(TokenType.STRING, or.getANDExprList().get(0).getAtomicExprList().get(0).getValueType());
}
 
Example 11
Source File: TestFirstAvailableIpAllocatorStrategyConcurrent.java    From zstack with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws ApiSenderException, InterruptedException, BrokenBarrierException {
    ZoneInventory zone = api.createZones(1).get(0);
    L2NetworkInventory linv = api.createNoVlanL2Network(zone.getUuid(), "eth0");
    L3NetworkInventory l3inv = api.createL3BasicNetwork(linv.getUuid());
    L3NetworkVO vo = dbf.findByUuid(l3inv.getUuid(), L3NetworkVO.class);
    Assert.assertNotNull(vo);
    IpRangeInventory ipInv = api.addIpRange(l3inv.getUuid(), startIp, endIp, "10.223.110.1", "255.255.255.0");
    IpRangeVO ipvo = dbf.findByUuid(ipInv.getUuid(), IpRangeVO.class);
    Assert.assertNotNull(ipvo);

    for (int i = 0; i < testNum; i++) {
        allocate(l3inv);
    }
    barrier.await();
    latch.await(120, TimeUnit.SECONDS);
    SimpleQuery<UsedIpVO> query = dbf.createQuery(UsedIpVO.class);
    long count = query.count();
    Assert.assertEquals(ipNum, count);
}
 
Example 12
Source File: T5_QualifyJMSTest.java    From learning with Apache License 2.0 6 votes vote down vote up
@Test
public void sendTextMessageToJMSQueue() throws Exception {
	// Mock the qualify service to verify it's invoked
	MockHandler qualifyMock = testKit.replaceService("QualificationService");
	
	// Create and send a JMS message with the request XML payload
    MessageProducer producer = hornetQ.getJMSSession().createProducer(
    		HornetQMixIn.getJMSQueue(REQUEST_QUEUE));
    TextMessage message = hornetQ.getJMSSession().createTextMessage();
    message.setText(testKit.readResourceString("xml/applicant-before.xml"));
    producer.send(message);
    
    // Verify that we received the message in the service
    qualifyMock.waitForOKMessage();
    Assert.assertEquals(1, qualifyMock.getMessages().size());
    
    // Did we get a reply?
    MessageConsumer consumer = hornetQ.getJMSSession().createConsumer(
    		HornetQMixIn.getJMSQueue(RESPONSE_QUEUE));
    Assert.assertNotNull(consumer.receive(1000));
}
 
Example 13
Source File: DocumentManagerImplTest.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testCopyToFolder() throws Exception {
	User user = userDao.findByUsername("admin");
	Document doc = docDao.findById(1);
	Assert.assertNotNull(doc);
	Folder folder = doc.getFolder();
	Assert.assertEquals(6, folder.getId());

	DocumentHistory transaction = new DocumentHistory();
	transaction.setFolderId(103L);
	transaction.setUser(user);
	transaction.setDocId(doc.getId());
	transaction.setUserId(1L);
	transaction.setNotified(0);
	transaction.setComment("pippo_reason");
	transaction.setFilename(doc.getFileName());

	Folder newFolder = folderDao.findById(6);
	docDao.initialize(doc);

	DummyStorer storer = (DummyStorer) Context.get().getBean(Storer.class);
	try {
		storer.setUseDummyFile(true);
		Document newDoc = documentManager.copyToFolder(doc, newFolder, transaction);
		Assert.assertNotSame(doc.getId(), newDoc.getId());
		Assert.assertEquals(newFolder, newDoc.getFolder());
	} finally {
		storer.setUseDummyFile(false);
	}
}
 
Example 14
Source File: SoapDocumentServiceTest.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testGetAliases() throws Exception {
	WSDocument[] docs = docService.getAliases("", 1L);
	Assert.assertNotNull(docs);
	Assert.assertEquals(1, docs.length);

	docs = docService.getAliases("", 2L);
	Assert.assertNotNull(docs);
	Assert.assertEquals(0, docs.length);
}
 
Example 15
Source File: HibernateBookmarkDAOTest.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testStore() throws PersistenceException {
	Bookmark book1 = dao.findById(1);
	dao.initialize(book1);
	book1.setDescription("pippo");
	dao.store(book1);
	Assert.assertNotNull(book1);

	Bookmark book2 = dao.findById(2);
	dao.initialize(book2);
	book2.setDescription("paperino");
	dao.store(book2);
	Assert.assertNotNull(book2);
}
 
Example 16
Source File: RrXTeeServiceImplTest.java    From j-road with Apache License 2.0 5 votes vote down vote up
@Test
public void getRR52() throws XRoadServiceConsumptionException {
	RR52Response response = rrXTeeServiceImpl.getRR52("47707178682",
			"Olga", "Sidorova");

	Assert.assertNotNull(response);

	List<Dok.Item> dokList = response.getDok().getItemList();
	Assert.assertTrue(!dokList.isEmpty());
	Assert.assertEquals("ELAMISLUBA", dokList.get(0).getDokDokTyyp());

	List<Isik.Item> isikList = response.getIsik().getItemList();
	Assert.assertTrue(!isikList.isEmpty());
	Assert.assertEquals("OLGA", isikList.get(0).getIsikEesnimi());
}
 
Example 17
Source File: HibernateSystemMessageDAOTest.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testFindById() {
	SystemMessage message = dao.findById(1);
	Assert.assertNotNull(message);
	Assert.assertEquals(1, message.getId());
	Assert.assertEquals("message text1", message.getMessageText());

	// Try with unexisting message
	message = dao.findById(99);
	Assert.assertNull(message);
}
 
Example 18
Source File: HibernateGenericDAOTest.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testFindByAlternateKey() {
	Generic generic = dao.findByAlternateKey("a", "a1", null, Tenant.DEFAULT_ID);
	Assert.assertNotNull(generic);
	Assert.assertEquals(new Long(0), generic.getInteger1());
	generic = dao.findByAlternateKey("a", "xxx", null, 99L);
	Assert.assertNull(generic);
}
 
Example 19
Source File: TestNetUtil.java    From craft-atom with MIT License 5 votes vote down vote up
@Test
public void testGetIpv4Address() throws IOException {
	String addr = NetUtil.getIpv4Address().getHostAddress();
	Assert.assertNotNull(addr);
	addr = NetUtil.getIpv4Address("11.24").getHostAddress();
	Assert.assertNotNull(addr);
	System.out.println(String.format("[CRAFT-ATOM-UTIL] (^_^)  <%s>  Case -> test get ipv4 address. ", CaseCounter.incr(2)));
}
 
Example 20
Source File: SifTranslationTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldTranslateStudentPersonalToStudent() {
    StudentPersonal info = new StudentPersonal();
    List<SliEntity> entities = translationManager.translate(info, ZONE_ID);

    Assert.assertEquals("Should create a single SLI student entity", 1, entities.size());
    Assert.assertNotNull("NULL sli entity", entities.get(0));
    Assert.assertEquals("Mapped SLI entitiy should be of type student", "student", entities.get(0).entityType());
}