当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionAssert类代码示例

本文整理汇总了Java中org.unitils.reflectionassert.ReflectionAssert的典型用法代码示例。如果您正苦于以下问题:Java ReflectionAssert类的具体用法?Java ReflectionAssert怎么用?Java ReflectionAssert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReflectionAssert类属于org.unitils.reflectionassert包,在下文中一共展示了ReflectionAssert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_zone_extracted_list_of_servers

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void test_zone_extracted_list_of_servers() throws MarathonException {
    ReflectionAssert.assertReflectionEquals(
            "should be two servers",
            IntStream.of(1,2)
                    .mapToObj(index ->
                            new MarathonServer(
                                    "host" + index + ".dc1",
                                    9090,
                                    Collections.emptyList())
                            .withZone("dc1")
                    ).collect(Collectors.toList()),
            serverList.getInitialListOfServers().stream()
                .filter(server -> server.getZone().equals("dc1"))
                .collect(Collectors.toList()),
            ReflectionComparatorMode.LENIENT_ORDER
    );
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:19,代码来源:MarathonServerListFetchZoneTests.java

示例2: testPrivateFieldsNoGetter

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void testPrivateFieldsNoGetter() {
    PrivateFieldsNoGetterObject obj1 = new PrivateFieldsNoGetterObject();
    obj1.publicString = "Hello";
    obj1.setPrivateInt(456);

    PrivateFieldsNoGetterObject obj2 = bundleAndUnbundle(obj1);

    // Public field should be bundled properly
    assertEquals(obj1.publicString, obj2.publicString);

    // Private field without getter should have been ignored
    try {
        ReflectionAssert.assertReflectionEquals(obj1, obj2);
        throw new RuntimeException("Should not have gotten here!");
    } catch (AssertionFailedError e) {
        // We expect to get to this branch.
    }
}
 
开发者ID:google,项目名称:easybundler,代码行数:20,代码来源:EasyBundlerTest.java

示例3: testReferenceGenomeManagement

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testReferenceGenomeManagement() {
    // clear the list of chromosomes for test purposes
    reference.setChromosomes(Collections.emptyList());
    // tests that a reference genome created in 'setup' can be retrieved by the known ID
    final Reference foundById = referenceGenomeDao.loadReferenceGenome(reference.getId());
    assertNotNull("Reference genome isn't found by the given ID.", foundById);
    ReflectionAssert.assertReflectionEquals("Unexpected reference genome is loaded by ID.", reference, foundById);
    // tests that a reference genome created in 'setup' can be retrieved in the list which contains
    // all chromosomes registered in the system
    final List<Reference> allReferenceGenomes = referenceGenomeDao.loadAllReferenceGenomes();
    assertTrue("Collection of available reference genomes is empty, but should contain at least one value.",
            CollectionUtils.isNotEmpty(allReferenceGenomes));
    final Optional<Reference> foundInList = allReferenceGenomes
            .stream()
            .filter(e -> reference.getId().equals(e.getId()))
            .findFirst();
    assertTrue("Reference genome isn't found by ID in the retrieved list.", foundInList.isPresent());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:21,代码来源:ReferenceGenomeDaoTest.java

示例4: testBeans

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
/**
 * Test the available beans
 * @throws IllegalAccessException related to Jackson conversion
 * @throws IllegalArgumentException related to Jackson conversion
 * @throws InvocationTargetException related to Jackson conversion
 * @throws IntrospectionException related to Jackson conversion
 */
@Test
public void testBeans() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException{
	PodamFactory factory = new PodamFactoryImpl();
	// Tests if setters are set appropriately
	ReflectionAssert.assertPropertiesNotNull("Some properties null.", 
			factory.manufacturePojo(MmtfStructure.class));
	testData(MmtfStructure.class, factory.manufacturePojo(MmtfStructure.class));
	
	ReflectionAssert.assertPropertiesNotNull("Some properties null.", 
			factory.manufacturePojo(BioAssemblyData.class));
	testData(BioAssemblyData.class, factory.manufacturePojo(BioAssemblyData.class));
	
	ReflectionAssert.assertPropertiesNotNull("Some properties null.", 
			factory.manufacturePojo(BioAssemblyTransformation.class));
	testData(BioAssemblyTransformation.class, factory.manufacturePojo(BioAssemblyTransformation.class));

	ReflectionAssert.assertPropertiesNotNull("Some properties null.", 
			factory.manufacturePojo(Entity.class));
	testData(Entity.class, factory.manufacturePojo(Entity.class));
	
	ReflectionAssert.assertPropertiesNotNull("Some properties null.", 
			factory.manufacturePojo(Group.class));
	testData(Group.class, factory.manufacturePojo(Group.class));

}
 
开发者ID:rcsb,项目名称:mmtf-java,代码行数:33,代码来源:TestDataHolders.java

示例5: testByComparisonWithJackson

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void testByComparisonWithJackson() throws IOException {

	for (String code : testCodes) {
		try {
			byte[] zipped = fetchMmtf(code);
			byte[] bytes = ReaderUtils.deflateGzip(zipped);

			MessagePackSerialization.setJackson(false);
			StructureDataInterface sdiJmol = parse(bytes);

			MessagePackSerialization.setJackson(true);
			StructureDataInterface sdiJackson = parse(bytes);

			ReflectionAssert.assertReflectionEquals(sdiJackson, sdiJmol);
		} catch (Exception ex) {
			throw new RuntimeException(code, ex);
		}
	}
}
 
开发者ID:rcsb,项目名称:mmtf-java,代码行数:21,代码来源:MessagePackSerializationTest.java

示例6: testGetScriptsAt_multiUserSupport

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void testGetScriptsAt_multiUserSupport() throws Exception {
    File parentFile = tempFolder.newFolder("test1");
    tempFolder.newFile("test1/file1.txt");
    tempFolder.newFile("test1/file2.sql");
    tempFolder.newFile("test1/@users_addusers.sql");
    tempFolder.newFile("test1/[email protected]_addusers.sql");
    tempFolder.newFile("test1/[email protected]_addusers.sql");


    List<Script> actual = new ArrayList<Script>();

    scriptSource.getScriptsAt(actual, parentFile.getParentFile().getAbsolutePath(), "test1", "users", true);
    List<String> actualNames = new ArrayList<String>();
    for (Script script : actual) {
        actualNames.add(script.getFileName());
    }

    Assert.assertEquals(3, actual.size());
    ReflectionAssert.assertReflectionEquals(Arrays.asList("test1/file2.sql", "test1/@users_addusers.sql", "test1/[email protected]_addusers.sql"), actualNames, ReflectionComparatorMode.LENIENT_ORDER);

}
 
开发者ID:linux-china,项目名称:unitils,代码行数:23,代码来源:DefaultScriptSourceTest.java

示例7: testAddMostRecentDifferentFiles

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Ignore
@Test
public void testAddMostRecentDifferentFiles() throws Exception {
    List<URL> filteredResources = new ArrayList<URL>();
    File file1 = new File("src/test/resources/org/unitils/dbunit/test1/testFile.txt");
    File file2 = new File("src/test/resources/org/unitils/dbunit/test2/testFile.txt");
    
    URL urlFile1 = new URL("file:///" + file1.getAbsolutePath());
    URL urlFile2 = new URL("file:///" + file2.getAbsolutePath());
    filteredResources.add(urlFile1);
    
    String resourceSearchName = file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf(pathSeperator) + 1);
    
    strategy.addMostRecent(filteredResources, urlFile2, resourceSearchName);

    
    Assert.assertEquals(1, filteredResources.size());
    ReflectionAssert.assertLenientEquals(Arrays.asList(urlFile2), filteredResources);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:20,代码来源:ResourcePickingStrategieTest.java

示例8: testCodec

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void testCodec() throws Exception {
  String expectedString =
          "{" +
                  "\"cores\":2," +
                  "\"memorySize\":1024," +
                  "\"instances\":2," +
                  "\"uplink\":100," +
                  "\"downlink\":100" +
          "}";
  final ResourceSpecification expected =
          new DefaultResourceSpecification(2, 1024, 2, 100, 100);
  final String actualString = gson.toJson(expected);
  Assert.assertEquals(expectedString, actualString);

  final JsonElement expectedJson = gson.toJsonTree(expected);
  final ResourceSpecification actual = gson.fromJson(expectedJson, DefaultResourceSpecification.class);
  final JsonElement actualJson = gson.toJsonTree(actual);

  Assert.assertEquals(expectedJson, actualJson);
  ReflectionAssert.assertLenientEquals(expected, actual);
}
 
开发者ID:apache,项目名称:twill,代码行数:23,代码来源:ResourceSpecificationCodecTest.java

示例9: deserialize_WithValidJson

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void deserialize_WithValidJson() {
    //Arrange
    String jsonAsString = "{\n" +
            "\"packageName\": \"testPackage\",\n" +
            "\"object\": \"testObject\"\n" +
            "}";
    JsonElement jsonElement = this.jsonConverter.fromJson(jsonAsString, JsonElement.class);

    ConversionObject expectedResult = new ConversionObject();
    expectedResult.setPackageName("testPackage");
    expectedResult.setObject("\"testObject\"");

    //Act
    ConversionObject actualResult = this.deserializer.deserialize(jsonElement, null, null);

    //Assert
    ReflectionAssert.assertReflectionEquals(expectedResult, actualResult);
}
 
开发者ID:rndsolutions,项目名称:hawkcd,代码行数:20,代码来源:ConversionObjectDeserializerTest.java

示例10: testGetEntity

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
/**
 * Tests retrieving one entity.
 * An entity should be retrieved and the properties of the entity should have the
 * same values as the entity persisted before the test.
 *
 * @throws IOException If error occurs. Indicates test failure.
 */
@Test(timeOut = TEST_TIMEOUT)
public void testGetEntity() throws IOException {
    final Response theResponse = RestAssured
        .given()
        .contentType("application/json")
        .accept("application/json")
        .when()
        .get(mResourceUrlPath + "/" + mExpectedEntity.getId());
    final String theResponseJson = theResponse.prettyPrint();
    theResponse
        .then()
        .statusCode(200)
        .contentType(ContentType.JSON);

    final Object theRetrievedEntity = JsonConverter.jsonToObject(
        theResponseJson, mExpectedEntity.getClass());
    ReflectionAssert.assertLenientEquals(
        "Retrieved entity should have the correct property values",
        mExpectedEntity, theRetrievedEntity);
}
 
开发者ID:krizsan,项目名称:rest-example,代码行数:28,代码来源:RestResourceTestBase.java

示例11: testCachedExecution

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void testCachedExecution() {
    MockContractsBolt bolt = new MockContractsBolt();
    MockCacheDAO cache = new MockCacheDAO();
    MockCachedContractBoltExecutor executor = new MockCachedContractBoltExecutor(bolt, cache);
    executor.prepare(mock(Map.class), mock(TopologyContext.class));
    assertThat(cache.cache.size()).isEqualTo(0);

    ObjectNode data = parseJson("{\"input1\":-1,\"optionalInput2\":-1}");
    BasicOutputCollector collector = execute(data, executor);
    Object output1 = getEmittedContract(collector);
    assertThat(cache.cache.size()).isEqualTo(1);
    assertThat(cache.cache.containsValue(output1));

    collector = execute(data, executor);
    Object output2 = getEmittedContract(collector);
    ReflectionAssert.assertReflectionEquals(output2, output1);
    assertThat(cache.cache.size()).isEqualTo(1);
}
 
开发者ID:forter,项目名称:storm-data-contracts,代码行数:20,代码来源:BaseContractsBoltExecutorTest.java

示例12: checkSurvivesBundle

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
/**
 * Put an object into a Bundle and then extract it out again, use reflection to ensure that
 * the resulting object is the same.
 */
private <T> void checkSurvivesBundle(T obj1) {
    // Bundle to object
    T obj2 = bundleAndUnbundle(obj1);

    // Make sure the objects are deep equal
    ReflectionAssert.assertReflectionEquals(obj1, obj2);
}
 
开发者ID:google,项目名称:easybundler,代码行数:12,代码来源:EasyBundlerTest.java

示例13: testChromosomeManagement

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testChromosomeManagement() {
    final List<Chromosome> chromosomes = reference.getChromosomes();
    // tests that batch of chromosomes are saved and IDs are assigned
    final int count = chromosomes.size();
    final int[] result = referenceGenomeDao.saveChromosomes(reference.getId(), chromosomes);
    assertEquals("Unexpected batch size.", count, result.length);
    for (int i = 0; i < count; i++) {
        assertEquals("Unexpected number of affected rows after chromosome has been saved successfully.",
                1, result[i]);
        Chromosome entity = chromosomes.get(i);
        assertNotNull("Chromosome ID has been assigned.", entity.getId());
        assertNotNull("Reference ID has been assigned.", entity.getReferenceId());
    }

    final Chromosome chromosome = chromosomes.get(0);

    // tests that a chromosome can be retrieved by the given ID
    final Chromosome foundById = referenceGenomeDao.loadChromosome(chromosome.getId());
    assertNotNull("Chromosome isn't found by the given ID.", foundById);
    ReflectionAssert.assertReflectionEquals("Unexpected chromosome is loaded by ID.", chromosome, foundById);
    // tests that all chromosomes related to a reference genome with the given ID can be retrieved
    final List<Chromosome> allChromosomes = referenceGenomeDao.loadAllChromosomesByReferenceId(reference.getId());
    assertTrue("Collection of chromosomes is empty, but it should contain more than 1 value.",
            CollectionUtils.isNotEmpty(allChromosomes));
    assertEquals("Unexpected number of chromosomes for the given reference is detected.",
            count, allChromosomes.size());
    final Optional<Chromosome> foundInList = allChromosomes
            .stream()
            .filter(e -> chromosome.getId().equals(e.getId()))
            .findFirst();
    assertTrue("Chromosome isn't found by ID in the retrieved list.", foundInList.isPresent());
    ReflectionAssert.assertReflectionEquals("Unexpected chromosome is found in the list.",
            chromosome, foundInList.get());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:37,代码来源:ReferenceGenomeDaoTest.java

示例14: Serialization

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
@Test
public void Serialization() throws Exception {
    AirlockMessage message = AirlockMessageGenerator.generateAirlockMessage();

    byte[] bytes = message.toByteArray();
    BinarySerializable obj2 = BinarySerializable.fromByteArray(bytes, AirlockMessage.class);
    ReflectionAssert.assertReflectionEquals(message, obj2);
}
 
开发者ID:vostok,项目名称:airlock.gate,代码行数:9,代码来源:SerializationTest.java

示例15: testGenricEncoder

import org.unitils.reflectionassert.ReflectionAssert; //导入依赖的package包/类
/**
 * Test whether calling all the set methods gives a none null get.
 * @throws IOException an error converting byte arrays
 */
@Test
public void testGenricEncoder() throws IOException {
	DummyApiImpl dummyApiImpl = new DummyApiImpl();
	EncoderInterface encoder = new GenericEncoder(dummyApiImpl);
	ReflectionAssert.assertPropertiesNotNull("Some properties null after encoding",  encoder.getMmtfEncodedStructure());
}
 
开发者ID:rcsb,项目名称:mmtf-java,代码行数:11,代码来源:TestEncoder.java


注:本文中的org.unitils.reflectionassert.ReflectionAssert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。