LDAP-295: DefaultObjectDirectoryMapper null check SpringVersion.getVersion()

This commit is contained in:
Rob Winch
2014-02-14 14:16:18 -06:00
parent 0bd11cd4e4
commit 5e27d29004
4 changed files with 52 additions and 21 deletions

View File

@@ -1,25 +1,34 @@
package org.springframework.ldap.odm.core.impl;
import org.junit.Before;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.util.StringUtils;
import javax.naming.Name;
import java.lang.reflect.Field;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.spy;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
import java.lang.reflect.Field;
import javax.naming.Name;
import org.junit.Before;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.core.SpringVersion;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.util.StringUtils;
/**
* @author Mattias Hellborg Arthursson
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(SpringVersion.class)
public class DefaultObjectDirectoryMapperTest {
private DefaultObjectDirectoryMapper tested;
@@ -29,6 +38,15 @@ public class DefaultObjectDirectoryMapperTest {
tested = new DefaultObjectDirectoryMapper();
}
// LDAP-295
@Test
public void springVersionIsNull() {
spy(SpringVersion.class);
when(SpringVersion.getVersion()).thenReturn(null);
new DefaultObjectDirectoryMapper();
}
@Test
public void testMapping() {
tested.manageClass(UnitTestPerson.class);