diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-03-22 15:11:37 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-03-22 15:11:37 +0000 |
commit | 3e1c7a3ad2173d3a29032fd893e28ec7d13b10ac (patch) | |
tree | f9f9b0b61189ff73772156b1ed00be2c674eec2f /archiva-database | |
parent | 2087d187e72013e87f86c6ddeaa617a8a2cea6d5 (diff) | |
download | archiva-3e1c7a3ad2173d3a29032fd893e28ec7d13b10ac.tar.gz archiva-3e1c7a3ad2173d3a29032fd893e28ec7d13b10ac.zip |
Boilerplate unit testing with hsqldb for other devs ...
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@521303 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database')
-rw-r--r-- | archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java index a359b9b66..5697afd11 100644 --- a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java @@ -25,6 +25,8 @@ import org.apache.maven.archiva.model.ArchivaRepositoryModel; import java.util.List; +import javax.jdo.JDOHelper; + /** * JdoArchivaDAOTest * @@ -35,33 +37,54 @@ public class JdoArchivaDAOTest extends AbstractArchivaDatabaseTestCase { public void testRepositoryCRUD() throws ArchivaDatabaseException { + // Create it ArchivaRepositoryModel repo = dao.createRepository( "testRepo", "http://localhost:8080/repository/foo" ); - assertNotNull( repo ); - repo.setName( "The Test Repostitory." ); + // Set some mandatory values + repo.setName( "The Test Repository." ); + repo.setCreationSource( "Test Case" ); repo.setLayoutName( "default" ); + // Save it. ArchivaRepositoryModel repoSaved = dao.saveRepository( repo ); assertNotNull( repoSaved ); + assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved ).toString() ); + // Test that something has been saved. List repos = dao.getRepositories(); assertNotNull( repos ); assertEquals( 1, repos.size() ); - + + // Test that retreived object is what we expect. + ArchivaRepositoryModel firstRepo = (ArchivaRepositoryModel) repos.get( 0 ); + assertNotNull( firstRepo ); + assertEquals( "testRepo", repo.getId() ); + assertEquals( "The Test Repository.", repo.getName() ); + assertEquals( "Test Case", repo.getCreationSource() ); + assertEquals( "default", repo.getLayoutName() ); + + // Change value and save. repoSaved.setName( "Saved Again" ); dao.saveRepository( repoSaved ); - + + // Test that only 1 object is saved. + assertEquals( 1, dao.getRepositories().size() ); + + // Get the specific repo. ArchivaRepositoryModel actualRepo = dao.getRepository( "testRepo" ); assertNotNull( actualRepo ); + + // Test expected values. assertEquals( "testRepo", actualRepo.getId() ); assertEquals( "http://localhost:8080/repository/foo", actualRepo.getUrl() ); assertEquals( "Saved Again", actualRepo.getName() ); - + + // Test that only 1 object is saved. assertEquals( 1, dao.getRepositories().size() ); - + + // Delete object. dao.deleteRepository( actualRepo ); assertEquals( 0, dao.getRepositories().size() ); } } - |