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

The following examples show how to use junit.framework.Assert#assertNull() . 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: OrganizationalUnitServiceWSTest.java    From development with Apache License 2.0 7 votes vote down vote up
@Test
@Order(order = 7)
public void deleteUnit() throws NonUniqueBusinessKeyException,
        MailOperationException, ObjectNotFoundException,
        DeletionConstraintException, OperationNotPermittedException {
    // given
    final String unitName = randomString("TestUnit");
    final String unitDesc = randomString("TestDesc");
    final String unitRefId = randomString("refId");

    // when
    unitService.createUnit(unitName, unitDesc, unitRefId);
    unitService.deleteUnit(unitName);

    // then
    VOOrganizationalUnit unit = getUnitWithName(unitName);
    Assert.assertNull(unit);
}
 
Example 2
Source File: AttributeCheckContextMapper.java    From spring-ldap with Apache License 2.0 6 votes vote down vote up
public DirContextAdapter mapFromContext(Object ctx) {
    DirContextAdapter adapter = (DirContextAdapter) ctx;
    Assert.assertEquals("Values and attributes need to have the same length ",
            expectedAttributes.length, expectedValues.length);
    for (int i = 0; i < expectedAttributes.length; i++) {
        String attributeValue = adapter
                .getStringAttribute(expectedAttributes[i]);
        Assert.assertNotNull("Attribute " + expectedAttributes[i]
                + " was not present", attributeValue);
        Assert.assertEquals(expectedValues[i], attributeValue);
    }

    for (String absentAttribute : absentAttributes) {
        Assert.assertNull(adapter.getStringAttribute(absentAttribute));
    }

    return adapter;
}
 
Example 3
Source File: ObjectCacheTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testIntCacheNegativeKeys() {
  IntObjectCache<Object> cache = new IntObjectCache<Object>(8);
  cache.put(-1, 1);
  cache.put(-2, 2);
  cache.put(-3, 3);
  cache.put(-4, 4);
  cache.put(1, 1);
  cache.put(2, 2);
  cache.put(3, 3);
  cache.put(4, 4);
  Assert.assertNull(cache.tryKey(0));
  Assert.assertNotNull(cache.tryKey(-1));
  Assert.assertNotNull(cache.tryKey(-2));
  Assert.assertNotNull(cache.tryKey(-3));
  Assert.assertNotNull(cache.tryKey(-4));
}
 
Example 4
Source File: ForwardRegisterTrackingTransformationProviderTest.java    From binnavi with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransformAndBothInputRegisterAreTainted() {
  final RegisterTrackingTransformationProvider transformationProvider =
      new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false,
          new TreeSet<String>(), false, AnalysisDirection.DOWN));
  final ReilInstruction instruction =
      ReilHelpers.createAnd(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "ebx",
          OperandSize.DWORD, "eax");
  final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult =
      transformationProvider.transformAnd(instruction, createTaintedState("ecx", "ebx"));

  Assert.assertNull(transformationResult.second());

  transformationResult.first().onInstructionExit();

  Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("eax"));
  Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ebx"));
  Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ecx"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ebx"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
  Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
  Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
 
Example 5
Source File: TestLogDaoTest.java    From zxl with Apache License 2.0 6 votes vote down vote up
@Test
public void put() {
	TestLog testLog = new TestLog();
	Family family = new Family();
	family.put("a", "1");
	family.put("b", "2");
	family.put("c", "3");
	family.put("ts", DateUtil.todaySortedTimestamp());
	testLog.setIn(family);

	String id = testLogRowKeyGenerator.generate(testLog);
	TestLog testLogInDB = testLogDao.get(id);
	Assert.assertNull(testLogInDB);

	id = testLogDao.put(testLog);
	Assert.assertNotNull(id);

	testLogInDB = testLogDao.get(id);
	Assert.assertNotNull(testLogInDB);
	Assert.assertEquals("1", testLogInDB.getIn().get("a"));
	Assert.assertEquals("2", testLogInDB.getIn().get("b"));
	Assert.assertEquals("3", testLogInDB.getIn().get("c"));
}
 
Example 6
Source File: ForwardRegisterTrackingTransformationProviderTest.java    From binnavi with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransformModBothInputRegisterIsTainted() {
  final RegisterTrackingTransformationProvider transformationProvider =
      new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false,
          new TreeSet<String>(), false, AnalysisDirection.DOWN));
  final ReilInstruction instruction =
      ReilHelpers.createMod(0, OperandSize.DWORD, "ebx", OperandSize.DWORD, "ecx",
          OperandSize.DWORD, "eax");
  final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult =
      transformationProvider.transformMod(instruction, createTaintedState("ecx", "ebx"));

  Assert.assertNull(transformationResult.second());

  transformationResult.first().onInstructionExit();

  Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("eax"));
  Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ecx"));
  Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ebx"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
  Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ebx"));
  Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
  Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
 
Example 7
Source File: SectionContainerBackendTest.java    From binnavi with Apache License 2.0 6 votes vote down vote up
@Test
public void createSectionTest5() throws CouldntSaveDataException {
  final SectionContainerBackend sectionContainerBackend =
      new SectionContainerBackend(provider, module);

  Assert.assertNotNull(sectionContainerBackend);

  final Section section =
      sectionContainerBackend.createSection(".data2", new CAddress("100", 16), new CAddress(
          "200", 16), SectionPermission.READ_WRITE_EXECUTE, null);

  Assert.assertNotNull(section);
  Assert.assertEquals(".data2", section.getName());
  Assert.assertEquals(new CAddress("100", 16), section.getStartAddress());
  Assert.assertEquals(new CAddress("200", 16), section.getEndAddress());
  Assert.assertEquals(SectionPermission.READ_WRITE_EXECUTE, section.getSectionPermission());
  Assert.assertNull(section.getData());

}
 
Example 8
Source File: TestSnapshotOnKvm.java    From zstack with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    VmInstanceInventory vm = deployer.vms.get("TestVm");
    String volUuid = vm.getRootVolumeUuid();
    VolumeSnapshotInventory inv = api.createSnapshot(volUuid);
    Assert.assertEquals(VolumeSnapshotState.Enabled.toString(), inv.getState());
    Assert.assertEquals(VolumeSnapshotStatus.Ready.toString(), inv.getStatus());
    VolumeVO vol = dbf.findByUuid(volUuid, 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(0, svo.getDistance());
    Assert.assertEquals(vol.getPrimaryStorageUuid(), svo.getPrimaryStorageUuid());
    Assert.assertNotNull(svo.getPrimaryStorageInstallPath());
    VolumeSnapshotTreeVO cvo = dbf.findByUuid(svo.getTreeUuid(), VolumeSnapshotTreeVO.class);
    Assert.assertNotNull(cvo);

    snapshotKvmSimulator.validate(inv);

    api.destroyVmInstance(vm.getUuid());
    api.expungeVm(vm.getUuid(), null);
}
 
Example 9
Source File: TestSnapshotOnKvm23.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 10
Source File: TestDetached.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testNonDatedDetachedAssociationSetToNull()
{
    Order detachedOrder = OrderFinder.findOne(OrderFinder.orderId().eq(4)).getDetachedCopy();
    Assert.assertNull(detachedOrder.getOrderStatus());

    OrderStatus orderStatus = new OrderStatus();
    orderStatus.setStatus(16);
    orderStatus.setLastUser("aUser");

    detachedOrder.setOrderStatus(orderStatus);

    detachedOrder.setOrderStatus(null);

    Assert.assertNull(detachedOrder.getOrderStatus());
}
 
Example 11
Source File: IT_TProxyListenerTest.java    From JavaLinuxNet with Apache License 2.0 5 votes vote down vote up
private void stopTProxyListener(TProxyListener proxy) throws Exception {
    proxy.halt();
    int cnt = 0;
    while (proxy.isRunning() & cnt < 10) {
        Thread.sleep(10);
        cnt++;
    }
    org.junit.Assert.assertTrue("TProxy Listener must be stopped", !proxy.isRunning());
    org.junit.Assert.assertTrue("TProxy Listener must be stopped", !proxy.isHalted());
    Assert.assertNull(proxy.getSocket());
}
 
Example 12
Source File: SecurityContextAreaAuthorizationTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
@DirtiesContext // changing security context
public void testNotAuthenticatedVisibleArea() throws Exception {
	DefaultSecurityContext securityContext = (DefaultSecurityContext)this.securityContext;
	securityContext.setAuthentications(null, null);
	Assert.assertFalse(securityContext.isLayerVisible(LAYER_ID));
	Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
	Assert.assertNull(geometry);
	securityContext.setAuthentications(null, null);
}
 
