From: <id...@us...> - 2009-03-18 07:40:24
|
Revision: 94 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=94&view=rev Author: idueppe Date: 2009-03-18 07:40:21 +0000 (Wed, 18 Mar 2009) Log Message: ----------- add .classpath to svn:ignore Property Changed: ---------------- trunk/sandbox/cse-ip/framework/test-utilities/ trunk/sandbox/cse-ip/sc-cdmm/ Property changes on: trunk/sandbox/cse-ip/framework/test-utilities ___________________________________________________________________ Added: svn:ignore + .classpath Property changes on: trunk/sandbox/cse-ip/sc-cdmm ___________________________________________________________________ Modified: svn:ignore - createDDL.jdbc dropDDL.jdbc + createDDL.jdbc dropDDL.jdbc .classpath This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-03-18 08:54:17
|
Revision: 95 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=95&view=rev Author: idueppe Date: 2009-03-18 08:54:12 +0000 (Wed, 18 Mar 2009) Log Message: ----------- Add license and reports to the pom and fixed the use of different version of toplink.essential between sc-cdmm and sc-idmapper Modified Paths: -------------- trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-cdmm/pom.xml Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-03-18 07:40:21 UTC (rev 94) +++ trunk/sandbox/cse-ip/pom.xml 2009-03-18 08:54:12 UTC (rev 95) @@ -37,30 +37,38 @@ </developer> </developers> + <licenses> + <license> + <name>GNU General Public License</name> + <url>http://www.gnu.org/copyleft/gpl.html</url> + </license> + </licenses> + <scm> <connection>scm:svn:https://cse-ip.svn.sourceforge.net/svnroot/cse-ip/trunk/cse-ip</connection> <url>https://cse-ip.svn.sourceforge.net/svnroot/cse-ip/trunk/cse-ip</url> </scm> + <organization> <name>CampusSource</name> <url>http://cse.campussource.de</url> </organization> <modules> - <module>framework</module> + <module>framework</module> <module>ica-his-lsf</module> <module>sc-idmapper</module> <module>sc-cdmm</module> <module>cse-ip-application</module> </modules> - + <repositories> <repository> <id>java-net</id> <name>Java.Net</name> <layout>legacy</layout> <url>https://maven-repository.dev.java.net/nonav/repository</url> - </repository> + </repository> </repositories> <build> @@ -123,6 +131,45 @@ </plugins> </build> + <reporting> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-pmd-plugin</artifactId> + <configuration> + <linkXref>true</linkXref> + <targetJdk>1.6</targetJdk> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-report-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>taglist-maven-plugin</artifactId> + <configuration> + <tags> + <tag>TODO</tag> + <tag>FIXME</tag> + </tags> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>cobertura-maven-plugin</artifactId> + </plugin> + </plugins> + </reporting> + <dependencyManagement> <dependencies> <dependency> Modified: trunk/sandbox/cse-ip/sc-cdmm/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-03-18 07:40:21 UTC (rev 94) +++ trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-03-18 08:54:12 UTC (rev 95) @@ -73,7 +73,7 @@ <dependency> <groupId>toplink.essentials</groupId> <artifactId>toplink-essentials</artifactId> - <version>2.1-60e</version> + <version>${toplink.version}</version> <scope>test</scope> </dependency> <dependency> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-03-24 18:21:45
|
Revision: 102 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=102&view=rev Author: idueppe Date: 2009-03-24 18:20:47 +0000 (Tue, 24 Mar 2009) Log Message: ----------- refactoring of pom.xml Modified Paths: -------------- trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-cdmm/pom.xml trunk/sandbox/cse-ip/sc-idmapper/pom.xml Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-03-24 15:02:05 UTC (rev 101) +++ trunk/sandbox/cse-ip/pom.xml 2009-03-24 18:20:47 UTC (rev 102) @@ -62,15 +62,36 @@ <module>cse-ip-application</module> </modules> + <repositories> <repository> + <id>download-java-net</id> + <name>Repository Java.Net</name> + <url>http://download.java.net/maven/2</url> + <layout>default</layout> + </repository> + <repository> <id>java-net</id> <name>Java.Net</name> <layout>legacy</layout> - <url>https://maven-repository.dev.java.net/nonav/repository</url> + <url>https://maven-repository.dev.java.net/repository</url> </repository> </repositories> + <pluginRepositories> + <pluginRepository> + <id>download-java-net</id> + <name>Repository Java.Net</name> + <url>http://download.java.net/maven/2</url> + <layout>default</layout> + </pluginRepository> + <pluginRepository> + <id>java-net</id> + <name>Java.Net</name> + <layout>legacy</layout> + <url>https://maven-repository.dev.java.net/repository</url> + </pluginRepository> + </pluginRepositories> <build> <defaultGoal>install</defaultGoal> <plugins> @@ -100,6 +121,9 @@ org.eclipse.wst.common.project.facet.core.nature </projectnature> </additionalProjectnatures> + <classpathContainers> + <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> + </classpathContainers> </configuration> </plugin> <plugin> @@ -173,6 +197,11 @@ <dependencyManagement> <dependencies> <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.4</version> @@ -204,6 +233,18 @@ <version>5.2.0</version> </dependency> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> @@ -211,12 +252,12 @@ <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> - <version>2.4</version> + <version>${commons-lang.version}</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> - <version>3.2.1</version> + <version>${commons-collections.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> @@ -228,6 +269,18 @@ <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>${mysql.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>toplink.essentials</groupId> + <artifactId>toplink-essentials</artifactId> + <version>2.1-60f</version> + <scope>test</scope> + </dependency> </dependencies> </dependencyManagement> @@ -238,8 +291,10 @@ <spring.version>2.5.6</spring.version> <jaxb-impl.version>2.1.7</jaxb-impl.version> <mysql.version>5.1.6</mysql.version> + <commons-lang.version>2.4</commons-lang.version> + <commons-collections.version>3.2.1</commons-collections.version> <slf4j.version>1.5.6</slf4j.version> - <toplink.version>2.1-60f</toplink.version> + <!-- TEST Bibliotheken --> </properties> </project> \ No newline at end of file Modified: trunk/sandbox/cse-ip/sc-cdmm/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-03-24 15:02:05 UTC (rev 101) +++ trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-03-24 18:20:47 UTC (rev 102) @@ -11,7 +11,7 @@ <groupId>de.campussource.cse</groupId> <artifactId>sc-cdmm</artifactId> <packaging>ejb</packaging> - <name>Service Component Canonical Date Model Manager</name> + <name>Service Component Canonical Data Model Manager</name> <version>1.0-SNAPSHOT</version> <dependencies> @@ -30,8 +30,6 @@ <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> - <version>1.0</version> - <scope>compile</scope> </dependency> <dependency> <groupId>commons-lang</groupId> @@ -44,7 +42,6 @@ <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> - <version>${mysql.version}</version> <scope>test</scope> </dependency> <dependency> @@ -55,13 +52,11 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>${slf4j.version}</version> <scope>test</scope> </dependency> <!-- <dependency> --> @@ -73,7 +68,6 @@ <dependency> <groupId>toplink.essentials</groupId> <artifactId>toplink-essentials</artifactId> - <version>${toplink.version}</version> <scope>test</scope> </dependency> <dependency> Modified: trunk/sandbox/cse-ip/sc-idmapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-03-24 15:02:05 UTC (rev 101) +++ trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-03-24 18:20:47 UTC (rev 102) @@ -44,7 +44,6 @@ <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> - <version>${mysql.version}</version> <scope>test</scope> </dependency> <dependency> @@ -64,16 +63,9 @@ <version>${slf4j.version}</version> <scope>test</scope> </dependency> -<!-- <dependency> --> -<!-- <groupId>org.hibernate</groupId> --> -<!-- <artifactId>hibernate-entitymanager</artifactId> --> -<!-- <version>3.4.0.GA</version> --> -<!-- <scope>test</scope>--> -<!-- </dependency> --> <dependency> <groupId>toplink.essentials</groupId> <artifactId>toplink-essentials</artifactId> - <version>${toplink.version}</version> <scope>test</scope> </dependency> <dependency> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-03-25 19:18:45
|
Revision: 114 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=114&view=rev Author: idueppe Date: 2009-03-25 19:17:46 +0000 (Wed, 25 Mar 2009) Log Message: ----------- renamed persistence unit for testing to cseip-test Modified Paths: -------------- trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/resources/META-INF/persistence.xml trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java trunk/sandbox/cse-ip/sc-idmapper/src/test/resources/META-INF/persistence.xml Added Paths: ----------- trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml Removed Paths: ------------- trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml Modified: trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java =================================================================== --- trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java 2009-03-25 19:17:46 UTC (rev 114) @@ -20,7 +20,7 @@ @BeforeClass public static void retrieveEntityManagerFactory() { - entityManagerFactory = Persistence.createEntityManagerFactory("cseip"); + entityManagerFactory = Persistence.createEntityManagerFactory("cseip-test"); } @Before Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/resources/META-INF/persistence.xml 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/resources/META-INF/persistence.xml 2009-03-25 19:17:46 UTC (rev 114) @@ -2,7 +2,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> - <persistence-unit name="cseip" transaction-type="RESOURCE_LOCAL"> + <persistence-unit name="cseip-test" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <class>de.campussource.cse.cdmm.domain.Account</class> <class>de.campussource.cse.cdmm.domain.Category</class> Deleted: trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml 2009-03-25 19:17:46 UTC (rev 114) @@ -1,21 +0,0 @@ -<persistence xmlns="http://java.sun.com/xml/ns/persistence" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" - version="1.0"> - <persistence-unit name="cs-idmapper" transaction-type="RESOURCE_LOCAL"> - <provider>oracle.toplink.essentials.PersistenceProvider</provider> - <class>de.campussource.cse.mapper.MappedClientObject</class> - <properties> - <property name="toplink.ddl-generation" value="drop-and-create-tables" /> - <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" /> - <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/cseip?createDatabaseIfNotExist=true" /> - <property name="toplink.jdbc.user" value="root" /> - <property name="toplink.jdbc.password" value="masterkey" /> - </properties> - </persistence-unit> -</persistence> - - - - - \ No newline at end of file Added: trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/resources/META-INF/persistence.xml 2009-03-25 19:17:46 UTC (rev 114) @@ -0,0 +1,15 @@ +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="cs-idmapper"> + <provider>oracle.toplink.essentials.PersistenceProvider</provider> + <jta-data-source>jdbc/cseip</jta-data-source> + <class>de.campussource.cse.mapper.MappedClientObject</class> + </persistence-unit> +</persistence> + + + + + \ No newline at end of file Modified: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java 2009-03-25 19:17:46 UTC (rev 114) @@ -3,6 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import javax.persistence.RollbackException; + import org.junit.Before; import org.junit.Test; @@ -23,6 +25,9 @@ @Before public void setUp() { txBegin(); + // CleanUp Database + entityManager.createNativeQuery("DELETE FROM MAPPED_CLIENT_OBJECT").executeUpdate(); + commitAndBeginTx(); mapper = new IdentityMapperBean(); autowireByType(mapper); } @@ -34,6 +39,16 @@ assertEquals(CLIENT_OBJECT_ID, clientId); } + @Test + public void testMultiBusToMapping() throws MapperException { + for (int i = 0; i < 10; i++) { + Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + String clientId = mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID); + assertEquals(CLIENT_OBJECT_ID, clientId); + commitAndBeginTx(); + } + } + @Test(expected = IdNotFoundException.class) public void testBusIdNotFound() throws IdNotFoundException { mapper.toClientObjectId(CLIENT_INSTANCE_ID, UNKNOWN_BUS_ID); @@ -48,16 +63,25 @@ @Test public void testPersistClientObjectId() throws MapperException { - // Persist a new mapping of client object id to a given bus id and verify the results + // Persist a new mapping of client object id to a given bus id and + // verify the results mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); commitAndBeginTx(); assertEquals(BUS_ID, mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID)); assertEquals(CLIENT_OBJECT_ID, mapper.toClientObjectId(BUS_ID, CLIENT_INSTANCE_ID)); - // Override the existing mapping to a new client object id and verify the results + // Override the existing mapping to a new client object id and verify + // the results mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, "NEW:CLIENT:OBJECT:ID"); assertEquals(BUS_ID, mapper.toBusId(CLIENT_INSTANCE_ID, "NEW:CLIENT:OBJECT:ID")); assertEquals("NEW:CLIENT:OBJECT:ID", mapper.toClientObjectId(BUS_ID, CLIENT_INSTANCE_ID)); } + + @Test(expected=RollbackException.class) + public void testErrorPersistClientObjectId() throws MapperException { + mapper.persistClientObjectId(1L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + mapper.persistClientObjectId(2L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + commitAndBeginTx(); + } @Test(expected = IllegalArgumentException.class) public void testToBusNoClientInstanceParameter() throws IdNotFoundException { @@ -80,17 +104,17 @@ } @Test(expected = IllegalArgumentException.class) - public void testPersistNoBusIdParameter() throws IdNotFoundException { + public void testPersistNoBusIdParameter() throws MapperException { mapper.persistClientObjectId(null, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); } @Test(expected = IllegalArgumentException.class) - public void testPersistNoInstanceIdParameter() throws IdNotFoundException { + public void testPersistNoInstanceIdParameter() throws MapperException { mapper.persistClientObjectId(BUS_ID, null, CLIENT_OBJECT_ID); } @Test(expected = IllegalArgumentException.class) - public void testPersistNoObjectIdParameter() throws IdNotFoundException { + public void testPersistNoObjectIdParameter() throws MapperException { mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, ""); } } Modified: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java 2009-03-25 19:17:46 UTC (rev 114) @@ -18,7 +18,7 @@ @Test public void testConfiguration() { try { - EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("cseip"); + EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("cseip-test"); EntityManager entityManager = entityManagerFactory.createEntityManager(); List<MappedClientObject> mappings = entityManager.createQuery("SELECT m FROM MappedClientObject m").getResultList(); Modified: trunk/sandbox/cse-ip/sc-idmapper/src/test/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/resources/META-INF/persistence.xml 2009-03-25 19:16:38 UTC (rev 113) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/resources/META-INF/persistence.xml 2009-03-25 19:17:46 UTC (rev 114) @@ -2,7 +2,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> - <persistence-unit name="cseip" transaction-type="RESOURCE_LOCAL"> + <persistence-unit name="cseip-test" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <class>de.campussource.cse.mapper.MappedClientObject</class> <properties> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-03-25 19:21:09
|
Revision: 116 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=116&view=rev Author: idueppe Date: 2009-03-25 19:21:05 +0000 (Wed, 25 Mar 2009) Log Message: ----------- project polishing Property Changed: ---------------- trunk/sandbox/cse-ip/ trunk/sandbox/cse-ip/cse-ip-application/ trunk/sandbox/cse-ip/framework/ trunk/sandbox/cse-ip/framework/test-utilities/ trunk/sandbox/cse-ip/ica-his-lsf/ trunk/sandbox/cse-ip/sc-cdmm/ trunk/sandbox/cse-ip/sc-idmapper/ Property changes on: trunk/sandbox/cse-ip ___________________________________________________________________ Added: svn:ignore + target Property changes on: trunk/sandbox/cse-ip/cse-ip-application ___________________________________________________________________ Added: svn:ignore + .project .settings target Property changes on: trunk/sandbox/cse-ip/framework ___________________________________________________________________ Added: svn:ignore + target Property changes on: trunk/sandbox/cse-ip/framework/test-utilities ___________________________________________________________________ Modified: svn:ignore - .classpath + .classpath .project .settings target Property changes on: trunk/sandbox/cse-ip/ica-his-lsf ___________________________________________________________________ Modified: svn:ignore - .project .classpath + .project .classpath .settings target Property changes on: trunk/sandbox/cse-ip/sc-cdmm ___________________________________________________________________ Modified: svn:ignore - createDDL.jdbc dropDDL.jdbc .classpath + createDDL.jdbc dropDDL.jdbc .classpath .project .settings target Property changes on: trunk/sandbox/cse-ip/sc-idmapper ___________________________________________________________________ Modified: svn:ignore - .project .classpath createDDL.jdbc dropDDL.jdbc + .project .classpath createDDL.jdbc dropDDL.jdbc .settings target This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-04-20 15:03:18
|
Revision: 126 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=126&view=rev Author: idueppe Date: 2009-04-20 15:03:04 +0000 (Mon, 20 Apr 2009) Log Message: ----------- fixed tests Modified Paths: -------------- trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/Constants.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManager.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Category.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/TestXmlConversion.java trunk/sandbox/cse-ip/sc-cdmm/src/test/resources/META-INF/persistence.xml Added Paths: ----------- trunk/sandbox/cse-ip/build.xml Added: trunk/sandbox/cse-ip/build.xml =================================================================== --- trunk/sandbox/cse-ip/build.xml (rev 0) +++ trunk/sandbox/cse-ip/build.xml 2009-04-20 15:03:04 UTC (rev 126) @@ -0,0 +1,83 @@ +<project name="cse-ip" default="install" basedir="."> + + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + <condition property="asadmin.executable" value="asadmin.bat" else="asadmin"><os family="windows"/></condition> + + <property environment="env"/> + + <property name="appname" value="solution.01.application"/> + <property name="asadmin" location="${env.GLASSFISH_HOME}/bin/${asadmin.executable}" /> + <property name="earfile" location="${basedir}/target/${appname}.ear"/> + + <property name="admin.host" value="localhost"/> + <property name="admin.port" value="4848" /> + <property name="admin.user" value="admin" /> + <property name="admin.pwfile" location="password.txt" /> + + <target name="init"> + </target> + + <target name="install" description="maven install"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean" description="maven clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="eclipse" description="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + + <target name="glassfish-start" description=""> + <exec executable="${asadmin}" failonerror="false"> + <arg line="start-domain domain1"/> + </exec> + </target> + + <target name="glassfish-stop" description=""> + <exec executable="${asadmin}" failonerror="false"> + <arg line="stop-domain domain1"/> + </exec> + </target> + + <target name="site" description="generate and deploy the project site"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <!-- + + <target name="glassfish-deploy" depends="init, clean, install" description=""> + <exec executable="${asadmin}" failonerror="false"> + <arg line="deploy" /> + <arg line="--user ${admin.user}" /> + <arg line="--passwordfile ${admin.pwfile}" /> + <arg line="--host ${admin.host}" /> + <arg line="--port ${admin.port}" /> + <arg line="--upload=true" /> + <arg line="${earfile}" /> + </exec> + </target> + + <target name="glassfish-undeploy" depends="" description=""> + <exec executable="${asadmin}" failonerror="false"> + <arg line="undeploy" /> + <arg line="--user ${admin.user}" /> + <arg line="--passwordfile ${admin.pwfile}" /> + <arg line="--host ${admin.host}" /> + <arg line="--port ${admin.port}" /> + <arg line="${appname}" /> + </exec> + </target> + --> + + +</project> Property changes on: trunk/sandbox/cse-ip/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java =================================================================== --- trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/framework/test-utilities/src/main/java/de/campussource/cse/common/test/AbstractPersistentUnitTest.java 2009-04-20 15:03:04 UTC (rev 126) @@ -20,7 +20,8 @@ @BeforeClass public static void retrieveEntityManagerFactory() { - entityManagerFactory = Persistence.createEntityManagerFactory("cseip-test"); + if (entityManagerFactory == null) + entityManagerFactory = Persistence.createEntityManagerFactory("cseip-test"); } @Before Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-20 15:03:04 UTC (rev 126) @@ -79,6 +79,11 @@ <url>http://www.gnu.org/copyleft/gpl.html</url> </license> </licenses> + + <issueManagement> + <url>https://apps.sourceforge.net/trac/cse-ip/</url> + <system>Trac</system> + </issueManagement> <scm> <connection>scm:svn:https://cse-ip.svn.sourceforge.net/svnroot/cse-ip/trunk</connection> Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/Constants.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/Constants.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/Constants.java 2009-04-20 15:03:04 UTC (rev 126) @@ -48,6 +48,7 @@ public static final String PROPERTY_NAME = "name"; public static final String PROPERTY_VALUE = "value"; public static final String PROPERTY_TRANSIENT = "transient"; + public static final String PROPERTY_STATE = "state"; //table names public static final String TABLENAME_ACCOUNT = "CDMM_ACCOUNT"; Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManager.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManager.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManager.java 2009-04-20 15:03:04 UTC (rev 126) @@ -2,14 +2,11 @@ import java.util.List; -import javax.ejb.Remote; - /** * Service bean for CDMM package * @author Sebastian Roekens * */ -@Remote public interface DataModelManager { public List<EventMessage> createOrUpdateCourse(CourseMessage courseMessage); Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-20 15:03:04 UTC (rev 126) @@ -5,6 +5,7 @@ import java.util.List; import javax.ejb.EJB; +import javax.ejb.Remote; import javax.ejb.Stateless; import de.campussource.cse.cdmm.dao.*; @@ -19,6 +20,7 @@ * */ @Stateless +@Remote(value=DataModelManager.class) public class DataModelManagerBean implements DataModelManager { @EJB Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Category.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Category.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Category.java 2009-04-20 15:03:04 UTC (rev 126) @@ -23,83 +23,91 @@ /** * Category entity object + * * @author Sebastian Roekens - * + * */ -@Entity(name=Constants.CATEGORY) -@Inheritance(strategy=InheritanceType.JOINED) +@Entity(name = Constants.CATEGORY) +@Inheritance(strategy = InheritanceType.JOINED) @Table(name = Constants.TABLENAME_CATEGORY) -@XmlRootElement(namespace=Constants.NAMESPACE_DATATYPES) -@XmlType(name=Constants.CATEGORY_TYPE, propOrder={Constants.PROPERTY_PARENT, Constants.PROPERTY_CHILDREN, Constants.PROPERTY_COURSES}, namespace=Constants.NAMESPACE_DATATYPES) +@XmlRootElement(namespace = Constants.NAMESPACE_DATATYPES) +@XmlType(name = Constants.CATEGORY_TYPE, propOrder = { Constants.PROPERTY_PARENT, Constants.PROPERTY_CHILDREN, + Constants.PROPERTY_COURSES }, namespace = Constants.NAMESPACE_DATATYPES) public class Category extends de.campussource.cse.cdmm.domain.Entity { - @ManyToOne(cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) + @ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }) @JoinTable(name = Constants.COLUMNNAME_CATEGORY2CATEGORY) private Category parent; - - @OneToMany(mappedBy=Constants.PARENT, cascade={CascadeType.REMOVE}) + + @OneToMany(mappedBy = Constants.PARENT, cascade = { CascadeType.REMOVE }) private List<Category> children; - - @ManyToMany(mappedBy=Constants.CATEGORIES) + + @ManyToMany(mappedBy = Constants.CATEGORIES) private List<Course> courses; - + public Category() { } - - public Category(Long id){ + + public Category(Long id) { setId(id); } - + /** * Convenience method for dependency check to prevent circular dependencies. * True if circular dependency would be created. * - * @param newChildCategory new child category to be added to this - * @return true, if newChildCategory is present in hierarchy above this, else false + * @param newChildCategory + * new child category to be added to this + * @return true, if newChildCategory is present in hierarchy above this, + * else false */ - private boolean checkForCircularDependencies(Category newChildCategory){ - if (this.equals(newChildCategory)){ + private boolean checkForCircularDependencies(Category newChildCategory) { + if (this.getId() != null && this.equals(newChildCategory)) { return true; } - if (this.isRoot()){ + if (this.getId() == null && this != newChildCategory) { return false; } + if (this.isRoot()) { + return false; + } return this.parent.checkForCircularDependencies(newChildCategory); } - + /** - * Private method for adding category to list of children. - * If list of children does not exist, it is created. + * Private method for adding category to list of children. If list of + * children does not exist, it is created. * - * @param category child category + * @param category + * child category * @return success of operation */ - private boolean addChild(Category category){ - if (this.children == null){ + private boolean addChild(Category category) { + if (this.children == null) { this.children = new ArrayList<Category>(); } - if (checkForCircularDependencies(category)){ + if (checkForCircularDependencies(category)) { return false; } return this.children.add(category); } - + /** * Convenience method for parent <-> children connection of categories. - * Parent of this is set to parent category and list of children of parent category - * is updated with this. - * - * @param parent parent category + * Parent of this is set to parent category and list of children of parent + * category is updated with this. + * + * @param parent + * parent category * @return Success of operation */ - public boolean addToParentCategory(Category parent){ + public boolean addToParentCategory(Category parent) { this.parent = parent; return parent.addChild(this); } - - - @XmlElementWrapper(name=Constants.CATEGORIES) - @XmlElement(name=Constants.CATEGORY) + + @XmlElementWrapper(name = Constants.CATEGORIES) + @XmlElement(name = Constants.CATEGORY) public List<Category> getChildren() { return children; } @@ -108,8 +116,8 @@ this.children = children; } - @XmlElementWrapper(name=Constants.COURSES) - @XmlElement(name=Constants.COURSE) + @XmlElementWrapper(name = Constants.COURSES) + @XmlElement(name = Constants.COURSE) @XmlIDREF public List<Course> getCourses() { return courses; @@ -119,7 +127,7 @@ this.courses = courses; } - @XmlElement(name=Constants.PARENT) + @XmlElement(name = Constants.PARENT) @XmlIDREF public Category getParent() { return parent; @@ -128,16 +136,15 @@ public void setParent(Category parent) { this.parent = parent; } - - + /** * Convenience method for checking if category is root category. * * @return true if category is root category, else returning false */ @XmlTransient - public boolean isRoot(){ - return (parent==null); + public boolean isRoot() { + return (parent == null); } } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java 2009-04-20 15:03:04 UTC (rev 126) @@ -2,6 +2,7 @@ import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.persistence.Column; @@ -13,11 +14,15 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import javax.persistence.Transient; +import javax.persistence.Version; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlID; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -36,7 +41,7 @@ @Table(name = Constants.TABLENAME_ENTITY) @Inheritance(strategy=InheritanceType.JOINED) @XmlRootElement(namespace=Constants.NAMESPACE_DATATYPES) -@XmlType(name=Constants.ENTITY_TYPE,propOrder={"id", Constants.PROPERTY_ATTRIBUTES}, namespace=Constants.NAMESPACE_DATATYPES) +@XmlType(name=Constants.ENTITY_TYPE,propOrder={"id", Constants.PROPERTY_STATE, Constants.PROPERTY_ATTRIBUTES}, namespace=Constants.NAMESPACE_DATATYPES) public class Entity{ @Id @@ -47,51 +52,38 @@ private List<Attribute> attributes; @Column(name=Constants.COLUMNNAME_STATE, nullable=false, insertable=true, updatable=true) - @Enumerated(EnumType.ORDINAL) - private State state; + @Enumerated(EnumType.STRING) + private State state = State.EXISTS; - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } - + @Version + private long version; + + @Column(name="LAST_UPDATE") + @Temporal(TemporalType.TIMESTAMP) + private Date date; + public Entity(){ } public Entity(Long id){ this.id = id; } + + private TransientAttribute attribute2TransientAttribute(Attribute attribute){ + return new TransientAttribute(attribute.getName(), attribute.getValue()); + } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Entity)) { - return false; - } - if (this.id == null) { - return false; - } else { - return this.id.equals(((Entity) obj).id); - } + private PersistentAttribute attribute2PersistentAttribute(Attribute attribute){ + return new PersistentAttribute(attribute.getName(), attribute.getValue()); } - - @Override - public int hashCode() { - if (this.id == null) { - return super.hashCode(); - } else { - return this.id.hashCode(); - } + + public State getState() { + return state; } - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(id).toString(); + @XmlElement(name=Constants.PROPERTY_STATE) + public void setState(State state) { + this.state = state; } public void setId(Long id) { @@ -111,14 +103,7 @@ return attributes; } - private TransientAttribute attribute2TransientAttribute(Attribute attribute){ - return new TransientAttribute(attribute.getName(), attribute.getValue()); - } - - private PersistentAttribute attribute2PersistentAttribute(Attribute attribute){ - return new PersistentAttribute(attribute.getName(), attribute.getValue()); - } - + // TODO Check if this is correct public void setAttributes(List<Attribute> attributes) { List<Attribute> newAttributeList = new ArrayList<Attribute>(); for (Attribute att : attributes){ @@ -130,4 +115,47 @@ } this.attributes = newAttributeList; } + + + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(id).toString(); + } + + public Date getDate() { + return date; + } + + @XmlTransient + public void setDate(Date date) { + this.date = date; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Entity other = (Entity) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + } \ No newline at end of file Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java 2009-04-20 15:03:04 UTC (rev 126) @@ -24,55 +24,56 @@ /** * Role entity object + * * @author Sebastian Roekens - * + * */ -@Entity(name=Constants.ROLE) +@Entity(name = Constants.ROLE) @Table(name = Constants.TABLENAME_ROLE) -@Inheritance(strategy=InheritanceType.JOINED) -@NamedQueries(value = { - @NamedQuery( - name = "Role.findByAccountAndCourse", - query = "select r from role r where r.account.id=:accountId and r.course.id = :courseId")}) -@XmlRootElement(namespace=Constants.NAMESPACE_DATATYPES) -@XmlType(name=Constants.ROLE_TYPE, propOrder={Constants.TYPE, Constants.ACCOUNT, Constants.COURSE}, namespace=Constants.NAMESPACE_DATATYPES) -public class Role extends de.campussource.cse.cdmm.domain.Entity{ - - @Column(name=Constants.COLUMNNAME_ROLE_TYPE, nullable=false, insertable=true, updatable=true) +@Inheritance(strategy = InheritanceType.JOINED) +@NamedQueries(value = { @NamedQuery(name = "Role.findByAccountAndCourse", query = "select r from role r where r.account.id=:accountId and r.course.id = :courseId") }) +@XmlRootElement(namespace = Constants.NAMESPACE_DATATYPES) +@XmlType(name = Constants.ROLE_TYPE, propOrder = { Constants.TYPE, Constants.ACCOUNT, Constants.COURSE }, namespace = Constants.NAMESPACE_DATATYPES) +public class Role extends de.campussource.cse.cdmm.domain.Entity { + + @Column(name = Constants.COLUMNNAME_ROLE_TYPE, nullable = false, insertable = true, updatable = true) @Enumerated(EnumType.ORDINAL) private RoleType type; - - @ManyToOne(optional=false, cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) - @JoinColumn(name=Constants.COLUMNNAME_ACCOUNT_ID, nullable=false) + + @ManyToOne(optional = false, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }) + @JoinColumn(name = Constants.COLUMNNAME_ACCOUNT_ID, nullable = false) private Account account; - - @ManyToOne(optional=false, cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) - @JoinColumn(name=Constants.COLUMNNAME_COURSE_ID, nullable=false) + + @ManyToOne(optional = false, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }) + @JoinColumn(name = Constants.COLUMNNAME_COURSE_ID, nullable = false) private Course course; - + public static final String FIND_BY_ACCOUNT_AND_COURSE = "Role.findByAccountAndCourse"; - - public Role(){ + + public Role() { } - + /** - * Convenience method to add role to a course and an account. - * Role is added to roles list of course and account object, and - * course and account are added to role object - * @param course target course role is associated to - * @param account target account role is associated to + * Convenience method to add role to a course and an account. Role is added + * to roles list of course and account object, and course and account are + * added to role object + * + * @param course + * target course role is associated to + * @param account + * target account role is associated to * @return success of operation */ - public boolean addToCourseAndAccount(Course course, Account account){ - if ((course==null)||(account==null)){ + public boolean addToCourseAndAccount(Course course, Account account) { + if ((course == null) || (account == null)) { return false; } List<Role> courseRoles = course.getRoles(); - if (courseRoles==null){ + if (courseRoles == null) { courseRoles = new ArrayList<Role>(); } List<Role> accountRoles = account.getRoles(); - if (accountRoles==null){ + if (accountRoles == null) { accountRoles = new ArrayList<Role>(); } this.setAccount(account); @@ -83,17 +84,17 @@ course.setRoles(courseRoles); return true; } - - public Role(Long id, RoleType type){ + + public Role(Long id, RoleType type) { setId(id); this.type = type; } - + public Role(Long id) { setId(id); } - @XmlElement(name=Constants.TYPE) + @XmlElement(name = Constants.TYPE) public RoleType getType() { return type; } @@ -102,7 +103,7 @@ this.type = type; } - @XmlElement(name=Constants.ACCOUNT_ID, required=true) + @XmlElement(name = Constants.ACCOUNT_ID, required = true) @XmlIDREF public Account getAccount() { return account; @@ -112,7 +113,7 @@ this.account = account; } - @XmlElement(name=Constants.COURSE_ID, required=true) + @XmlElement(name = Constants.COURSE_ID, required = true) @XmlIDREF public Course getCourse() { return course; Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java 2009-04-20 15:03:04 UTC (rev 126) @@ -15,15 +15,15 @@ import de.campussource.cse.cdmm.domain.Category; import de.campussource.cse.common.test.AbstractPersistentUnitTest; +public class CategoryDaoTest extends AbstractPersistentUnitTest { -public class CategoryDaoTest extends AbstractPersistentUnitTest{ - private CategoryDao dao; private Category category; private Category parentCategory; /** - * Creates a category object, a parent object for this category and the category dao. + * Creates a category object, a parent object for this category and the + * category dao. */ @Before public void setUp() { @@ -33,47 +33,46 @@ autowireByType(dao); txBegin(); } - + @After - public void tearDown(){ + public void tearDown() { txCommit(); } - -//FIXME fix broken tests -// /** -// * Checks if category can be persisted -// */ -// @Test -// public void testPersistCategory() { -// try { -// dao.persist(category); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException on creation of category"); -// } -// assertNotNull(category.getId()); -// } -// -// -// /** -// * Checks if category can be found by id -// */ -// @Test -// public void testFindCategory() { -// try { -// dao.persist(category); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException on creation of category"); -// } assertNotNull(category.getId()); -// Category coid = null; -// try { -// coid = dao.find(category.getId()); -// } catch (DataModelManagerException e) { -// fail("Created category could not be retrieved"); -// } -// assertEquals(category, coid); -// } - + /** + * Checks if category can be persisted + */ + @Test + public void testPersistCategory() { + try { + dao.persist(category); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException on creation of category"); + } + assertNotNull(category.getId()); + } + + /** + * Checks if category can be found by id + */ + @Test + public void testFindCategory() { + try { + dao.persist(category); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException on creation of category"); + } + assertNotNull(category.getId()); + Category coid = null; + try { + coid = dao.find(category.getId()); + } catch (DataModelManagerException e) { + fail("Created category could not be retrieved"); + } + assertEquals(category, coid); + } + + /** * Checks if category can be deleted */ @Test @@ -82,7 +81,8 @@ dao.persist(category); } catch (DataModelManagerException e) { fail("Unexpected DataModelManagerException on creation of category"); - } assertNotNull(category.getId()); + } + assertNotNull(category.getId()); try { dao.remove(category); } catch (DataModelManagerException e) { @@ -94,20 +94,21 @@ fail("Deleting of category failed"); } catch (DataModelManagerException e) { // Exception should occur - } + } } - + /** * Checks if cascading saving and cascading deleting work */ @Test - public void testCascading(){ + public void testCascading() { category.addToParentCategory(parentCategory); try { dao.persist(category); } catch (DataModelManagerException e) { fail("Unexpected DataModelManagerException on creation of category"); - } assertNotNull(category.getId()); + } + assertNotNull(category.getId()); assertNotNull(parentCategory.getId()); assertEquals(category.getParent(), parentCategory); assertEquals(parentCategory.getChildren().get(0), category); @@ -122,16 +123,16 @@ fail("Deleting of parent category failed"); } catch (DataModelManagerException e) { // Exception should occur - } + } try { @SuppressWarnings("unused") Category retrievedCategory = dao.find(category.getId()); fail("Cascaded deleting of child category failed"); } catch (DataModelManagerException e) { - // Exception should occur - } + // Exception should occur + } } - + /** * Checks if searching for not existing ids returns null */ @@ -146,24 +147,23 @@ } assertNull(foundCategory); } -//FIXME fix broken tests -// /** -// * Checks if circular category dependencies are prevented -// */ -// @Test -// public void testCircularDependencyCheck(){ -// assertTrue(category.addToParentCategory(parentCategory)); -// try { -// dao.persist(category); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException on creation of category"); -// } -// assertFalse(parentCategory.addToParentCategory(category)); -// } -// -// + + /** + * Checks if circular category dependencies are prevented + */ + @Test + public void testCircularDependencyCheck() { + assertTrue(category.addToParentCategory(parentCategory)); + try { + dao.persist(category); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException on creation of category"); + } + assertFalse(parentCategory.addToParentCategory(category)); + } + private Category newCategory() { - return new Category(); + return new Category(); } } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java 2009-04-20 15:03:04 UTC (rev 126) @@ -17,7 +17,7 @@ import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class CourseDaoTest extends AbstractPersistentUnitTest { - + private CourseDao dao; private Course course; @@ -31,47 +31,48 @@ autowireByType(dao); txBegin(); } - + @After - public void tearDown(){ + public void tearDown() { txCommit(); } -//FIXME fix broken tests -// /** -// * Tests creating of a course object -// */ -// @Test -// public void testPersistCourse() { -// try { -// dao.persist(course); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException!"); -// } -// assertNotNull(course.getId()); -// } -// -// -// /** -// * Tests searching for a course object by id -// */ -// @Test -// public void testFindCourse() { -// try { -// dao.persist(course); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException!"); -// } -// assertNotNull(course.getId()); -// commitAndBeginTx(); -// Course coid = null; -// try { -// coid = dao.find(course.getId()); -// } catch (DataModelManagerException e) { -// fail("Creating or retrieving of course failed!"); -// } -// assertEquals(course, coid); -// } + + /** + * Tests creating of a course object + */ + @Test + public void testPersistCourse() { + try { + dao.persist(course); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException!"); + } + assertNotNull(course.getId()); + } + + + /** + * Tests searching for a course object by id + */ + @Test + public void testFindCourse() { + try { + dao.persist(course); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException!"); + } + assertNotNull(course.getId()); + commitAndBeginTx(); + Course coid = null; + try { + coid = dao.find(course.getId()); + } catch (DataModelManagerException e) { + fail("Creating or retrieving of course failed!"); + } + assertEquals(course, coid); + } + /** * Tests deleting of course object */ @@ -94,9 +95,9 @@ fail("Deleting of course failed"); } catch (DataModelManagerException e) { // Exception should occur - } + } } - + /** * Tests if searching for not existing id returns null */ @@ -107,90 +108,89 @@ foundCourse = dao.find(0L); fail("Exception should occur"); } catch (DataModelManagerException e) { - //Exception should occur + // Exception should occur } assertNull(foundCourse); } - -//FIXME fix broken tests -// /** -// * Tests cascading to category objects. -// */ -// @Test -// public void testCascadingToCategory(){ -// Category category = new Category(); -// CategoryDao categoryDao = new CategoryDao(); -// autowireByType(categoryDao); -// try { -// categoryDao.persist(category); -// } catch (DataModelManagerException e1) { -// fail("Unexpected DataModelManagerException"); -// } -// assertNotNull(category.getId()); -// course.addToCategory(category); -// try { -// dao.persist(course); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException!"); -// } -// assertNotNull(course.getId()); -// assertNotNull(course.getCategories()); -// assertNotNull(category.getCourses()); -// assertEquals(course.getCategories().get(0), category); -// assertEquals(category.getCourses().get(0), course); -// } -// -// /** -// * Tests cascading in course hierarchy and correct course hierarchy -// */ -// @Test -// public void testWorkgroupCascading(){ -// //check correct cascading on creation of workgroup -// Course workgroup1 = new Course(); -// Course workgroup2 = new Course(); -// workgroup1.addAsWorkgroupTo(course); -// try { -// dao.persist(workgroup1); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException"); -// } -// assertNotNull(workgroup1.getId()); -// assertNotNull(course.getId()); -// assertNotNull(workgroup1.getParent()); -// assertEquals(workgroup1.getParent(), course); -// assertNotNull(course.getWorkgroups()); -// assertEquals(course.getWorkgroups().get(0), workgroup1); -// //check if circular dependency is prevented -// assertFalse(workgroup2.addAsWorkgroupTo(workgroup1)); -// //check correct deleting cascading -// try { -// dao.remove(course); -// } catch (DataModelManagerException e) { -// fail("Unexpected Exception on removing of course"); -// } -// try { -// @SuppressWarnings("unused") -// Course retrievedCourse = dao.find(course.getId()); -// fail("Deleting of course failed"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// @SuppressWarnings("unused") -// Course retrievedWorkgroup = dao.find(workgroup1.getId()); -// fail("Cascaded deleting of workgroup failed"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// } - - + + /** + * Tests cascading to category objects. + */ + @Test + public void testCascadingToCategory() { + Category category = new Category(); + CategoryDao categoryDao = new CategoryDao(); + autowireByType(categoryDao); + try { + categoryDao.persist(category); + } catch (DataModelManagerException e1) { + fail("Unexpected DataModelManagerException"); + } + assertNotNull(category.getId()); + course.addToCategory(category); + try { + dao.persist(course); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException!"); + } + assertNotNull(course.getId()); + assertNotNull(course.getCategories()); + assertNotNull(category.getCourses()); + assertEquals(course.getCategories().get(0), category); + assertEquals(category.getCourses().get(0), course); + } + /** + * Tests cascading in course hierarchy and correct course hierarchy + */ + @Test + public void testWorkgroupCascading() { + // check correct cascading on creation of workgroup + Course workgroup1 = new Course(); + Course workgroup2 = new Course(); + workgroup1.addAsWorkgroupTo(course); + try { + dao.persist(workgroup1); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException"); + } + assertNotNull(workgroup1.getId()); + assertNotNull(course.getId()); + assertNotNull(workgroup1.getParent()); + assertEquals(workgroup1.getParent(), course); + assertNotNull(course.getWorkgroups()); + assertEquals(course.getWorkgroups().get(0), workgroup1); + // check if circular dependency is prevented + assertFalse(workgroup2.addAsWorkgroupTo(workgroup1)); + // check correct deleting cascading + try { + dao.remove(course); + } catch (DataModelManagerException e) { + fail("Unexpected Exception on removing of course"); + } + try { + @SuppressWarnings("unused") + Course retrievedCourse = dao.find(course.getId()); + fail("Deleting of course failed"); + } catch (DataModelManagerException e) { + // Exception should occur + } + try { + @SuppressWarnings("unused") + Course retrievedWorkgroup = dao.find(workgroup1.getId()); + fail("Cascaded deleting of workgroup failed"); + } catch (DataModelManagerException e) { + // Exception should occur + } + } + + /** * Convenience method for creating a course object with a unique id + * * @return course object with unique id */ private Course newCourse() { - return new Course(); + return new Course(); } } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java 2009-04-20 15:03:04 UTC (rev 126) @@ -15,6 +15,7 @@ import de.campussource.cse.cdmm.domain.Course; import de.campussource.cse.cdmm.domain.Role; import de.campussource.cse.cdmm.domain.RoleType; +import de.campussource.cse.cdmm.domain.State; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class RoleDaoTest extends AbstractPersistentUnitTest { @@ -25,292 +26,290 @@ private Account account; + @Before + public void setUp() { + //set up daos + dao = new RoleDao(); + autowireByType(dao); + //create role object with needed dependencies + course = new Course(); + account = new Account(); + role = newRole(); + txBegin(); + } + + @After + public void tearDown(){ + txCommit(); + } + + /** + * Tests if Role can be persisted + */ @Test - public void testNothing(){} + public void testPersistRole() { + try { + dao.persist(role); + } catch (MissingAttributeException e) { + e.printStackTrace(); + fail("Unexpected MissingAttributeException!"); + } + assertNotNull(role.getId()); + } + -// @Before -// public void setUp() { -// //set up daos -// dao = new RoleDao(); -// autowireByType(dao); -// //create role object with needed dependencies -// course = new Course(); -// account = new Account(); -// role = newRole(); -// txBegin(); -// } -// -// @After -// public void tearDown(){ -// txCommit(); -// } + /** + * Tests if role can be found by id + */ + @Test + public void testFindRole() { + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected MissingAttributeException!"); + } + assertNotNull(role.getId()); + Role roid = null; + try { + roid = dao.find(role.getId()); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException!"); + } + assertEquals(role, roid); + } -//FIXME fix broken tests -// /** -// * Tests if Role can be persisted -// */ -// @Test -// public void testPersistRole() { -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException!"); -// } -// assertNotNull(role.getId()); -// } -// -// -// /** -// * Tests if role can be found by id -// */ -// @Test -// public void testFindRole() { -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException!"); -// } -// assertNotNull(role.getId()); -// Role roid = null; -// try { -// roid = dao.find(role.getId()); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException!"); -// } -// assertEquals(role, roid); -// } -// -// /** -// * Tests if Role can be deleted -// */ -// @Test -// public void testRemoveRole() { -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException!"); -// } -// assertNotNull(role.getId()); -// try { -// dao.remove(role); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException!"); -// } -// try { -// @SuppressWarnings("unused") -// Role retrievedRole = dao.find(role.getId()); -// fail("Deleting failed"); -// } catch (DataModelManagerException e) { -// //Exception is correct -// } -// CourseDao courseDao = new CourseDao(); -// autowireByType(courseDao); -// try { -// Course retrievedCourse = courseDao.find(course.getId()); -// assertNotNull(retrievedCourse); -// } catch (DataModelManagerException e) { -// fail("Account should not be deleted!"); -// } -// } -// -// /** -// * Tests if search for not existing id returns null -// */ -// @Test -// public void testDoNotFindById() { -// @SuppressWarnings("unused") -// Role foundRole; -// try { -// foundRole = dao.find(0L); -// fail("DataModelManagerException should have been thrown, due to search for an not existing object!"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// } -// -// /** -// * Tests if create and update statements are correctly cascaded -// * to account and course entities -// */ -// @Test -// public void testCascadingOnCreate(){ -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException occured!"); -// } -// assertNotNull(role.getId()); -// assertNotNull(course.getId()); -// assertNotNull(account.getId()); -// assertNotNull(account.getRoles()); -// assertNotNull(course.getRoles()); -// assertEquals(course.getRoles().get(0), role); -// assertEquals(account.getRoles().get(0), role); -// assertEquals(role.getCourse(), course); -// assertEquals(role.getAccount(), account); -// } -// -// /** -// * Tests if role objects are deleted on deletion of parent course object -// */ -// @Test -// public void testCascadingOnDeleteCourse(){ -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException occured!"); -// } -// assertNotNull(role.getId()); -// assertNotNull(course.getId()); -// assertNotNull(account.getId()); -// assertNotNull(account.getRoles()); -// assertNotNull(course.getRoles()); -// assertEquals(course.getRoles().get(0), role); -// assertEquals(account.getRoles().get(0), role); -// assertEquals(role.getCourse(), course); -// assertEquals(role.getAccount(), account); -// -// commitAndBeginTx(); -// -// CourseDao courseDao = new CourseDao(); -// autowireByType(courseDao); -// try { -// courseDao.remove(course); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException occured!"); -// } -// try{ -// @SuppressWarnings("unused") -// Course retrievedCourse = courseDao.find(course.getId()); -// fail("Course deleting failed!"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// @SuppressWarnings("unused") -// Role retrievedRole = dao.find(role.getId()); -// fail("Cascaded Role deleting failed!"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// } -// -// @Test -// public void testCascadingOnDeleteAccount(){ -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected MissingAttributeException occured!"); -// } -// assertNotNull(role.getId()); -// assertNotNull(course.getId()); -// assertNotNull(account.getId()); -// assertNotNull(account.getRoles()); -// assertNotNull(course.getRoles()); -// assertEquals(course.getRoles().get(0), role); -// assertEquals(account.getRoles().get(0), role); -// assertEquals(role.getCourse(), course); -// assertEquals(role.getAccount(), account); -// -// commitAndBeginTx(); -// -// AccountDao accountDao = new AccountDao(); -// autowireByType(accountDao); -// try { -// accountDao.remove(account); -// } catch (DataModelManagerException e) { -// fail("Unexpected DataModelManagerException occured!"); -// } -// try { -// @SuppressWarnings("unused") -// Account retrievedAccount = accountDao.find(account.getId()); -// fail("Account deleting failed!"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// @SuppressWarnings("unused") -// Role retrievedRole = dao.find(role.getId()); -// fail("Cascaded role deleting failed"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// } -// -// @Test -// public void testRetrieveRole(){ -// Role role = new Role(); -// role.setType(RoleType.PARTICIPANT); -// Account account = new Account(); -// Course course = new Course(); -// -// try { -// dao.persist(role); -// fail("It should not be able to persist role without course and account reference"); -// } catch (MissingAttributeException e) { -// //Exception should occur; -// } -// role.setCourse(course); -// try { -// dao.persist(role); -// fail("It should not be able to persist role without course and account reference"); -// } catch (MissingAttributeException e) { -// //Exception should occur; -// } -// role.setCourse(null); -// role.setAccount(account); -// try { -// dao.persist(role); -// fail("It should not be able to persist role without course and account reference"); -// } catch (MissingAttributeException e) { -// //Exception should occur; -// } -// role.setCourse(course); -// try { -// dao.persist(role); -// } catch (MissingAttributeException e) { -// fail("Unexpected Missing Attribute Exception"); -// } -// Role retrievedRole = null; -// try { -// retrievedRole = dao.retrieveRole(0, course.getId()); -// fail("Retrieved object should not exist"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// retrievedRole = dao.retrieveRole(account.getId(),0); -// fail("Retrieved object should not exist"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// retrievedRole = dao.retrieveRole(1l, 1l); -// fail("Retrieved object should not exist"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// try { -// retrievedRole = dao.retrieveRole(account.getId(), course.getId()); -// } catch (DataModelManagerException e) { -// fail("Retrieved object should exist"); -// } -// assertNotNull(retrievedRole); -// assertEquals(role, retrievedRole); -// -// try { -// dao.remove(null); -// fail("null can't be removed"); -// } catch (DataModelManagerException e) { -// //Exception should occur -// } -// -// } + /** + * Tests if Role can be deleted + */ + @Test + public void testRemoveRole() { + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected MissingAttributeException!"); + } + assertNotNull(role.getId()); + try { + dao.remove(role); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException!"); + } + try { + @SuppressWarnings("unused") + Role retrievedRole = dao.find(role.getId()); + fail("Deleting failed"); + } catch (DataModelManagerException e) { + //Exception is correct + } + CourseDao courseDao = new CourseDao(); + autowireByType(courseDao); + try { + Course retrievedCourse = courseDao.find(course.getId()); + assertNotNull(retrievedCourse); + } catch (DataModelManagerException e) { + fail("Account should not be deleted!"); + } + } + /** + * Tests if search for not existing id returns null + */ + @Test + public void testDoNotFindById() { + @SuppressWarnings("unused") + Role foundRole; + try { + foundRole = dao.find(0L); + fail("DataModelManagerException should have been thrown, due to search for an not existing object!"); + } catch (DataModelManagerException e) { + //Exception should occur + } + } + + /** + * Tests if create and update statements are correctly cascaded + * to account and course entities + */ + @Test + public void testCascadingOnCreate(){ + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected MissingAttributeException occured!"); + } + assertNotNull(role.getId()); + assertNotNull(course.getId()); + assertNotNull(account.getId()); + assertNotNull(account.getRoles()); + assertNotNull(course.getRoles()); + assertEquals(course.getRoles().get(0), role); + assertEquals(account.getRoles().get(0), role); + assertEquals(role.getCourse(), course); + assertEquals(role.getAccount(), account); + } + + /** + * Tests if role objects are deleted on deletion of parent course object + */ + @Test + public void testCascadingOnDeleteCourse(){ + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected MissingAttributeException occured!"); + } + assertNotNull(role.getId()); + assertNotNull(course.getId()); + assertNotNull(account.getId()); + assertNotNull(account.getRoles()); + assertNotNull(course.getRoles()); + assertEquals(course.getRoles().get(0), role); + assertEquals(account.getRoles().get(0), role); + assertEquals(role.getCourse(), course); + assertEquals(role.getAccount(), account); + + commitAndBeginTx(); + + CourseDao courseDao = new CourseDao(); + autowireByType(courseDao); + try { + courseDao.remove(course); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException occured!"); + } + try{ + @SuppressWarnings("unused") + Course retrievedCourse = courseDao.find(course.getId()); + fail("Course deleting failed!"); + } catch (DataModelManagerException e) { + //Exception should occur + } + try { + @SuppressWarnings("unused") + Role retrievedRole = dao.find(role.getId()); + fail("Cascaded Role deleting failed!"); + } catch (DataModelManagerException e) { + //Exception should occur + } + } + + @Test + public void testCascadingOnDeleteAccount(){ + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected MissingAttributeException occured!"); + } + assertNotNull(role.getId()); + assertNotNull(course.getId()); + assertNotNull(account.getId()); + assertNotNull(account.getRoles()); + assertNotNull(course.getRoles()); + assertEquals(course.getRoles().get(0), role); + assertEquals(account.getRoles().get(0), role); + assertEquals(role.getCourse(), course); + assertEquals(role.getAccount(), account); + + commitAndBeginTx(); + + AccountDao accountDao = new AccountDao(); + autowireByType(accountDao); + try { + accountDao.remove(account); + } catch (DataModelManagerException e) { + fail("Unexpected DataModelManagerException occured!"); + } + try { + @SuppressWarnings("unused") + Account retrievedAccount = accountDao.find(account.getId()); + fail("Account deleting failed!"); + } catch (DataModelManagerException e) { + //Exception should occur + } + try { + @SuppressWarnings("unused") + Role retrievedRole = dao.find(role.getId()); + fail("Cascaded role deleting failed"); + } catch (DataModelManagerException e) { + //Exception should occur + } + } + + @Test + public void testRetrieveRole(){ + Role role = new Role(); + role.setType(RoleType.PARTICIPANT); + Account account = new Account(); + Course course = new Course(); + + try { + dao.persist(role); + fail("It should not be able to persist role without course and account reference"); + } catch (MissingAttributeException e) { + //Exception should occur; + } + role.setCourse(course); + try { + dao.persist(role); + fail("It should not be able to persist role without course and account reference"); + } catch (MissingAttributeException e) { + //Exception should occur; + } + role.setCourse(null); + role.setAccount(account); + try { + dao.persist(role); + fail("It should not be able to persist role without course and account reference"); + } catch (MissingAttributeException e) { + //Exception should occur; + } + role.setCourse(course); + try { + dao.persist(role); + } catch (MissingAttributeException e) { + fail("Unexpected Missing Attribute Exception"); + } + Role retrievedRole = null; + try { + retrievedRole = dao.retrieveRole(0, course.getId()); + fail("Retrieved object should not exist"); + } catch (DataModelManagerException e) { + //Exception should occur + } + try { + retrievedRole = dao.retrieveRole(account.getId(),0); + fail("Retrieved object should not exist"); + } catch (DataModelManagerException e) { + //Exception should occur + } + try { + retrievedRole = dao.retrieveRole(1l, 1l); + fail("Retrieved object should not exist"); + } catch (DataModelManagerException e) { + //Exception should occur + } + try { + retrievedRole = dao.retrieveRole(account.getId(), course.getId()); + } catch (DataModelManagerException e) { + fail("Retrieved object should exist"); + } + assertNotNull(retrievedRole); + assertEquals(role, retrievedRole); + + try { + dao.remove(null); + fail("null can't be removed"); + } catch (DataModelManagerException e) { + //Exception should occur + } + + } + private Role newRole() { Role role = new Role(); role.addToCourseAndAccount(course, account); role.setType(RoleType.ASSISTANT); + role.setState(State.EXISTS); return role; } } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/TestXmlConversion.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/TestXmlConversion.java 2009-04-20 11:28:57 UTC (rev 125) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/TestXmlConversion.java 2009-04-20 15:03:04 UTC (rev 126) @@ -33,468 +33,458 @@ import de.campussource.cse.cdmm.domain.Role; import de.campussource.cse.cdmm.domain.RoleType; import de.campussource.cse.cdmm.domain.TransientAttribute; - + /** * @author Sebastian Roekens - * + * */ -public class TestXmlConversion extends TestCase{ +public class TestXmlConversion extends TestCase { + private static Long currentTimeMillis = System.currentTimeMillis(); - private Long createUniqueId(){ + private Long createUniqueId() { return currentTimeMillis++; } - + @Test - public void testNothing(){ + public void testAccountXml() { + System.out.println("----- entering Account XML Test -----"); + // create and fetch account object + EntityContainer container = generateTestStructure(); + Account account = null; + for (Account acc : container.getAccounts()) { + if (acc instanceof Account && !(acc instanceof Group)) { + account = acc; + } + } + if (account == null) { + fail("no account object created"); + } + + // create jaxb context and marshaller + Marshaller marshaller = null; + JAXBContext context = null; + try { + context = JAXBContext.newInstance(Account.class); + marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + } catch (JAXBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + // convert account object to xml + String outputXml = ""; + try { + Writer writer = new StringWriter(); + marshaller.marshal(account, writer); + outputXml = writer.toString(); + writer.close(); + } catch (JAXBException e) { + fail(e.getMessage()); + } catch (IOException e) { + fail(e.getMessage()); + } + assertTrue((outputXml != null) && (!outputXml.trim().isEmpty())); + System.out.println(outputXml); + + // convert xml back to an object and assert equality to source object + Account convertedAccount = null; + try { + Unmarshaller unmarshaller = context.createUnmarshaller(); + convertedAccount = (Account) unmarshaller.unmarshal(new StringReader(outputXml)); + System.out.println(convertedAccount.toString()); + } catch (JAXBException e) { + fail(e.getMessage()); + } + assertTrue(account.equals(convertedAccount)); + System.out.println("----- leaving Account XML Test -----"); } - -//FIXME fix broken tests -// @Test -// public void testAccountXml(){ -// System.out.println("----- entering Account XML Test -----"); -// //create and fetch account object -// EntityContainer container = generateTestStructure(); -// Account account = null; -// for (Account acc : container.getAccounts()){ -// if (acc instanceof Account && !(acc instanceof Group)){ -// account = acc; -// } -// } -// if (account == null){ -// fail("no account object created"); -// } -// -// //create jaxb context and marshaller -// Marshaller marshaller=null; -// JAXBContext context=null; -// try { -// context = JAXBContext.newInstance(Account.class); -// marshaller = context.createMarshaller(); -// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); -// } catch (JAXBException e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// //convert account object to xml -// String outputXml = ""; -// try { -// Writer writer = new StringWriter(); -// marshaller.marshal(account, writer); -// outputXml = writer.toString(); -// writer.close(); -// } catch (JAXBException e) { -// fail(e.getMessage()); -// } catch (IOException e) { -// fail(e.getMessage()); -// } -// assertTrue((outputXml!=null)&&(outputXml!="")); -// System.out.println(outputXml); -// -// //convert xml back to an object and assert equality to source object -// Account convertedAccount=null; -// try { -// Unmarshaller unmarshaller = context.createUnmarshaller(); -// convertedAccount = (Account) unmarshaller.unmarshal(new StringReader(outputXml)); -// System.out.println(convertedAccount.toString()); -// } catch (JAXBException e) { -// fail(e.getMessage()); -// } -// assertTrue(account.equals(convertedAccount)); -// System.out.println("----- leaving Account XML Test -----"); -// } -// -// @Test -// public void testCategoryXml(){ -// System.out.println("----- entering Category XML Test -----"); -// //create and fetch category object -// EntityContainer container = generateTestStructure(); -// Category category = container.getRootCategory(); -// assertNotNull(category); -// -// //create jaxb context and marshaller -// Marshaller marshaller=null; -// JAXBContext context=null; -// try { -// context = JAXBContext.newInstance(Category.class); -// marshaller = context.createMarshaller(); -// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); -// } catch (JAXBException e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// //convert category object to xml -// String outputXml = ""; -// try { -// Writer writer = new StringWriter(); -// marshaller.marshal(category, writer); -// outputXml = writer.toString(); -// writer.close(); -// } catch (JAXBException e) { -// fail(e.getMessage()); -// } catch (IOException e) { -// fail(e.getMessage()); -// } -// assertTrue((outputXml!=null)&&(outputXml!="")); -// System.out.println(outputXml); -// -// //convert xml back to an object and assert equality to source object -// Category convertedCategory=null; -// try { -// Unmarshaller unmarshaller = context.createUnmarshaller(); -// convertedCategory = (Category) unmarshaller.unmarshal(new StringReader(outputXml)); -// System.out.println(convertedCategory.toString()); -// } catch (JAXBException e) { -// fail(e.getMessage()); -// } -// assertTrue(category.equals(convertedCategory)); -// System.out.println("----- leaving Category XML Test -----"); -// } -// -// @Test -// public void testCourseXml(){ -// System.out.println("----- entering Course XML Test -----"); -// //create and fetch course object -// EntityContainer container = generateTestStructure(); -// Course course = container.getCourses().get(0); -// assertNotNull(course); -// -// //create jaxb context and marshaller -// Marshaller marshaller=null; -// JAXBContext context=null; -// try { -// context = JAXBContext.newInstance(Course.class); -// marshaller = context.createMarshaller(); -// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); -// } catch (JAXBException e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// //convert course object to xml -// String outputXml = ""; -// try { -// Writer writer = new StringWriter(); -// marshaller.marshal(course, writer); -// outputXml = writer.toString(); -// writer.close(); -// } catch (JAXBException e) { -// fail(e.getMessage()); -// } catch (IOException e) { -// fail(e.getMessage()); -// } -// assertTrue((outputXml!=null)&&(outputXml!="")); -// System.out.println(outputXml); -// -// //convert xml back to an object and assert equality to source object -// Course convertedCourse=null; -// try { -// Unmarshaller unmarshaller = context.createUnmarshaller(); -// convertedCourse = (Course) unmarshaller.unmarsha... [truncated message content] |
From: <ro...@us...> - 2009-04-21 09:47:07
|
Revision: 130 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=130&view=rev Author: roekens Date: 2009-04-21 09:46:52 +0000 (Tue, 21 Apr 2009) Log Message: ----------- refactoring of exception structure: introduced sc-common project which contains a ServiceComponentException and an IDNotFoundException refactored sc-cdmm and sc-idmapper to use sc-common Modified Paths: -------------- trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-cdmm/pom.xml trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingAttributeException.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingParameterException.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAO.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAOJPA.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/RoleDao.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/AccountDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DaoTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingAttributeExceptionTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingParameterExceptionTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java trunk/sandbox/cse-ip/sc-idmapper/pom.xml trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java Added Paths: ----------- trunk/sandbox/cse-ip/sc-common/ trunk/sandbox/cse-ip/sc-common/pom.xml trunk/sandbox/cse-ip/sc-common/src/ trunk/sandbox/cse-ip/sc-common/src/main/ trunk/sandbox/cse-ip/sc-common/src/main/java/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ServiceComponentException.java trunk/sandbox/cse-ip/sc-common/src/test/ trunk/sandbox/cse-ip/sc-common/src/test/java/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/IdNotFoundExceptionTest.java trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ServiceComponentExceptionTest.java trunk/sandbox/cse-ip/sc-common/src/test/resources/ trunk/sandbox/cse-ip/sc-common/src/test/resources/log4j.properties Removed Paths: ------------- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerException.java trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/IdNotFoundException.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DataModelManagerExceptionTest.java trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/IdNotFoundExceptionTest.java trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdNotFoundException.java trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/MapperException.java trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdNotFoundExceptionTest.java Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-21 09:46:52 UTC (rev 130) @@ -112,6 +112,7 @@ <module>ica-his-lsf</module> <module>sc-idmapper</module> <module>sc-cdmm</module> + <module>sc-common</module> <module>cse-ip-application</module> </modules> Modified: trunk/sandbox/cse-ip/sc-cdmm/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-04-21 09:46:52 UTC (rev 130) @@ -22,6 +22,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-common</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> <groupId>javax.ejb</groupId> <artifactId>ejb-api</artifactId> <version>3.0</version> Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-21 09:46:52 UTC (rev 130) @@ -13,6 +13,7 @@ import de.campussource.cse.cdmm.domain.Course; import de.campussource.cse.cdmm.domain.Role; import de.campussource.cse.cdmm.domain.State; +import de.campussource.cse.common.exception.ServiceComponentException; /** * Service bean for CDMM package @@ -45,7 +46,7 @@ try { loadedCourse = courseDao.find(courseMessage.getCourse().getId()); state=loadedCourse.getState(); - } catch (DataModelManagerException e1) { + } catch (ServiceComponentException e1) { //do nothing } @@ -58,7 +59,7 @@ eventMessage.setEntity(course); try { courseDao.persist(course); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //TODO handle me } if (state==State.EXISTS){ @@ -99,7 +100,7 @@ private void createByReference(Category category) { try { Category loadedCategory = categoryDao.find(category.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { CategoryMessage cm = new CategoryMessage(); cm.setCategory(category); cm.setInputEvent(InputEventType.CREATE_BY_REFERENCE); @@ -111,7 +112,7 @@ private void createByReference(Course course) { try { Course loadedCourse = courseDao.find(course.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { CourseMessage cm = new CourseMessage(); cm.setCourse(course); cm.setInputEvent(InputEventType.CREATE_BY_REFERENCE); Deleted: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerException.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,26 +0,0 @@ -package de.campussource.cse.cdmm; - -/** - * General CDMM exception - * @author Sebastian Roekens - */ -public class DataModelManagerException extends Exception { - - private static final long serialVersionUID = -2553188081269164041L; - - public DataModelManagerException() { - } - - public DataModelManagerException(String message) { - super(message); - } - - public DataModelManagerException(Throwable cause) { - super(cause); - } - - public DataModelManagerException(String message, Throwable cause) { - super(message, cause); - } - -} \ No newline at end of file Deleted: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/IdNotFoundException.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/IdNotFoundException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/IdNotFoundException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,26 +0,0 @@ -package de.campussource.cse.cdmm; - -/** - * Exception to represent failed searches for objects - * e.g. no objetc with given id existing - * @author Sebastian Roekens - */ -public class IdNotFoundException extends DataModelManagerException { - - private static final long serialVersionUID = 3260263352045745859L; - - public IdNotFoundException() {} - - public IdNotFoundException(String message) { - super(message); - } - - public IdNotFoundException(Throwable cause) { - super(cause); - } - - public IdNotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingAttributeException.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingAttributeException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingAttributeException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,10 +1,12 @@ package de.campussource.cse.cdmm; +import de.campussource.cse.common.exception.ServiceComponentException; + /** * Exception to represent missing attributes in objects which shall be persisted * @author Sebastian Roekens */ -public class MissingAttributeException extends DataModelManagerException { +public class MissingAttributeException extends ServiceComponentException { private static final long serialVersionUID = 3260263352045745856L; Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingParameterException.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingParameterException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/MissingParameterException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,10 +1,12 @@ package de.campussource.cse.cdmm; +import de.campussource.cse.common.exception.ServiceComponentException; + /** * Exception to represent missing parameters in method calls * @author Sebastian Roekens */ -public class MissingParameterException extends DataModelManagerException { +public class MissingParameterException extends ServiceComponentException { private static final long serialVersionUID = 3260263352045745857L; Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAO.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAO.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAO.java 2009-04-21 09:46:52 UTC (rev 130) @@ -2,7 +2,7 @@ import java.io.Serializable; -import de.campussource.cse.cdmm.DataModelManagerException; +import de.campussource.cse.common.exception.ServiceComponentException; /** * @author Ingo D\xFCppe @@ -15,22 +15,22 @@ * Finder method to find persisted entities by id * @param id id of searched object * @return entity object with given id - * @throws DataModelManagerException + * @throws ServiceComponentException */ - public T find(Serializable id) throws DataModelManagerException; + public T find(Serializable id) throws ServiceComponentException; /** * DAO method to persist given object * @param entity object to persist - * @throws DataModelManagerException + * @throws ServiceComponentException */ - public void persist(T entity) throws DataModelManagerException; + public void persist(T entity) throws ServiceComponentException; /** * DAO method to delete entity objects * @param entity object to delete - * @throws DataModelManagerException + * @throws ServiceComponentException */ - public void remove(T entity) throws DataModelManagerException; + public void remove(T entity) throws ServiceComponentException; } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAOJPA.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAOJPA.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/DAOJPA.java 2009-04-21 09:46:52 UTC (rev 130) @@ -8,8 +8,8 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import de.campussource.cse.cdmm.DataModelManagerException; -import de.campussource.cse.cdmm.IdNotFoundException; +import de.campussource.cse.common.exception.ServiceComponentException; +import de.campussource.cse.common.exception.IdNotFoundException; import de.campussource.cse.cdmm.MissingParameterException; @@ -33,7 +33,7 @@ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) - public E find(Serializable id) throws DataModelManagerException{ + public E find(Serializable id) throws ServiceComponentException{ E result = entityManager.find(persistentClass, id); if (result == null){ throw new IdNotFoundException("Id: "+ id + "could not be found."); @@ -43,12 +43,12 @@ @Override @TransactionAttribute(TransactionAttributeType.MANDATORY) - public void persist(E entity) throws DataModelManagerException{ + public void persist(E entity) throws ServiceComponentException{ entityManager.persist(entity); } @Override - public void remove(E entity) throws DataModelManagerException{ + public void remove(E entity) throws ServiceComponentException{ if (entity == null){ throw new MissingParameterException("Parameter entity is mandatory!"); } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/RoleDao.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/RoleDao.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/dao/RoleDao.java 2009-04-21 09:46:52 UTC (rev 130) @@ -4,8 +4,8 @@ import javax.persistence.NoResultException; import javax.persistence.Query; -import de.campussource.cse.cdmm.DataModelManagerException; -import de.campussource.cse.cdmm.IdNotFoundException; +import de.campussource.cse.common.exception.ServiceComponentException; +import de.campussource.cse.common.exception.IdNotFoundException; import de.campussource.cse.cdmm.MissingAttributeException; import de.campussource.cse.cdmm.MissingParameterException; import de.campussource.cse.cdmm.domain.Role; @@ -29,7 +29,7 @@ } @Override - public void remove(Role role) throws DataModelManagerException{ + public void remove(Role role) throws ServiceComponentException{ if (role==null){ throw new MissingParameterException("Parameter role is mandatory!"); } @@ -48,9 +48,9 @@ * @param accountId id of account reference of searched role * @param courseId id of course reference of searched role * @return role object with given account and course reference - * @throws DataModelManagerException Exception is thrown, when no role with given accountId and courseId exists + * @throws ServiceComponentException Exception is thrown, when no role with given accountId and courseId exists */ - public Role retrieveRole(long accountId, long courseId) throws DataModelManagerException{ + public Role retrieveRole(long accountId, long courseId) throws ServiceComponentException{ if (accountId == 0){ throw new MissingParameterException("Paramter accountId is mandatory!"); } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/AccountDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/AccountDaoTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/AccountDaoTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -10,6 +10,7 @@ import de.campussource.cse.cdmm.dao.AccountDao; import de.campussource.cse.cdmm.domain.Account; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class AccountDaoTest extends AbstractPersistentUnitTest { @@ -28,8 +29,8 @@ public void testPersistAccount() { try { dao.persist(account); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } assertNotNull(account.getId()); txCommit(); @@ -40,14 +41,14 @@ public void testFindAccount() { try { dao.persist(account); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } assertNotNull(account.getId()); commitAndBeginTx(); Account acid = null; try { acid = dao.find(account.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Created account could not be found"); } assertEquals(account, acid); @@ -57,13 +58,13 @@ public void testRemoveAccount() { try { dao.persist(account); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } assertNotNull(account.getId()); commitAndBeginTx(); try { dao.remove(account); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Unexpected DataModelMaangerException"); } commitAndBeginTx(); @@ -71,7 +72,7 @@ @SuppressWarnings("unused") Account retrievedAccount = dao.find(account.getId()); fail("Deleting of account failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur; } @@ -83,7 +84,7 @@ try { foundAccount = dao.find(0L); fail("Exception should occur"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } assertNull(foundAccount); Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CategoryDaoTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -13,6 +13,7 @@ import de.campussource.cse.cdmm.dao.CategoryDao; import de.campussource.cse.cdmm.domain.Category; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class CategoryDaoTest extends AbstractPersistentUnitTest { @@ -46,8 +47,8 @@ public void testPersistCategory() { try { dao.persist(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException on creation of category"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException on creation of category"); } assertNotNull(category.getId()); } @@ -59,14 +60,14 @@ public void testFindCategory() { try { dao.persist(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException on creation of category"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException on creation of category"); } assertNotNull(category.getId()); Category coid = null; try { coid = dao.find(category.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Created category could not be retrieved"); } assertEquals(category, coid); @@ -79,20 +80,20 @@ public void testRemoveCategory() { try { dao.persist(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException on creation of category"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException on creation of category"); } assertNotNull(category.getId()); try { dao.remove(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } try { @SuppressWarnings("unused") Category retrievedCategory = dao.find(category.getId()); fail("Deleting of category failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } } @@ -105,8 +106,8 @@ category.addToParentCategory(parentCategory); try { dao.persist(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException on creation of category"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException on creation of category"); } assertNotNull(category.getId()); assertNotNull(parentCategory.getId()); @@ -114,21 +115,21 @@ assertEquals(parentCategory.getChildren().get(0), category); try { dao.remove(parentCategory); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } try { @SuppressWarnings("unused") Category retrievedParentCategory = dao.find(parentCategory.getId()); fail("Deleting of parent category failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } try { @SuppressWarnings("unused") Category retrievedCategory = dao.find(category.getId()); fail("Cascaded deleting of child category failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } } @@ -142,7 +143,7 @@ try { foundCategory = dao.find(0L); fail("Exception should occur"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } assertNull(foundCategory); @@ -156,8 +157,8 @@ assertTrue(category.addToParentCategory(parentCategory)); try { dao.persist(category); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException on creation of category"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException on creation of category"); } assertFalse(parentCategory.addToParentCategory(category)); } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/CourseDaoTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -14,6 +14,7 @@ import de.campussource.cse.cdmm.dao.CourseDao; import de.campussource.cse.cdmm.domain.Category; import de.campussource.cse.cdmm.domain.Course; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class CourseDaoTest extends AbstractPersistentUnitTest { @@ -44,8 +45,8 @@ public void testPersistCourse() { try { dao.persist(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } assertNotNull(course.getId()); } @@ -59,15 +60,15 @@ public void testFindCourse() { try { dao.persist(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } assertNotNull(course.getId()); commitAndBeginTx(); Course coid = null; try { coid = dao.find(course.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Creating or retrieving of course failed!"); } assertEquals(course, coid); @@ -80,20 +81,20 @@ public void testRemoveCourse() { try { dao.persist(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } assertNotNull(course.getId()); try { dao.remove(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } try { @SuppressWarnings("unused") Course retrievedCourse = dao.find(course.getId()); fail("Deleting of course failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } } @@ -107,7 +108,7 @@ try { foundCourse = dao.find(0L); fail("Exception should occur"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } assertNull(foundCourse); @@ -123,15 +124,15 @@ autowireByType(categoryDao); try { categoryDao.persist(category); - } catch (DataModelManagerException e1) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e1) { + fail("Unexpected ServiceComponentException"); } assertNotNull(category.getId()); course.addToCategory(category); try { dao.persist(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } assertNotNull(course.getId()); assertNotNull(course.getCategories()); @@ -151,8 +152,8 @@ workgroup1.addAsWorkgroupTo(course); try { dao.persist(workgroup1); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException"); } assertNotNull(workgroup1.getId()); assertNotNull(course.getId()); @@ -165,21 +166,21 @@ // check correct deleting cascading try { dao.remove(course); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Unexpected Exception on removing of course"); } try { @SuppressWarnings("unused") Course retrievedCourse = dao.find(course.getId()); fail("Deleting of course failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } try { @SuppressWarnings("unused") Course retrievedWorkgroup = dao.find(workgroup1.getId()); fail("Cascaded deleting of workgroup failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { // Exception should occur } } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DaoTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DaoTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -6,6 +6,7 @@ import org.junit.Test; import de.campussource.cse.cdmm.dao.AccountDao; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class DaoTest extends AbstractPersistentUnitTest { @@ -23,7 +24,7 @@ try { accountDao.remove(null); fail("Exception should occur"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { } } Deleted: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DataModelManagerExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DataModelManagerExceptionTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/DataModelManagerExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,39 +0,0 @@ -package de.campussource.cse.cdmm; - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * @author Sebastian Roekens - */ -public class DataModelManagerExceptionTest { - - @Test - public void testDefaultConstructor() { - Exception e = new IdNotFoundException(); - assertNotNull(e); - } - - @Test - public void testMessageConstructor() { - Exception e = new DataModelManagerException("message"); - assertEquals("message", e.getMessage()); - } - - @Test - public void testCauseConstructor() { - Exception e = new DataModelManagerException("message"); - Exception e2 = new DataModelManagerException(e); - assertEquals(e,e2.getCause()); - } - - @Test - public void testMessageCauseConstructor() { - Exception e = new DataModelManagerException("message"); - Exception e2 = new DataModelManagerException("message", e); - assertEquals(e, e2.getCause()); - assertEquals("message", e2.getMessage()); - } - -} \ No newline at end of file Deleted: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/IdNotFoundExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/IdNotFoundExceptionTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/IdNotFoundExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,39 +0,0 @@ -package de.campussource.cse.cdmm; - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * @author Sebastian Roekens - */ -public class IdNotFoundExceptionTest { - - @Test - public void testDefaultConstructor() { - DataModelManagerException dmme = new IdNotFoundException(); - assertNotNull(dmme); - } - - @Test - public void testMessageConstructor() { - DataModelManagerException dmme = new IdNotFoundException("message"); - assertEquals("message", dmme.getMessage()); - } - - @Test - public void testCauseConstructor() { - DataModelManagerException dmme = new IdNotFoundException("message"); - DataModelManagerException dmme2 = new IdNotFoundException(dmme); - assertEquals(dmme,dmme2.getCause()); - } - - @Test - public void testMessageCauseConstructor() { - DataModelManagerException dmme = new IdNotFoundException("message"); - DataModelManagerException dmme2 = new IdNotFoundException("message", dmme); - assertEquals(dmme, dmme2.getCause()); - assertEquals("message", dmme2.getMessage()); - } - -} \ No newline at end of file Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingAttributeExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingAttributeExceptionTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingAttributeExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -4,6 +4,8 @@ import org.junit.Test; +import de.campussource.cse.common.exception.ServiceComponentException; + /** * @author Sebastian Roekens */ @@ -11,27 +13,27 @@ @Test public void testDefaultConstructor() { - DataModelManagerException dmme = new MissingAttributeException(); + ServiceComponentException dmme = new MissingAttributeException(); assertNotNull(dmme); } @Test public void testMessageConstructor() { - DataModelManagerException dmme = new MissingAttributeException("message"); + ServiceComponentException dmme = new MissingAttributeException("message"); assertEquals("message", dmme.getMessage()); } @Test public void testCauseConstructor() { - DataModelManagerException dmme = new MissingAttributeException("message"); - DataModelManagerException dmme2 = new MissingAttributeException(dmme); + ServiceComponentException dmme = new MissingAttributeException("message"); + ServiceComponentException dmme2 = new MissingAttributeException(dmme); assertEquals(dmme,dmme2.getCause()); } @Test public void testMessageCauseConstructor() { - DataModelManagerException dmme = new MissingAttributeException("message"); - DataModelManagerException dmme2 = new MissingAttributeException("message", dmme); + ServiceComponentException dmme = new MissingAttributeException("message"); + ServiceComponentException dmme2 = new MissingAttributeException("message", dmme); assertEquals(dmme, dmme2.getCause()); assertEquals("message", dmme2.getMessage()); } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingParameterExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingParameterExceptionTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/MissingParameterExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -4,6 +4,8 @@ import org.junit.Test; +import de.campussource.cse.common.exception.ServiceComponentException; + /** * @author Sebastian Roekens */ @@ -11,27 +13,27 @@ @Test public void testDefaultConstructor() { - DataModelManagerException dmme = new MissingParameterException(); + ServiceComponentException dmme = new MissingParameterException(); assertNotNull(dmme); } @Test public void testMessageConstructor() { - DataModelManagerException dmme = new MissingParameterException("message"); + ServiceComponentException dmme = new MissingParameterException("message"); assertEquals("message", dmme.getMessage()); } @Test public void testCauseConstructor() { - DataModelManagerException dmme = new MissingParameterException("message"); - DataModelManagerException dmme2 = new MissingParameterException(dmme); + ServiceComponentException dmme = new MissingParameterException("message"); + ServiceComponentException dmme2 = new MissingParameterException(dmme); assertEquals(dmme,dmme2.getCause()); } @Test public void testMessageCauseConstructor() { - DataModelManagerException dmme = new MissingParameterException("message"); - DataModelManagerException dmme2 = new MissingParameterException("message", dmme); + ServiceComponentException dmme = new MissingParameterException("message"); + ServiceComponentException dmme2 = new MissingParameterException("message", dmme); assertEquals(dmme, dmme2.getCause()); assertEquals("message", dmme2.getMessage()); } Modified: trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-cdmm/src/test/java/de/campussource/cse/cdmm/RoleDaoTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -16,6 +16,7 @@ import de.campussource.cse.cdmm.domain.Role; import de.campussource.cse.cdmm.domain.RoleType; import de.campussource.cse.cdmm.domain.State; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; public class RoleDaoTest extends AbstractPersistentUnitTest { @@ -72,8 +73,8 @@ Role roid = null; try { roid = dao.find(role.getId()); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } assertEquals(role, roid); } @@ -91,14 +92,14 @@ assertNotNull(role.getId()); try { dao.remove(role); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException!"); } try { @SuppressWarnings("unused") Role retrievedRole = dao.find(role.getId()); fail("Deleting failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception is correct } CourseDao courseDao = new CourseDao(); @@ -106,7 +107,7 @@ try { Course retrievedCourse = courseDao.find(course.getId()); assertNotNull(retrievedCourse); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Account should not be deleted!"); } } @@ -120,8 +121,8 @@ Role foundRole; try { foundRole = dao.find(0L); - fail("DataModelManagerException should have been thrown, due to search for an not existing object!"); - } catch (DataModelManagerException e) { + fail("ServiceComponentException should have been thrown, due to search for an not existing object!"); + } catch (ServiceComponentException e) { //Exception should occur } } @@ -174,21 +175,21 @@ autowireByType(courseDao); try { courseDao.remove(course); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException occured!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException occured!"); } try{ @SuppressWarnings("unused") Course retrievedCourse = courseDao.find(course.getId()); fail("Course deleting failed!"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } try { @SuppressWarnings("unused") Role retrievedRole = dao.find(role.getId()); fail("Cascaded Role deleting failed!"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } } @@ -216,21 +217,21 @@ autowireByType(accountDao); try { accountDao.remove(account); - } catch (DataModelManagerException e) { - fail("Unexpected DataModelManagerException occured!"); + } catch (ServiceComponentException e) { + fail("Unexpected ServiceComponentException occured!"); } try { @SuppressWarnings("unused") Account retrievedAccount = accountDao.find(account.getId()); fail("Account deleting failed!"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } try { @SuppressWarnings("unused") Role retrievedRole = dao.find(role.getId()); fail("Cascaded role deleting failed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } } @@ -273,24 +274,24 @@ try { retrievedRole = dao.retrieveRole(0, course.getId()); fail("Retrieved object should not exist"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } try { retrievedRole = dao.retrieveRole(account.getId(),0); fail("Retrieved object should not exist"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } try { retrievedRole = dao.retrieveRole(1l, 1l); fail("Retrieved object should not exist"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } try { retrievedRole = dao.retrieveRole(account.getId(), course.getId()); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { fail("Retrieved object should exist"); } assertNotNull(retrievedRole); @@ -299,7 +300,7 @@ try { dao.remove(null); fail("null can't be removed"); - } catch (DataModelManagerException e) { + } catch (ServiceComponentException e) { //Exception should occur } Added: trunk/sandbox/cse-ip/sc-common/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-common/pom.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-common/pom.xml 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>cse-ip</artifactId> + <groupId>de.campussource.cse</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-common</artifactId> + <packaging>jar</packaging> + <name>Service Component Common</name> + <version>1.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + +</project> \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-common/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java (rev 0) +++ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,26 @@ +package de.campussource.cse.common.exception; + +/** + * Exception to represent failed searches for objects + * e.g. no object with given id existing + * @author Sebastian Roekens + */ +public class IdNotFoundException extends ServiceComponentException { + + private static final long serialVersionUID = 3260263352045745859L; + + public IdNotFoundException() {} + + public IdNotFoundException(String message) { + super(message); + } + + public IdNotFoundException(Throwable cause) { + super(cause); + } + + public IdNotFoundException(String message, Throwable cause) { + super(message, cause); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ServiceComponentException.java =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ServiceComponentException.java (rev 0) +++ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ServiceComponentException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,25 @@ +package de.campussource.cse.common.exception; + +/** + * Exception to represent missing attributes in objects which shall be persisted + * @author Sebastian Roekens + */ +public class ServiceComponentException extends Exception { + + private static final long serialVersionUID = 3260263352045742366L; + + public ServiceComponentException() {} + + public ServiceComponentException(String message) { + super(message); + } + + public ServiceComponentException(Throwable cause) { + super(cause); + } + + public ServiceComponentException(String message, Throwable cause) { + super(message, cause); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/ServiceComponentException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/IdNotFoundExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/IdNotFoundExceptionTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/IdNotFoundExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,39 @@ +package de.campussource.cse.common.exception; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * @author Sebastian Roekens + */ +public class IdNotFoundExceptionTest { + + @Test + public void testDefaultConstructor() { + ServiceComponentException dmme = new IdNotFoundException(); + assertNotNull(dmme); + } + + @Test + public void testMessageConstructor() { + ServiceComponentException dmme = new IdNotFoundException("message"); + assertEquals("message", dmme.getMessage()); + } + + @Test + public void testCauseConstructor() { + ServiceComponentException dmme = new IdNotFoundException("message"); + ServiceComponentException dmme2 = new IdNotFoundException(dmme); + assertEquals(dmme,dmme2.getCause()); + } + + @Test + public void testMessageCauseConstructor() { + ServiceComponentException dmme = new IdNotFoundException("message"); + ServiceComponentException dmme2 = new IdNotFoundException("message", dmme); + assertEquals(dmme, dmme2.getCause()); + assertEquals("message", dmme2.getMessage()); + } + +} \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/IdNotFoundExceptionTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ServiceComponentExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ServiceComponentExceptionTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ServiceComponentExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,39 @@ +package de.campussource.cse.common.exception; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * @author Sebastian Roekens + */ +public class ServiceComponentExceptionTest { + + @Test + public void testDefaultConstructor() { + Exception e = new IdNotFoundException(); + assertNotNull(e); + } + + @Test + public void testMessageConstructor() { + Exception e = new ServiceComponentException("message"); + assertEquals("message", e.getMessage()); + } + + @Test + public void testCauseConstructor() { + Exception e = new ServiceComponentException("message"); + Exception e2 = new ServiceComponentException(e); + assertEquals(e,e2.getCause()); + } + + @Test + public void testMessageCauseConstructor() { + Exception e = new ServiceComponentException("message"); + Exception e2 = new ServiceComponentException("message", e); + assertEquals(e, e2.getCause()); + assertEquals("message", e2.getMessage()); + } + +} \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-common/src/test/java/de/campussource/cse/common/exception/ServiceComponentExceptionTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-common/src/test/resources/log4j.properties =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/test/resources/log4j.properties (rev 0) +++ trunk/sandbox/cse-ip/sc-common/src/test/resources/log4j.properties 2009-04-21 09:46:52 UTC (rev 130) @@ -0,0 +1,15 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +log4j.rootCategory=debug, stdout + +log4j.logger.org.hibernate=info + +log4j.logger.oracle.toplink=debug + +log4j.logger.org.hibernate.SQL=debug +log4j.logger.org.hibernate.type=debug +log4j.logger.org.hibernate.id=debug +log4j.logger.org.hibernate.cache=debug \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-common/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/sc-idmapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-04-21 09:46:52 UTC (rev 130) @@ -22,6 +22,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-common</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> <groupId>javax.ejb</groupId> <artifactId>ejb-api</artifactId> <version>3.0</version> Deleted: trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdNotFoundException.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdNotFoundException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdNotFoundException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,26 +0,0 @@ -package de.campussource.cse.mapper; - - -/** - * - * @author Ingo Dueppe - */ -public class IdNotFoundException extends MapperException { - - private static final long serialVersionUID = 3260263352045745855L; - - public IdNotFoundException() {} - - public IdNotFoundException(String message) { - super(message); - } - - public IdNotFoundException(Throwable cause) { - super(cause); - } - - public IdNotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} Modified: trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java 2009-04-21 09:46:52 UTC (rev 130) @@ -2,6 +2,8 @@ import javax.ejb.Remote; +import de.campussource.cse.common.exception.IdNotFoundException; + /** * IdentityMapper manage the administration of mappings between the global * unique busId and client specific object ids. Each mapping exists of three Modified: trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 09:46:52 UTC (rev 130) @@ -11,6 +11,8 @@ import org.apache.commons.lang.Validate; +import de.campussource.cse.common.exception.IdNotFoundException; + /** * Standard IdentityMapper implementation * @author Ingo Dueppe Deleted: trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/MapperException.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/MapperException.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/MapperException.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,26 +0,0 @@ -package de.campussource.cse.mapper; - -/** - * General mapper exception - * @author Ingo Dueppe - */ -public class MapperException extends Exception { - - private static final long serialVersionUID = -2553188081269164040L; - - public MapperException() { - } - - public MapperException(String message) { - super(message); - } - - public MapperException(Throwable cause) { - super(cause); - } - - public MapperException(String message, Throwable cause) { - super(message, cause); - } - -} Deleted: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdNotFoundExceptionTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdNotFoundExceptionTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdNotFoundExceptionTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -1,39 +0,0 @@ -package de.campussource.cse.mapper; - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * @author Ingo Dueppe - */ -public class IdNotFoundExceptionTest { - - @Test - public void testDefaultConstructor() { - MapperException me = new IdNotFoundException(); - assertNotNull(me); - } - - @Test - public void testMessageConstructor() { - MapperException me = new IdNotFoundException("message"); - assertEquals("message", me.getMessage()); - } - - @Test - public void testCauseConstructor() { - MapperException me = new IdNotFoundException("message"); - MapperException me2 = new IdNotFoundException(me); - assertEquals(me,me2.getCause()); - } - - @Test - public void testMessageCauseConstructor() { - MapperException me = new IdNotFoundException("message"); - MapperException me2 = new IdNotFoundException("message", me); - assertEquals(me, me2.getCause()); - assertEquals("message", me2.getMessage()); - } - -} Modified: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java 2009-04-20 15:42:24 UTC (rev 129) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java 2009-04-21 09:46:52 UTC (rev 130) @@ -8,6 +8,8 @@ import org.junit.Before; import org.junit.Test; +import de.campussource.cse.common.exception.IdNotFoundException; +import de.campussource.cse.common.exception.ServiceComponentException; import de.campussource.cse.common.test.AbstractPersistentUnitTest; /** @@ -33,14 +35,14 @@ } @Test - public void testBusToClientMapping() throws MapperException { + public void testBusToClientMapping() throws ServiceComponentException { Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); String clientId = mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID); assertEquals(CLIENT_OBJECT_ID, clientId); } @Test - public void testMultiBusToMapping() throws MapperException { + public void testMultiBusToMapping() throws ServiceComponentException { for (int i = 0; i < 10; i++) { Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); String clientId = mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID); @@ -62,7 +64,7 @@ } @Test - public void testPersistClientObjectId() throws MapperException { + public void testPersistClientObjectId() throws ServiceComponentException { // Persist a new mapping of client object id to a given bus id and // verify the results mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); @@ -77,7 +79,7 @@ } @Test(expected=RollbackException.class) - public void testErrorPersistClientObjectId() throws MapperException { + public void testErrorPersistClientObjectId() throws ServiceComponentException { mapper.persistClientObjectId(1L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); mapper.persistClientObjectId(2L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); commitAndBeginTx(); @@ -104,17 +106,17 @@ } @Test(expected = IllegalArgumentException.class) - public void testPersistNoBusIdParameter() throws MapperException { + public void testPersistNoBusIdParameter() throws ServiceComponentException { mapper.persistClientObjectId(null, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); } @Test(expected = IllegalArgumentException.class) - public void testPersistNoInstanceIdParameter() throws MapperException { + public void testPersistNoInstanceIdParameter() throws ServiceComponentException { mapper.persistClientObjectId(BUS_ID, null, CLIENT_OBJECT_ID); } @Test(expected = IllegalArgumentException.class) - public void testPersistNoObjectIdParameter() throws MapperException { + public void testPersistNoObjectIdParameter() throws ServiceComponentException { mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, ""); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-04-21 11:22:25
|
Revision: 133 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=133&view=rev Author: idueppe Date: 2009-04-21 11:21:37 +0000 (Tue, 21 Apr 2009) Log Message: ----------- add wsdl generation to pom.xml of sc-idmapper Modified Paths: -------------- trunk/sandbox/cse-ip/build.xml trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-idmapper/pom.xml trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java Added Paths: ----------- trunk/sandbox/cse-ip/sc-idmapper/build.xml trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java Modified: trunk/sandbox/cse-ip/build.xml =================================================================== --- trunk/sandbox/cse-ip/build.xml 2009-04-21 11:04:38 UTC (rev 132) +++ trunk/sandbox/cse-ip/build.xml 2009-04-21 11:21:37 UTC (rev 133) @@ -53,31 +53,4 @@ </exec> </target> - <!-- - - <target name="glassfish-deploy" depends="init, clean, install" description=""> - <exec executable="${asadmin}" failonerror="false"> - <arg line="deploy" /> - <arg line="--user ${admin.user}" /> - <arg line="--passwordfile ${admin.pwfile}" /> - <arg line="--host ${admin.host}" /> - <arg line="--port ${admin.port}" /> - <arg line="--upload=true" /> - <arg line="${earfile}" /> - </exec> - </target> - - <target name="glassfish-undeploy" depends="" description=""> - <exec executable="${asadmin}" failonerror="false"> - <arg line="undeploy" /> - <arg line="--user ${admin.user}" /> - <arg line="--passwordfile ${admin.pwfile}" /> - <arg line="--host ${admin.host}" /> - <arg line="--port ${admin.port}" /> - <arg line="${appname}" /> - </exec> - </target> - --> - - </project> Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-21 11:04:38 UTC (rev 132) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-21 11:21:37 UTC (rev 133) @@ -94,12 +94,8 @@ <distributionManagement> <site> <id>cse-ip.sourceforge.net</id> - <url>scp://web.sourceforge.net/home/groups/c/cs/cse-ip/htdocs</url> + <url>scp://shell.sourceforge.net/home/groups/c/cs/cse-ip/htdocs</url> </site> - <repository> - <id>cse-ip.sourceforge.net</id> - <url>scp://web.sourceforge.net/home/groups/c/cs/cse-ip/htdocs/maven2</url> - </repository> </distributionManagement> <organization> Added: trunk/sandbox/cse-ip/sc-idmapper/build.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/build.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-idmapper/build.xml 2009-04-21 11:21:37 UTC (rev 133) @@ -0,0 +1,41 @@ +<project name="cse-ip :: sc :: mapper :: build" default="install" basedir="."> + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + + <target name="compile"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="install"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + + <target name="wsgen"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsgen"/> + </exec> + </target> + + <target name="wsimport"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsimport"/> + </exec> + </target> + + +</project> Property changes on: trunk/sandbox/cse-ip/sc-idmapper/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/sc-idmapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-04-21 11:04:38 UTC (rev 132) +++ trunk/sandbox/cse-ip/sc-idmapper/pom.xml 2009-04-21 11:21:37 UTC (rev 133) @@ -22,6 +22,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <version>2.1.5</version> + <scope>compile</scope> + </dependency> + <dependency> <groupId>de.campussource.cse</groupId> <artifactId>sc-common</artifactId> <version>${pom.version}</version> @@ -30,7 +36,7 @@ <groupId>javax.ejb</groupId> <artifactId>ejb-api</artifactId> <version>3.0</version> - <scope>provided</scope> + <!-- <scope>provided</scope>--> </dependency> <dependency> <groupId>javax.persistence</groupId> @@ -81,6 +87,22 @@ </dependencies> <build> + <resources> + <resource> + <directory>${project.build.directory}/resources-generated</directory> + <includes> + <include>**/*.xsd</include> + <include>**/*.wsdl</include> + <include>**/*.xml</include> + </includes> + </resource> + <resource> + <directory>${project.build.directory}/sources-generated</directory> + <includes> + <include>**/*.java</include> + </includes> + </resource> + </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -89,6 +111,30 @@ <ejbVersion>3.0</ejbVersion> </configuration> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>1.10</version> + <executions> + <execution> + <phase>generate-test-sources</phase> + <goals> + <goal>wsgen</goal> + <goal>wsimport</goal> + </goals> + </execution> + </executions> + <configuration> + <sei>de.campussource.cse.mapper.IdentityMapperBean</sei> + <packageName>de.campussource.cse.mapper.generated</packageName> + <keep>true</keep> + <genWsdl>true</genWsdl> + <verbose>true</verbose> + <resourceDestDir>${project.build.directory}/resources-generated</resourceDestDir> + <sourceDestDir>${project.build.directory}/sources-generated</sourceDestDir> + <wsdlLocation>${project.build.directory}/resources-generated/IdentityMapperBean.wsdl</wsdlLocation> + </configuration> + </plugin> </plugins> </build> Modified: trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 11:04:38 UTC (rev 132) +++ trunk/sandbox/cse-ip/sc-idmapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 11:21:37 UTC (rev 133) @@ -3,6 +3,7 @@ import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; +import javax.jws.WebService; import javax.persistence.EntityExistsException; import javax.persistence.EntityManager; import javax.persistence.NoResultException; @@ -18,10 +19,11 @@ * @author Ingo Dueppe */ @Stateless +@WebService(name="IdentityMapper", targetNamespace="http://cse.campussource.de/mapper") public class IdentityMapperBean implements IdentityMapper { @PersistenceContext - private EntityManager em; + private EntityManager manager; @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) @@ -31,9 +33,9 @@ Validate.notEmpty(clientObjectId, "IdentityMapper.persistClientObjectId: Parameter clientObjectId is mandatory."); MappedClientObject mapped = new MappedClientObject(busId, clientInstanceId, clientObjectId); try { - em.persist(mapped); + manager.persist(mapped); } catch (EntityExistsException eee) { - em.merge(mapped); + manager.merge(mapped); } System.out.println("MappedClientObject "+mapped.toString()); } @@ -44,7 +46,7 @@ Validate.notNull(clientInstanceId, "IdentityMapper.toBusId: Parameter clientInstanceId is mandatory."); Validate.notNull(clientObjectId, "IdentityMapper.toBusId: Parameter clientObjectId is mandatory."); try { - Query query = em.createNamedQuery(MappedClientObject.FIND_BUSID); + Query query = manager.createNamedQuery(MappedClientObject.FIND_BUSID); query.setParameter("clientInstanceId", clientInstanceId); query.setParameter("clientObjectId", clientObjectId); return (Long) query.getSingleResult(); @@ -57,7 +59,7 @@ MappedClientObject mapped = new MappedClientObject(); mapped.setClientInstanceId(clientInstanceId); mapped.setClientObjectId(clientObjectId); - em.persist(mapped); + manager.persist(mapped); return mapped.getBusId(); } @@ -67,7 +69,7 @@ Validate.notNull(busId,"IdentityMapper.toClientObjectId: Parameter busId is mandatory."); Validate.notNull(clientInstanceId,"IdentityMapper.toClientObjectId: Parameter clientInstanceId is mandatory."); try { - Query query = em.createNamedQuery(MappedClientObject.FIND_OBJECTID); + Query query = manager.createNamedQuery(MappedClientObject.FIND_OBJECTID); query.setParameter("clientInstanceId", clientInstanceId); query.setParameter("busId", busId); return (String) query.getSingleResult(); Added: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java 2009-04-21 11:21:37 UTC (rev 133) @@ -0,0 +1,18 @@ +package de.campussource.cse.mapper; + +import javax.xml.ws.Endpoint; + +import org.junit.Test; + + + +public class IdentityMapperWebServiceTest { + + @Test + public void testWebService() { + Endpoint endpoint = Endpoint.publish("http://localhost:12345/mapper", new IdentityMapperBean()); +// JOptionPane.showMessageDialog(null, "Mapper Server"); + endpoint.stop(); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-idmapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-04-21 12:25:51
|
Revision: 135 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=135&view=rev Author: roekens Date: 2009-04-21 12:25:41 +0000 (Tue, 21 Apr 2009) Log Message: ----------- refactoring of sc-idmapper to sc-mapper Modified Paths: -------------- trunk/sandbox/cse-ip/cse-ip-application/pom.xml trunk/sandbox/cse-ip/pom.xml Added Paths: ----------- trunk/sandbox/cse-ip/sc-mapper/ trunk/sandbox/cse-ip/sc-mapper/build.xml trunk/sandbox/cse-ip/sc-mapper/createDDL.jdbc trunk/sandbox/cse-ip/sc-mapper/dropDDL.jdbc trunk/sandbox/cse-ip/sc-mapper/pom.xml trunk/sandbox/cse-ip/sc-mapper/src/ trunk/sandbox/cse-ip/sc-mapper/src/main/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperLocal.java trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObject.java trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObjectPK.java trunk/sandbox/cse-ip/sc-mapper/src/main/resources/ trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/ trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/persistence.xml trunk/sandbox/cse-ip/sc-mapper/src/test/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectPKTest.java trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectTest.java trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java trunk/sandbox/cse-ip/sc-mapper/src/test/resources/ trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/ trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/persistence.xml trunk/sandbox/cse-ip/sc-mapper/src/test/resources/log4j.properties Removed Paths: ------------- trunk/sandbox/cse-ip/sc-idmapper/ Modified: trunk/sandbox/cse-ip/cse-ip-application/pom.xml =================================================================== --- trunk/sandbox/cse-ip/cse-ip-application/pom.xml 2009-04-21 11:35:08 UTC (rev 134) +++ trunk/sandbox/cse-ip/cse-ip-application/pom.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -17,7 +17,7 @@ <dependencies> <dependency> <groupId>de.campussource.cse</groupId> - <artifactId>sc-idmapper</artifactId> + <artifactId>sc-mapper</artifactId> <version>${pom.version}</version> <type>ejb</type> </dependency> @@ -40,7 +40,7 @@ <modules> <ejbModule> <groupId>de.campussource.cse</groupId> - <artifactId>sc-idmapper</artifactId> + <artifactId>sc-mapper</artifactId> </ejbModule> </modules> <modules> Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-21 11:35:08 UTC (rev 134) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -106,7 +106,7 @@ <modules> <module>framework</module> <module>ica-his-lsf</module> - <module>sc-idmapper</module> + <module>sc-mapper</module> <module>sc-cdmm</module> <module>sc-common</module> <module>cse-ip-application</module> Added: trunk/sandbox/cse-ip/sc-mapper/build.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/build.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/build.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,41 @@ +<project name="cse-ip :: sc :: mapper :: build" default="install" basedir="."> + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + + <target name="compile"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="install"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + + <target name="wsgen"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsgen"/> + </exec> + </target> + + <target name="wsimport"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsimport"/> + </exec> + </target> + + +</project> Property changes on: trunk/sandbox/cse-ip/sc-mapper/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/createDDL.jdbc =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/createDDL.jdbc (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/createDDL.jdbc 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,4 @@ +CREATE TABLE MAPPED_CLIENT_OBJECT (BUS_ID BIGINT NOT NULL, CLIENT_INSTANCE_ID BIGINT NOT NULL, CLIENT_OBJECT_ID VARCHAR(255) NOT NULL, PRIMARY KEY (BUS_ID, CLIENT_INSTANCE_ID)) +ALTER TABLE MAPPED_CLIENT_OBJECT ADD CONSTRAINT UNQ_MAPPED_CLIENT_OBJECT_0 UNIQUE (CLIENT_OBJECT_ID, CLIENT_INSTANCE_ID) +CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38), PRIMARY KEY (SEQ_NAME)) +INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0) Added: trunk/sandbox/cse-ip/sc-mapper/dropDDL.jdbc =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/dropDDL.jdbc (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/dropDDL.jdbc 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,3 @@ +ALTER TABLE MAPPED_CLIENT_OBJECT DROP FOREIGN KEY UNQ_MAPPED_CLIENT_OBJECT_0 +DROP TABLE MAPPED_CLIENT_OBJECT +DELETE FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN' Added: trunk/sandbox/cse-ip/sc-mapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/pom.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/pom.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>cse-ip</artifactId> + <groupId>de.campussource.cse</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-mapper</artifactId> + <packaging>ejb</packaging> + <name>Service Component Id-Mapper</name> + <version>1.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>test-utilities</artifactId> + <version>${pom.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <version>2.1.5</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-common</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>javax.ejb</groupId> + <artifactId>ejb-api</artifactId> + <version>3.0</version> + <!-- <scope>provided</scope>--> + </dependency> + <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>toplink.essentials</groupId> + <artifactId>toplink-essentials</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <resources> + <resource> + <directory>${project.build.directory}/resources-generated</directory> + <includes> + <include>**/*.xsd</include> + <include>**/*.wsdl</include> + <include>**/*.xml</include> + </includes> + </resource> + <resource> + <directory>${project.build.directory}/sources-generated</directory> + <includes> + <include>**/*.java</include> + </includes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ejb-plugin</artifactId> + <configuration> + <ejbVersion>3.0</ejbVersion> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>1.10</version> + <executions> + <execution> + <phase>generate-test-sources</phase> + <goals> + <goal>wsgen</goal> + <goal>wsimport</goal> + </goals> + </execution> + </executions> + <configuration> + <sei>de.campussource.cse.mapper.IdentityMapperBean</sei> + <packageName>de.campussource.cse.mapper.generated</packageName> + <keep>true</keep> + <genWsdl>true</genWsdl> + <verbose>true</verbose> + <resourceDestDir>${project.build.directory}/resources-generated</resourceDestDir> + <sourceDestDir>${project.build.directory}/sources-generated</sourceDestDir> + <wsdlLocation>${project.build.directory}/resources-generated/IdentityMapperBean.wsdl</wsdlLocation> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,47 @@ +package de.campussource.cse.mapper; + +import javax.ejb.Remote; + +import de.campussource.cse.common.exception.IdNotFoundException; + +/** + * IdentityMapper manage the administration of mappings between the global + * unique busId and client specific object ids. Each mapping exists of three + * ids. The global unique bus id, the client instance unique object id, and the + * client unique instance id. + * + * @author Ingo Dueppe + */ +@Remote +public interface IdentityMapper { + + /** + * Convert a clientInstanceId and a clientObjectId to a busID. If the busId + * doesn't exist for the given combination of the parameters then a new busId will be generated. + * + * @param clientInstanceId the Id of the client instance. + * @param clientObjectId the Id of the client object. The id can be any arbitrary string. + * @return busId according to the clientInstance- and clientObjectId. + */ + public Long toBusId(Long clientInstanceId, String clientObjectId); + + /** + * Convert the combination of busId and clientInstanceId to a clientObjectId. + * + * @param busId a existing bus id. + * @param clientInstanceId a existing client instance id. + * @return the corresponding clientObjectID + * @throws IdNotFoundException thrown if either the busId or the clientInstanceId doesn't exists. + */ + public String toClientObjectId(Long busId, Long clientInstanceId) throws IdNotFoundException; + + /** + * Save or update the clientObjectId according to the given busId and clientInstanceId. + * + * @param busId the global unique busId. + * @param clientInstanceId the global unique client instance id. + * @param clientObjectId the client unique object id. + */ + public void persistClientObjectId(Long busId, Long clientInstanceId, String clientObjectId); + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapper.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,82 @@ +package de.campussource.cse.mapper; + +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.jws.WebService; +import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import org.apache.commons.lang.Validate; + +import de.campussource.cse.common.exception.IdNotFoundException; + +/** + * Standard IdentityMapper implementation + * @author Ingo Dueppe + */ +@Stateless +@WebService(name="IdentityMapper", targetNamespace="http://cse.campussource.de/mapper") +public class IdentityMapperBean implements IdentityMapper { + + @PersistenceContext + private EntityManager manager; + + @Override + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void persistClientObjectId(Long busId, Long clientInstanceId, String clientObjectId) { + Validate.notNull(busId, "IdentityMapper.persistClientObjectId: Parameter busId is mandatory."); + Validate.notNull(clientInstanceId, "IdentityMapper.persistClientObjectId: Parameter clientInstanceId is mandatory."); + Validate.notEmpty(clientObjectId, "IdentityMapper.persistClientObjectId: Parameter clientObjectId is mandatory."); + MappedClientObject mapped = new MappedClientObject(busId, clientInstanceId, clientObjectId); + try { + manager.persist(mapped); + } catch (EntityExistsException eee) { + manager.merge(mapped); + } + System.out.println("MappedClientObject "+mapped.toString()); + } + + @Override + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public Long toBusId(Long clientInstanceId, String clientObjectId) { + Validate.notNull(clientInstanceId, "IdentityMapper.toBusId: Parameter clientInstanceId is mandatory."); + Validate.notNull(clientObjectId, "IdentityMapper.toBusId: Parameter clientObjectId is mandatory."); + try { + Query query = manager.createNamedQuery(MappedClientObject.FIND_BUSID); + query.setParameter("clientInstanceId", clientInstanceId); + query.setParameter("clientObjectId", clientObjectId); + return (Long) query.getSingleResult(); + } catch (NoResultException nre) { + return createMapping(clientInstanceId, clientObjectId); + } + } + + private Long createMapping(Long clientInstanceId, String clientObjectId) { + MappedClientObject mapped = new MappedClientObject(); + mapped.setClientInstanceId(clientInstanceId); + mapped.setClientObjectId(clientObjectId); + manager.persist(mapped); + return mapped.getBusId(); + } + + @Override + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public String toClientObjectId(Long busId, Long clientInstanceId) throws IdNotFoundException { + Validate.notNull(busId,"IdentityMapper.toClientObjectId: Parameter busId is mandatory."); + Validate.notNull(clientInstanceId,"IdentityMapper.toClientObjectId: Parameter clientInstanceId is mandatory."); + try { + Query query = manager.createNamedQuery(MappedClientObject.FIND_OBJECTID); + query.setParameter("clientInstanceId", clientInstanceId); + query.setParameter("busId", busId); + return (String) query.getSingleResult(); + } catch (NoResultException nre) { + throw new IdNotFoundException(nre); + } + + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperLocal.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperLocal.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperLocal.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,13 @@ +package de.campussource.cse.mapper; + +import javax.ejb.Local; + +/** + * The local interface of IdentityMapper + * @see de.campussource.cse.mapper.IdentityMapper + * @author Ingo Dueppe + */ +@Local +public interface IdentityMapperLocal extends IdentityMapper { + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperLocal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObject.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObject.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObject.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,103 @@ +package de.campussource.cse.mapper; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * @author Ingo Dueppe + */ +@Entity(name="MappedClientObject") +@Table(name = "MAPPED_CLIENT_OBJECT", + uniqueConstraints = @UniqueConstraint(columnNames = { "CLIENT_OBJECT_ID", "CLIENT_INSTANCE_ID" })) +@NamedQueries(value = { + @NamedQuery( + name = "MappedClientObject.findObjectId", + query = "select c.clientObjectId from MappedClientObject c where c.busId=:busId and c.clientInstanceId = :clientInstanceId"), + @NamedQuery( + name = "MappedClientObject.findBusId", + query = "select c.busId from MappedClientObject c where c.clientObjectId=:clientObjectId and c.clientInstanceId = :clientInstanceId") }) +@IdClass(value=MappedClientObjectPK.class) +public class MappedClientObject { + + public static final String FIND_OBJECTID = "MappedClientObject.findObjectId"; + public static final String FIND_BUSID = "MappedClientObject.findBusId"; + + private Long busId; + + private Long clientInstanceId; + + private String clientObjectId; + + public MappedClientObject() { + }; + + public MappedClientObject(Long busId, Long clientInstanceId, String clientObjectId) { + this.busId = busId; + this.clientInstanceId = clientInstanceId; + this.clientObjectId = clientObjectId; + } + + @Id + @Column(name="BUS_ID", nullable = false) + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getBusId() { + return busId; + } + + public void setBusId(Long busId) { + this.busId = busId; + } + + @Id + @Column(name="CLIENT_INSTANCE_ID", nullable=false) + public Long getClientInstanceId() { + return clientInstanceId; + } + + public void setClientInstanceId(Long clientInstanceId) { + this.clientInstanceId = clientInstanceId; + } + + @Column(name="CLIENT_OBJECT_ID", nullable=false) + public String getClientObjectId() { + return clientObjectId; + } + + public void setClientObjectId(String clientObjectId) { + this.clientObjectId = clientObjectId; + } + + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof MappedClientObject)) { + return false; + } + MappedClientObject other = (MappedClientObject) obj; + return new EqualsBuilder().append(busId, other.busId).append(clientInstanceId, other.clientInstanceId).isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder().append(busId).append(clientInstanceId).toHashCode(); + } + + public String toString() { + return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(busId).append(clientInstanceId).append( + clientObjectId).toString(); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObject.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObjectPK.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObjectPK.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObjectPK.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,63 @@ +package de.campussource.cse.mapper; + +import java.io.Serializable; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * @author Ingo Dueppe + */ +public class MappedClientObjectPK implements Serializable { + + private static final long serialVersionUID = 4835950977456597594L; + + private Long busId; + private Long clientInstanceId; + + public MappedClientObjectPK() { + } + + public MappedClientObjectPK(Long busId, Long clientInstanceId) { + this.busId = busId; + this.clientInstanceId = clientInstanceId; + } + + public Long getBusId() { + return busId; + } + + public void setBusId(Long busId) { + this.busId = busId; + } + + public Long getClientInstanceId() { + return clientInstanceId; + } + + public void setClientInstanceId(Long clientInstanceId) { + this.clientInstanceId = clientInstanceId; + } + + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof MappedClientObjectPK)) { + return false; + } + MappedClientObjectPK other = (MappedClientObjectPK) obj; + return new EqualsBuilder().append(busId, other.busId).append(clientInstanceId, other.clientInstanceId).isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder().append(busId).append(clientInstanceId).toHashCode(); + } + + public String toString() { + return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(busId).append(clientInstanceId).toString(); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/MappedClientObjectPK.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/persistence.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/persistence.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,15 @@ +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="cs-mapper"> + <provider>oracle.toplink.essentials.PersistenceProvider</provider> + <jta-data-source>jdbc/cseip</jta-data-source> + <class>de.campussource.cse.mapper.MappedClientObject</class> + </persistence-unit> +</persistence> + + + + + \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/resources/META-INF/persistence.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,122 @@ +package de.campussource.cse.mapper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.persistence.RollbackException; + +import org.junit.Before; +import org.junit.Test; + +import de.campussource.cse.common.exception.IdNotFoundException; +import de.campussource.cse.common.exception.ServiceComponentException; +import de.campussource.cse.common.test.AbstractPersistentUnitTest; + +/** + * @author Ingo Dueppe + */ +public class IdentityMapperTest extends AbstractPersistentUnitTest { + + private static final Long UNKNOWN_BUS_ID = -1000L; + private static final Long BUS_ID = 1000L; + private static final Long CLIENT_INSTANCE_ID = 1000L; + private static final String CLIENT_OBJECT_ID = "CSE:SYSTEM:CLIENTID"; + + private IdentityMapper mapper; + + @Before + public void setUp() { + txBegin(); + // CleanUp Database + entityManager.createNativeQuery("DELETE FROM MAPPED_CLIENT_OBJECT").executeUpdate(); + commitAndBeginTx(); + mapper = new IdentityMapperBean(); + autowireByType(mapper); + } + + @Test + public void testBusToClientMapping() throws ServiceComponentException { + Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + String clientId = mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID); + assertEquals(CLIENT_OBJECT_ID, clientId); + } + + @Test + public void testMultiBusToMapping() throws ServiceComponentException { + for (int i = 0; i < 10; i++) { + Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + String clientId = mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID); + assertEquals(CLIENT_OBJECT_ID, clientId); + commitAndBeginTx(); + } + } + + @Test(expected = IdNotFoundException.class) + public void testBusIdNotFound() throws IdNotFoundException { + mapper.toClientObjectId(CLIENT_INSTANCE_ID, UNKNOWN_BUS_ID); + } + + @Test(expected = IdNotFoundException.class) + public void testClientObjectIdNotFound() throws IdNotFoundException { + Long busId = mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + assertNotNull(busId); + mapper.toClientObjectId(busId, CLIENT_INSTANCE_ID + uniqueId()); + } + + @Test + public void testPersistClientObjectId() throws ServiceComponentException { + // Persist a new mapping of client object id to a given bus id and + // verify the results + mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + commitAndBeginTx(); + assertEquals(BUS_ID, mapper.toBusId(CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID)); + assertEquals(CLIENT_OBJECT_ID, mapper.toClientObjectId(BUS_ID, CLIENT_INSTANCE_ID)); + // Override the existing mapping to a new client object id and verify + // the results + mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, "NEW:CLIENT:OBJECT:ID"); + assertEquals(BUS_ID, mapper.toBusId(CLIENT_INSTANCE_ID, "NEW:CLIENT:OBJECT:ID")); + assertEquals("NEW:CLIENT:OBJECT:ID", mapper.toClientObjectId(BUS_ID, CLIENT_INSTANCE_ID)); + } + + @Test(expected=RollbackException.class) + public void testErrorPersistClientObjectId() throws ServiceComponentException { + mapper.persistClientObjectId(1L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + mapper.persistClientObjectId(2L, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + commitAndBeginTx(); + } + + @Test(expected = IllegalArgumentException.class) + public void testToBusNoClientInstanceParameter() throws IdNotFoundException { + mapper.toBusId(null, CLIENT_OBJECT_ID); + } + + @Test(expected = IllegalArgumentException.class) + public void testToBusNoObjectIdParameter() throws IdNotFoundException { + mapper.toBusId(CLIENT_INSTANCE_ID, null); + } + + @Test(expected = IllegalArgumentException.class) + public void testToClientNoBusIdParameter() throws IdNotFoundException { + mapper.toClientObjectId(null, CLIENT_INSTANCE_ID); + } + + @Test(expected = IllegalArgumentException.class) + public void testToClientNoInstanceIdParameter() throws IdNotFoundException { + mapper.toClientObjectId(BUS_ID, null); + } + + @Test(expected = IllegalArgumentException.class) + public void testPersistNoBusIdParameter() throws ServiceComponentException { + mapper.persistClientObjectId(null, CLIENT_INSTANCE_ID, CLIENT_OBJECT_ID); + } + + @Test(expected = IllegalArgumentException.class) + public void testPersistNoInstanceIdParameter() throws ServiceComponentException { + mapper.persistClientObjectId(BUS_ID, null, CLIENT_OBJECT_ID); + } + + @Test(expected = IllegalArgumentException.class) + public void testPersistNoObjectIdParameter() throws ServiceComponentException { + mapper.persistClientObjectId(BUS_ID, CLIENT_INSTANCE_ID, ""); + } +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,18 @@ +package de.campussource.cse.mapper; + +import javax.xml.ws.Endpoint; + +import org.junit.Test; + + + +public class IdentityMapperWebServiceTest { + + @Test + public void testWebService() { + Endpoint endpoint = Endpoint.publish("http://localhost:12345/mapper", new IdentityMapperBean()); +// JOptionPane.showMessageDialog(null, "Mapper Server"); + endpoint.stop(); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/IdentityMapperWebServiceTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectPKTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectPKTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectPKTest.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,63 @@ +package de.campussource.cse.mapper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * @author Ingo Dueppe + */ +public class MappedClientObjectPKTest { + + @Test + public void testEquals() { + MappedClientObjectPK pk = new MappedClientObjectPK(); + assertTrue(pk.equals(pk)); + + assertFalse(new MappedClientObjectPK().equals(new Object())); + assertFalse(new Object().equals(new MappedClientObjectPK())); + + assertFalse(new MappedClientObjectPK(1L, 1L).equals(new MappedClientObjectPK())); + assertFalse(new MappedClientObjectPK().equals(new MappedClientObjectPK(1L, 1L))); + + assertTrue(new MappedClientObjectPK(1L, 1L).equals(new MappedClientObjectPK(1L, 1L))); + + assertFalse(new MappedClientObjectPK(1L, 2L).equals(new MappedClientObjectPK(2L, 1L))); + assertFalse(new MappedClientObjectPK(1L, 1L).equals(new MappedClientObjectPK(1L, 2L))); + + assertTrue(new MappedClientObjectPK(1L, null).equals(new MappedClientObjectPK(1L, null))); + assertFalse(new MappedClientObjectPK(null, null).equals(new MappedClientObjectPK(1L, null))); + + assertTrue(new MappedClientObjectPK().equals(new MappedClientObjectPK())); + } + + @Test + public void testSetters() { + MappedClientObjectPK pk = new MappedClientObjectPK(); + + assertTrue(pk.getBusId() == null); + assertTrue(pk.getClientInstanceId() == null); + + pk.setBusId(1L); + assertEquals((Long)1L, pk.getBusId()); + + pk.setClientInstanceId(1L); + assertEquals((Long)1L, pk.getClientInstanceId()); + } + + @Test + public void testToString() { + assertFalse(new MappedClientObjectPK().toString().isEmpty()); + } + + @Test + public void testHashCode() { + assertEquals(new MappedClientObjectPK(1L,1L).hashCode(), new MappedClientObjectPK(1L,1L).hashCode()); + assertNotSame(new MappedClientObjectPK(1L,1L).hashCode(), new MappedClientObjectPK(1L,2L).hashCode()); + assertNotSame(new MappedClientObjectPK(1L,1L).hashCode(), new MappedClientObjectPK(2L,1L).hashCode()); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectPKTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectTest.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,54 @@ +package de.campussource.cse.mapper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * @author Ingo Dueppe + */ +public class MappedClientObjectTest { + + @Test + public void testEquals() { + MappedClientObject mapped = new MappedClientObject(); + assertTrue(mapped.equals(mapped)); + + assertFalse(new MappedClientObject().equals(new Object())); + assertFalse(new Object().equals(new MappedClientObject())); + + assertFalse(new MappedClientObject(1L, 1L, "").equals(new MappedClientObject())); + assertFalse(new MappedClientObject().equals(new MappedClientObject(1L, 1L, ""))); + + assertTrue(new MappedClientObject(1L, 1L, "").equals(new MappedClientObject(1L, 1L, ""))); + assertTrue(new MappedClientObject(1L, 1L, "").equals(new MappedClientObject(1L, 1L, "XYZ"))); + + assertFalse(new MappedClientObject(1L, 2L, "").equals(new MappedClientObject(2L, 1L, ""))); + assertFalse(new MappedClientObject(1L, 1L, "").equals(new MappedClientObject(1L, 2L, ""))); + + assertTrue(new MappedClientObject(1L, null, "").equals(new MappedClientObject(1L, null, ""))); + assertFalse(new MappedClientObject(null, null, "").equals(new MappedClientObject(1L, null, ""))); + + assertTrue(new MappedClientObject().equals(new MappedClientObject())); + + assertFalse(new MappedClientObject().equals(null)); + } + + @Test + public void testToString() { + assertFalse(new MappedClientObject().toString().isEmpty()); + assertFalse(new MappedClientObject(1L, 1L,"TEST").toString().isEmpty()); + } + + @Test + public void testHashCode() { + assertEquals(new MappedClientObject(1L,1L,"").hashCode(), new MappedClientObject(1L,1L,"").hashCode()); + assertEquals(new MappedClientObject(1L,1L,"321").hashCode(), new MappedClientObject(1L,1L,"123").hashCode()); + assertNotSame(new MappedClientObject(1L,1L,"").hashCode(), new MappedClientObject(1L,2L,"").hashCode()); + assertNotSame(new MappedClientObject(1L,1L,"").hashCode(), new MappedClientObject(2L,1L,"").hashCode()); + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/MappedClientObjectTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,35 @@ +package de.campussource.cse.mapper; + +import static org.junit.Assert.assertNotNull; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +import org.junit.Test; + +/** + * @author Ingo Dueppe + */ +public class PersistentUnitConfigurationTest { + + @Test + public void testConfiguration() { + try { + EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("cseip-test"); + EntityManager entityManager = entityManagerFactory.createEntityManager(); + + List<MappedClientObject> mappings = entityManager.createQuery("SELECT m FROM MappedClientObject m").getResultList(); + assertNotNull(mappings); + + entityManager.close(); + entityManagerFactory.close(); + } catch (RuntimeException rt) { + rt.printStackTrace(); + throw rt; + } + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/PersistentUnitConfigurationTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/persistence.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/persistence.xml 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,21 @@ +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="cseip-test" transaction-type="RESOURCE_LOCAL"> + <provider>oracle.toplink.essentials.PersistenceProvider</provider> + <class>de.campussource.cse.mapper.MappedClientObject</class> + <properties> + <property name="toplink.ddl-generation" value="drop-and-create-tables" /> + <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" /> + <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/cseiptest?createDatabaseIfNotExist=true" /> + <property name="toplink.jdbc.user" value="root" /> + <property name="toplink.jdbc.password" value="masterkey" /> + </properties> + </persistence-unit> +</persistence> + + + + + \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/resources/META-INF/persistence.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper/src/test/resources/log4j.properties =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/resources/log4j.properties (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/resources/log4j.properties 2009-04-21 12:25:41 UTC (rev 135) @@ -0,0 +1,15 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +log4j.rootCategory=debug, stdout + +log4j.logger.org.hibernate=info + +log4j.logger.oracle.toplink=debug + +log4j.logger.org.hibernate.SQL=debug +log4j.logger.org.hibernate.type=debug +log4j.logger.org.hibernate.id=debug +log4j.logger.org.hibernate.cache=debug \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-04-21 14:22:36
|
Revision: 137 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=137&view=rev Author: roekens Date: 2009-04-21 13:41:08 +0000 (Tue, 21 Apr 2009) Log Message: ----------- - added build.xml for cdmm - first integration of webservice as in sc-mapper Modified Paths: -------------- trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-cdmm/pom.xml trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java trunk/sandbox/cse-ip/sc-mapper/pom.xml Added Paths: ----------- trunk/sandbox/cse-ip/sc-cdmm/build.xml Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-21 13:25:38 UTC (rev 136) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-21 13:41:08 UTC (rev 137) @@ -331,10 +331,17 @@ <version>2.1-60f</version> <scope>test</scope> </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <version>${jaxws-rt.version}</version> + <scope>compile</scope> + </dependency> </dependencies> </dependencyManagement> <properties> + <jaxws-rt.version>2.1.5</jaxws-rt.version> <servicemix.version>3.3</servicemix.version> <servicemix-tooling.version>3.2.3</servicemix-tooling.version> <camel.version>1.6.0</camel.version> Added: trunk/sandbox/cse-ip/sc-cdmm/build.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/build.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-cdmm/build.xml 2009-04-21 13:41:08 UTC (rev 137) @@ -0,0 +1,41 @@ +<project name="cse-ip :: sc :: cdmm :: build" default="install" basedir="."> + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + + <target name="compile"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="install"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + + <target name="wsgen"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsgen"/> + </exec> + </target> + + <target name="wsimport"> + <exec executable="${maven.executable}"> + <arg line="jaxws:wsimport"/> + </exec> + </target> + + +</project> Property changes on: trunk/sandbox/cse-ip/sc-cdmm/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/sc-cdmm/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-04-21 13:25:38 UTC (rev 136) +++ trunk/sandbox/cse-ip/sc-cdmm/pom.xml 2009-04-21 13:41:08 UTC (rev 137) @@ -22,6 +22,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <scope>compile</scope> + </dependency> + <dependency> <groupId>de.campussource.cse</groupId> <artifactId>sc-common</artifactId> <version>${pom.version}</version> @@ -30,7 +35,7 @@ <groupId>javax.ejb</groupId> <artifactId>ejb-api</artifactId> <version>3.0</version> - <scope>provided</scope> + </dependency> <dependency> <groupId>javax.persistence</groupId> @@ -83,6 +88,22 @@ </dependencies> <build> + <resources> + <resource> + <directory>${project.build.directory}/resources-generated</directory> + <includes> + <include>**/*.xsd</include> + <include>**/*.wsdl</include> + <include>**/*.xml</include> + </includes> + </resource> + <resource> + <directory>${project.build.directory}/sources-generated</directory> + <includes> + <include>**/*.java</include> + </includes> + </resource> + </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -91,6 +112,30 @@ <ejbVersion>3.0</ejbVersion> </configuration> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>1.10</version> + <executions> + <execution> + <phase>generate-test-sources</phase> + <goals> + <goal>wsgen</goal> + <goal>wsimport</goal> + </goals> + </execution> + </executions> + <configuration> + <sei>de.campussource.cse.cdmm.DataModelManagerBean</sei> + <packageName>de.campussource.cse.cdmm.generated</packageName> + <keep>true</keep> + <genWsdl>true</genWsdl> + <verbose>true</verbose> + <resourceDestDir>${project.build.directory}/resources-generated</resourceDestDir> + <sourceDestDir>${project.build.directory}/sources-generated</sourceDestDir> + <wsdlLocation>${project.build.directory}/resources-generated/IdentityMapperBean.wsdl</wsdlLocation> + </configuration> + </plugin> </plugins> </build> Modified: trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-21 13:25:38 UTC (rev 136) +++ trunk/sandbox/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/DataModelManagerBean.java 2009-04-21 13:41:08 UTC (rev 137) @@ -7,6 +7,7 @@ import javax.ejb.EJB; import javax.ejb.Remote; import javax.ejb.Stateless; +import javax.jws.WebService; import de.campussource.cse.cdmm.dao.*; import de.campussource.cse.cdmm.domain.Category; @@ -22,6 +23,7 @@ */ @Stateless @Remote(value=DataModelManager.class) +@WebService(name="DataModelManager", targetNamespace="http://cse.campussource.de/cdmm") public class DataModelManagerBean implements DataModelManager { @EJB Modified: trunk/sandbox/cse-ip/sc-mapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/pom.xml 2009-04-21 13:25:38 UTC (rev 136) +++ trunk/sandbox/cse-ip/sc-mapper/pom.xml 2009-04-21 13:41:08 UTC (rev 137) @@ -24,7 +24,6 @@ <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> - <version>2.1.5</version> <scope>compile</scope> </dependency> <dependency> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-04-21 18:51:39
|
Revision: 144 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=144&view=rev Author: idueppe Date: 2009-04-21 18:51:24 +0000 (Tue, 21 Apr 2009) Log Message: ----------- additional annotations Modified Paths: -------------- trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/webservice/IdentityMapperWebServiceTest.java Added Paths: ----------- trunk/sandbox/cse-ip/sc-common/build.xml trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/package-info.java Added: trunk/sandbox/cse-ip/sc-common/build.xml =================================================================== --- trunk/sandbox/cse-ip/sc-common/build.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-common/build.xml 2009-04-21 18:51:24 UTC (rev 144) @@ -0,0 +1,28 @@ +<project name="cse-ip :: sc :: common :: build" default="install" basedir="."> + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + + <target name="compile"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="install" depends="clean"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + +</project> Property changes on: trunk/sandbox/cse-ip/sc-common/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java =================================================================== --- trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java 2009-04-21 17:54:48 UTC (rev 143) +++ trunk/sandbox/cse-ip/sc-common/src/main/java/de/campussource/cse/common/exception/IdNotFoundException.java 2009-04-21 18:51:24 UTC (rev 144) @@ -1,10 +1,13 @@ package de.campussource.cse.common.exception; +import javax.xml.ws.WebFault; + /** * Exception to represent failed searches for objects * e.g. no object with given id existing * @author Sebastian Roekens */ +@WebFault(name="IdNotFound", targetNamespace="http://cse.campussource.de/common") public class IdNotFoundException extends ServiceComponentException { private static final long serialVersionUID = 3260263352045745859L; Modified: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 17:54:48 UTC (rev 143) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/IdentityMapperBean.java 2009-04-21 18:51:24 UTC (rev 144) @@ -24,7 +24,8 @@ @Stateless @WebService( name="IdentityMapper", - targetNamespace="http://cse.campussource.de/mapper") + targetNamespace="http://cse.campussource.de/mapper", + endpointInterface="") public class IdentityMapperBean implements IdentityMapper { @PersistenceContext Added: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/package-info.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/package-info.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/package-info.java 2009-04-21 18:51:24 UTC (rev 144) @@ -0,0 +1,8 @@ +@XmlSchema( + namespace="http://cse.campussource.de/mapper", + elementFormDefault=XmlNsForm.UNQUALIFIED, + attributeFormDefault=XmlNsForm.QUALIFIED) +package de.campussource.cse.mapper; + +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; Property changes on: trunk/sandbox/cse-ip/sc-mapper/src/main/java/de/campussource/cse/mapper/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/webservice/IdentityMapperWebServiceTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/webservice/IdentityMapperWebServiceTest.java 2009-04-21 17:54:48 UTC (rev 143) +++ trunk/sandbox/cse-ip/sc-mapper/src/test/java/de/campussource/cse/mapper/webservice/IdentityMapperWebServiceTest.java 2009-04-21 18:51:24 UTC (rev 144) @@ -39,17 +39,20 @@ txBegin(); IdentityMapper mapper = new IdentityMapperBeanService().getIdentityMapperPort(); + // RETRIEVE BUSID Long busId = mapper.toBusId(12345L, CLIENT_OBJECTID); assertNotNull(busId); txCommit(); txBegin(); + // RETRIEVE CLIENTID String clientId = mapper.toClientObjectId(busId, 12345L); assertNotNull(clientId); assertEquals(CLIENT_OBJECTID, clientId); - } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <id...@us...> - 2009-04-21 21:22:36
|
Revision: 146 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=146&view=rev Author: idueppe Date: 2009-04-21 21:22:23 +0000 (Tue, 21 Apr 2009) Log Message: ----------- in progress: added rest client to sc-mapper Modified Paths: -------------- trunk/sandbox/cse-ip/build.xml trunk/sandbox/cse-ip/pom.xml trunk/sandbox/cse-ip/sc-mapper/pom.xml Added Paths: ----------- trunk/sandbox/cse-ip/sc-mapper-rest/ trunk/sandbox/cse-ip/sc-mapper-rest/build.xml trunk/sandbox/cse-ip/sc-mapper-rest/pom.xml trunk/sandbox/cse-ip/sc-mapper-rest/src/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/IdentityMapperRestBean.java trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/MappedObject.java trunk/sandbox/cse-ip/sc-mapper-rest/src/main/resources/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestIdentityMapperIntegrationTest.java trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestfulTest.java trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/persistence.xml trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/log4j.properties Modified: trunk/sandbox/cse-ip/build.xml =================================================================== --- trunk/sandbox/cse-ip/build.xml 2009-04-21 19:27:23 UTC (rev 145) +++ trunk/sandbox/cse-ip/build.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -1,4 +1,4 @@ -<project name="cse-ip" default="install" basedir="."> +<project name="cse-ip :: build" default="install" basedir="."> <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> <condition property="asadmin.executable" value="asadmin.bat" else="asadmin"><os family="windows"/></condition> Modified: trunk/sandbox/cse-ip/pom.xml =================================================================== --- trunk/sandbox/cse-ip/pom.xml 2009-04-21 19:27:23 UTC (rev 145) +++ trunk/sandbox/cse-ip/pom.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -109,11 +109,18 @@ <module>sc-common</module> <module>sc-mapper</module> <module>sc-cdmm</module> + <module>sc-mapper-rest</module> <module>cse-ip-application</module> </modules> <repositories> + <repository> + <id>jboss</id> + <name>JBoss</name> + <url>http://repository.jboss.com/maven2</url> + <layout>default</layout> + </repository> <repository> <id>download-java-net</id> <name>Repository Java.Net</name> Modified: trunk/sandbox/cse-ip/sc-mapper/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper/pom.xml 2009-04-21 19:27:23 UTC (rev 145) +++ trunk/sandbox/cse-ip/sc-mapper/pom.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -22,16 +22,16 @@ <scope>test</scope> </dependency> <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-common</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <scope>compile</scope> </dependency> <dependency> - <groupId>de.campussource.cse</groupId> - <artifactId>sc-common</artifactId> - <version>${pom.version}</version> - </dependency> - <dependency> <groupId>javax.ejb</groupId> <artifactId>ejb-api</artifactId> <version>3.0</version> Added: trunk/sandbox/cse-ip/sc-mapper-rest/build.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/build.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/build.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,28 @@ +<project name="cse-ip :: sc :: mapper :: rest :: build" default="install" basedir="."> + <condition property="maven.executable" value="mvn.bat" else="mvn"><os family="windows" /></condition> + + <target name="compile"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="clean"> + <exec executable="${maven.executable}"> + <arg line="clean"/> + </exec> + </target> + + <target name="install" depends="clean"> + <exec executable="${maven.executable}"> + <arg line="install"/> + </exec> + </target> + + <target name="eclipse"> + <exec executable="${maven.executable}"> + <arg line="eclipse:clean eclipse:eclipse"/> + </exec> + </target> + +</project> Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/pom.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/pom.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/pom.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>cse-ip</artifactId> + <groupId>de.campussource.cse</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-mapper-rest</artifactId> + <packaging>war</packaging> + <name>Service Component Mapper REST</name> + <version>1.0-SNAPSHOT</version> + + + + <dependencies> + <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>sc-mapper</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>de.campussource.cse</groupId> + <artifactId>test-utilities</artifactId> + <version>${pom.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-server</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + +</project> \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/IdentityMapperRestBean.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/IdentityMapperRestBean.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/IdentityMapperRestBean.java 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,69 @@ +package de.campussource.cse.mapper.rest; + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +import de.campussource.cse.common.exception.IdNotFoundException; + +@Path("/mapper") +public class IdentityMapperRestBean { + + private Map<Long, String> busToClient = new HashMap<Long, String>(); + private Map<String, Long> clientToBus = new HashMap<String, Long>(); + + private Long toBus(String client) { + Long bus = clientToBus.get(client); + if (bus == null) { + bus = System.currentTimeMillis(); + busToClient.put(bus, client); + clientToBus.put(client, bus); + } + + return bus; + } + + private String toClient(Long bus) { + return busToClient.get(bus); + } + + @GET + @Path("/client/{instanceid}/{objectid}") + @Produces("application/xml") + public MappedObject toBusId(@PathParam("instanceid") Long clientInstanceId, + @PathParam("objectid") String clientObjectId) { + + MappedObject mapped = new MappedObject(); + mapped.setBusId(toBus(clientObjectId)); +// mapped.setBusId(mapper.toBusId(clientInstanceId, clientObjectId)); + mapped.setClientInstanceId(clientInstanceId); + mapped.setClientObjectId(clientObjectId); + + return mapped; + } + + @GET + @Path("/bus/{busid}/{instanceid}") + @Produces("application/xml") + public MappedObject toClientObjectId( + @PathParam("busid") Long busId, + @PathParam("instanceid") Long clientInstanceId) throws IdNotFoundException { + MappedObject mapped = new MappedObject(); + mapped.setBusId(busId); + mapped.setClientInstanceId(clientInstanceId); + mapped.setClientObjectId(toClient(busId)); +// mapped.setClientObjectId(mapper.toClientObjectId(busId, clientInstanceId)); + + return mapped; + } + + +// public static void setMapper(IdentityMapper identityMapper) { +// mapper = identityMapper; +// } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/IdentityMapperRestBean.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/MappedObject.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/MappedObject.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/MappedObject.java 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,48 @@ +package de.campussource.cse.mapper.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +@XmlRootElement(name="Mapped") +@XmlType(name="MappedObjectType", namespace="http://cse.campussource.de/mapper") +@XmlAccessorType(XmlAccessType.FIELD) +public class MappedObject { + + @XmlElement(name="BusId") + private Long busId; + + @XmlElement(name="ClientInstanceId") + private Long clientInstanceId; + + @XmlElement(name="ClientObjectId") + private String clientObjectId; + + public Long getBusId() { + return busId; + } + + public void setBusId(Long busId) { + this.busId = busId; + } + + public Long getClientInstanceId() { + return clientInstanceId; + } + + public void setClientInstanceId(Long clientInstanceId) { + this.clientInstanceId = clientInstanceId; + } + + public String getClientObjectId() { + return clientObjectId; + } + + public void setClientObjectId(String clientObjectId) { + this.clientObjectId = clientObjectId; + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/main/java/de/campussource/cse/mapper/rest/MappedObject.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestIdentityMapperIntegrationTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestIdentityMapperIntegrationTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestIdentityMapperIntegrationTest.java 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,91 @@ +package de.campussource.cse.mapper.rest; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.sun.jersey.api.container.httpserver.HttpServerFactory; +import com.sun.net.httpserver.HttpServer; + +public class RestIdentityMapperIntegrationTest{ + + private static final String LOCALHOST = "http://localhost:8888/"; + private static HttpServer server; + + @BeforeClass + public static void setUp() throws Exception { + System.out.println("Creating Server..."); + + + server = HttpServerFactory.create(LOCALHOST); + server.start(); + + + System.out.println("HTTP Server started."); + System.out.println("Running tests..."); + + } + +// @Before +// public void setup() { +// IdentityMapper mapper = new IdentityMapperBean(); +// autowireByType(mapper); +// IdentityMapperRestBean.setMapper(mapper); +// JOptionPane.showMessageDialog(null, "JAX-RS Server is running!"); +// } + + private static String testResourceAtUrl(URL url) throws Exception { + try { + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("GET"); + connection.connect(); + + InputStream is = connection.getInputStream(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder buffer = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + buffer.append(line); + } + System.out.println("Read: " + buffer.toString()); + + connection.disconnect(); + + return buffer.toString(); + + } catch (IOException e) { + e.printStackTrace(); + } + throw new Exception("Could not establish connection to " + url.toExternalForm()); + } + + @Test + public void testRest() throws Exception { + String activationText = testResourceAtUrl(new URL(LOCALHOST + "mapper/client/12345/objectid")); + assertNotNull(activationText); + assertFalse(activationText.isEmpty()); + } + + @AfterClass + public static void tearDown() throws IOException { + if (server != null) { + System.out.println("Stopping server..."); + server.stop(0); + System.out.println("Server stopped"); + } + + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestIdentityMapperIntegrationTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestfulTest.java =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestfulTest.java (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestfulTest.java 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,96 @@ +package de.campussource.cse.mapper.rest; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +import javax.swing.JOptionPane; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.sun.jersey.api.container.httpserver.HttpServerFactory; +import com.sun.net.httpserver.HttpServer; + +@Path("/unittest") +public class RestfulTest { + + private static final String LOCALHOST = "http://localhost:8888/"; + + private static HttpServer server; + + @GET + @Produces("text/plain") + public String testSystem() { + return "Hello. This is a test"; + } + + @BeforeClass + public static void setUp() throws Exception { + System.out.println("Creating Server..."); + + server = HttpServerFactory.create(LOCALHOST); + server.start(); + + JOptionPane.showMessageDialog(null, "JAX-RS Server is running!"); + + System.out.println("HTTP Server started."); + System.out.println("Running tests..."); + + } + + private static String testResourceAtUrl(URL url) throws Exception { + try { + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("GET"); + connection.connect(); + + InputStream is = connection.getInputStream(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder buffer = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + buffer.append(line); + } + System.out.println("Read: " + buffer.toString()); + + connection.disconnect(); + + return buffer.toString(); + + } catch (IOException e) { + e.printStackTrace(); + } + throw new Exception("Could not establish connection to " + url.toExternalForm()); + } + + @Test + public void testRest() throws Exception { + String activationText = testResourceAtUrl(new URL(LOCALHOST + "/mapper")); + assertNotNull(activationText); + assertFalse(activationText.isEmpty()); + } + + @AfterClass + public static void tearDown() throws IOException { + if (server != null) { + System.out.println("Stopping server..."); + server.stop(0); + System.out.println("Server stopped"); + } + + } + +} Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/java/de/campussource/cse/mapper/rest/RestfulTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/persistence.xml =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/persistence.xml (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/persistence.xml 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,21 @@ +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="cseip-test" transaction-type="RESOURCE_LOCAL"> + <provider>oracle.toplink.essentials.PersistenceProvider</provider> + <class>de.campussource.cse.mapper.MappedClientObject</class> + <properties> + <property name="toplink.ddl-generation" value="drop-and-create-tables" /> + <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" /> + <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/cseiptest?createDatabaseIfNotExist=true" /> + <property name="toplink.jdbc.user" value="root" /> + <property name="toplink.jdbc.password" value="masterkey" /> + </properties> + </persistence-unit> +</persistence> + + + + + \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/META-INF/persistence.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/log4j.properties =================================================================== --- trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/log4j.properties (rev 0) +++ trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/log4j.properties 2009-04-21 21:22:23 UTC (rev 146) @@ -0,0 +1,15 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +log4j.rootCategory=debug, stdout + +log4j.logger.org.hibernate=info + +log4j.logger.oracle.toplink=debug + +log4j.logger.org.hibernate.SQL=debug +log4j.logger.org.hibernate.type=debug +log4j.logger.org.hibernate.id=debug +log4j.logger.org.hibernate.cache=debug \ No newline at end of file Property changes on: trunk/sandbox/cse-ip/sc-mapper-rest/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |