org.springframework.tests.sample.objects.TestObject Java Examples
The following examples show how to use
org.springframework.tests.sample.objects.TestObject.
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: AutoPopulatingListTests.java From spring-analysis-note with MIT License | 6 votes |
private void doTestWithClass(AutoPopulatingList<Object> list) { Object lastElement = null; for (int x = 0; x < 10; x++) { Object element = list.get(x); assertNotNull("Element is null", list.get(x)); assertTrue("Element is incorrect type", element instanceof TestObject); assertNotSame(lastElement, element); lastElement = element; } String helloWorld = "Hello World!"; list.add(10, null); list.add(11, helloWorld); assertEquals(helloWorld, list.get(11)); assertTrue(list.get(10) instanceof TestObject); assertTrue(list.get(12) instanceof TestObject); assertTrue(list.get(13) instanceof TestObject); assertTrue(list.get(20) instanceof TestObject); }
Example #2
Source File: AutoPopulatingListTests.java From java-technology-stack with MIT License | 6 votes |
private void doTestWithClass(AutoPopulatingList<Object> list) { Object lastElement = null; for (int x = 0; x < 10; x++) { Object element = list.get(x); assertNotNull("Element is null", list.get(x)); assertTrue("Element is incorrect type", element instanceof TestObject); assertNotSame(lastElement, element); lastElement = element; } String helloWorld = "Hello World!"; list.add(10, null); list.add(11, helloWorld); assertEquals(helloWorld, list.get(11)); assertTrue(list.get(10) instanceof TestObject); assertTrue(list.get(12) instanceof TestObject); assertTrue(list.get(13) instanceof TestObject); assertTrue(list.get(20) instanceof TestObject); }
Example #3
Source File: AutoPopulatingListTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void doTestWithClass(AutoPopulatingList<Object> list) { Object lastElement = null; for (int x = 0; x < 10; x++) { Object element = list.get(x); assertNotNull("Element is null", list.get(x)); assertTrue("Element is incorrect type", element instanceof TestObject); assertNotSame(lastElement, element); lastElement = element; } String helloWorld = "Hello World!"; list.add(10, null); list.add(11, helloWorld); assertEquals(helloWorld, list.get(11)); assertTrue(list.get(10) instanceof TestObject); assertTrue(list.get(12) instanceof TestObject); assertTrue(list.get(13) instanceof TestObject); assertTrue(list.get(20) instanceof TestObject); }
Example #4
Source File: ClassUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testForName() throws ClassNotFoundException { assertEquals(String.class, ClassUtils.forName("java.lang.String", classLoader)); assertEquals(String[].class, ClassUtils.forName("java.lang.String[]", classLoader)); assertEquals(String[].class, ClassUtils.forName(String[].class.getName(), classLoader)); assertEquals(String[][].class, ClassUtils.forName(String[][].class.getName(), classLoader)); assertEquals(String[][][].class, ClassUtils.forName(String[][][].class.getName(), classLoader)); assertEquals(TestObject.class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject", classLoader)); assertEquals(TestObject[].class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject[]", classLoader)); assertEquals(TestObject[].class, ClassUtils.forName(TestObject[].class.getName(), classLoader)); assertEquals(TestObject[][].class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject[][]", classLoader)); assertEquals(TestObject[][].class, ClassUtils.forName(TestObject[][].class.getName(), classLoader)); assertEquals(short[][][].class, ClassUtils.forName("[[[S", classLoader)); }
Example #5
Source File: ConventionsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void list() { assertEquals("Incorrect plural List form", "testObjectList", Conventions.getVariableName(Collections.singletonList(new TestObject()))); assertEquals("Incorrect plural List form", "testObjectList", Conventions.getVariableNameForParameter(getMethodParameter(List.class))); assertEquals("Incorrect plural List form", "testObjectList", Conventions.getVariableNameForReturnType(getMethodForReturnType(List.class))); }
Example #6
Source File: ReflectionUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void doWithProtectedMethods() { ListSavingMethodCallback mc = new ListSavingMethodCallback(); ReflectionUtils.doWithMethods(TestObject.class, mc, new ReflectionUtils.MethodFilter() { @Override public boolean matches(Method m) { return Modifier.isProtected(m.getModifiers()); } }); assertFalse(mc.getMethodNames().isEmpty()); assertTrue("Must find protected method on Object", mc.getMethodNames().contains("clone")); assertTrue("Must find protected method on Object", mc.getMethodNames().contains("finalize")); assertFalse("Public, not protected", mc.getMethodNames().contains("hashCode")); assertFalse("Public, not protected", mc.getMethodNames().contains("absquatulate")); }
Example #7
Source File: ConventionsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void simpleObject() { assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableName(new TestObject())); assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableNameForParameter(getMethodParameter(TestObject.class))); assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableNameForReturnType(getMethodForReturnType(TestObject.class))); }
Example #8
Source File: ReflectionUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void validCopyToSubType() { TestObject src = new TestObject(); TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField(); dest.magic = 11; testValidCopy(src, dest); // Should have left this one alone assertEquals(11, dest.magic); }
Example #9
Source File: LocalVariableTableParameterNameDiscovererTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Method getName = TestObject.class.getMethod("getName"); String[] names = discoverer.getParameterNames(getName); assertNotNull("should find method info", names); assertEquals("no argument names", 0, names.length); }
Example #10
Source File: AutoPopulatingListTests.java From spring-analysis-note with MIT License | 5 votes |
private void doTestWithElementFactory(AutoPopulatingList<Object> list) { doTestWithClass(list); for (int x = 0; x < list.size(); x++) { Object element = list.get(x); if (element instanceof TestObject) { assertEquals(x, ((TestObject) element).getAge()); } } }
Example #11
Source File: ClassUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testCountOverloadedMethods() { assertFalse(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "foobar")); // no args assertTrue(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "hashCode")); // matches although it takes an arg assertTrue(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "setAge")); }
Example #12
Source File: ReflectionUtilsTests.java From java-technology-stack with MIT License | 5 votes |
private void testValidCopy(TestObject src, TestObject dest) { src.setName("freddie"); src.setAge(15); src.setSpouse(new TestObject()); assertFalse(src.getAge() == dest.getAge()); ReflectionUtils.shallowCopyFieldState(src, dest); assertEquals(src.getAge(), dest.getAge()); assertEquals(src.getSpouse(), dest.getSpouse()); }
Example #13
Source File: ReflectionUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void doWithProtectedMethods() { ListSavingMethodCallback mc = new ListSavingMethodCallback(); ReflectionUtils.doWithMethods(TestObject.class, mc, new ReflectionUtils.MethodFilter() { @Override public boolean matches(Method m) { return Modifier.isProtected(m.getModifiers()); } }); assertFalse(mc.getMethodNames().isEmpty()); assertTrue("Must find protected method on Object", mc.getMethodNames().contains("clone")); assertTrue("Must find protected method on Object", mc.getMethodNames().contains("finalize")); assertFalse("Public, not protected", mc.getMethodNames().contains("hashCode")); assertFalse("Public, not protected", mc.getMethodNames().contains("absquatulate")); }
Example #14
Source File: ReflectionUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void testValidCopy(TestObject src, TestObject dest) { src.setName("freddie"); src.setAge(15); src.setSpouse(new TestObject()); assertFalse(src.getAge() == dest.getAge()); ReflectionUtils.shallowCopyFieldState(src, dest); assertEquals(src.getAge(), dest.getAge()); assertEquals(src.getSpouse(), dest.getSpouse()); }
Example #15
Source File: ReflectionUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void validCopyToSubType() { TestObject src = new TestObject(); TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField(); dest.magic = 11; testValidCopy(src, dest); // Should have left this one alone assertEquals(11, dest.magic); }
Example #16
Source File: ClassUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testCountOverloadedMethods() { assertFalse(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "foobar")); // no args assertTrue(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "hashCode")); // matches although it takes an arg assertTrue(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "setAge")); }
Example #17
Source File: LocalVariableTableParameterNameDiscovererTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException { Method setName = TestObject.class.getMethod("setName", String.class); String[] names = discoverer.getParameterNames(setName); assertNotNull("should find method info", names); assertEquals("one argument", 1, names.length); assertEquals("name", names[0]); }
Example #18
Source File: ConventionsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void set() { assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableName(Collections.singleton(new TestObject()))); assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableNameForParameter(getMethodParameter(Set.class))); assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class))); }
Example #19
Source File: LocalVariableTableParameterNameDiscovererTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Method getName = TestObject.class.getMethod("getName", new Class[0]); String[] names = discoverer.getParameterNames(getName); assertNotNull("should find method info", names); assertEquals("no argument names", 0, names.length); }
Example #20
Source File: ReflectionUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void validCopyToSubType() { TestObject src = new TestObject(); TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField(); dest.magic = 11; testValidCopy(src, dest); // Should have left this one alone assertEquals(11, dest.magic); }
Example #21
Source File: LocalVariableTableParameterNameDiscovererTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Constructor<TestObject> noArgsCons = TestObject.class.getConstructor(new Class[0]); String[] names = discoverer.getParameterNames(noArgsCons); assertNotNull("should find cons info", names); assertEquals("no argument names", 0, names.length); }
Example #22
Source File: LocalVariableTableParameterNameDiscovererTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException { Method setName = TestObject.class.getMethod("setName", new Class[] { String.class }); String[] names = discoverer.getParameterNames(setName); assertNotNull("should find method info", names); assertEquals("one argument", 1, names.length); assertEquals("name", names[0]); }
Example #23
Source File: AutoPopulatingListTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void doTestWithElementFactory(AutoPopulatingList<Object> list) { doTestWithClass(list); for(int x = 0; x < list.size(); x++) { Object element = list.get(x); if(element instanceof TestObject) { assertEquals(x, ((TestObject) element).getAge()); } } }
Example #24
Source File: LocalVariableTableParameterNameDiscovererTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException { Method setName = TestObject.class.getMethod("setName", String.class); String[] names = discoverer.getParameterNames(setName); assertNotNull("should find method info", names); assertEquals("one argument", 1, names.length); assertEquals("name", names[0]); }
Example #25
Source File: LocalVariableTableParameterNameDiscovererTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void consParameterNameDiscoveryArgs() throws NoSuchMethodException { Constructor<TestObject> twoArgCons = TestObject.class.getConstructor(new Class[] { String.class, int.class }); String[] names = discoverer.getParameterNames(twoArgCons); assertNotNull("should find cons info", names); assertEquals("one argument", 2, names.length); assertEquals("name", names[0]); assertEquals("age", names[1]); }
Example #26
Source File: LocalVariableTableParameterNameDiscovererTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Constructor<TestObject> noArgsCons = TestObject.class.getConstructor(); String[] names = discoverer.getParameterNames(noArgsCons); assertNotNull("should find cons info", names); assertEquals("no argument names", 0, names.length); }
Example #27
Source File: ConventionsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void set() { assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableName(Collections.singleton(new TestObject()))); assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableNameForParameter(getMethodParameter(Set.class))); assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class))); }
Example #28
Source File: AutoPopulatingListTests.java From java-technology-stack with MIT License | 5 votes |
private void doTestWithElementFactory(AutoPopulatingList<Object> list) { doTestWithClass(list); for (int x = 0; x < list.size(); x++) { Object element = list.get(x); if (element instanceof TestObject) { assertEquals(x, ((TestObject) element).getAge()); } } }
Example #29
Source File: LocalVariableTableParameterNameDiscovererTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void consParameterNameDiscoveryArgs() throws NoSuchMethodException { Constructor<TestObject> twoArgCons = TestObject.class.getConstructor(String.class, int.class); String[] names = discoverer.getParameterNames(twoArgCons); assertNotNull("should find cons info", names); assertEquals("one argument", 2, names.length); assertEquals("name", names[0]); assertEquals("age", names[1]); }
Example #30
Source File: ConventionsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void simpleObject() { assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableName(new TestObject())); assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableNameForParameter(getMethodParameter(TestObject.class))); assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableNameForReturnType(getMethodForReturnType(TestObject.class))); }