Example 13
Source File: TestDeleteDiskOffering2.java    From zstack with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    DiskOfferingInventory dinv = new DiskOfferingInventory();
    dinv.setDiskSize(SizeUnit.GIGABYTE.toByte(10));
    dinv.setName("Test");
    dinv.setDescription("Test");
    dinv = api.addDiskOffering(dinv);

    VolumeInventory vinv = api.createDataVolume("TestData", dinv.getUuid());
    Assert.assertNotNull(vinv.getDiskOfferingUuid());
    api.deleteDiskOffering(dinv.getUuid());
    VolumeVO vol = dbf.findByUuid(vinv.getUuid(), VolumeVO.class);
    Assert.assertNull(vol.getDiskOfferingUuid());
}
 
Example 14
Source File: ObjectCacheTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testIntCacheFiniteness() {
  IntObjectCache<Integer> cache = new IntObjectCache<Integer>(4);
  cache.put(0, 0);
  cache.put(1, 1);
  cache.put(2, 2);
  cache.put(3, 3);
  cache.put(4, 4);
  // 0 should already leave the cache
  Assert.assertNull(cache.tryKey(0));
}
 
Example 15
Source File: RpcUtilsTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 场景:同步调用,不默认添加acctachment
 * 验证:acctachment中没有添加id属性
 */
@Test
public void testAttachInvocationIdIfAsync_sync() {
	URL url = URL.valueOf("dubbo://localhost/");
	Invocation inv = new RpcInvocation("test", new Class[]{}, new String[]{});
	RpcUtils.attachInvocationIdIfAsync(url, inv);
	Assert.assertNull(RpcUtils.getInvocationId(inv));
}
 
Example 16
Source File: NaturalKeyExtractorTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotExtractNestedKeyFieldWhenParentFieldIsNotANaturalKey() throws NoNaturalKeysDefinedException {

    Entity e = setup();
    Map<String, String> parentValue = new HashMap<String, String>();
    parentValue.put("childField", "someNestedValue");
    e.getBody().put("parentField", parentValue);

    // add another optional schema field that is not present
    AppInfo mockAppInfo = Mockito.mock(AppInfo.class);
    Mockito.when(mockAppInfo.applyNaturalKeys()).thenReturn(true);
    Mockito.when(mockAppInfo.getType()).thenReturn(AnnotationType.APPINFO);
    mockSchema.addAnnotation(mockAppInfo);

    // create the parent field schema
    ComplexSchema parentFieldSchema = new ComplexSchema();
    mockSchema.addField("parentField", parentFieldSchema);
    AppInfo mockAppInfoForParent = Mockito.mock(AppInfo.class);
    Mockito.when(mockAppInfoForParent.isNaturalKey()).thenReturn(false);
    Mockito.when(mockAppInfoForParent.getType()).thenReturn(AnnotationType.APPINFO);
    parentFieldSchema.addAnnotation(mockAppInfoForParent);

    // create the child field schema
    NeutralSchema mockChildFieldSchema = Mockito.mock(NeutralSchema.class);
    AppInfo mockFieldAppInfo = Mockito.mock(AppInfo.class);
    Mockito.when(mockChildFieldSchema.getAppInfo()).thenReturn(mockFieldAppInfo);
    Mockito.when(mockFieldAppInfo.isNaturalKey()).thenReturn(true);
    Mockito.when(mockFieldAppInfo.isRequired()).thenReturn(false);

    // add the child schema to the parent
    parentFieldSchema.addField("childField", mockChildFieldSchema);

    Map<String, String> naturalKeys = naturalKeyExtractor.getNaturalKeys(e);

    Assert.assertEquals(1, naturalKeys.size());
    Assert.assertEquals("someValue", naturalKeys.get("someField"));
    Assert.assertNull("The nested field should not be extracted", naturalKeys.get("parentField.childField"));
    Mockito.verify(entitySchemaRegistry, Mockito.times(1)).getSchema(Mockito.anyString());
}
 
