clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enrid...@apache.org
Subject [4/5] CLEREZZA-813 Moved the two virtuoso modules to the clerezza root folder. Added to the main pom.xml
Date Sat, 29 Mar 2014 18:05:27 GMT
http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/VirtuosoWeightedProvider.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/VirtuosoWeightedProvider.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/VirtuosoWeightedProvider.java
deleted file mode 100644
index 1e4628b..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/VirtuosoWeightedProvider.java
+++ /dev/null
@@ -1,937 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage.access;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException;
-import org.apache.clerezza.rdf.core.access.EntityUndeletableException;
-import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoGraph;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoMGraph;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Service;
-import org.osgi.framework.Constants;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.ComponentException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import virtuoso.jdbc4.VirtuosoConnection;
-import virtuoso.jdbc4.VirtuosoException;
-import virtuoso.jdbc4.VirtuosoPreparedStatement;
-import virtuoso.jdbc4.VirtuosoResultSet;
-import virtuoso.jdbc4.VirtuosoStatement;
-
-/**
- * A {@link org.apache.clerezza.rdf.core.access.WeightedTcProvider} for
- * Virtuoso.
- * 
- * @author enridaga
- * 
- */
-@Component(metatype = true, immediate = true)
-@Service(WeightedTcProvider.class)
-@Properties({
-		@Property(name = "password", description = "User password"),
-		@Property(name = "host", description = "The host running the Virtuoso server"),
-		@Property(name = "port", description = "The port number"),
-		@Property(name = "user", description = "User name"),
-		@Property(name = "weight", intValue = 110, description = "Weight assigned to this provider"),
-		@Property(name = TcManager.GENERAL_PURPOSE_TC, boolValue = true) })
-public class VirtuosoWeightedProvider implements WeightedTcProvider {
-
-	// JDBC driver class (XXX move to DataAccess?)
-	public static final String DRIVER = "virtuoso.jdbc4.Driver";
-
-	// Default value for the property "weight"
-	public static final int DEFAULT_WEIGHT = 110;
-
-	// Names of properties in OSGi configuration
-	public static final String HOST = "host";
-	public static final String PORT = "port";
-	public static final String USER = "user";
-	public static final String PASSWORD = "password";
-	public static final String WEIGHT = "weight";
-
-	// Name of the graph used to contain the registry of the created graphs
-	public static final String ACTIVE_GRAPHS_GRAPH = "urn:x-virtuoso:active-graphs";
-
-	// Loaded graphs
-	private Map<UriRef, VirtuosoMGraph> graphs = new HashMap<UriRef, VirtuosoMGraph>();
-
-	// DataAccess registry
-	private Set<DataAccess> dataAccessSet = new HashSet<DataAccess>();
-
-	// Logger
-	private Logger logger = LoggerFactory
-			.getLogger(VirtuosoWeightedProvider.class);
-
-	// Fields
-	private String host;
-	private Integer port;
-	private String user;
-	private String pwd;
-	private String connStr;
-	private int weight = DEFAULT_WEIGHT;
-
-	/**
-	 * Creates a new {@link VirtuosoWeightedProvider}.
-	 * 
-	 * Before the weighted provider can be used, the method
-	 * <code>activate</code> has to be called.
-	 */
-	public VirtuosoWeightedProvider() {
-		logger.debug("Created VirtuosoWeightedProvider.");
-	}
-
-	public VirtuosoWeightedProvider(String jdbcConnectionString,
-			String jdbcUser, String jdbcPassword) {
-		connStr = jdbcConnectionString;
-		user = jdbcUser;
-		pwd = jdbcPassword;
-	}
-
-	/**
-	 * Activates this component.<br />
-	 * 
-	 * @param cCtx
-	 *            Execution context of this component. A value of null is
-	 *            acceptable when you set the property connection
-	 * @throws ConfigurationException
-	 * @throws IllegalArgumentException
-	 *             No component context given and connection was not set.
-	 */
-	@Activate
-	public void activate(ComponentContext cCtx) {
-		logger.trace("activate(ComponentContext {})", cCtx);
-		logger.info("Activating VirtuosoWeightedProvider...");
-
-		if (cCtx == null) {
-			logger.error("No component context given and connection was not set");
-			throw new IllegalArgumentException(
-					"No component context given and connection was not set");
-		} else if (cCtx != null) {
-			logger.debug("Context is given: {}", cCtx);
-			String pid = (String) cCtx.getProperties().get(
-					Constants.SERVICE_PID);
-			try {
-
-				// Bind logging of DriverManager
-				if (logger.isDebugEnabled()) {
-					logger.debug("Activating logging for DriverManager");
-					// DriverManager.setLogWriter(new PrintWriter(System.err));
-					DriverManager.setLogWriter(new PrintWriter(new Writer() {
-						private Logger l = LoggerFactory
-								.getLogger(DriverManager.class);
-						private StringBuilder b = new StringBuilder();
-
-						@Override
-						public void write(char[] cbuf, int off, int len)
-								throws IOException {
-							b.append(cbuf, off, len);
-						}
-
-						@Override
-						public void flush() throws IOException {
-							l.debug("{}", b.toString());
-							b = new StringBuilder();
-						}
-
-						@Override
-						public void close() throws IOException {
-							l.debug("{}", b.toString());
-							l.debug("Log DriverManager PrintWriter closed");
-						}
-					}));
-				}
-
-				// FIXME The following should not be needed...
-				try {
-					this.weight = (Integer) cCtx.getProperties().get(WEIGHT);
-				} catch (NumberFormatException nfe) {
-					logger.warn(nfe.toString());
-					logger.warn("Setting weight to defaults");
-					this.weight = DEFAULT_WEIGHT;
-				}
-
-				/**
-				 * Initialize connection properties
-				 */
-				// We take the configuration of the SCR component
-				Object phost = cCtx.getProperties().get(HOST);
-				Object pport = cCtx.getProperties().get(PORT);
-				Object puser = cCtx.getProperties().get(USER);
-				Object ppwd = cCtx.getProperties().get(PASSWORD);
-
-				// If the component is not configured, we inspect system properties
-				// Maybe this is a first launch, otherwise we set a value as default
-				if(phost == null && System.getProperty("virtuoso.host") != null){
-					phost = System.getProperty("virtuoso.host");
-				} else if(phost == null){
-					phost = "localhost"; 
-				}
-				if(pport == null && System.getProperty("virtuoso.port") != null){
-					pport = System.getProperty("virtuoso.port");
-				} else if(pport == null){
-					pport = Integer.valueOf(1111); 
-				}
-				if(puser == null && System.getProperty("virtuoso.user") != null){
-					puser = System.getProperty("virtuoso.user");
-				} else if(puser == null){
-					puser = "dba"; 
-				}
-				if(ppwd == null && System.getProperty("virtuoso.password") != null){
-					ppwd = System.getProperty("virtuoso.password");
-				} else if(ppwd == null){
-					ppwd = "dba"; 
-				}
-				// We set the configuration
-				host = (String) phost;
-				port = (Integer) pport;
-				user = (String) puser;
-				pwd = (String) ppwd;
-
-				// Build connection string
-				connStr = getConnectionString(host, port);
-
-				// Check connection
-				VirtuosoConnection connection = getConnection(connStr, user,
-						pwd);
-				logger.info("Connection to {} initialized. User is {}", connStr, user);
-				// everything went ok
-				connection.close();
-			} catch (VirtuosoException e) {
-				logger.error(
-						"A problem occurred while initializing connection to Virtuoso",
-						e);
-				logger.error("Be sure you have configured the connection parameters correctly in the OSGi/SCR configuration");
-				cCtx.disableComponent(pid);
-				throw new ComponentException(e.getLocalizedMessage());
-			} catch (SQLException e) {
-				logger.error(
-						"A problem occurred while initializing connection to Virtuoso",
-						e);
-				logger.error("Be sure you have configured the connection parameters correctly in the OSGi/SCR configuration");
-				cCtx.disableComponent(pid);
-				throw new ComponentException(e.getLocalizedMessage());
-			} catch (ClassNotFoundException e) {
-				logger.error(
-						"A problem occurred while initializing connection to Virtuoso",
-						e);
-				logger.error("Be sure you have configured the connection parameters correctly in the OSGi/SCR configuration");
-				cCtx.disableComponent(pid);
-				throw new ComponentException(e.getLocalizedMessage());
-			}
-		}
-		// Load remembered graphs
-		Set<UriRef> remembered = readRememberedGraphs();
-		for (UriRef name : remembered) {
-			if (canModify(name)) {
-				graphs.put(name, new VirtuosoMGraph(name.getUnicodeString(),
-						createDataAccess()));
-			} else {
-				graphs.put(name, new VirtuosoGraph(name.getUnicodeString(),
-						createDataAccess()));
-			}
-		}
-		logger.info("Activated VirtuosoWeightedProvider.");
-	}
-
-	public static final String getConnectionString(String hostName,
-			Integer portNumber) {
-		return new StringBuilder().append("jdbc:virtuoso://").append(hostName)
-				.append(":").append(portNumber).append("/CHARSET=UTF-8")
-				.toString();
-	}
-
-	private Set<UriRef> readRememberedGraphs() {
-		logger.trace(" readRememberedGraphs()");
-		String SQL = "SPARQL SELECT DISTINCT ?G FROM <" + ACTIVE_GRAPHS_GRAPH
-				+ "> WHERE { ?G a <urn:x-virtuoso/active-graph> }";
-		VirtuosoConnection connection = null;
-		Exception e = null;
-		VirtuosoStatement st = null;
-		VirtuosoResultSet rs = null;
-		Set<UriRef> remembered = new HashSet<UriRef>();
-		try {
-			connection = getConnection();
-			st = (VirtuosoStatement) connection.createStatement();
-			logger.debug("Executing SQL: {}", SQL);
-			rs = (VirtuosoResultSet) st.executeQuery(SQL);
-			while (rs.next()) {
-				UriRef name = new UriRef(rs.getString(1));
-				logger.debug(" > Graph {}", name);
-				remembered.add(name);
-			}
-		} catch (VirtuosoException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} catch (SQLException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} catch (ClassNotFoundException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} finally {
-
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (Exception ex) {
-			}
-			;
-			try {
-				if (st != null)
-					st.close();
-			} catch (Exception ex) {
-			}
-			;
-			if (connection != null) {
-				try {
-					connection.close();
-				} catch (VirtuosoException e1) {
-					logger.error("Cannot close connection", e1);
-				}
-			}
-		}
-		if (e != null) {
-			throw new RuntimeException(e);
-		}
-		return remembered;
-	}
-
-	private void rememberGraphs(UriRef... graphs) {
-		logger.trace(" saveActiveGraphs()");
-		if (graphs.length > 0) {
-			// Returns the list of graphs in the virtuoso quad store
-			String SQL = "SPARQL INSERT INTO <" + ACTIVE_GRAPHS_GRAPH
-					+ "> { `iri(??)` a <urn:x-virtuoso/active-graph> }";
-			VirtuosoConnection connection = null;
-			Exception e = null;
-			VirtuosoPreparedStatement st = null;
-			VirtuosoResultSet rs = null;
-			try {
-				try {
-					connection = getConnection();
-					connection.setAutoCommit(false);
-					st = (VirtuosoPreparedStatement) connection
-							.prepareStatement(SQL);
-					logger.debug("Executing SQL: {}", SQL);
-					for (UriRef u : graphs) {
-						logger.trace(" > remembering {}", u);
-						st.setString(1, u.getUnicodeString());
-						st.executeUpdate();
-					}
-					connection.commit();
-				} catch (Exception e1) {
-					logger.error("Error while executing query/connection.", e1);
-					e = e1;
-					connection.rollback();
-				}
-			} catch (SQLException e1) {
-				logger.error("Error while executing query/connection.", e1);
-				e = e1;
-			} finally {
-				try {
-					if (rs != null)
-						rs.close();
-				} catch (Exception ex) {
-				}
-				;
-				try {
-					if (st != null)
-						st.close();
-				} catch (Exception ex) {
-				}
-				;
-				if (connection != null) {
-					try {
-						connection.close();
-					} catch (VirtuosoException e1) {
-						logger.error("Cannot close connection", e1);
-					}
-				}
-			}
-			if (e != null) {
-				throw new RuntimeException(e);
-			}
-		}
-	}
-
-	private void forgetGraphs(UriRef... graphs) {
-		logger.trace(" forgetGraphs()");
-		if (graphs.length > 0) {
-			// Returns the list of graphs in the virtuoso quad store
-			String SQL = "SPARQL WITH <"
-					+ ACTIVE_GRAPHS_GRAPH
-					+ "> DELETE { ?s ?p ?v } WHERE { ?s ?p ?v . FILTER( ?s = iri(??) ) }";
-			VirtuosoConnection connection = null;
-			Exception e = null;
-			VirtuosoPreparedStatement st = null;
-			VirtuosoResultSet rs = null;
-			try {
-				try {
-					connection = getConnection();
-					connection.setAutoCommit(false);
-					st = (VirtuosoPreparedStatement) connection
-							.prepareStatement(SQL);
-					logger.debug("Executing SQL: {}", SQL);
-					for (UriRef u : graphs) {
-						logger.trace(" > remembering {}", u);
-						st.setString(1, u.getUnicodeString());
-						st.executeUpdate();
-					}
-					connection.commit();
-				} catch (Exception e1) {
-					logger.error("Error while executing query/connection.", e1);
-					e = e1;
-					connection.rollback();
-				}
-			} catch (SQLException e1) {
-				logger.error("Error while executing query/connection.", e1);
-				e = e1;
-			} finally {
-				try {
-					if (rs != null)
-						rs.close();
-				} catch (Exception ex) {
-				}
-				;
-				try {
-					if (st != null)
-						st.close();
-				} catch (Exception ex) {
-				}
-				;
-				if (connection != null) {
-					try {
-						connection.close();
-					} catch (VirtuosoException e1) {
-						logger.error("Cannot close connection", e1);
-					}
-				}
-			}
-			if (e != null) {
-				throw new RuntimeException(e);
-			}
-		}
-	}
-
-	/**
-	 * Deactivates this component.
-	 * 
-	 * @param cCtx
-	 *            component context provided by OSGi
-	 */
-	@Deactivate
-	public void deactivate(ComponentContext cCtx) {
-		logger.debug("deactivate(ComponentContext {})", cCtx);
-		// Save active (possibly empty) graphs to a dedicated graph
-		rememberGraphs();
-		// XXX Important. Close all opened resources
-		for (DataAccess mg : dataAccessSet) {
-			mg.close();
-		}
-		logger.info("Shutdown complete.");
-	}
-
-	public VirtuosoConnection getConnection() throws SQLException,
-			ClassNotFoundException {
-		return getConnection(connStr, user, pwd);
-	}
-
-	private VirtuosoConnection getConnection(final String connStr,final String user,
-			final String pwd) throws SQLException, ClassNotFoundException {
-		logger.debug("getConnection(String {}, String {}, String *******)",
-				connStr, user);
-		/**
-		 * FIXME For some reasons, it looks the DriverManager is instantiating a
-		 * new virtuoso.jdbc4.Driver instance upon any activation. (Enable DEBUG
-		 * to see this)
-		 */
-		logger.debug("Loading JDBC Driver");
-		try {
-			VirtuosoConnection c = AccessController
-					.doPrivileged(new PrivilegedAction<VirtuosoConnection>() {
-						public VirtuosoConnection run() {
-							try {
-								Class.forName(VirtuosoWeightedProvider.DRIVER,
-										true, this.getClass().getClassLoader());
-								return (VirtuosoConnection) DriverManager
-										.getConnection(connStr, user, pwd);
-							} catch (ClassNotFoundException e) {
-								throw new RuntimeException(e);
-							} catch (SQLException e) {
-								throw new RuntimeException(e);
-							}
-						}
-					});
-			c.setAutoCommit(true);
-			return c;
-		} catch (SQLException e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-	/**
-	 * Retrieves the Graph (unmodifiable) with the given UriRef If no graph
-	 * exists with such name, throws a NoSuchEntityException
-	 */
-	@Override
-	public Graph getGraph(UriRef name) throws NoSuchEntityException {
-		logger.debug("getGraph(UriRef {}) ", name);
-		// If it is read-only, returns the Graph
-		// If it is not read-only, returns the getGraph() version of the MGraph
-		VirtuosoMGraph g = loadGraphOnce(name);
-		if (g instanceof Graph) {
-			return (Graph) g;
-		} else {
-			return g.getGraph();
-		}
-	}
-
-	/**
-	 * Retrieves the MGraph (modifiable) with the given UriRef. If no graph
-	 * exists with such name, throws a NoSuchEntityException.
-	 * 
-	 * @return mgraph
-	 */
-	@Override
-	public MGraph getMGraph(UriRef name) throws NoSuchEntityException {
-		logger.debug("getMGraph(UriRef {}) ", name);
-		VirtuosoMGraph g = loadGraphOnce(name);
-		if (g instanceof Graph) {
-			// We have this graph but only in read-only mode!
-			throw new NoSuchEntityException(name);
-		}
-		return g;
-	}
-
-	/**
-	 * Load the graph once. It check whether a graph object have been already
-	 * created for that UriRef, if yes returns it.
-	 * 
-	 * If not check if at least 1 triple is present in the quad for such graph
-	 * identifier. If yes, creates a new graph object and loads it in the map,
-	 * referring to it on next calls.
-	 *
-	 * This method returns a VirtuosoGraph if the graph is read-only
-	 * 
-	 * @param name
-	 * @return
-	 */
-	private VirtuosoMGraph loadGraphOnce(UriRef name) {
-		logger.debug("loadGraphOnce({})", name);
-
-		// Check whether the graph have been already loaded once
-		if (graphs.containsKey(name)) {
-			logger.debug("{} is already loaded", name);
-			return graphs.get(name);
-		} else {
-			VirtuosoMGraph graph = null;
-			logger.debug("Attempt to load {}", name);
-			// Let's create the graph object
-			String SQL = "SPARQL SELECT ?G WHERE { GRAPH ?G {[] [] []} . FILTER(?G = "
-					+ name + ")} LIMIT 1";
-
-			Statement st = null;
-			VirtuosoResultSet rs = null;
-			VirtuosoConnection connection = null;
-			Exception e = null;
-			try {
-				connection = getConnection(connStr, user, pwd);
-				st = connection.createStatement();
-				logger.debug("Executing SQL: {}", SQL);
-				st.execute(SQL);
-				rs = (VirtuosoResultSet) st.getResultSet();
-				if (rs.next() == false) {
-					// The graph is empty, it is not readable or does not exists
-					logger.debug("Graph does not exists: {}", name);
-					throw new NoSuchEntityException(name);
-				} else {
-					// The graph exists and it is readable ...
-					logger.trace("Graph {} is readable", name);
-					// is it writable?
-					logger.trace("Is {} writable?", name);
-					if (canModify(name)) {
-						logger.trace("Creating writable graph {}",
-								name);
-						graphs.put(name,
-								new VirtuosoMGraph(name.getUnicodeString(),
-										createDataAccess()));
-					} else {
-						logger.trace("Creating read-only graph {}",
-								name);
-						graphs.put(name,
-								new VirtuosoMGraph(name.getUnicodeString(),
-										createDataAccess()).asVirtuosoGraph());
-					}
-					graph = graphs.get(name);
-				}
-
-			} catch (VirtuosoException ve) {
-				logger.error("Error while executing query/connection.", ve);
-				e = ve;
-			} catch (SQLException se) {
-				logger.error("Error while executing query/connection.", se);
-				e = se;
-			} catch (ClassNotFoundException ce) {
-				logger.error("Error while executing query/connection.", ce);
-				e = ce;
-			} finally {
-				try {
-					if (rs != null)
-						rs.close();
-				} catch (Exception ex) {
-				}
-				;
-				try {
-					if (st != null)
-						st.close();
-				} catch (Exception ex) {
-				}
-				;
-				if (connection != null) {
-					try {
-						connection.close();
-					} catch (VirtuosoException e1) {
-						logger.error("Cannot close connection", e1);
-					}
-				}
-			}
-			if (e != null) {
-				throw new RuntimeException(e);
-			}
-			return graph;
-		}
-
-	}
-
-	public DataAccess createDataAccess() {
-		DataAccess da = new DataAccess(connStr, user, pwd);
-		dataAccessSet.add(da);
-		// Remember all opened ones
-		return da;
-	}
-
-	/**
-	 * Generic implementation of the get(M)Graph method. If the named graph is
-	 * modifiable, behaves the same as getMGraph(UriRef name), elsewhere,
-	 * behaves as getGraph(UriRef name)
-	 */
-	@Override
-	public TripleCollection getTriples(UriRef name)
-			throws NoSuchEntityException {
-		logger.debug("getTriples(UriRef {}) ", name);
-		return loadGraphOnce(name);
-	}
-
-	/**
-	 * Returns the list of graphs in the virtuoso quad store. The returned set
-	 * is unmodifiable.
-	 * 
-	 * @return graphs
-	 */
-	@Override
-	public Set<UriRef> listGraphs() {
-		logger.debug("listGraphs()");
-		Set<UriRef> graphs = new HashSet<UriRef>();
-		// XXX Add the active (possibly empty) mgraphs
-		graphs.addAll(this.graphs.keySet());
-		// Returns the list of graphs in the virtuoso quad store
-		String SQL = "SPARQL SELECT DISTINCT ?G WHERE {GRAPH ?G {[] [] []} }";
-		VirtuosoConnection connection = null;
-		Exception e = null;
-		VirtuosoStatement st = null;
-		VirtuosoResultSet rs = null;
-		try {
-			connection = getConnection();
-			st = (VirtuosoStatement) connection.createStatement();
-			logger.debug("Executing SQL: {}", SQL);
-			rs = (VirtuosoResultSet) st.executeQuery(SQL);
-			while (rs.next()) {
-				UriRef graph = new UriRef(rs.getString(1));
-				logger.debug(" > Graph {}", graph);
-				graphs.add(graph);
-			}
-		} catch (VirtuosoException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} catch (SQLException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} catch (ClassNotFoundException e1) {
-			logger.error("Error while executing query/connection.", e1);
-			e = e1;
-		} finally {
-
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (Exception ex) {
-			}
-			;
-			try {
-				if (st != null)
-					st.close();
-			} catch (Exception ex) {
-			}
-			;
-			if (connection != null) {
-				try {
-					connection.close();
-				} catch (VirtuosoException e1) {
-					logger.error("Cannot close connection", e1);
-				}
-			}
-		}
-		if (e != null) {
-			throw new RuntimeException(e);
-		}
-		return Collections.unmodifiableSet(graphs);
-	}
-
-	@Override
-	public Set<UriRef> listMGraphs() {
-		logger.debug("listMGraphs()");
-		Set<UriRef> graphs = listGraphs();
-		Set<UriRef> mgraphs = new HashSet<UriRef>();
-		logger.debug("Modifiable graphs:");
-		for (UriRef u : graphs) {
-			if (canModify(u)) {
-				logger.debug(" > {}", u);
-				mgraphs.add(u);
-			}
-		}
-		return Collections.unmodifiableSet(mgraphs);
-	}
-
-	private long getPermissions(String graph) {
-		VirtuosoConnection connection = null;
-		ResultSet rs = null;
-		Statement st = null;
-		logger.debug("getPermissions(String {})", graph);
-		Exception e = null;
-		Long result = null;
-		try {
-			connection = getConnection();
-			String sql = "SELECT DB.DBA.RDF_GRAPH_USER_PERMS_GET ('" + graph
-					+ "','" + connection.getMetaData().getUserName() + "') ";
-			logger.debug("Executing SQL: {}", sql);
-			st = connection.createStatement();
-			st.execute(sql);
-			rs = st.getResultSet();
-			rs.next();
-			result = rs.getLong(1);
-			logger.debug("Permission: {}", result);
-		} catch (VirtuosoException ve) {
-			logger.error("A virtuoso SQL exception occurred.");
-			e = ve;
-		} catch (SQLException se) {
-			logger.error("An SQL exception occurred.");
-			e = se;
-		} catch (ClassNotFoundException e1) {
-			logger.error("An ClassNotFoundException occurred.");
-			e = e1;
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (Exception ex) {
-			}
-			;
-			try {
-				if (st != null)
-					st.close();
-			} catch (Exception ex) {
-			}
-			;
-			if (connection != null) {
-				try {
-					connection.close();
-				} catch (VirtuosoException e1) {
-					logger.error("Cannot close connection", e1);
-				}
-			}
-		}
-		if (e != null) {
-			throw new RuntimeException(e);
-		}
-		return result;
-	}
-
-	public boolean canRead(UriRef graph) {
-		logger.debug("canRead(UriRef {})", graph);
-		return (isRead(getPermissions(graph.getUnicodeString())));
-	}
-
-	public boolean canModify(UriRef graph) {
-		logger.debug("canModify(UriRef {})", graph);
-		return (isWrite(getPermissions(graph.getUnicodeString())));
-	}
-
-	private boolean testPermission(long value, int bit) {
-		logger.debug("testPermission(long {},int {})", value, bit);
-		return BigInteger.valueOf(value).testBit(bit);
-	}
-
-	private boolean isRead(long permission) {
-		logger.debug("isRead(long {})", permission);
-		return testPermission(permission, 1);
-	}
-
-	private boolean isWrite(long permission) {
-		logger.debug("isWrite(long {})", permission);
-		return testPermission(permission, 2);
-	}
-
-	@Override
-	public Set<UriRef> listTripleCollections() {
-		logger.debug("listTripleCollections()");
-		// I think this should behave the same as listGraphs() in our case.
-		return listGraphs();
-	}
-
-	private VirtuosoMGraph createVirtuosoMGraph(UriRef name)
-			throws UnsupportedOperationException, EntityAlreadyExistsException {
-		logger.debug("createVirtuosoMGraph(UriRef {})", name);
-		// If the graph already exists, we throw an exception
-		try {
-			loadGraphOnce(name);
-			throw new EntityAlreadyExistsException(name);
-		} catch (NoSuchEntityException nsee) {
-			if (canModify(name)) {
-				graphs.put(name, new VirtuosoMGraph(name.getUnicodeString(),
-						createDataAccess()));
-				rememberGraphs(name);
-				return graphs.get(name);
-			} else {
-				logger.error("Cannot create MGraph {}", name);
-				throw new UnsupportedOperationException();
-			}
-		}
-	}
-
-	/**
-	 * Creates an initially empty MGraph. If the name already exists in the
-	 * store, throws an {@see EntityAlreadyExistsException}
-	 */
-	@Override
-	public MGraph createMGraph(UriRef name)
-			throws UnsupportedOperationException, EntityAlreadyExistsException {
-		logger.debug("createMGraph(UriRef {})", name);
-		return createVirtuosoMGraph(name);
-	}
-
-	/**
-	 * Creates a new graph with the given triples, then returns the readable
-	 * (not modifiable) version of the graph
-	 * 
-	 */
-	@Override
-	public Graph createGraph(UriRef name, TripleCollection triples)
-			throws UnsupportedOperationException, EntityAlreadyExistsException {
-		logger.debug("createGraph(UriRef {}, TripleCollection {})", name,
-				triples);
-		VirtuosoMGraph mgraph = createVirtuosoMGraph(name);
-		mgraph.addAll(triples);
-		return mgraph.getGraph();
-	}
-
-	/**
-	 * Clears the given graph and removes it from the loaded graphs.
-	 * 
-	 */
-	@Override
-	public void deleteTripleCollection(UriRef name)
-			throws UnsupportedOperationException, NoSuchEntityException,
-			EntityUndeletableException {
-		logger.debug("deleteTripleCollection(UriRef {})", name);
-		TripleCollection g = (VirtuosoMGraph) getTriples(name);
-		if (g instanceof Graph) {
-			throw new EntityUndeletableException(name);
-		} else {
-			((MGraph) g).clear();
-			graphs.remove(name);
-			forgetGraphs(name);
-		}
-	}
-
-	/**
-	 * Returns the names of a graph. Personally don't know why a graph should
-	 * have more then 1 identifier. Anyway, this does not happen with Virtuoso
-	 * 
-	 * @return names
-	 */
-	@Override
-	public Set<UriRef> getNames(Graph graph) {
-		logger.debug("getNames(Graph {})", graph);
-		return Collections.singleton(new UriRef(((VirtuosoMGraph) graph)
-				.getName()));
-	}
-
-	/**
-	 * Returns the weight of this provider.
-	 * 
-	 */
-	@Override
-	public int getWeight() {
-		logger.debug("getWeight()");
-		/**
-		 * The weight
-		 */
-		return this.weight;
-	}
-
-	/**
-	 * Sets the weight
-	 * 
-	 * @param weight
-	 */
-	public void setWeight(int weight) {
-		logger.debug("setWeight(int {})", weight);
-		this.weight = weight;
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.access.WeightedTcProvider
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.access.WeightedTcProvider b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.access.WeightedTcProvider
deleted file mode 100644
index bfb2afc..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.access.WeightedTcProvider
+++ /dev/null
@@ -1 +0,0 @@
-rdf.virtuoso.storage.access.VirtuosoWeightedProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/log4j.properties b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/log4j.properties
deleted file mode 100644
index 201aca8..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-#log4j.rootLogger=DEBUG, S
-#log4j.appender.S = org.apache.log4j.ConsoleAppender
-#log4j.appender.S.layout = org.apache.log4j.PatternLayout
-#log4j.appender.S.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
-

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/.DS_Store
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/.DS_Store b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/.DS_Store
deleted file mode 100644
index 353ff0a..0000000
Binary files a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/.DS_Store and /dev/null differ

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/.DS_Store
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/.DS_Store b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/.DS_Store
deleted file mode 100644
index 88ced45..0000000
Binary files a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/.DS_Store and /dev/null differ

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ConnectionTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ConnectionTest.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ConnectionTest.java
deleted file mode 100644
index 6a1e4b5..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ConnectionTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import virtuoso.jdbc4.VirtuosoConnection;
-import virtuoso.jdbc4.VirtuosoException;
-
-/**
- * Tests the connection to the Virtuoso DBMS
- * 
- * @author enridaga
- */
-public class ConnectionTest {
-
-	static final Logger log = LoggerFactory.getLogger(ConnectionTest.class);
-
-	private static VirtuosoConnection connection = null;
-
-	@BeforeClass
-	public static void before() throws ClassNotFoundException, SQLException {
-		org.junit.Assume.assumeTrue(!TestUtils.SKIP);
-		connection = TestUtils.getConnection();
-	}
-
-	@Test
-	public void testIsClosed() {
-		assertFalse(connection.isClosed());
-	}
-
-	@Test
-	public void testIsConnectionLost() {
-		assertFalse(connection.isConnectionLost(0));
-	}
-
-	@Test
-	public void testIsReadOnly() throws VirtuosoException {
-		assertFalse(connection.isReadOnly());
-	}
-
-	@Test
-	public void testConnection() {
-		log.info("testConnection()");
-		try {
-
-			Statement st = connection.createStatement();
-			log.debug("Populate graph <mytest>");
-			String[] queries = {
-					"sparql clear graph <mytest>",
-					"sparql insert into graph <mytest> { <xxx> <P01> \"test1\"@en }",
-					"sparql insert into graph <mytest> { <xxx> <P01> \"test2\"@it }",
-					"sparql PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> insert into graph <mytest> { <xxx> <P01> \"test3\"^^xsd:string }",
-					"sparql insert into graph <mytest> { <xxx> <P01> \"test4\" }",
-					"sparql insert into graph <mytest> { <xxx> <P01> \"test5\" . <xxx> <P02> _:b1"
-							+ " . _:b1 <P03> <yyy> " + " . _:b3 <P05> <zzz> "
-							+ " . _:b3 <P05> <ppp> " +
-							// This is to consider that we can force it
-							" .  <nodeID://b10005> <P05> <ooo> " + " }",
-					"sparql insert into graph <mytest> { <nodeID://b10005> <property> <nodeID://b10007>}",
-					"sparql insert into graph <mytest> { <enridaga> <property> \"Literal value\"^^<http://datatype#type>}",
-					"sparql insert into graph <mytest> { <nodeID://b10005> <property> <nodeID://b10007>}" };
-			for (String q : queries) {
-				log.debug("Querying: {}", q);
-				st.execute(q);
-			}
-
-			String query = "sparql SELECT * from <mytest> WHERE {?s ?p ?o}";
-			log.debug("Querying: {}", query);
-			ResultSet rs = st.executeQuery(query);
-			TestUtils.stamp(rs);
-		} catch (SQLException e) {
-			log.error("SQL ERROR: ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			log.error("SQL ERROR: ", e);
-			assertTrue(false);
-		}
-	}
-
-	@Test
-	public void test() throws ClassNotFoundException, SQLException {
-		DatabaseMetaData dm = connection.getMetaData();
-		log.debug("Username is {}", dm.getUserName());
-		Properties p = connection.getClientInfo();
-		if (p == null) {
-			log.warn("Client info is null...");
-		} else
-			for (Entry<Object, Object> e : p.entrySet()) {
-				log.info("Client info property: {} => {}", e.getKey(),
-						e.getValue());
-			}
-		String SQL = "SELECT DISTINCT id_to_iri(G) FROM DB.DBA.RDF_QUAD quad ";
-		VirtuosoConnection cn = TestUtils.getConnection();
-		long startAt = System.currentTimeMillis();
-		// get the list of quad using SQL
-		log.debug("Executing SQL: {}", SQL);
-		cn.createStatement().executeQuery(SQL);
-		long endAt = System.currentTimeMillis();
-		log.debug("Using SQL: {}ms", endAt - startAt);
-		SQL = "SPARQL SELECT DISTINCT ?G WHERE {GRAPH ?G {?S ?P ?O} }";
-		startAt = System.currentTimeMillis();
-		// get the list of quad using SQL+SPARQL
-		log.debug("Executing SQL: {}", SQL);
-		cn.createStatement().executeQuery(SQL);
-		endAt = System.currentTimeMillis();
-		log.debug("Using SQL+SPARQL: {}ms", endAt - startAt);
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/RdfIOTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/RdfIOTest.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/RdfIOTest.java
deleted file mode 100644
index 7221c9b..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/RdfIOTest.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import java.io.IOException;
-import java.net.URL;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Iterator;
-
-import org.apache.clerezza.platform.config.SystemConfig;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl;
-import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoBNode;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoMGraph;
-import org.apache.clerezza.rdf.virtuoso.storage.access.DataAccess;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import virtuoso.jdbc4.VirtuosoException;
-
-public class RdfIOTest {
-	static VirtuosoMGraph mgraph = null;
-	static final String TEST_GRAPH_NAME = "RdfIOTest";
-	static final String XSD = "http://www.w3.org/2001/XMLSchema#";
-	static Logger log = LoggerFactory.getLogger(RdfIOTest.class);
-	static DataAccess da;
-
-	@BeforeClass
-	public static void assume(){
-		org.junit.Assume.assumeTrue(!TestUtils.SKIP);
-	}
-	
-	/**
-	 * Clean before any test
-	 * 
-	 * @throws ClassNotFoundException
-	 * @throws SQLException
-	 */
-	@Before
-	public void before() throws ClassNotFoundException, SQLException {
-		
-		da = TestUtils.getProvider().createDataAccess();
-		mgraph = new VirtuosoMGraph(TEST_GRAPH_NAME, da);
-		mgraph.clear();
-		log.debug("Clearing graph <{}>", TEST_GRAPH_NAME);
-	}
-
-	/**
-	 * Clean after a test
-	 * 
-	 * @throws VirtuosoException
-	 * @throws ClassNotFoundException
-	 * @throws SQLException
-	 */
-	@After
-	public void clear() throws VirtuosoException, ClassNotFoundException,
-			SQLException {
-		log.debug("Clearing graph <{}> of size {}", TEST_GRAPH_NAME,
-				mgraph.size());
-		// clear all resources
-		da.close();
-		
-		da = null;
-		mgraph = null;
-		
-		log.debug("Removing graph <{}>", TEST_GRAPH_NAME);
-		Statement st = TestUtils.getConnection().createStatement();
-		st.execute("SPARQL CLEAR GRAPH <" + TEST_GRAPH_NAME + ">");
-		st.close();
-	}
-
-	@Test
-	public void xsdString() throws ClassNotFoundException, SQLException {
-		log.info("Text an xsd:string");
-		TypedLiteral object = new TypedLiteralImpl("lorem ipsum", new UriRef(
-				XSD + "string"));
-		UriRef subject = new UriRef("urn:io-test:reto");
-		UriRef predicate = new UriRef("urn:io-test:hasText");
-
-		Triple read = writeAndRead(subject, predicate, object);
-		Assert.assertTrue(read
-				.equals(new TripleImpl(subject, predicate, object)));
-		Assert.assertTrue(read.getObject() instanceof TypedLiteral);
-		TypedLiteral l = (TypedLiteral) read.getObject();
-		Assert.assertEquals(l.getLexicalForm(), "lorem ipsum");
-		Assert.assertEquals(l.getDataType(), new UriRef(XSD + "string"));
-
-	}
-
-	@Test
-	public void longString() throws ClassNotFoundException, SQLException, InterruptedException {
-		log.info("Test a long xsd:string");
-		StringBuilder longStr = new StringBuilder();
-		int c = 250000;
-		while (c > 0) {
-			longStr.append(" lorem ipsum ");
-			c--;
-		}
-		int size = longStr.length();
-		TypedLiteral object = new TypedLiteralImpl(longStr.toString(),
-				new UriRef(XSD + "string"));
-		UriRef subject = new UriRef("urn:io-test:reto");
-		UriRef predicate = new UriRef("urn:io-test:hasText");
-		Triple read = writeAndRead(subject, predicate, object);
-		Assert.assertTrue(read
-				.equals(new TripleImpl(subject, predicate, object)));
-		Assert.assertTrue(read.getObject() instanceof TypedLiteral);
-		TypedLiteral l = (TypedLiteral) read.getObject();
-		Assert.assertEquals(l.getDataType(), new UriRef(XSD + "string"));
-		Assert.assertTrue(l.getLexicalForm().length() == size);
-	}
-
-	private Triple writeAndRead(NonLiteral subject, UriRef predicate,
-			Resource object) throws ClassNotFoundException, SQLException {
-		Triple t = new TripleImpl(subject, predicate, object);
-		mgraph.add(t);
-		Triple read = mgraph.getGraph().iterator().next();
-		return read;
-	}
-
-	@Test
-	public void subjectAsUriTest() throws ClassNotFoundException, SQLException {
-		log.info("Test subject as UriRef");
-
-		NonLiteral subject;
-		UriRef predicate = new UriRef("urn:io-test:predicate");
-		UriRef object = new UriRef("urn:io-test:object");
-
-		// subject may be UriRef
-		subject = new UriRef("urn:io-test:enridaga");
-		Triple read = writeAndRead(subject, predicate, object);
-		Assert.assertTrue(read.getSubject().equals(subject));
-		Assert.assertEquals(read.getSubject(), new UriRef(
-				"urn:io-test:enridaga"));
-		Assert.assertNotSame(read.getSubject(), new UriRef(
-				"urn:io-test:alexdma"));
-		Assert.assertEquals(read, new TripleImpl(subject, predicate, object));
-
-	}
-
-	@Test
-	public void subjectAsBnodeTest() throws ClassNotFoundException,
-			SQLException {
-		log.info("Test subject as BNode");
-
-		NonLiteral subject;
-		UriRef predicate = new UriRef("urn:io-test:predicate");
-		UriRef object = new UriRef("urn:io-test:object");
-
-		// subject may be BNode
-		subject = new BNode();
-		Triple read = writeAndRead(subject, predicate, object);
-		// bnodes cannot be equals!
-		Assert.assertFalse(read.getSubject().equals(subject));
-		Assert.assertTrue(read.getSubject() instanceof BNode);
-		Assert.assertNotSame(read.getSubject(), new UriRef(
-				"urn:io-test:enridaga"));
-		Assert.assertNotSame(read.getSubject(), new UriRef(
-				"urn:io-test:alexdma"));
-		// bnodes cannot be equals!
-		Assert.assertNotSame(read, new TripleImpl(subject, predicate, object));
-	}
-
-	@Test
-	public void objectAsUriTest() throws ClassNotFoundException, SQLException {
-		log.info("Test object as UriRef");
-
-		NonLiteral subject = new UriRef("urn:io-test:enridaga");
-		UriRef predicate = new UriRef("urn:io-test:predicate");
-		UriRef object = new UriRef("urn:io-test:object");
-
-		Triple read = writeAndRead(subject, predicate, object);
-		//
-		Assert.assertTrue(read.getObject().equals(object));
-		Assert.assertTrue(read.getObject() instanceof UriRef);
-		Assert.assertEquals(read.getObject(), new UriRef("urn:io-test:object"));
-		Assert.assertNotSame(read.getSubject(), new UriRef(
-				"urn:io-test:alexdma"));
-		Assert.assertEquals(read, new TripleImpl(subject, predicate, object));
-	}
-
-	@Test
-	public void objectAsBnodeTest() throws ClassNotFoundException, SQLException {
-		log.info("Test object as Bnode");
-
-		NonLiteral subject = new UriRef("urn:io-test:subject");
-		UriRef predicate = new UriRef("urn:io-test:predicate");
-		Resource object;
-
-		// subject may be BNode
-		object = new BNode();
-		Triple read = writeAndRead(subject, predicate, object);
-		// bnodes cannot be equals!
-		Assert.assertFalse(read.getObject().equals(object));
-		Assert.assertTrue(read.getSubject().equals(subject));
-		
-		Assert.assertTrue(read.getObject() instanceof BNode);
-		Assert.assertTrue(read.getObject() instanceof VirtuosoBNode);
-		
-		Assert.assertNotSame(read.getObject(), new UriRef(
-				"urn:io-test:enridaga"));
-		Assert.assertNotSame(read.getObject(),
-				new UriRef("urn:io-test:alexdma"));
-		// these bnodes cannot be equals!
-		Assert.assertNotSame(read, new TripleImpl(subject, predicate, object));
-	}
-
-	@Test
-	public void bnodesTest() throws ClassNotFoundException, SQLException {
-		log.info("Test iterations and filter with bnode");
-
-		NonLiteral s1 = new BNode();
-		NonLiteral s2 = new BNode();
-		NonLiteral s3 = new BNode();
-		NonLiteral s4 = new BNode();
-
-		UriRef p1 = new UriRef("p1");
-		UriRef p2 = new UriRef("p2");
-		UriRef p3 = new UriRef("p3");
-
-		mgraph.add(new TripleImpl(s1, p1, s2));
-		// Get the bnode of s1
-		Triple first = mgraph.filter(null, p1, null).next();
-
-		Assert.assertTrue(first.getSubject() instanceof VirtuosoBNode);
-		Assert.assertTrue(first.getObject() instanceof VirtuosoBNode);
-		
-		BNode s1intern = (BNode) first.getSubject();
-		BNode s2intern = (BNode) first.getObject();
-		
-		mgraph.add(new TripleImpl(s2intern, p1, s3));
-		Triple second = mgraph.filter(s2intern, p1, null).next();
-		Assert.assertTrue(second.getObject() instanceof VirtuosoBNode);
-		
-		mgraph.add(new TripleImpl(s1intern, p2, s4));
-		Triple third = mgraph.filter(s1intern, p2, null).next();
-		Assert.assertTrue(third.getObject() instanceof VirtuosoBNode);
-		BNode s4intern = (BNode) third.getObject();
-		
-		mgraph.add(new TripleImpl(s1intern, p2, s4intern));
-		mgraph.add(new TripleImpl(s4intern, p3, s1intern));
-
-		Iterator<Triple> all = mgraph.iterator();
-		while(all.hasNext()){
-			Triple l = all.next();
-			log.info("{} {} {}",new Object[]{ l.getSubject(), l.getPredicate(), l.getObject()});
-		}
-		Iterator<Triple> i = mgraph.filter(null, p2, null);
-		int n = 0;
-		while (i.hasNext()) {
-			n++;
-			Triple s1t = i.next();
-			Iterator<Triple> s1i = mgraph.filter(s1t.getSubject(), null, null);
-			boolean found = false;
-			while (s1i.hasNext()) {
-				Triple s1it = s1i.next();
-				found = true;
-				log.info("{} {}",s1it.getSubject(), s1t.getSubject());
-				Assert.assertTrue(s1it.getSubject().equals(s1t.getSubject()));
-				Assert.assertTrue(s1it.getPredicate().equals(p1)
-						|| s1it.getPredicate().equals(p2));
-
-			}
-			Assert.assertTrue(found);
-			Assert.assertTrue(s1t.getObject() instanceof VirtuosoBNode);
-			Assert.assertTrue(s1t.getSubject() instanceof VirtuosoBNode);
-			Iterator<Triple> s4i = mgraph.filter((NonLiteral) s1t.getObject(),
-					null, null);
-			log.info("s4 {} ",s1t.getObject());
-			while (s4i.hasNext()) {
-				Triple s4it = s4i.next();
-				log.info("{} {}",s4it.getSubject(), s1t.getObject());
-				Assert.assertTrue(s4it.getSubject().equals(s1t.getObject()));
-				Assert.assertTrue(s4it.getPredicate().equals(p3));
-			}
-		}
-		Assert.assertEquals(n, 1);
-
-	}
-
-	@Test
-	public void sysconfigTest(){
-		
-		SystemConfig sc = new SystemConfig();
-		MGraph systemGraph = mgraph;
-		URL config = sc.getClass().getResource(SystemConfig.CONFIG_FILE);
-        if (config == null) {
-            throw new RuntimeException("no config file found");
-        }
-        ParsingProvider parser = new JenaParserProvider();
-        try {
-            parser.parse(systemGraph, config.openStream(),
-                    SupportedFormat.RDF_XML, null);
-        } catch (IOException ex) {
-            log.warn("Cannot parse coniguration at URL: {}", config);
-            throw new RuntimeException(ex);
-        }
-	}
-	
-	@Test
-	public void testUnicodeChars() throws ClassNotFoundException, SQLException {
-		log.info("Text an xsd:string");
-		
-		String s = "lorem ipsum è é £ ò ç à ù β ät ü ä";
-		TypedLiteral object = new TypedLiteralImpl(s, new UriRef(
-				XSD + "string"));
-		UriRef subject = new UriRef("urn:io-test:reto");
-		UriRef predicate = new UriRef("urn:io-test:hasText");
-
-		Triple read = writeAndRead(subject, predicate, object);
-		log.info("o: {} :: {}", object, read.getObject());
-		Assert.assertTrue(read
-				.equals(new TripleImpl(subject, predicate, object)));
-		Assert.assertTrue(read.getObject() instanceof TypedLiteral);
-		TypedLiteral l = (TypedLiteral) read.getObject();
-		Assert.assertEquals(l.getLexicalForm(), s);
-		Assert.assertEquals(l.getDataType(), new UriRef(XSD + "string"));
-
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/TestUtils.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/TestUtils.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/TestUtils.java
deleted file mode 100644
index e96d62b..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/TestUtils.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.virtuoso.storage.access.VirtuosoWeightedProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import virtuoso.jdbc4.VirtuosoConnection;
-import virtuoso.jdbc4.VirtuosoExtendedString;
-import virtuoso.jdbc4.VirtuosoRdfBox;
-import virtuoso.jdbc4.VirtuosoResultSet;
-
-/**
- * Utilities for tests
- * 
- * @author enridaga
- * 
- */
-public class TestUtils {
-
-	public static final String FOAF_NS = "http://xmlns.com/foaf/0.1/";
-
-	private static VirtuosoWeightedProvider provider = null;
-	private static String jdbcConnectionString = null;
-	private static String jdbcUser = null;
-	private static String jdbcPassword = null;
-	private static String jdbcDriver = null;
-
-	static Logger log = LoggerFactory.getLogger(TestUtils.class);
-	public static boolean SKIP = false;
-	static {
-		String skipProperty = System.getProperty("virtuoso.test");
-		if (skipProperty == null) {
-			log.info("virtuoso.skip property is not set. We skip tests by default.");
-			SKIP = true;
-		} else
-			SKIP = !skipProperty.equals("true");
-	}
-
-	public static VirtuosoConnection getConnection() throws SQLException, ClassNotFoundException{
-		return getProvider().getConnection();
-	}
-	public static VirtuosoWeightedProvider getProvider()
-			throws ClassNotFoundException, SQLException {
-		if (provider == null) {
-			initProvider();
-		}
-		return provider;
-	}
-
-	private static void initProvider() throws ClassNotFoundException,
-			SQLException {
-		if (SKIP) {
-			log.warn("Skipping tests.");
-			return;
-		}
-		String host = System.getProperty("virtuoso.host");
-		String port = System.getProperty("virtuoso.port");
-		jdbcUser = System.getProperty("virtuoso.user");
-		jdbcPassword = System.getProperty("virtuoso.password");
-		jdbcDriver = System.getProperty("virtuoso.driver");
-		if (host == null) {
-			host = "localhost";
-			log.info("Missing param 'host', setting to default: {}", host);
-		}
-		if (port == null) {
-			port = "1111";
-			log.info("Missing param 'port', setting to default: {}", port);
-		}
-		if (jdbcUser == null) {
-			jdbcUser = "dba";
-			log.info("Missing param 'user', setting to default: {}", jdbcUser);
-		}
-		if (jdbcPassword == null) {
-			jdbcPassword = "dba";
-			log.info("Missing param 'password', setting to default: {}",
-					jdbcPassword);
-		}
-		if (jdbcDriver == null) {
-			jdbcDriver = "virtuoso.jdbc4.Driver";
-			log.info("Missing param 'password', setting to default: {}",
-					jdbcDriver);
-		}
-
-		StringBuilder cb = new StringBuilder();
-		cb.append("jdbc:virtuoso://");
-		cb.append(host);
-		cb.append(":");
-		cb.append(port).append("/CHARSET=UTF-8");
-		jdbcConnectionString = cb.toString();
-//		Class.forName(VirtuosoWeightedProvider.DRIVER);
-		log.info("Create provider");
-//		connection = (VirtuosoConnection) DriverManager.getConnection(
-//				jdbcConnectionString, jdbcUser, jdbcPassword);
-		provider = new VirtuosoWeightedProvider(jdbcConnectionString, jdbcUser, jdbcPassword);
-		log.debug("Connection URL: {}", jdbcConnectionString);
-		log.debug("Connection user: {}", jdbcUser);
-	}
-
-	public static void stamp(ResultSet rs) {
-		try {
-			ResultSetMetaData rsmd;
-
-			StringBuilder output = new StringBuilder();
-			output.append(System.getProperty("line.separator"));
-			output.append("------------------------------");
-			output.append(System.getProperty("line.separator"));
-			rsmd = rs.getMetaData();
-
-			while (rs.next()) {
-				for (int i = 1; i <= rsmd.getColumnCount(); i++) {
-					String s = rs.getString(i);
-					Object o = ((VirtuosoResultSet) rs).getObject(i);
-					if (o instanceof VirtuosoExtendedString) {
-						// In case is IRI
-						VirtuosoExtendedString vs = (VirtuosoExtendedString) o;
-						if (vs.iriType == VirtuosoExtendedString.IRI
-								&& (vs.strType & 0x01) == 0x01) {
-							output.append(" <" + vs.str + "> ");
-							log.debug(" {} is IRI", vs.str);
-						} else if (vs.iriType == VirtuosoExtendedString.BNODE) {
-							log.debug(" {} is BNODE", vs.str);
-							output.append(" <" + vs.str + "> ");
-						} else {
-							// In case is untyped literal
-							log.debug(" {} is an untyped literal", vs.str);
-							output.append(vs.str);
-						}
-					} else if (o instanceof VirtuosoRdfBox) {
-						// In case is typed literal
-						VirtuosoRdfBox rb = (VirtuosoRdfBox) o;
-						output.append(rb.rb_box + " lang=" + rb.getLang()
-								+ " type=" + rb.getType());
-						log.debug(" {} is an typed literal", rb.rb_box);
-
-					} else if (rs.wasNull()) {
-						log.debug(" NULL ");
-						output.append("NULL");
-					} else {
-						// Is simple untyped string
-						output.append(s);
-					}
-
-				}
-				output.append("\n");
-			}
-
-			output.append(System.getProperty("line.separator"));
-			output.append("------------------------------");
-			output.append(System.getProperty("line.separator"));
-			log.info(output.toString());
-		} catch (Exception e) {
-			log.error("ERROR", e);
-		}
-	}
-
-	public static void stamp(Triple next) {
-		log.info("> TRIPLE : "+next.getSubject().toString() + " "
-				+ next.getPredicate().toString() + " "
-				+ next.getObject().toString());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ThreadSafetyTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ThreadSafetyTest.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ThreadSafetyTest.java
deleted file mode 100644
index fb418ab..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/ThreadSafetyTest.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoMGraph;
-import org.apache.clerezza.rdf.virtuoso.storage.access.DataAccess;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * 
- * Credit: This code is largely cloned by the thread safe test in
- * {@see org.apache.clerezza.rdf.sesame.storage.ThreadSafetyTest}
- * 
- * @author enridaga
- * 
- */
-public class ThreadSafetyTest {
-
-	private ExecutorService executor;
-	private VirtuosoMGraph mgraph;
-	private DataAccess da = null;
-	static Logger log = LoggerFactory.getLogger(ThreadSafetyTest.class);
-
-	@BeforeClass
-	public static void assume(){
-		org.junit.Assume.assumeTrue(!TestUtils.SKIP);
-	}
-	
-	@Before
-	public void setUp() throws Exception {
-		
-		da = TestUtils.getProvider().createDataAccess();
-		da.clearGraph("ThreadSafetyTest");
-		mgraph = new VirtuosoMGraph("ThreadSafetyTest",
-				da);
-		mgraph.clear();
-		executor = Executors.newCachedThreadPool();
-	}
-
-	@After
-	public void tearDown() throws Exception {
-		try {
-			executor.shutdown();
-			if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
-				fail("Timeout while waiting for termination");
-			}
-		} finally {
-			mgraph.clear();
-			mgraph = null;
-			da.close();
-			da = null;
-		}
-	}
-
-	@Test
-	public void testProduceFirstAndThenConsume() throws Exception {
-		log.info("testProduceFirstAndThenConsume()");
-		// Produce first...
-		Future<Result> fp = executor.submit(new Producer("A", 100));
-		fp.get().assertResult();
-
-		// ...and then consume
-		Future<Result> fc = executor.submit(new Consumer("A", 100));
-		fc.get().assertResult();
-		Iterator<Triple> it = mgraph.iterator();
-		while (it.hasNext()) {
-			TestUtils.stamp(it.next());
-		}
-		// test graph size
-		assertEquals(0, mgraph.size());
-	}
-
-	@Test
-	public void testProduceAndConsumeSingle() throws Exception {
-		log.info("testProduceAndConsumeSingle()");
-		List<Task> tasks = Arrays.asList(
-				new Consumer("A", 100), new Producer("A", 100));
-		List<Future<Result>> futures = executor.invokeAll(tasks);
-		for (Future<Result> future : futures) {
-			future.get().assertResult();
-		}
-		assertEquals(0, mgraph.size());
-	}
-
-	@Test
-	public void testProduceAndConsumeMultiple() throws Exception {
-		log.info("testProduceAndConsumeMultiple()");
-		List<Task> tasks = Arrays.asList(
-				new Consumer("A", 100), new Producer("A", 100),
-				new Consumer("B", 100), new Producer("B", 100),
-				new Consumer("C", 100), new Producer("C", 100),
-				new Consumer("D", 100), new Producer("D", 100));
-		List<Future<Result>> futures = executor.invokeAll(tasks);
-		for (Future<Result> future : futures) {
-			future.get().assertResult();
-		}
-		assertEquals(0, mgraph.size());
-	}
-
-	@Test
-	public void testProduceAndConsumeMixed() throws Exception {
-		log.info("testProduceAndConsumeMixed()");
-		List<? extends Task> tasks = Arrays.asList(
-				new Consumer("A", 110), new Consumer("A", 170),
-				new Consumer("B", 100), new Consumer("B", 500),
-				new Consumer("C", 230), new Consumer("C", 230),
-				new Consumer("D", 540), new Consumer("D", 10),
-				new Producer("D", 50), new Producer("D", 500),
-				new Producer("C", 400), new Producer("C", 60),
-				new Producer("B", 300), new Producer("B", 300),
-				new Producer("A", 200), new Producer("A", 80));
-		List<Future<Result>> futures = executor.invokeAll(tasks);
-		for (Future<Result> future : futures) {
-			future.get().assertResult();
-		}
-		assertEquals(0, mgraph.size());
-	}
-	/**
-	 * The <code>Task</code> specifies a <code>Callable</code> whoes execution
-	 * results in an <code>Integer</code>.
-	 */
-	private abstract class Task implements Callable<Result> {
-
-		protected final String collectionName;
-		protected final UriRef subject;
-		protected final UriRef predicate;
-		protected final int numElements;
-
-		/**
-		 * Creates a new <code>Task</code>.
-		 * 
-		 * @param collectionName
-		 *            Name of the task's collection.
-		 * @param numElements
-		 *            The number of elements to process.
-		 */
-		protected Task(String collectionName, int numElements) {
-			if (collectionName == null) {
-				throw new IllegalArgumentException("Invalid name: null");
-			} else if (collectionName.length() <= 0) {
-				throw new IllegalArgumentException("Invalid name: '"
-						+ collectionName + "'");
-			} else if (numElements < 0) {
-				throw new IllegalArgumentException("Invalid numElements: "
-						+ numElements);
-			}
-			this.numElements = numElements;
-			this.collectionName = collectionName;
-			subject = new UriRef("http://example.org/" + "collection/"
-					+ collectionName);
-			predicate = new UriRef("http://example.org/ontology/contains");
-		}
-
-		/**
-		 * Causes the currently executing thread object to temporarily pause and
-		 * allow other threads to execute.
-		 */
-		protected void yield() {
-			try {
-				Thread.sleep(5);
-			} catch (InterruptedException e) {
-				Thread.currentThread().interrupt();
-			}
-		}
-	}
-
-	/**
-	 * This class represents a task that produces triples that are stored in the
-	 * graph.
-	 */
-	private class Producer extends Task {
-
-		/**
-		 * Creates a new <code>Producer</code> task.
-		 * 
-		 * @param collectionName
-		 *            Name of the task's collection.
-		 * @param numElements
-		 *            The number of elements to produce.
-		 */
-		public Producer(String collectionName, int numElements) {
-			super(collectionName, numElements);
-		}
-
-		@Override
-		public Result call() throws InterruptedException {
-			int counter = 0;
-			for (int elementName = 1; counter < numElements; elementName++) {
-				yield();
-				final Triple t = createTriple(elementName);
-				if (mgraph.add(t)) {
-					counter++;
-					yield();
-				} else {
-					System.out.println("WARNING: element " + t + "NOT created");
-				}
-			}
-			return new Result(collectionName, "Produced elements", numElements,
-					counter);
-		}
-
-		/**
-		 * Creates a new collection element triple.
-		 * 
-		 * @param value
-		 *            Value of the collection element.
-		 * @return A new triple representing the collection element.
-		 */
-		protected Triple createTriple(int value) {
-			final UriRef object = new UriRef("http://example.org/"
-					+ collectionName + "/" + Integer.valueOf(value)
-					+ Math.random());
-			return new TripleImpl(subject, predicate, object);
-		}
-	}
-
-	/**
-	 * This class represents a task that produces triples that are stored in the
-	 * graph.
-	 */
-	private class Consumer extends Task {
-
-		/**
-		 * Creates a new <code>Consumer</code> task.
-		 * 
-		 * @param collectionName
-		 *            Name of the task's collection.
-		 * @param numElements
-		 *            The number of elements to consume.
-		 */
-		public Consumer(String collectionName, int numElements) {
-			super(collectionName, numElements);
-		}
-
-		/**
-		 * Performs this task.
-		 * 
-		 * @return the number of elements successfully added to the graph.
-		 */
-		@Override
-		public Result call() throws InterruptedException {
-			int counter = 0;
-			while (counter < numElements) {
-				yield();
-
-				Triple triple = null;
-				mgraph.getLock().writeLock().lock();
-				try {
-					// System.out.println("synchonized");
-					Iterator<Triple> i = mgraph
-							.filter(subject, predicate, null);
-					if (i.hasNext()) {
-						triple = i.next();
-					}
-
-					if (triple != null && mgraph.remove(triple)) {
-						counter++;
-					}
-				} finally {
-					mgraph.getLock().writeLock().unlock();
-				}
-			}
-			return new Result(collectionName, "Consumed elements", numElements,
-					counter);
-		}
-	}
-
-	/**
-	 * Task result that asserts the number of processed elements.
-	 */
-	private class Result {
-
-		private final int expected;
-		private final int actual;
-		private final String msg;
-		private final String cn;
-
-		/**
-		 * Creates a new task result that asserts the element count.
-		 * 
-		 * @param cn
-		 *            Name of the affected collection.
-		 * @param msg
-		 *            Assertion message to print.
-		 * @param expected
-		 *            Expected number of processed elements.
-		 * @param actual
-		 *            Actual number of processed elements.
-		 */
-		public Result(String cn, String msg, int expected, int actual) {
-			this.expected = expected;
-			this.actual = actual;
-			this.msg = msg;
-			this.cn = cn;
-		}
-
-		/**
-		 * Asserts this result.
-		 */
-		public void assertResult() {
-			assertEquals("[" + cn + "] " + msg, expected, actual);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoGraphTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoGraphTest.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoGraphTest.java
deleted file mode 100644
index 2280a3f..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoGraphTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoGraph;
-
-/**
- * Tests the {@link VirtuosoGraph} implementation of {@link Graph}
- * 
- * @author enridaga
- *
- */
-public class VirtuosoGraphTest {
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/bb87e83f/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoMGraphTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoMGraphTest.java b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoMGraphTest.java
deleted file mode 100644
index 0d7b1ec..0000000
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/org/apache/clerezza/rdf/virtuoso/storage/VirtuosoMGraphTest.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.virtuoso.storage;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Iterator;
-
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Language;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl;
-import org.apache.clerezza.rdf.virtuoso.storage.VirtuosoMGraph;
-import org.apache.clerezza.rdf.virtuoso.storage.access.DataAccess;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import virtuoso.jdbc4.VirtuosoException;
-
-public class VirtuosoMGraphTest {
-	static VirtuosoMGraph mgraph = null;
-	static DataAccess da = null;
-	static final String TEST_GRAPH_NAME = "VirtuosoMGraphTest";
-
-	static Logger log = LoggerFactory.getLogger(VirtuosoMGraphTest.class);
-	
-	@BeforeClass
-	public static void assume(){
-		org.junit.Assume.assumeTrue(!TestUtils.SKIP);
-	}
-	
-	/**
-	 * Clean before any test
-	 * 
-	 * @throws ClassNotFoundException
-	 * @throws SQLException
-	 */
-	@Before
-	public void before() throws ClassNotFoundException, SQLException {
-		
-		da = TestUtils.getProvider().createDataAccess();
-		mgraph = new VirtuosoMGraph(TEST_GRAPH_NAME, da);
-		mgraph.clear();
-		log.debug("Clearing graph <{}>", TEST_GRAPH_NAME);
-	}
-
-	final UriRef enridaga = new UriRef("enridaga");
-	final UriRef alexdma = new UriRef("alexdma");
-	final UriRef anuzzolese = new UriRef("anuzzolese");
-	final UriRef predicate = new UriRef("http://property/name");
-	final PlainLiteral object = new PlainLiteralImpl("Enrico Daga", new Language("it"));
-	final TypedLiteral objectTyped = new TypedLiteralImpl("Enrico Daga", new UriRef("http://www.w3.org/2001/XMLSchema#string"));
-	final TypedLiteral objectXml = new TypedLiteralImpl("<div>Enrico Daga</div>" , 
-			new UriRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"));
-	final UriRef knows = new UriRef(TestUtils.FOAF_NS + "knows");
-
-	@Test
-	public void testAddSingle() {
-		log.info("testAddSingle()");
-		Triple triple = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return predicate;
-			}
-
-			@Override
-			public Resource getObject() {
-				return object;
-			}
-		};
-		boolean success = mgraph.add(triple);
-		assertTrue(success);
-		assertTrue(mgraph.size() == 1);
-		assertTrue(mgraph.filter(enridaga, predicate, object).hasNext());
-		assertTrue(mgraph.filter(enridaga, predicate, object).next().equals(triple));
-	}
-	
-	@Test
-	public void testAddSingleTypedLiteral() {
-		log.info("testAddSingleTypedLiteral()");
-		Triple triple = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return predicate;
-			}
-
-			@Override
-			public Resource getObject() {
-				return objectTyped;
-			}
-		};
-		boolean success = mgraph.add(triple);
-		assertTrue(success);
-		assertTrue(mgraph.size() == 1);
-		assertTrue(mgraph.filter(enridaga, predicate, objectTyped).hasNext());
-		assertTrue(mgraph.filter(enridaga, predicate, objectTyped).next().equals(triple));
-	}
-
-	@Ignore
-	@Test
-	public void testAddSingleXMLLiteral() {
-		log.info("testAddSingleXMLLiteral()");
-		Triple triple = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return predicate;
-			}
-
-			@Override
-			public Resource getObject() {
-				return objectXml;
-			}
-		};
-		boolean success = mgraph.add(triple);
-		assertTrue(success);
-		assertTrue(mgraph.size() == 1);
-		Triple rt = mgraph.filter(enridaga, predicate, null).next();
-		log.info(" > s: {} ", rt.getSubject());
-		log.info(" > p: {} ", rt.getPredicate());
-		log.info(" > o: {} ", rt.getObject());
-		log.info(" > tl?: {} ", rt.getObject() instanceof TypedLiteral);
-		assertTrue(mgraph.filter(enridaga, predicate, objectXml).hasNext());
-		assertTrue(mgraph.filter(enridaga, predicate, objectXml).next().equals(triple));
-	}
-
-
-	@Test
-	public void testFilter() {
-		log.info("testFilter(); Test filter(s,p,o)");
-		// We use testAdd to prepare this
-		testAddSingle();
-		
-		Iterator<Triple> its = mgraph.filter(null, null, null);
-		while (its.hasNext()) {
-			Triple t = its.next();
-			log.info("Found --- triple: {}", t);
-			log.info("Found --- s: {} {}", t.getSubject(), t.getSubject().getClass());
-			log.info("Found --- p: {} {}", t.getPredicate(), t.getPredicate().getClass());
-			log.info("Found --- o: {} {}", t.getObject(), t.getObject().getClass());
-			assertEquals(t.getSubject(), enridaga);
-			assertEquals(t.getPredicate(), predicate);
-			assertEquals(t.getObject(), object);
-		}
-
-		Iterator<Triple> it = mgraph.filter(enridaga, predicate, object);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			log.debug("Found matching triple: {}", t);
-			assertEquals(t.getSubject(), enridaga);
-			assertEquals(t.getPredicate(), predicate);
-			assertEquals(t.getObject(), object);
-		}
-		assertTrue(found);
-	}
-
-	@Test
-	public void testFilterSubject() {
-		log.info("testFilterSubject(); Test filter(s,null,null)");
-		// We use testAdd to prepare this
-		testAddSingle();
-		Iterator<Triple> it = mgraph.filter(enridaga, null, null);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getSubject(), enridaga);
-		}
-		assertTrue(found);
-	}
-
-
-	@Test
-	public void testFilterSubjectBnode() throws VirtuosoException, SQLException, ClassNotFoundException {
-		log.info("testFilterSubjectBnode(); Test filter(s,null,null)");
-		final BNode bn = new BNode();
-		// We use testAdd to prepare this
-		Triple triple = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return bn;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return predicate;
-			}
-
-			@Override
-			public Resource getObject() {
-				return new BNode();
-			}
-		};
-
-		boolean success = mgraph.add(triple);
-		assertTrue(success);
-		Iterator<Triple> it = mgraph.filter(bn, predicate, null);
-		boolean found = false;
-		Triple t = null; // we will use it to make a further query
-		while (it.hasNext()) {
-			found = true;
-			 t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getPredicate(), predicate);
-		}
-		assertTrue(found);
-		
-		assertNotNull(t);
-		
-		log.info("{}",t.getSubject());
-		it = mgraph.filter(t.getSubject(), predicate, t.getObject());
-		found = false;
-		while (it.hasNext()) {
-			found = true;
-			 t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getPredicate(), predicate);
-		}
-		assertTrue(found);
-	}
-
-	@Test
-	public void testFilterPredicate() {
-		log.info("testFilterPredicate(); Test filter(null,p,null)");
-		// We use testAdd to prepare this
-		testAddSingle();
-		Iterator<Triple> it = mgraph.filter(null, predicate, null);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getPredicate(), predicate);
-		}
-		assertTrue(found);
-	}
-
-	@Test
-	public void testFilterObject() {
-		log.info("testFilterObject(); Test filter(null,null,o)");
-		// We use testAdd to prepare this
-		testAddSingle();
-		Iterator<Triple> it = mgraph.filter(null, null, object);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getObject(), object);
-		}
-		assertTrue(found);
-	}
-
-	@Test
-	public void testFilterObjectTyped() {
-		log.info("testFilterObjectTyped(); Test filter(null,null,o)");
-		// We use testAdd to prepare this
-		testAddSingleTypedLiteral();
-		Iterator<Triple> it = mgraph.filter(null, null, objectTyped);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getObject(), objectTyped);
-		}
-		assertTrue(found);
-	}
-
-	@Ignore
-	@Test
-	public void testFilterObjectXml() {
-		log.info("testFilterObjectXml(); Test filter(null,null,o)");
-		// We use testAdd to prepare this
-		testAddSingleXMLLiteral();
-		Iterator<Triple> it = mgraph.filter(null, null, objectXml);
-		boolean found = false;
-		while (it.hasNext()) {
-			found = true;
-			Triple t = it.next();
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple: {}", t);
-				TestUtils.stamp(t);
-			}
-			assertEquals(t.getObject(), objectXml);
-		}
-		assertTrue(found);
-	}
-
-	@Test
-	public void testSize() {
-		log.info("testSize()");
-		// We use testAdd to prepare this
-		testAddSingle();
-		// Should be 1 at this time
-		log.debug("How many triples are in graph <{}>? {}", TEST_GRAPH_NAME,
-				mgraph.size());
-		assertTrue(mgraph.size() > 0);
-	}
-
-	@Test
-	public void testIncreaseSize() {
-		log.info("testIncreaseSize()");
-		int beforeSize = mgraph.size();
-		Triple t = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return knows;
-			}
-
-			@Override
-			public Resource getObject() {
-				return alexdma;
-			}
-		};
-		assertTrue(mgraph.add(t));
-		int afterSize = mgraph.size();
-		assertEquals(beforeSize + 1, afterSize);
-	}
-
-	@Test
-	public void testAddRemoveSize() {
-		log.info("testAddRemoveSize()");
-		int beforeSize = mgraph.size();
-		Triple t = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return knows;
-			}
-
-			@Override
-			public Resource getObject() {
-				return alexdma;
-			}
-		};
-		assertTrue(mgraph.add(t));
-		assertTrue(mgraph.remove(t));
-		int afterSize = mgraph.size();
-		assertEquals(beforeSize, afterSize);
-	}
-
-	@Test
-	public void testGetGraphReadOnly() {
-		log.info("testGetGraphReadOnly()");
-		Graph g = mgraph.getGraph();
-		Triple t = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return knows;
-			}
-
-			@Override
-			public Resource getObject() {
-				return anuzzolese;
-			}
-		};
-		// This should not be allowed
-		boolean success;
-		try {
-			success = g.add(t);
-		} catch (UnsupportedOperationException e) {
-			success = false;
-		}
-		assertFalse(success);
-	}
-
-	@Test
-	public void testContains() {
-		log.info("testContains()");
-		Triple t = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return knows;
-			}
-
-			@Override
-			public Resource getObject() {
-				return anuzzolese;
-			}
-		};
-		boolean addWorks = mgraph.add(t);
-		assertTrue(addWorks);
-
-		// This second triple is equivalent
-		Triple t2 = new Triple() {
-
-			@Override
-			public NonLiteral getSubject() {
-				return enridaga;
-			}
-
-			@Override
-			public UriRef getPredicate() {
-				return knows;
-			}
-
-			@Override
-			public Resource getObject() {
-				return anuzzolese;
-			}
-		};
-		Iterator<Triple> it = mgraph.filter(t2.getSubject(), t2.getPredicate(),
-				t2.getObject());
-		while (it.hasNext()) {
-			if (log.isDebugEnabled()) {
-				log.debug("Found matching triple");
-				TestUtils.stamp(it.next());
-			}else{
-				it.next();
-			}
-		}
-		assertTrue(mgraph.contains(t2));
-		// Also the related read-only graph
-		assertTrue(mgraph.getGraph().contains(t2));
-	}
-
-	@After
-	public void clear() throws VirtuosoException, ClassNotFoundException,
-			SQLException {
-		log.info("Clearing graph <{}> of size {}", TEST_GRAPH_NAME,
-				mgraph.size());
-		log.debug("Removing graph <{}>", TEST_GRAPH_NAME);
-		da.close();
-		da = null;
-		mgraph = null;
-		Statement st = TestUtils.getConnection().createStatement();
-		st.execute("SPARQL CLEAR GRAPH <" + TEST_GRAPH_NAME + ">");
-		st.close();
-	}
-}


Mime
View raw message