Skip to content

Commit

Permalink
Re-introducing FakeJavaMailSender testing semantics removed in prior …
Browse files Browse the repository at this point in the history
…commit.

Signed-off-by: Steve Taylor <staylor@pivotal.io>
  • Loading branch information
fhanik authored and staylor14 committed Jun 21, 2016
1 parent b2174ed commit 6ee89b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
@@ -1,5 +1,3 @@
package org.cloudfoundry.identity.uaa.provider;

/** /**
* **************************************************************************** * ****************************************************************************
* Cloud Foundry * Cloud Foundry
Expand All @@ -14,6 +12,9 @@
* subcomponent's license, as noted in the LICENSE file. * subcomponent's license, as noted in the LICENSE file.
* ***************************************************************************** * *****************************************************************************
*/ */
package org.cloudfoundry.identity.uaa.provider;


public class PasswordPolicy { public class PasswordPolicy {


public static final String PASSWORD_POLICY_FIELD = "passwordPolicy"; public static final String PASSWORD_POLICY_FIELD = "passwordPolicy";
Expand Down
Expand Up @@ -160,6 +160,8 @@ public void cleanup() throws Exception {


@Test @Test
public void testRootContextDefaults() throws Exception { public void testRootContextDefaults() throws Exception {
String originalSmtpHost = System.getProperty("smtp.host");
System.setProperty("smtp.host","");
context = getServletContext(activeProfiles, "login.yml","uaa.yml", "file:./src/main/webapp/WEB-INF/spring-servlet.xml"); context = getServletContext(activeProfiles, "login.yml","uaa.yml", "file:./src/main/webapp/WEB-INF/spring-servlet.xml");


JdbcUaaUserDatabase userDatabase = context.getBean(JdbcUaaUserDatabase.class); JdbcUaaUserDatabase userDatabase = context.getBean(JdbcUaaUserDatabase.class);
Expand Down Expand Up @@ -222,12 +224,7 @@ public void testRootContextDefaults() throws Exception {
EmailService emailService = context.getBean("emailService", EmailService.class); EmailService emailService = context.getBean("emailService", EmailService.class);
Field f = ReflectionUtils.findField(EmailService.class, "mailSender"); Field f = ReflectionUtils.findField(EmailService.class, "mailSender");
assertNotNull("Unable to find the JavaMailSender object on EmailService for validation.", f); assertNotNull("Unable to find the JavaMailSender object on EmailService for validation.", f);
String smtpHost = context.getEnvironment().getProperty("smtp.host"); assertEquals(FakeJavaMailSender.class, emailService.getMailSender().getClass());
if (smtpHost==null || smtpHost.length()==0) {
assertEquals(FakeJavaMailSender.class, emailService.getMailSender().getClass());
} else {
assertEquals(JavaMailSenderImpl.class, emailService.getMailSender().getClass());
}


assertEquals("admin@localhost", emailService.getFromAddress()); assertEquals("admin@localhost", emailService.getFromAddress());


Expand Down Expand Up @@ -307,6 +304,12 @@ public void testRootContextDefaults() throws Exception {
assertTrue(corFilter.getXhrConfiguration().isAllowedCredentials()); assertTrue(corFilter.getXhrConfiguration().isAllowedCredentials());
assertFalse(corFilter.getDefaultConfiguration().isAllowedCredentials()); assertFalse(corFilter.getDefaultConfiguration().isAllowedCredentials());


if (StringUtils.hasText(originalSmtpHost)) {
System.setProperty("smtp.host", originalSmtpHost);
} else {
System.clearProperty("smtp.host");
}

} }


@Test @Test
Expand Down

0 comments on commit 6ee89b6

Please sign in to comment.