Example 17
Source File: TestLog4jAppenderWithAvro.java    From mt-flume with Apache License 2.0 5 votes vote down vote up
@Test
public void testAvroGeneric() throws IOException {
  loadProperties("flume-log4jtest-avro-generic.properties");
  PropertyConfigurator.configure(props);
  Logger logger = LogManager.getLogger(TestLog4jAppenderWithAvro.class);
  String msg = "This is log message number " + String.valueOf(0);

  Schema schema = new Schema.Parser().parse(
      getClass().getClassLoader().getResource("myrecord.avsc").openStream());
  GenericRecordBuilder builder = new GenericRecordBuilder(schema);
  GenericRecord record = builder.set("message", msg).build();

  logger.info(record);

  Transaction transaction = ch.getTransaction();
  transaction.begin();
  Event event = ch.take();
  Assert.assertNotNull(event);

  GenericDatumReader<GenericRecord> reader = new GenericDatumReader<GenericRecord>(schema);
  BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(event.getBody(), null);
  GenericRecord recordFromEvent = reader.read(null, decoder);
  Assert.assertEquals(msg, recordFromEvent.get("message").toString());

  Map<String, String> hdrs = event.getHeaders();

  Assert.assertNull(hdrs.get(Log4jAvroHeaders.MESSAGE_ENCODING.toString()));

  Assert.assertEquals("Schema URL should be set",
      "file:///tmp/myrecord.avsc", hdrs.get(Log4jAvroHeaders.AVRO_SCHEMA_URL.toString
      ()));
  Assert.assertNull("Schema string should not be set",
      hdrs.get(Log4jAvroHeaders.AVRO_SCHEMA_LITERAL.toString()));

  transaction.commit();
  transaction.close();

}
 
Example 18
Source File: TestUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TestUtilities() {
    Assert.assertNull(DEFAULT);
    DEFAULT = this;
    ClassLoader l = TestUtilities.class.getClassLoader();
    setLookups(new Lookup[] {
        Lookups.metaInfServices(l),
        Lookups.singleton(l)
    });
}
 
Example 19
Source File: StorageCacheReplacementAlgorithmLRUTest.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
@Test
public void testSelectObjectFailed() {
    cacheReplacementAlgorithm.setUnusedTimeInterval(1);
    try {
        VMTemplateVO template = new VMTemplateVO();
        template.setTemplateType(Storage.TemplateType.USER);
        template.setUrl(UUID.randomUUID().toString());
        template.setUniqueName(UUID.randomUUID().toString());
        template.setName(UUID.randomUUID().toString());
        template.setPublicTemplate(true);
        template.setFeatured(true);
        template.setRequiresHvm(true);
        template.setBits(64);
        template.setFormat(Storage.ImageFormat.VHD);
        template.setEnablePassword(true);
        template.setEnableSshKey(true);
        template.setGuestOSId(1);
        template.setBootable(true);
        template.setPrepopulate(true);
        template.setCrossZones(true);
        template.setExtractable(true);
        template = templateDao.persist(template);

        VMTemplateVO template2 = new VMTemplateVO();
        template2.setTemplateType(Storage.TemplateType.USER);
        template2.setUrl(UUID.randomUUID().toString());
        template2.setUniqueName(UUID.randomUUID().toString());
        template2.setName(UUID.randomUUID().toString());
        template2.setPublicTemplate(true);
        template2.setFeatured(true);
        template2.setRequiresHvm(true);
        template2.setBits(64);
        template2.setFormat(Storage.ImageFormat.VHD);
        template2.setEnablePassword(true);
        template2.setEnableSshKey(true);
        template2.setGuestOSId(1);
        template2.setBootable(true);
        template2.setPrepopulate(true);
        template2.setCrossZones(true);
        template2.setExtractable(true);
        template2 = templateDao.persist(template2);

        ImageStoreVO imageStoreVO = new ImageStoreVO();
        imageStoreVO.setRole(DataStoreRole.ImageCache);
        imageStoreVO.setName(UUID.randomUUID().toString());
        imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
        imageStoreVO.setProtocol("nfs");
        imageStoreVO.setUrl(UUID.randomUUID().toString());
        imageStoreVO = imageStoreDao.persist(imageStoreVO);

        Date date = DateUtil.now();

        TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
        templateStoreVO1.setLastUpdated(date);
        templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
        templateStoreVO1.setDataStoreId(imageStoreVO.getId());
        templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
        templateStoreVO1.setCopy(true);
        templateStoreVO1.setTemplateId(template.getId());
        templateDataStoreDao.persist(templateStoreVO1);

        TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
        templateStoreVO2.setLastUpdated(date);
        templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
        templateStoreVO2.setDataStoreId(imageStoreVO.getId());
        templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
        templateStoreVO2.setCopy(true);
        templateStoreVO2.setTemplateId(template2.getId());
        templateDataStoreDao.persist(templateStoreVO2);

        DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
        Assert.assertNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));

    } catch (Exception e) {
        Assert.fail();
    }
}
 
Example 20
Source File: SiteHandlerTest.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Test
public void testParseHtmlNoBody() {
    PageParts pp = siteHandler.parseHtmlParts("<html><head><title>Hello</title></head></html>", debug);
    Assert.assertNull(pp);
}