-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fuer Rekursion in BeanUtil.get()
- Loading branch information
Showing
4 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" output="test-bin" path="test"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry exported="true" kind="lib" path="lib/mckoidb.jar"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/util"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/releases | ||
/test-bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/********************************************************************** | ||
* | ||
* Copyright (c) by Olaf Willuhn | ||
* All rights reserved | ||
* | ||
**********************************************************************/ | ||
|
||
package de.willuhn.datasource; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Unit-Tests fuer die Bean-Utils. | ||
*/ | ||
public class TestBeanUtil | ||
{ | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test001() throws Exception | ||
{ | ||
Customer c = new Customer(); | ||
String s = (String) BeanUtil.get(c,"project.task.name"); | ||
Assert.assertEquals("Test-Task",s); | ||
|
||
Project p = (Project) BeanUtil.get(c,"project"); | ||
Assert.assertEquals(p.getClass(),Project.class); | ||
|
||
Task t = (Task) BeanUtil.get(c,"project.task"); | ||
Assert.assertEquals(t.getClass(),Task.class); | ||
|
||
s = (String) BeanUtil.get(t,"name"); | ||
Assert.assertEquals("Test-Task",s); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test002() throws Exception | ||
{ | ||
Project p = new Project(); | ||
String s = (String) BeanUtil.get(p,"task.name"); | ||
Assert.assertEquals("Test-Task",s); | ||
|
||
Task t = (Task) BeanUtil.get(p,"task"); | ||
Assert.assertEquals(t.getClass(),Task.class); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test003() throws Exception | ||
{ | ||
Project p = new Project(); | ||
String s = (String) BeanUtil.get(p,"name"); | ||
Assert.assertEquals("Test-Project",s); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test004() throws Exception | ||
{ | ||
Customer c = new Customer(); | ||
Task t = (Task) BeanUtil.get(c,"project.task"); | ||
Assert.assertEquals(t.getClass(),Task.class); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test005() throws Exception | ||
{ | ||
Customer c = new Customer(); | ||
Assert.assertNull(BeanUtil.get(c,"project.invalid")); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void test006() throws Exception | ||
{ | ||
Customer c = new Customer(); | ||
Assert.assertNull(BeanUtil.get(c,"project.invalid.name")); | ||
} | ||
|
||
|
||
@SuppressWarnings("javadoc") | ||
public class Customer | ||
{ | ||
private String name = "Test-Customer"; | ||
private Project project = new Project(); | ||
|
||
public String getName() | ||
{ | ||
return this.name; | ||
} | ||
|
||
public Project getProject() | ||
{ | ||
return this.project; | ||
} | ||
} | ||
|
||
@SuppressWarnings("javadoc") | ||
public class Project | ||
{ | ||
private String name = "Test-Project"; | ||
private Task task = new Task(); | ||
|
||
public String getName() | ||
{ | ||
return this.name; | ||
} | ||
|
||
public Task getTask() | ||
{ | ||
return this.task; | ||
} | ||
} | ||
|
||
@SuppressWarnings("javadoc") | ||
public class Task | ||
{ | ||
private String name = "Test-Task"; | ||
|
||
public String getName() | ||
{ | ||
return this.name; | ||
} | ||
} | ||
} | ||
|
||
|