Revision: 1896
Author: [email protected]
Date: Mon Jun 7 06:47:17 2010
Log: Add method to create url to a Project. This is a temporary fix, in the
long run the accessible URL should be merged with the URI (Issue 287)
http://code.google.com/p/simal/source/detail?r=1896
Added:
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/AbstractJenaModelTest.java
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/TestProject.java
Modified:
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/Project.java
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFUtils.java
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/TestInternetAddress.java
=======================================
--- /dev/null
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/AbstractJenaModelTest.java
Mon Jun 7 06:47:17 2010
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2010 University of Oxford
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package uk.ac.osswatch.simal.model.jena;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import uk.ac.osswatch.simal.SimalRepositoryFactory;
+import uk.ac.osswatch.simal.model.ModelSupport;
+import uk.ac.osswatch.simal.rdf.ISimalRepository;
+import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
+
+/**
+ *
+ */
+public abstract class AbstractJenaModelTest {
+
+ protected static ISimalRepository repository;
+ private static final String TEST_OSS_WATCH_DOAP
= "testData/ossWatchDOAP.xml";
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ if (repository != null) {
+ try {
+ repository.destroy();
+ } catch (SimalRepositoryException e) {
+ // Don't care if failing to destroy repo
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ repository = SimalRepositoryFactory
+ .getInstance(SimalRepositoryFactory.JENA);
+ if (!repository.isInitialised()) {
+ repository.initialise(null);
+ }
+
+
repository.addProject(ISimalRepository.class.getClassLoader().getResource(
+ TEST_OSS_WATCH_DOAP), ModelSupport.TEST_FILE_BASE_URL);
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/TestProject.java
Mon Jun 7 06:47:17 2010
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2010 University of Oxford
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package uk.ac.osswatch.simal.model.jena;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+
+import uk.ac.osswatch.simal.SimalRepositoryFactory;
+import uk.ac.osswatch.simal.model.IProject;
+import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
+
+/**
+ *
+ */
+public class TestProject extends AbstractJenaModelTest {
+
+ private static final String TEST_PROJECT_SEE_ALSO
= "http://www.oss-watch.ac.uk/ossWatch#";
+
+ @Test
+ public void testGenerateURL() {
+ try {
+ IProject project =
SimalRepositoryFactory.getProjectService().findProjectBySeeAlso(TEST_PROJECT_SEE_ALSO);
+ if(project != null && project instanceof Project) {
+ String generatedURL = ((Project) project).generateURL();
+ assertEquals("http://localhost:8080/project/simalID/" +
project.getSimalID(),generatedURL);
+ return;
+ }
+ fail("Project with seeAlso '" + TEST_PROJECT_SEE_ALSO + "'that was
just inserted seems null");
+ } catch (SimalRepositoryException e) {
+ fail("Couldn't find project just inserted.");
+ }
+ }
+}
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/Project.java
Tue Nov 17 16:35:07 2009
+++
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/Project.java
Mon Jun 7 06:47:17 2010
@@ -473,7 +473,37 @@
return feeds;
}
-public int getOpennessRating() throws SimalRepositoryException {
+ /**
+ * Temporary fix to return an accessible url to the project; imitates
+ * construction mechanism of the BookmarkablePageLink in Wicket.
+ *
+ * TODO Redesign in line with best practice linked data approach, eg.
+ * make URI of the project an accessible URL.
+ *
+ * @return URL of a web page where project can be viewed.
+ */
+ public String generateURL() {
+ // http://<host>/project/simalID/<simalID>
+ StringBuffer url = new StringBuffer();
+
+ try {
+ url.append(SimalProperties
+ .getProperty(SimalProperties.PROPERTY_USER_WEBAPP_BASEURL));
+ if (!url.toString().endsWith("/")) {
+ url.append('/');
+ }
+ url.append("project/simalID/");
+ url.append(getSimalID());
+ } catch (SimalRepositoryException e) {
+ logger.info("Could not generate url using property "
+ + SimalProperties.PROPERTY_USER_WEBAPP_BASEURL + "; error:"
+ + e.getMessage(), e);
+ }
+
+ return url.toString();
+ }
+
+ public int getOpennessRating() throws SimalRepositoryException {
IReviewService service = SimalRepositoryFactory.getReviewService();
Set<IReview> reviews = service.getReviewsForProject(this);
if (reviews.size() == 0) {
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFUtils.java
Fri Jun 4 04:48:47 2010
+++
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFUtils.java
Mon Jun 7 06:47:17 2010
@@ -22,9 +22,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import uk.ac.osswatch.simal.SimalProperties;
import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
@@ -55,8 +52,6 @@
public static final String SIMAL_PERSON_ID = "personId";
public static final String SIMAL_PROJECT_ID = "projectId";
- static final Logger LOGGER = LoggerFactory.getLogger(RDFUtils.class);
-
public static final String DOAP_NS = DOAP.NS;
public static final String DC_NS = DC.NS;
public static final String FOAF_NS = FOAF.NS;
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java
Fri Jun 4 04:48:47 2010
+++
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java
Mon Jun 7 06:47:17 2010
@@ -18,11 +18,15 @@
package uk.ac.osswatch.simal.rdf.io;
+import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -30,6 +34,8 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.DOMException;
@@ -38,12 +44,15 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import uk.ac.osswatch.simal.HomepageLabelGenerator;
import uk.ac.osswatch.simal.SimalProperties;
import uk.ac.osswatch.simal.SimalRepositoryFactory;
import uk.ac.osswatch.simal.model.IDoapCategory;
import uk.ac.osswatch.simal.model.simal.SimalOntology;
+import uk.ac.osswatch.simal.rdf.SimalException;
import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
import com.hp.hpl.jena.rdf.model.Model;
@@ -51,15 +60,44 @@
/**
* Utility class for specific RDF/XML functions.
*/
-public class RDFXMLUtils {
+public final class RDFXMLUtils {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(RDFXMLUtils.class);
+
+ private RDFXMLUtils() {
+ // don't allow instantation
+ }
+
+ public static Document convertXmlStringToDom(String xmlSource) throws
SimalException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder;
+ Document domResult = null;
+ if (xmlSource != null) {
+ try {
+ builder = factory.newDocumentBuilder();
+ domResult = builder.parse(new InputSource(new
StringReader(xmlSource)));
+ } catch (ParserConfigurationException e) {
+ LOGGER.warn("Unexpected ParserConfigurationException: " +
e.getMessage(),e);
+ } catch (SAXException e) {
+ LOGGER.warn("Unexpected SAXException: " + e.getMessage(),e);
+ throw new SimalException("Tried to create DOM Document from
invalid XML", e);
+ } catch (IOException e) {
+ LOGGER.warn("Unexpected IOException: " + e.getMessage(),e);
+ }
+ }
+ return domResult;
+ }
/**
- * Parse the Document and write to the model.
+ * Parse the Document and write to the model.
+ *
* @param doc
* @param model
* @throws SimalRepositoryException
*/
- public static void addRDFXMLToModel(Document doc, Model model) throws
SimalRepositoryException {
+ public static void addRDFXMLToModel(Document doc, Model model)
+ throws SimalRepositoryException {
StringWriter xmlAsWriter = new StringWriter();
StreamResult result = new StreamResult(xmlAsWriter);
try {
@@ -74,7 +112,7 @@
}
String xml = xmlAsWriter.toString();
StringReader xmlReader = new StringReader(xml);
- // FIXME Are we sure this is the right way? JavaDoc suggests otherwise.
+ // FIXME Are we sure this is the right way? JavaDoc suggests otherwise.
model.read(xmlReader, "");
}
@@ -88,8 +126,10 @@
* @rdf:resource/doap#BKRepository<br/> CVSRepository:
* @rdf:resource/doap#CVSRepository<br/> SVNRepository:
* @rdf:resource/doap#SVNRepository<br/> Version:
- *
http://simal.oss-watch.ac.uk/doap/PROJECT_NAME/@revision#Version<br/>
- *
http://simal.oss-watch.ac.uk/foaf/PERSON_NAME#Person<br/>
+ * http://simal.oss-watch.ac.uk/
+ *
doap/PROJECT_NAME/@revision#Version<br/>
+ *
http://simal.oss-watch.ac.uk/foaf/PERSON_NAME
+ * #Person<br/>
*
* @param url
* the URL of the file to parse
@@ -99,22 +139,22 @@
*/
public static void removeBNodes(final Document doc) throws DOMException,
UnsupportedEncodingException {
-
+
NodeList nl =
doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "Repository");
removeBlankRepositoryNodes(nl);
-
+
nl = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "ArchRepository");
removeBlankRepositoryNodes(nl);
-
+
nl = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "BKRepository");
removeBlankRepositoryNodes(nl);
-
+
nl = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "CVSRepository");
removeBlankRepositoryNodes(nl);
-
+
nl = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "SVNRepository");
removeBlankRepositoryNodes(nl);
-
+
nl = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "Version");
removeBlankVersionNodes(nl);
}
@@ -136,14 +176,14 @@
Element el = (Element) nl.item(i);
if (!el.hasAttributeNS(RDFUtils.RDF_NS, "about")) {
String uri = null;
- Node locationNode =
el.getElementsByTagNameNS(RDFUtils.DOAP_NS, "location")
- .item(0);
+ Node locationNode = el.getElementsByTagNameNS(RDFUtils.DOAP_NS,
+ "location").item(0);
if (locationNode != null) {
uri =
locationNode.getAttributes().getNamedItemNS(RDFUtils.RDF_NS,
"resource").getNodeValue().trim();
} else {
- locationNode =
el.getElementsByTagNameNS(RDFUtils.DOAP_NS, "anon-root")
- .item(0);
+ locationNode = el.getElementsByTagNameNS(RDFUtils.DOAP_NS,
+ "anon-root").item(0);
if (locationNode != null) {
uri = locationNode.getFirstChild().getNodeValue();
uri = uri.substring(uri.indexOf("@") + 1);
@@ -151,13 +191,13 @@
+ uri.substring(uri.indexOf(":") + 1);
}
}
-
+
if (uri == null) {
uri = "http://simal.oss-watch.ac.uk/"
+ getProjectName(getProjectElement(el)) + "#"
+ el.getLocalName();
}
-
+
if (!uri.endsWith("/")) {
uri = uri + "/";
}
@@ -184,14 +224,16 @@
Element el = (Element) nl.item(i);
if (!el.hasAttributeNS(RDFUtils.RDF_NS, "about")) {
StringBuilder uri = new
StringBuilder(RDFUtils.PROJECT_NAMESPACE_URI);
- Node nameNode =
el.getElementsByTagNameNS(RDFUtils.DOAP_NS, "name").item(0);
- uri.append(nameNode.getFirstChild().getNodeValue());
- Node revisionNode =
el.getElementsByTagNameNS(RDFUtils.DOAP_NS, "revision")
+ Node nameNode =
el.getElementsByTagNameNS(RDFUtils.DOAP_NS, "name")
.item(0);
+ uri.append(nameNode.getFirstChild().getNodeValue());
+ Node revisionNode = el.getElementsByTagNameNS(RDFUtils.DOAP_NS,
+ "revision").item(0);
uri.append("/");
uri.append(revisionNode.getFirstChild().getNodeValue());
uri.append("#Version");
- el.setAttributeNS(RDFUtils.RDF_NS, "rdf:about",
RDFUtils.encode(uri.toString()));
+ el.setAttributeNS(RDFUtils.RDF_NS, "rdf:about",
RDFUtils.encode(uri
+ .toString()));
}
}
}
@@ -210,10 +252,10 @@
String uri = homepage.getAttributeNS(RDFUtils.RDF_NS, "resource");
String label = homepage.getAttributeNS(RDFUtils.RDFS_NS, "label");
if (label.length() == 0) {
- label = HomepageLabelGenerator.getHomepageLabel(uri);
+ label = HomepageLabelGenerator.getHomepageLabel(uri);
homepage.setAttributeNS(RDFUtils.RDFS_NS, "label", label);
- RDFUtils.LOGGER.debug("Set title of webpage at {} to {}", new
String[] { uri,
- label });
+ LOGGER.debug("Set title of webpage at {} to {}", new String[] {
+ uri, label });
}
}
}
@@ -226,8 +268,9 @@
*/
public static void checkCategoryIDs(Document doc)
throws SimalRepositoryException {
- RDFUtils.LOGGER.debug("Check category IDs in RDF file");
- NodeList categories =
doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "category");
+ LOGGER.debug("Check category IDs in RDF file");
+ NodeList categories = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS,
+ "category");
Element category;
Attr simalIDAtt;
String id = null;
@@ -239,13 +282,15 @@
IDoapCategory simalCategory;
try {
Attr att =
category.getAttributeNodeNS(RDFUtils.RDF_NS, "resource");
- simalCategory =
SimalRepositoryFactory.getCategoryService().get(att.getNodeValue().trim());
+ simalCategory = SimalRepositoryFactory.getCategoryService().get(
+ att.getNodeValue().trim());
if (simalCategory != null) {
id = simalCategory.getSimalID();
} else {
id = SimalRepositoryFactory.getPersonService().getNewID();
}
- simalIDAtt = doc.createAttributeNS(SimalOntology.NS,
RDFUtils.SIMAL_CATEGORY_ID);
+ simalIDAtt = doc.createAttributeNS(SimalOntology.NS,
+ RDFUtils.SIMAL_CATEGORY_ID);
simalIDAtt.setValue(id);
category.setAttributeNode(simalIDAtt);
} catch (Exception e) {
@@ -256,8 +301,7 @@
}
/**
- * If there are IDs for other instances of Simal then ad
- * rdf:seeAlso nodes.
+ * If there are IDs for other instances of Simal then ad rdf:seeAlso
nodes.
*
* @param doc
* @throws ISimalRepositoryException
@@ -270,9 +314,10 @@
String simalPersonID = null;
for (int i = 0; i < people.getLength(); i = i + 1) {
person = (Element) people.item(i);
-
+
// make all simal ID's for other servers a seeAlso tuple
- simalIDNL = person.getElementsByTagNameNS(SimalOntology.NS,
RDFUtils.SIMAL_PERSON_ID);
+ simalIDNL = person.getElementsByTagNameNS(SimalOntology.NS,
+ RDFUtils.SIMAL_PERSON_ID);
for (int iDidx = 0; iDidx < simalIDNL.getLength(); iDidx++) {
Node idNode = simalIDNL.item(iDidx);
if (idNode.getParentNode().equals(person)) {
@@ -288,8 +333,7 @@
}
/**
- * If there are IDs for other instances of Simal
- * then ad rdf:seeAlso nodes.
+ * If there are IDs for other instances of Simal then ad rdf:seeAlso
nodes.
*
* @param doc
* @throws ISimalRepositoryException
@@ -300,12 +344,13 @@
Element project;
NodeList simalIDNL;
String projectID = null;
-
+
for (int i = 0; i < projects.getLength(); i = i + 1) {
project = (Element) projects.item(i);
-
+
// make all simal ID's for other servers a seeAlso tuple
- simalIDNL = project.getElementsByTagNameNS(SimalOntology.NS,
RDFUtils.SIMAL_PROJECT_ID);
+ simalIDNL = project.getElementsByTagNameNS(SimalOntology.NS,
+ RDFUtils.SIMAL_PROJECT_ID);
for (int iDidx = 0; iDidx < simalIDNL.getLength(); iDidx++) {
Node idNode = simalIDNL.item(iDidx);
if (idNode.getParentNode().equals(project)) {
@@ -334,7 +379,7 @@
"seeAlso");
seeAlso.setAttributeNS(RDFUtils.RDF_NS, "resource", uri);
node.appendChild(seeAlso);
- RDFUtils.LOGGER.debug("Added rdfs:seeAlso=\"{}\"", uri);
+ LOGGER.debug("Added rdfs:seeAlso=\"{}\"", uri);
}
/**
@@ -345,22 +390,25 @@
*/
public static void checkPersonSHA1(Document doc)
throws SimalRepositoryException {
- RDFUtils.LOGGER.debug("Check person SHA1 in RDF file");
+ LOGGER.debug("Check person SHA1 in RDF file");
NodeList people =
doc.getElementsByTagNameNS(RDFUtils.FOAF_NS, "Person");
Element person;
for (int i = 0; i < people.getLength(); i = i + 1) {
person = (Element) people.item(i);
- NodeList emailNL =
person.getElementsByTagNameNS(RDFUtils.FOAF_NS, "mbox");
+ NodeList emailNL = person
+ .getElementsByTagNameNS(RDFUtils.FOAF_NS, "mbox");
for (int i1 = 0; i1 < emailNL.getLength(); i1 = i1 + 1) {
Element emailEl = (Element) emailNL.item(i1);
- String mbox =
emailEl.getAttributeNS(RDFUtils.RDF_NS, "resource").trim();
+ String mbox = emailEl.getAttributeNS(RDFUtils.RDF_NS, "resource")
+ .trim();
String sha1;
try {
sha1 = RDFUtils.getSHA1(mbox);
} catch (NoSuchAlgorithmException e) {
throw new SimalRepositoryException("Unable to create SHA1 Sum",
e);
}
- Element sha1Element =
doc.createElementNS(RDFUtils.FOAF_NS, "mbox_sha1sum");
+ Element sha1Element = doc.createElementNS(RDFUtils.FOAF_NS,
+ "mbox_sha1sum");
Text sha1Text = doc.createTextNode(sha1);
sha1Element.appendChild(sha1Text);
person.appendChild(sha1Element);
@@ -375,16 +423,19 @@
* @param repo
*/
public static void checkResources(Document doc) {
- RDFUtils.LOGGER.debug("Check resources found in RDF file");
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.DOAP_NS,
- "bug-database"));
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.DOAP_NS,
- "download-page"));
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.FOAF_NS, "homepage"));
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "license"));
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.DOAP_NS,
- "mailing-list"));
-
RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "wiki"));
+ LOGGER.debug("Check resources found in RDF file");
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.DOAP_NS, "bug-database"));
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.DOAP_NS, "download-page"));
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.FOAF_NS, "homepage"));
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.DOAP_NS, "license"));
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.DOAP_NS, "mailing-list"));
+ RDFXMLUtils.validateResourceDefinition(doc.getElementsByTagNameNS(
+ RDFUtils.DOAP_NS, "wiki"));
}
/**
@@ -395,9 +446,10 @@
* @param doc
*/
public static void checkCDataSections(Document doc) {
- NodeList nodes =
doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "description");
+ NodeList nodes = doc
+ .getElementsByTagNameNS(RDFUtils.DOAP_NS, "description");
validateCData(nodes);
-
+
nodes = doc.getElementsByTagNameNS(RDFUtils.DOAP_NS, "shortdesc");
validateCData(nodes);
}
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/TestInternetAddress.java
Fri Mar 5 09:49:24 2010
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/model/jena/TestInternetAddress.java
Mon Jun 7 06:47:17 2010
@@ -18,7 +18,8 @@
package uk.ac.osswatch.simal.model.jena;
-import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
import java.util.HashMap;
import java.util.Map;
@@ -30,19 +31,13 @@
import uk.ac.osswatch.simal.SimalRepositoryFactory;
import uk.ac.osswatch.simal.model.IInternetAddress;
import uk.ac.osswatch.simal.model.IPerson;
-import uk.ac.osswatch.simal.model.ModelSupport;
-import uk.ac.osswatch.simal.rdf.ISimalRepository;
import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
/**
* Test the class uk.ac.osswatch.simal.model.jena.InternetAddress,
especially
* the method getObfuscatedAddress()
*/
-public class TestInternetAddress {
-
- protected static ISimalRepository repository;
-
- private static final String TEST_OSS_WATCH_DOAP
= "testData/ossWatchDOAP.xml";
+public class TestInternetAddress extends AbstractJenaModelTest {
private static final String TEST_DEVELOPER_SEE_ALSO
= "http://people.apache.org/~rgardler/foaf.rdf.xml";
@@ -50,20 +45,12 @@
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- repository = SimalRepositoryFactory
- .getInstance(SimalRepositoryFactory.JENA);
- if (!repository.isInitialised()) {
- repository.initialise(null);
- }
-
-
repository.addProject(ISimalRepository.class.getClassLoader().getResource(
- TEST_OSS_WATCH_DOAP), ModelSupport.TEST_FILE_BASE_URL);
EXPECTED_OBFUSCATED_EMAILS.put("mailto:[email protected]",
"mailto:rgardler [at] apache...org");
EXPECTED_OBFUSCATED_EMAILS.put("mailto:[email protected]",
"mailto:ross.gardler [at] oucs...ox...ac...uk");
}
-
+
@Test
public void testInternetAddress() {
try {
--
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.