Click a person row to see the attribute values (country and company rows do not have additional info)
+
+ ${row}
+
+
+
+
diff --git a/samples/article-spring30/src/main/webapp/WEB-INF/ldap.properties b/samples/article-spring30/src/main/webapp/WEB-INF/ldap.properties
new file mode 100644
index 00000000..8843f1f1
--- /dev/null
+++ b/samples/article-spring30/src/main/webapp/WEB-INF/ldap.properties
@@ -0,0 +1,4 @@
+urls=ldap://127.0.0.1:3900
+userDn=uid=admin,ou=system
+password=secret
+base=dc=jayway,dc=se
diff --git a/samples/article-spring30/src/main/webapp/WEB-INF/setup_data.ldif b/samples/article-spring30/src/main/webapp/WEB-INF/setup_data.ldif
new file mode 100644
index 00000000..e6d7dce6
--- /dev/null
+++ b/samples/article-spring30/src/main/webapp/WEB-INF/setup_data.ldif
@@ -0,0 +1,35 @@
+dn: c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Sweden
+description: The country of Sweden
+
+dn: ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Sweden
+
+dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company1, Some Person
+telephoneNumber: +46 555-123456
+
+dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person2
+userPassword: password
+cn: Some Person2
+sn: Person2
+description: Sweden, Company1, Some Person2
+telephoneNumber: +46 555-654321
diff --git a/samples/article-spring30/src/main/webapp/WEB-INF/web.xml b/samples/article-spring30/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..3482f7a9
--- /dev/null
+++ b/samples/article-spring30/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,34 @@
+
+
+
+ Spring LDAP Basic Example
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ basic
+
+ org.springframework.web.servlet.DispatcherServlet
+
+
+ contextConfigLocation
+ /WEB-INF/basic-servlet.xml
+
+ 1
+
+
+
+ basic
+ *.do
+
+
+
+ index.htm
+
+
diff --git a/samples/article-spring30/src/main/webapp/index.htm b/samples/article-spring30/src/main/webapp/index.htm
new file mode 100644
index 00000000..c4a3f6f3
--- /dev/null
+++ b/samples/article-spring30/src/main/webapp/index.htm
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
new file mode 100644
index 00000000..a682c53a
--- /dev/null
+++ b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/AbstractPersonDaoIntegrationTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.ldap.samples.article.dao;
+
+import java.util.List;
+
+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;
+
+/**
+ * Abstract base class for PersonDao integration tests.
+ *
+ * @author Mattias Hellborg Arthursson
+ * @author Ulrik Sandberg
+ */
+public abstract class AbstractPersonDaoIntegrationTest
+ extends
+ AbstractDependencyInjectionSpringContextTests {
+
+ protected Person person;
+
+ protected PersonDao personDao;
+
+ protected String[] getConfigLocations() {
+ return new String[] { "config/testContext.xml" };
+ }
+
+ protected void onSetUp() throws Exception {
+ super.onSetUp();
+ person = new Person();
+ person.setCountry("Sweden");
+ person.setCompany("company1");
+ person.setFullName("Some Person");
+ person.setLastName("Person");
+ person
+ .setDescription("Sweden, Company1, Some Person");
+ person.setPhone("+46 555-123456");
+ }
+
+ protected void onTearDown() throws Exception {
+ super.onTearDown();
+ person = null;
+ personDao = null;
+ }
+
+ /**
+ * Having a single test method test create, update and delete is not exactly
+ * the ideal way of testing, since they depend on each other. A better way
+ * would be to separate the tests and load a test fixture before each
+ * operation, in order to guarantee the expected state every time. See the
+ * ldaptemplate-person sample for the correct way to do this.
+ */
+ public void testCreateUpdateDelete() {
+ try {
+ person.setFullName("Another Person");
+ personDao.create(person);
+ personDao.findByPrimaryKey(
+ "Sweden", "company1",
+ "Another Person");
+ // if we got here, create succeeded
+
+ person
+ .setDescription("Another description");
+ personDao.update(person);
+ Person result = personDao
+ .findByPrimaryKey(
+ "Sweden", "company1",
+ "Another Person");
+ assertEquals(
+ "Another description", result
+ .getDescription());
+ } finally {
+ personDao.delete(person);
+ try {
+ personDao.findByPrimaryKey(
+ "Sweden", "company1",
+ "Another Person");
+ 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(2, result.size());
+ String first = (String) result.get(0);
+ assertEquals("Some Person", first);
+ }
+
+ public void testFindAll() {
+ List result = personDao.findAll();
+ assertEquals(2, result.size());
+ Person first = (Person) result.get(0);
+ assertEquals("Some Person", first
+ .getFullName());
+ }
+
+ public void testFindByPrimaryKey() {
+ Person result = personDao.findByPrimaryKey(
+ "Sweden", "company1", "Some Person");
+ assertEquals(person, result);
+ }
+}
diff --git a/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
new file mode 100644
index 00000000..928207fd
--- /dev/null
+++ b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/PersonDaoImplIntegrationTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2005-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.ldap.samples.article.dao;
+
+import org.springframework.ldap.samples.article.dao.PersonDaoImpl;
+
+/**
+ * Integration tests for the PersonDaoImpl class.
+ *
+ * @author Mattias Hellborg Arthursson
+ * @author Ulrik Sandberg
+ */
+public class PersonDaoImplIntegrationTest extends
+ AbstractPersonDaoIntegrationTest {
+
+ public void setPersonDao(
+ PersonDaoImpl personDao) {
+ this.personDao = personDao;
+ }
+}
diff --git a/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
new file mode 100644
index 00000000..4cc677f9
--- /dev/null
+++ b/samples/article-spring30/src/test/java/org/springframework/ldap/samples/article/dao/TraditionalPersonDaoImplIntegrationTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.ldap.samples.article.dao;
+
+/**
+ * Integration tests for the TraditionalPersonDaoImpl class.
+ *
+ * @author Mattias Hellborg Arthursson
+ * @author Ulrik Sandberg
+ */
+public class TraditionalPersonDaoImplIntegrationTest
+ extends AbstractPersonDaoIntegrationTest {
+
+ public void setPersonDao(
+ TraditionalPersonDaoImpl personDao) {
+ this.personDao = personDao;
+ }
+}
diff --git a/samples/article-spring30/src/test/resources/config/ldap.properties b/samples/article-spring30/src/test/resources/config/ldap.properties
new file mode 100644
index 00000000..8843f1f1
--- /dev/null
+++ b/samples/article-spring30/src/test/resources/config/ldap.properties
@@ -0,0 +1,4 @@
+urls=ldap://127.0.0.1:3900
+userDn=uid=admin,ou=system
+password=secret
+base=dc=jayway,dc=se
diff --git a/samples/article-spring30/src/test/resources/config/testContext.xml b/samples/article-spring30/src/test/resources/config/testContext.xml
new file mode 100644
index 00000000..4a762506
--- /dev/null
+++ b/samples/article-spring30/src/test/resources/config/testContext.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/article-spring30/src/test/resources/setup_data.ldif b/samples/article-spring30/src/test/resources/setup_data.ldif
new file mode 100644
index 00000000..e6d7dce6
--- /dev/null
+++ b/samples/article-spring30/src/test/resources/setup_data.ldif
@@ -0,0 +1,35 @@
+dn: c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Sweden
+description: The country of Sweden
+
+dn: ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Sweden
+
+dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company1, Some Person
+telephoneNumber: +46 555-123456
+
+dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person2
+userPassword: password
+cn: Some Person2
+sn: Person2
+description: Sweden, Company1, Some Person2
+telephoneNumber: +46 555-654321
diff --git a/samples/pom.xml b/samples/pom.xml
index f19d0223..2d491dd8 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -17,6 +17,7 @@
samples-utilsarticlearticle-spring20
+ article-spring30demos