diff --git a/samples/article/pom.xml b/samples/article/pom.xml
index dd7756d6..ee9e91b3 100644
--- a/samples/article/pom.xml
+++ b/samples/article/pom.xml
@@ -71,16 +71,4 @@
test
-
\ No newline at end of file
diff --git a/samples/article/readme.txt b/samples/article/readme.txt
index 492ff22f..ce205f2f 100644
--- a/samples/article/readme.txt
+++ b/samples/article/readme.txt
@@ -1,4 +1,4 @@
-Sample application demonstrating how to do the most basic stuff in Spring LDAP
+Sample application demonstrating how to do the most basic stuff in Spring LDAP.
A very simple dao implementation is provided in
org.springframework.ldap.samples.article.dao.PersonDaoImpl
It demonstrates some basic operations using Spring LDAP. For reference purposes,
@@ -7,11 +7,14 @@ available in TraditionalPersonDaoImpl.
How to use:
-----------
-The project is in a maven build structure. Make sure you have installed the samples-utils artifact, as this will be
+The project is in a Maven build structure. Make sure you have installed the samples-utils artifact, as this will be
needed for this project to work.
-mvn jetty:run will start up a web server demonstrating the capabilities. The web application will be available
+'mvn jetty:run' will start up a web server demonstrating the capabilities. The web application will be available
under http://localhost:8080/spring-ldap-person-article/
-mvn eclipse:eclipse will construct an eclipse project for you to use. Import that project into eclipse using
+'mvn eclipse:eclipse' will construct an Eclipse project for you to use. Import that project into Eclipse using
File/Import/Existing Project, and select this directory.
+
+'mvn test' will run some integration tests that require the LDAP server to be running. It's recommended to run
+'mvn jetty:run' from another terminal window before 'mvn test'.
\ No newline at end of file
diff --git a/samples/article/src/main/java/log4j.properties b/samples/article/src/main/java/log4j.properties
index 4ab57157..80ee2eb0 100644
--- a/samples/article/src/main/java/log4j.properties
+++ b/samples/article/src/main/java/log4j.properties
@@ -14,6 +14,3 @@ log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#Pattern to output : date priority [category] - line_separator
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n
-
-#Enable debug logging
-#log4j.category.net.sf.ldaptemplate=DEBUG
diff --git a/samples/article/src/main/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImpl.java b/samples/article/src/main/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImpl.java
index 2affc9fe..e7f5335b 100644
--- a/samples/article/src/main/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImpl.java
+++ b/samples/article/src/main/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImpl.java
@@ -33,7 +33,6 @@ import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import org.apache.commons.lang.StringUtils;
-import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.ldap.samples.article.domain.Person;
/**
@@ -90,6 +89,7 @@ public class TraditionalPersonDaoImpl implements
dn, null,
getAttributesToBind(person));
} catch (NamingException e) {
+
throw new RuntimeException(e);
} finally {
if (ctx != null) {
@@ -147,9 +147,6 @@ public class TraditionalPersonDaoImpl implements
String cn = (String) attr.get();
list.add(cn);
}
- } catch (NameNotFoundException e) {
- // The base context was not found.
- // Just clean up and exit.
} catch (NamingException e) {
throw new RuntimeException(e);
} finally {
@@ -194,10 +191,6 @@ public class TraditionalPersonDaoImpl implements
.getAttributes();
list.add(mapToPerson(dn, attributes));
}
- } catch (NameNotFoundException e) {
- // The base context was not found, which basically means
- // that the search did not return any results. Just clean up and
- // exit.
} catch (NamingException e) {
throw new RuntimeException(e);
} finally {
@@ -234,7 +227,7 @@ public class TraditionalPersonDaoImpl implements
.getAttributes(dn);
return mapToPerson(dn, attributes);
} catch (NameNotFoundException e) {
- throw new DataRetrievalFailureException(
+ throw new RuntimeException(
"Did not find entry with primary key '"
+ dn + "'", e);
} catch (NamingException e) {
diff --git a/samples/article/src/main/webapp/WEB-INF/applicationContext.xml b/samples/article/src/main/webapp/WEB-INF/applicationContext.xml
index 1cc7472c..5331fea0 100644
--- a/samples/article/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/samples/article/src/main/webapp/WEB-INF/applicationContext.xml
@@ -8,7 +8,6 @@
-
diff --git a/samples/article/src/test/java/.dummy b/samples/article/src/test/java/.dummy
deleted file mode 100644
index e69de29b..00000000
diff --git a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
similarity index 87%
rename from samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
rename to samples/article/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
index e9e63f95..a682c53a 100644
--- a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
+++ b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
@@ -17,7 +17,7 @@ package org.springframework.ldap.samples.article.dao;
import java.util.List;
-import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.ldap.NameNotFoundException;
import org.springframework.ldap.samples.article.dao.PersonDao;
import org.springframework.ldap.samples.article.domain.Person;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
@@ -90,23 +90,25 @@ public abstract class AbstractPersonDaoIntegrationTest
personDao.findByPrimaryKey(
"Sweden", "company1",
"Another Person");
- fail("DataRetrievalFailureException expected");
- } catch (DataRetrievalFailureException expected) {
- // expected
+ fail("NameNotFoundException (when using Spring LDAP) or RuntimeException (when using traditional) expected");
+ } catch (NameNotFoundException expected) {
+ // expected
+ } catch (RuntimeException expected) {
+ // expected
}
}
}
public void testGetAllPersonNames() {
List result = personDao.getAllPersonNames();
- assertEquals(5, result.size());
+ assertEquals(2, result.size());
String first = (String) result.get(0);
assertEquals("Some Person", first);
}
public void testFindAll() {
List result = personDao.findAll();
- assertEquals(5, result.size());
+ assertEquals(2, result.size());
Person first = (Person) result.get(0);
assertEquals("Some Person", first
.getFullName());
diff --git a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
similarity index 92%
rename from samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
rename to samples/article/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
index 928207fd..dd013179 100644
--- a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
+++ b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
@@ -20,7 +20,7 @@ import org.springframework.ldap.samples.article.dao.PersonDaoImpl;
/**
* Integration tests for the PersonDaoImpl class.
*
- * @author Mattias Hellborg Arthursson
+ * @author Mattias Hellborg Arthurssonrthursson
* @author Ulrik Sandberg
*/
public class PersonDaoImplIntegrationTest extends
diff --git a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
similarity index 90%
rename from samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
rename to samples/article/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
index e2ce5377..4cc677f9 100644
--- a/samples/article/src/itest/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
+++ b/samples/article/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
@@ -15,8 +15,6 @@
*/
package org.springframework.ldap.samples.article.dao;
-import org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl;
-
/**
* Integration tests for the TraditionalPersonDaoImpl class.
*
diff --git a/samples/article/src/test/resources/config/ldap.properties b/samples/article/src/test/resources/config/ldap.properties
index 270d8f72..8843f1f1 100644
--- a/samples/article/src/test/resources/config/ldap.properties
+++ b/samples/article/src/test/resources/config/ldap.properties
@@ -1,4 +1,4 @@
-urls=ldap://127.0.0.1
-userDn=cn=Manager,dc=jayway,dc=se
+urls=ldap://127.0.0.1:3900
+userDn=uid=admin,ou=system
password=secret
base=dc=jayway,dc=se
diff --git a/samples/article/src/test/resources/config/testContext.xml b/samples/article/src/test/resources/config/testContext.xml
index 7f3b07f3..b9a60eea 100644
--- a/samples/article/src/test/resources/config/testContext.xml
+++ b/samples/article/src/test/resources/config/testContext.xml
@@ -26,7 +26,7 @@
-
+