diff options
Diffstat (limited to 'eaaf_core/src/test/java/at')
3 files changed, 87 insertions, 2 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java index 33bd1010..19054634 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java @@ -307,7 +307,7 @@ public class AuthenticationDataBuilderTest { throw new Exception("GivenName wrong"); } - if (!authData.getFormatedDateOfBirth().equals("1973-06-04")) { + if (!authData.getDateOfBirth().equals("1973-06-04")) { throw new Exception("DateOfBirth wrong"); } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java index 21cf71a9..f155b3b4 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java @@ -29,7 +29,7 @@ public class BirthdayAttrBuilderTest extends AbstractAttributeBuilderTest { final DateFormat format = new SimpleDateFormat(PvpAttributeDefinitions.BIRTHDATE_FORMAT_PATTERN); Assert.assertEquals("Birthday does NOT match", authData.getDateOfBirth(), - format.parse(value)); + value); } catch (final Exception e) { Assert.assertTrue("Attr. builder has an exception", e == null); diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java new file mode 100644 index 00000000..9d99b158 --- /dev/null +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java @@ -0,0 +1,85 @@ +package at.gv.egiz.eaaf.core.impl.idp.auth.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; + +import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData; + +@RunWith(BlockJUnit4ClassRunner.class) +public class AuthenticationDataTest { + + @Test + public void formatedDateButNotSet() { + AuthenticationData authData = new AuthenticationData(); + assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy")); + + } + + @Test + public void formatedDateButInvalidPattern() { + AuthenticationData authData = new AuthenticationData(); + authData.setDateOfBirth("1940-01-01"); + assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("aa-bb-cccc")); + + } + + @Test + public void validDateStatic() { + AuthenticationData authData = new AuthenticationData(); + + String date = "1940-01-01"; + authData.setDateOfBirth(date); + + assertNotNull("birthday", authData.getDateOfBirth()); + assertEquals("birthday attribute", date, + authData.getDateOfBirth()); + assertEquals("birthday attribute", "01/01/1940", + authData.getDateOfBirthFormated("dd/MM/yyy")); + + } + + + @Test + public void validButNotUsal() { + AuthenticationData authData = new AuthenticationData(); + authData.setDateOfBirth("1970-00-00"); + + assertNotNull("birthday", authData.getDateOfBirth()); + assertEquals("birthday attribute", "1970-00-00", + authData.getDateOfBirth()); + assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy")); + + } + + @Test + public void invalidDate() { + AuthenticationData authData = new AuthenticationData(); + authData.setDateOfBirth("1970/00/00"); + + assertNull("birthday", authData.getDateOfBirth()); + assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy")); + + } + + + @Test + public void validDateRandom() { + AuthenticationData authData = new AuthenticationData(); + + String date = RandomStringUtils.randomNumeric(4) + "-" + RandomStringUtils.randomNumeric(2) + + "-" + RandomStringUtils.randomNumeric(2); + authData.setDateOfBirth(date); + + assertNotNull("birthday", authData.getDateOfBirth()); + assertEquals("birthday attribute", date, + authData.getDateOfBirth()); + + } + +} |