Revision: 1985
Author: [email protected]
Date: Fri Jul 30 04:48:00 2010
Log: Fixed findbugs warning and expanded testing for adding projects.
http://code.google.com/p/simal/source/detail?r=1985
Modified:
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestAddFileToRepository.java
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestRepository.java
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestAddFileToRepository.java
Wed May 26 06:23:31 2010
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestAddFileToRepository.java
Fri Jul 30 04:48:00 2010
@@ -15,10 +15,10 @@
*/
package uk.ac.osswatch.simal.integrationTest.model.repository;
+import static junit.framework.Assert.fail;
+
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URISyntaxException;
import org.junit.Test;
import org.slf4j.Logger;
@@ -27,9 +27,7 @@
import uk.ac.osswatch.simal.SimalRepositoryFactory;
import uk.ac.osswatch.simal.model.IProject;
import uk.ac.osswatch.simal.rdf.ISimalRepository;
-import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
-
-import static junit.framework.Assert.fail;
+import uk.ac.osswatch.simal.rdf.io.RDFXMLUtils;
/**
* test common activities relating to Projects.
@@ -47,8 +45,26 @@
"testData/testAddFromForm.xml", "testData/testAddFromFormSimpler.xml"
};
@Test
- public void testAdd() throws SimalRepositoryException,
URISyntaxException,
- IOException {
+ public void testAddGeneric() {
+ try {
+ performAdd(true);
+ } catch (Exception e) {
+ LOGGER.warn("Exception adding test data via generic mechanism: " +
e.getMessage(), e);
+ fail();
+ }
+ }
+
+ @Test
+ public void testAddProject() {
+ try {
+ performAdd(false);
+ } catch (Exception e) {
+ LOGGER.warn("Exception adding test data via project API: " +
e.getMessage(), e);
+ fail();
+ }
+ }
+
+ private void performAdd(boolean generic) throws Exception {
int i = 0;
for (String testFileName : ADD_FROM_FORM_FILE) {
File testFile = new File(ISimalRepository.class.getClassLoader()
@@ -60,14 +76,17 @@
byte b[] = new byte[x];
fis.read(b);
String data = new String(b);
- getRepository().add(data);
- } catch (Exception e) {
- LOGGER.warn("Exception adding test data: " + e.getMessage(), e);
- fail();
+ if (generic) {
+ getRepository().add(data);
+ } else {
+ SimalRepositoryFactory.getProjectService().createProject(
+ RDFXMLUtils.convertXmlStringToDom(data));
+ }
} finally {
fis.close();
- IProject project1 =
SimalRepositoryFactory.getProjectService().getProject(PROJECT_URIS[i]);
- if(project1 != null) {
+ IProject project1 = SimalRepositoryFactory.getProjectService()
+ .getProject(PROJECT_URIS[i]);
+ if (project1 != null) {
project1.delete();
}
i++;
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestRepository.java
Wed May 26 06:23:31 2010
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/integrationTest/model/repository/TestRepository.java
Fri Jul 30 04:48:00 2010
@@ -126,15 +126,23 @@
int peopleBefore =
SimalRepositoryFactory.getPersonService().getAll().size();
File testFile = new File(ISimalRepository.class.getClassLoader()
.getResource(ModelSupport.TEST_FILE_URI_WITH_QNAME).toURI());
- FileInputStream fis = new FileInputStream(testFile);
- int x = fis.available();
- byte b[] = new byte[x];
- fis.read(b);
- String data = new String(b);
- getRepository().add(data);
- int peopleAfter =
SimalRepositoryFactory.getPersonService().getAll().size();
-
-
+
+ FileInputStream fis = null;
+
+ try {
+ fis = new FileInputStream(testFile);
+ int x = fis.available();
+ byte b[] = new byte[x];
+ fis.read(b);
+ String data = new String(b);
+ getRepository().add(data);
+ } finally {
+ if(fis != null) {
+ fis.close();
+ }
+ }
+
+ int peopleAfter =
SimalRepositoryFactory.getPersonService().getAll().size();
Iterator<IPerson> people =
SimalRepositoryFactory.getPersonService().getAll().iterator();
while (people.hasNext()) {
IPerson person = people.next();
--
You received this message because you are subscribed to the Google Groups "Simal
Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simal-commits?hl=en.