本文整理汇总了Java中org.unitils.reflectionassert.ReflectionAssert.assertLenientEquals方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionAssert.assertLenientEquals方法的具体用法?Java ReflectionAssert.assertLenientEquals怎么用?Java ReflectionAssert.assertLenientEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.unitils.reflectionassert.ReflectionAssert
的用法示例。
在下文中一共展示了ReflectionAssert.assertLenientEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: testFilter
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testFilter() throws MalformedURLException {
List<URL> filteredResources = new ArrayList<URL>();
File file1 = new File("src/test/resources/org/unitils/dbunit/test1/testFile.txt");
URL urlFile1 = new URL("file:///" + file1.getAbsolutePath());
filteredResources.add(urlFile1);
String resourceSearchName = file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf(pathSeperator) + 1);
strategy.filter(filteredResources, resourceSearchName);
Assert.assertEquals(1, filteredResources.size());
ReflectionAssert.assertLenientEquals(Arrays.asList(urlFile1), filteredResources);
}
示例3: testObject
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
/**
* @throws SecurityException
* @throws NoSuchFieldException
*/
@Test
public void testObject() throws SecurityException, NoSuchFieldException{
Person expected = new Person("testName", "testSurname");
ReflectionUtils.setFieldValue(testclass, "personTest", expected);
ReflectionAssert.assertLenientEquals(expected, testclass.getPersonTest());
}
示例4: testFindById
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
@DataSet("../datasets/SinglePerson.xml")
public void testFindById() {
Session currentSession = sessionFactory.getCurrentSession();
Person userFromDb = (Person) currentSession.get(Person.class, 1L);
ReflectionAssert.assertLenientEquals(person, userFromDb);
}
示例5: testGetProfileWithAnnotations
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testGetProfileWithAnnotations() {
profileModule.getProfile(TestClass6.class);
ReflectionAssert.assertLenientEquals("Test if the actual context is a GenericXmlApplicationContext", AnnotationConfigApplicationContext.class, profileModule.getCtx().getClass());
//drop table DummyTable
dropTableDummyTable();
}
示例6: testCreate
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testCreate() {
Map<String, DatabaseConfiguration> databaseConfigurations = new HashMap<String, DatabaseConfiguration>();
databaseConfigurations.put("database1", config1);
databaseConfigurations.put("database2", config2);
DatabaseConfigurations configs = new DatabaseConfigurations(null, databaseConfigurations);
ReflectionAssert.assertLenientEquals(configs, factory.create());
}
示例7: testGetScriptsAt_qualifiers
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testGetScriptsAt_qualifiers() throws Exception {
String nameFolder = "getscriptsat_qualifiers";
File parentFile = tempFolder.newFolder(nameFolder);
tempFolder.newFile(nameFolder + "/01_#include1_products.sql");
tempFolder.newFile(nameFolder + "/#include1_#include2_products.sql");
tempFolder.newFile(nameFolder + "/01_#include1_#include2_products.sql");
tempFolder.newFile(nameFolder + "/01_#refdata_#postgres_products.sql");
tempFolder.newFile(nameFolder + "/01_#include1_#exclude2_products.sql");
String path = getPath(parentFile);
scriptSource = new ResourceScriptSource();
configuration.setProperty(DefaultScriptSource.PROPKEY_INCLUDE_QUALIFIERS, "include1, include2, include3");
configuration.setProperty(DefaultScriptSource.PROPKEY_EXCLUDE_QUALIFIERS, "exclude1, exclude2");
configuration.setProperty(DefaultScriptSource.PROPKEY_SCRIPT_LOCATIONS, path);
configuration.setProperty(DefaultScriptSource.PROPKEY_SCRIPT_EXTENSIONS, "sql");
configuration.setProperty(DefaultScriptSource.PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME, "postprocessing");
configuration.setProperty(DefaultScriptSource.PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES, "false");
configuration.setProperty("database.dialect", "hsqldb");
scriptSource.init(configuration);
List<Script> actual = new ArrayList<Script>();
scriptSource.getScriptsAt(actual, path, nameFolder, "users", true);
List<String> actualNames = new ArrayList<String>();
for (Script script : actual) {
actualNames.add(script.getFileName());
}
Assert.assertEquals(3, actualNames.size());
ReflectionAssert.assertLenientEquals(Arrays.asList("01_%23include1_products.sql", "%23include1_%23include2_products.sql", "01_%23include1_%23include2_products.sql"), actualNames);
}
示例8: testGetScriptsAt_qualifiers
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testGetScriptsAt_qualifiers() throws Exception {
String nameFolder = "getscriptsat_qualifiers";
File parentFile = tempFolder.newFolder(nameFolder);
tempFolder.newFile(nameFolder + "/01_#include1_products.sql");
tempFolder.newFile(nameFolder + "/#include1_#include2_products.sql");
tempFolder.newFile(nameFolder + "/01_#include1_#include2_products.sql");
tempFolder.newFile(nameFolder + "/01_#refdata_#postgres_products.sql");
tempFolder.newFile(nameFolder + "/01_#include1_#exclude2_products.sql");
scriptSource = new DefaultScriptSource();
configuration.setProperty(DefaultScriptSource.PROPKEY_INCLUDE_QUALIFIERS, "include1, include2, include3");
scriptSource.init(configuration);
List<Script> actual = new ArrayList<Script>();
scriptSource.getScriptsAt(actual, parentFile.getParentFile().getAbsolutePath(), nameFolder, "users", true);
List<String> actualNames = new ArrayList<String>();
for (Script script : actual) {
actualNames.add(script.getFileName());
}
Assert.assertEquals(3, actualNames.size());
ReflectionAssert.assertLenientEquals(Arrays.asList(nameFolder + "/01_#include1_products.sql", nameFolder + "/#include1_#include2_products.sql", nameFolder + "/01_#include1_#include2_products.sql"), actualNames);
}
示例9: testAddMostRecentDuplicateFile
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testAddMostRecentDuplicateFile() throws IOException {
List<URL> filteredResources = new ArrayList<URL>();
File file1 = new File("src/test/resources/org/unitils/dbunit/test1/testFile.txt");
URL urlFile1 = new URL("file:///" + file1.getAbsolutePath());
filteredResources.add(urlFile1);
String resourceSearchName = file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf(pathSeperator) + 1);
strategy.addMostRecent(filteredResources, urlFile1, resourceSearchName);
Assert.assertEquals(1, filteredResources.size());
ReflectionAssert.assertLenientEquals(Arrays.asList(urlFile1), filteredResources);
}
示例10: testComputeParams
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testComputeParams() throws Exception {
List<Object[]> parameters = new ArrayList<Object[]>();
parameters.add(new Object[]{1,2});
sut = unitilsParameterized.new TestClassRunnerForParameters(Testclass1.class, parameters, 0);
Object[] actual = sut.computeParams();
Object[] expected = new Object[]{1,2};
ReflectionAssert.assertLenientEquals(expected, actual);
}
示例11: testAddMostRecentEmptyFilteredResources
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testAddMostRecentEmptyFilteredResources() throws Exception {
List<URL> filteredResources = new ArrayList<URL>();
File file1 = new File("src/test/resources/org/unitils/dbunit/test1/testFile.txt");
URL urlFile1 = new URL("file:///" + file1.getAbsolutePath());
String resourceSearchName = file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf("\\") + 1);
strategy.addMostRecent(filteredResources, urlFile1, resourceSearchName);
Assert.assertEquals(1, filteredResources.size());
ReflectionAssert.assertLenientEquals(Arrays.asList(urlFile1), filteredResources);
}
示例12: testBuilder
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testBuilder() throws Exception {
final ResourceSpecification actual = ResourceSpecification.Builder.with()
.setVirtualCores(5)
.setMemory(4, ResourceSpecification.SizeUnit.GIGA)
.setInstances(3)
.setUplink(10, ResourceSpecification.SizeUnit.GIGA)
.setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
.build();
final DefaultResourceSpecification expected =
new DefaultResourceSpecification(5, 4096, 3, 10240, 5120);
ReflectionAssert.assertLenientEquals(expected, actual);
}
示例13: testBuilderWithLists
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
public void testBuilderWithLists() throws Exception {
final ResourceSpecification actual = ResourceSpecification.Builder.with()
.setVirtualCores(5)
.setMemory(4, ResourceSpecification.SizeUnit.GIGA)
.setInstances(3)
.setUplink(10, ResourceSpecification.SizeUnit.GIGA)
.setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
.build();
final DefaultResourceSpecification expected =
new DefaultResourceSpecification(5, 4096, 3, 10240, 5120);
ReflectionAssert.assertLenientEquals(expected, actual);
}
示例14: testByte
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
/**
* @throws SecurityException
* @throws NoSuchFieldException
*/
@Test
public void testByte() throws SecurityException, NoSuchFieldException{
ReflectionUtils.setFieldValue(testclass, "byteTest", new Byte("125"));
ReflectionAssert.assertLenientEquals(new Byte("125"), testclass.getByteTest());
}
示例15: testFindById
import org.unitils.reflectionassert.ReflectionAssert; //导入方法依赖的package包/类
@Test
@DataSet("../datasets/SinglePerson.xml")
public void testFindById() {
Person userFromDb = entityManager.find(Person.class, 1L);
ReflectionAssert.assertLenientEquals(person, userFromDb);
}