Java Code Examples for org.eclipse.rdf4j.model.Resource

The following examples show how to use org.eclipse.rdf4j.model.Resource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rdf4j   Source File: PropertyShape.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
String describe(SailRepositoryConnection connection, Resource resource) {
	GraphQuery graphQuery = connection.prepareGraphQuery("describe ?a where {BIND(?resource as ?a)}");
	graphQuery.setBinding("resource", resource);

	try (Stream<Statement> stream = graphQuery.evaluate().stream()) {

		LinkedHashModel statements = stream.collect(Collectors.toCollection(LinkedHashModel::new));
		statements.setNamespace(SHACL.PREFIX, SHACL.NAMESPACE);

		WriterConfig config = new WriterConfig();
		config.set(BasicWriterSettings.PRETTY_PRINT, true);
		config.set(BasicWriterSettings.INLINE_BLANK_NODES, true);

		StringWriter stringWriter = new StringWriter();

		Rio.write(statements, stringWriter, RDFFormat.TURTLE, config);

		return stringWriter.toString();
	}
}
 
Example 2
@Test
public void sequenceItemsAreAbbreviated() throws RDFHandlerException, IOException {
	StringWriter writer = new StringWriter();
	RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);

	rdfWriter.startRDF();

	Resource res = vf.createIRI("http://example.com/#");

	rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG));

	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_1"), vf.createIRI("http://example.com/#1")));
	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2")));
	rdfWriter.endRDF();

	List<String> rdfLines = rdfOpenTags(writer.toString());

	assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:li", "<rdf:li"), rdfLines);
}
 
Example 3
@Override
public void clearInferred(Resource... contexts) throws SailException {
	verifyIsOpen();
	verifyIsActive();
	synchronized (datasets) {
		if (inferredOnlySink == null) {
			IsolationLevel level = getIsolationLevel();
			SailSource branch = branch(IncludeInferred.inferredOnly);
			inferredOnlyDataset = branch.dataset(level);
			inferredOnlySink = branch.sink(level);
			explicitOnlyDataset = branch(IncludeInferred.explicitOnly).dataset(level);
		}
		if (this.hasConnectionListeners()) {
			remove(null, null, null, inferredOnlyDataset, inferredOnlySink, contexts);
		}
		inferredOnlySink.clear(contexts);
	}
}
 
Example 4
@Test
public void inSequenceItemsMixedWithOtherElementsAreAbbreviated() throws RDFHandlerException, IOException {
	StringWriter writer = new StringWriter();
	RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);

	rdfWriter.startRDF();

	Resource res = vf.createIRI("http://example.com/#");

	rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG));

	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2")));
	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_1"), vf.createIRI("http://example.com/#1")));
	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_3"), vf.createIRI("http://example.com/#3")));
	rdfWriter.handleStatement(
			vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2")));
	rdfWriter.endRDF();

	List<String> rdfLines = rdfOpenTags(writer.toString());

	assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:_2", "<rdf:li", "<rdf:_3", "<rdf:li"), rdfLines);
}
 
Example 5
/***
 * Add a new repository to the manager.
 *
 * @param configStream input stream of the repository configuration
 * @return ID of the repository as string
 * @throws IOException
 * @throws RDF4JException
 */
protected String addRepository(InputStream configStream) throws IOException, RDF4JException {
	RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE, SimpleValueFactory.getInstance());

	Model graph = new LinkedHashModel();
	rdfParser.setRDFHandler(new StatementCollector(graph));
	rdfParser.parse(
			new StringReader(IOUtil.readString(new InputStreamReader(configStream, StandardCharsets.UTF_8))),
			RepositoryConfigSchema.NAMESPACE);
	configStream.close();

	Resource repositoryNode = Models.subject(graph.filter(null, RDF.TYPE, RepositoryConfigSchema.REPOSITORY))
			.orElseThrow(() -> new RepositoryConfigException("could not find subject resource"));

	RepositoryConfig repoConfig = RepositoryConfig.create(graph, repositoryNode);
	repoConfig.validate();
	manager.addRepositoryConfig(repoConfig);

	String repId = Models.objectLiteral(graph.filter(repositoryNode, RepositoryConfigSchema.REPOSITORYID, null))
			.orElseThrow(() -> new RepositoryConfigException("missing repository id"))
			.stringValue();

	return repId;
}
 
Example 6
private void checkConstraints(Resource subj, List<IRI> classHierarchy)
		throws RDF4JException {
	if (sail.isInitializing() || !sail.isValidateConstraints()) {
		return;
	}

	Map<IRI, List<Resource>> constraintsByClass = getConstraintsForSubject(subj, classHierarchy);

	if (!constraintsByClass.isEmpty()) {
		// check constraints
		logger.debug("checking constraints for resource {}", subj);
		for (Map.Entry<IRI, List<Resource>> clsEntry : constraintsByClass.entrySet()) {
			List<Resource> constraints = clsEntry.getValue();
			for (Resource constraint : constraints) {
				checkConstraint(subj, constraint);
			}
		}
	}
}
 
Example 7
public Value evaluate(ValueExprTripleRef node, BindingSet bindings)
		throws QueryEvaluationException {
	Value subj = evaluate(node.getSubjectVar(), bindings);
	if (!(subj instanceof Resource)) {
		throw new ValueExprEvaluationException("no subject value");
	}
	Value pred = evaluate(node.getPredicateVar(), bindings);
	if (!(pred instanceof IRI)) {
		throw new ValueExprEvaluationException("no predicate value");
	}
	Value obj = evaluate(node.getObjectVar(), bindings);
	if (obj == null) {
		throw new ValueExprEvaluationException("no object value");
	}
	return tripleSource.getValueFactory().createTriple((Resource) subj, (IRI) pred, obj);

}
 
Example 8
protected void assertQueryResult(String literal, IRI predicate, Resource resultUri) throws Exception {
	try (RepositoryConnection connection = repository.getConnection()) {
		// fire a query for all subjects with a given term
		String queryString = "SELECT Resource " + "FROM {Resource} <" + MATCHES + "> {} " + " <" + QUERY + "> {\""
				+ literal + "\"} ";
		TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SERQL, queryString);
		try (TupleQueryResult result = query.evaluate()) {
			// check the result
			assertTrue("query for literal '" + literal + " did not return any results, expected was " + resultUri,
					result.hasNext());
			BindingSet bindings = result.next();
			assertEquals("query for literal '" + literal + " did not return the expected resource", resultUri,
					bindings.getValue("Resource"));
			assertFalse(result.hasNext());
		}
	}
}
 
Example 9
Source Project: rdf4j   Source File: RDFWriterTest.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testListWithObject() throws Exception {
	Model input = new LinkedHashModel();
	Resource _1 = vf.createBNode();
	input.add(uri1, uri2, _1);
	input.add(_1, RDF.FIRST, bnode);
	input.add(bnode, RDF.TYPE, RDFS.RESOURCE);
	input.add(_1, RDF.REST, RDF.NIL);
	ByteArrayOutputStream outputWriter = new ByteArrayOutputStream();
	RDFWriter rdfWriter = rdfWriterFactory.getWriter(outputWriter);
	setupWriterConfig(rdfWriter.getWriterConfig());
	rdfWriter.startRDF();
	for (Statement st : input) {
		rdfWriter.handleStatement(st);
	}
	rdfWriter.endRDF();
	logger.debug(new String(outputWriter.toByteArray()));
	ByteArrayInputStream inputReader = new ByteArrayInputStream(outputWriter.toByteArray());
	RDFParser rdfParser = rdfParserFactory.getParser();
	setupParserConfig(rdfParser.getParserConfig());
	Model parsedOutput = new LinkedHashModel();
	rdfParser.setRDFHandler(new StatementCollector(parsedOutput));
	rdfParser.parse(inputReader, "");
	assertSameModel(input, parsedOutput);
}
 
Example 10
Source Project: Wikidata-Toolkit   Source File: ValueRdfConverterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteGlobeCoordinatesValue() throws RDFHandlerException,
		RDFParseException, IOException {
	GlobeCoordinatesValueConverter valueConverter = new GlobeCoordinatesValueConverter(
			this.rdfWriter, this.propertyRegister, this.rdfConversionBuffer);

	GlobeCoordinatesValue value = this.objectFactory
			.getGlobeCoordinatesValue(51.033333333333, 13.733333333333,
					(GlobeCoordinatesValue.PREC_DECI_DEGREE),
					"http://www.wikidata.org/entity/Q2");
	PropertyIdValue propertyIdValue = objectFactory.getPropertyIdValue(
			"P625", "http://www.wikidata.org/entity/");
	Value valueURI = valueConverter.getRdfValue(value, propertyIdValue,
			false);
	valueConverter.writeValue(value, (Resource) valueURI);
	this.rdfWriter.finish();
	Model model = RdfTestHelpers.parseRdf(this.out.toString());
	assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
			.getResourceFromFile("GlobeCoordinatesValue.rdf")));
}
 
Example 11
Source Project: rya   Source File: GeoIndexerSfTest.java    License: Apache License 2.0 6 votes vote down vote up
private static Statement genericStatementGml(final Geometry geo, final IRI encodingMethod) {
    final Resource subject = VF.createIRI("uri:" + NAMES.get(geo));
    final IRI predicate = GeoConstants.GEO_AS_GML;

    final String gml ;
    if (encodingMethod == USE_JTS_LIB_ENCODING) {
        gml = geoToGmlUseJtsLib(geo);
    } else if (encodingMethod == USE_ROUGH_ENCODING) {
        gml = geoToGmlRough(geo);
    }
    else {
        throw new Error("invalid encoding method: "+encodingMethod);
    //        System.out.println("===created GML====");
    //        System.out.println(gml);
    //        System.out.println("========== GML====");
    }

    final Value object = VF.createLiteral(gml, GeoConstants.XMLSCHEMA_OGC_GML);
    return VF.createStatement(subject, predicate, object);
}
 
Example 12
Source Project: Halyard   Source File: HalyardTableUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parser method returning Statement from a single HBase Result Cell
 * @param c HBase Result Cell
 * @param vf ValueFactory to construct Statement and its Values
 * @return Statements
 */
public static Statement parseStatement(Cell c, ValueFactory vf) {
    ByteBuffer bb = ByteBuffer.wrap(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength());
    byte[] sb = new byte[bb.getInt()];
    byte[] pb = new byte[bb.getInt()];
    byte[] ob = new byte[bb.getInt()];
    bb.get(sb);
    bb.get(pb);
    bb.get(ob);
    byte[] cb = new byte[bb.remaining()];
    bb.get(cb);
    Resource subj = readResource(sb, vf);
    IRI pred = readIRI(pb, vf);
    Value value = readValue(ob, vf);
    Statement stmt;
    if (cb.length == 0) {
        stmt = vf.createStatement(subj, pred, value);
    } else {
        Resource context = readResource(cb, vf);
        stmt = vf.createStatement(subj, pred, value, context);
    }
    return stmt;
}
 
Example 13
@Override
public boolean remove(Resource subj, IRI pred, Value obj, Resource... contexts) {
	if (isEmpty()) {
		return false;
	}

	Iterator<ModelStatement> iter = matchPattern(subj, pred, obj, contexts);
	if (!iter.hasNext()) {
		return false;
	}
	while (iter.hasNext()) {
		iter.next();
		iter.remove();
	}
	return true;
}
 
Example 14
public FederationEvalStrategy(FederationContext federationContext) {
	super(new org.eclipse.rdf4j.query.algebra.evaluation.TripleSource() {

		@Override
		public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(
				Resource subj, IRI pred, Value obj, Resource... contexts)
				throws QueryEvaluationException {
			throw new FedXRuntimeException(
					"Federation Strategy does not support org.openrdf.query.algebra.evaluation.TripleSource#getStatements."
							+
							" If you encounter this exception, please report it.");
		}

		@Override
		public ValueFactory getValueFactory() {
			return SimpleValueFactory.getInstance();
		}
	}, federationContext.getFederatedServiceResolver());
	this.federationContext = federationContext;
	this.executor = federationContext.getManager().getExecutor();
	this.cache = createSourceSelectionCache();
}
 
Example 15
Source Project: rdf4j   Source File: SpinRenderer.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void meet(Union node) throws RDFHandlerException {
	listEntry();
	handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.UNION_CLASS));
	Resource elementsList = valueFactory.createBNode();
	handler.handleStatement(valueFactory.createStatement(subject, SP.ELEMENTS_PROPERTY, elementsList));
	ListContext elementsCtx = newList(elementsList);
	listEntry();
	ListContext leftCtx = newList(subject);
	node.getLeftArg().visit(this);
	endList(leftCtx);

	listEntry();
	ListContext rightCtx = newList(subject);
	node.getRightArg().visit(this);
	endList(rightCtx);
	endList(elementsCtx);
}
 
Example 16
@Override
public final CloseableIteration<? extends Statement, SailException> getStatements(Resource subj, IRI pred,
		Value obj, boolean includeInferred, Resource... contexts) throws SailException {
	flushPendingUpdates();
	connectionLock.readLock().lock();
	try {
		verifyIsOpen();
		boolean registered = false;
		CloseableIteration<? extends Statement, SailException> iteration = getStatementsInternal(subj, pred, obj,
				includeInferred, contexts);
		try {
			CloseableIteration<? extends Statement, SailException> registeredIteration = registerIteration(
					iteration);
			registered = true;
			return registeredIteration;
		} finally {
			if (!registered) {
				iteration.close();
			}
		}
	} finally {
		connectionLock.readLock().unlock();
	}
}
 
Example 17
@Before
public void setUp() {
	Model m = new LinkedHashModel();
	m.add(RDF.ALT, RDF.TYPE, RDFS.CLASS);
	m.add(RDF.BAG, RDF.TYPE, RDFS.CLASS);

	TripleSource ts = new TripleSource() {

		@Override
		public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(Resource subj,
				IRI pred, Value obj, Resource... contexts) throws QueryEvaluationException {
			return new CloseableIteratorIteration<>(m.getStatements(subj, pred, obj, contexts).iterator());
		}

		@Override
		public ValueFactory getValueFactory() {
			return vf;
		}
	};
	evaluator = new StrictEvaluationStrategy(ts, null);
}
 
Example 18
/**
 * Removes the supplied statements from a specific context in this repository, ignoring any context information
 * carried by the statements themselves.
 *
 * @param statementIter The statements to remove. In case the iterator is a {@link CloseableIteration}, it will be
 *                      closed before this method returns.
 * @throws RepositoryException If the statements could not be removed from the repository, for example because the
 *                             repository is not writable.
 * @see #getRemoveContexts()
 */
@Override
public <E extends Exception> void remove(Iteration<? extends Statement, E> statementIter, Resource... contexts)
		throws RepositoryException, E {
	final IRI[] removeContexts = getRemoveContexts();
	if (isAllContext(contexts) && removeContexts.length == 1) {
		super.remove(new ConvertingIteration<Statement, Statement, E>(statementIter) {

			@Override
			protected Statement convert(Statement st) {
				if (st.getContext() == null) {
					return getValueFactory().createStatement(st.getSubject(), st.getPredicate(), st.getObject(),
							removeContexts[0]);
				}
				return st;
			}
		});
	} else {
		super.remove(statementIter, contexts);
	}
}
 
Example 19
@Override
public Resource export(Model m) {

	Resource implNode = super.export(m);

	m.setNamespace("fedx", NAMESPACE);
	if (getDataConfig() != null) {
		m.add(implNode, DATA_CONFIG, vf.createLiteral(getDataConfig()));
	}

	if (getMembers() != null) {

		Model members = getMembers();
		Set<Resource> memberNodes = members.subjects();
		for (Resource memberNode : memberNodes) {
			m.add(implNode, MEMBER, memberNode);
			m.addAll(members.filter(memberNode, null, null));
		}
	}

	return implNode;
}
 
Example 20
Source Project: rdf4j   Source File: ExploreServlet.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gets whether this is the first time the result quad has been seen.
 *
 * @param patternPredicate the predicate asked for, or null if another quad element was asked for
 * @param patternObject    the object asked for, or null if another quad element was asked for
 * @param result           the result statement to determine if we've already seen
 * @param patternContext   the context asked for, or null if another quad element was asked for
 * @return true, if this is the first time the quad has been seen, false otherwise
 */
private boolean isFirstTimeSeen(Statement result, IRI patternPredicate, Value patternObject,
		Resource... patternContext) {
	Resource resultSubject = result.getSubject();
	IRI resultPredicate = result.getPredicate();
	Value resultObject = result.getObject();
	boolean firstTimeSeen;
	if (1 == patternContext.length) {
		// I.e., when context matches explore value.
		Resource ctx = patternContext[0];
		firstTimeSeen = !(ctx.equals(resultSubject) || ctx.equals(resultPredicate) || ctx.equals(resultObject));
	} else if (null != patternObject) {
		// I.e., when object matches explore value.
		firstTimeSeen = !(resultObject.equals(resultSubject) || resultObject.equals(resultPredicate));
	} else if (null != patternPredicate) {
		// I.e., when predicate matches explore value.
		firstTimeSeen = !(resultPredicate.equals(resultSubject));
	} else {
		// I.e., when subject matches explore value.
		firstTimeSeen = true;
	}
	return firstTimeSeen;
}
 
Example 21
Source Project: Halyard   Source File: HBaseSailTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEvaluate() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    rep.shutDown();
}
 
Example 22
Source Project: rdf4j   Source File: SpinRenderer.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(ParsedGraphQuery query, RDFHandler handler) throws RDFHandlerException {
	handler.startRDF();
	Resource querySubj = valueFactory.createBNode();
	handler.handleStatement(valueFactory.createStatement(querySubj, RDF.TYPE, SP.CONSTRUCT_CLASS));
	if (output.text) {
		handler.handleStatement(valueFactory.createStatement(querySubj, SP.TEXT_PROPERTY,
				valueFactory.createLiteral(query.getSourceString())));
	}
	if (output.rdf) {
		TupleExpr expr = query.getTupleExpr();
		SpinVisitor visitor = new ConstructVisitor(handler, querySubj, query.getDataset());
		expr.visit(visitor);
		visitor.end();
	}
	handler.endRDF();
}
 
Example 23
Source Project: rya   Source File: CombineContextsRdfInserter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handleStatement(Statement st)
        throws RDFHandlerException {
    Resource subj = st.getSubject();
    IRI pred = st.getPredicate();
    Value obj = st.getObject();
    Resource ctxt = st.getContext();

    if (!preserveBNodeIDs) {
        if (subj instanceof BNode) {
            subj = mapBNode((BNode) subj);
        }

        if (obj instanceof BNode) {
            obj = mapBNode((BNode) obj);
        }

        if (!enforcesContext() && ctxt instanceof BNode) {
            ctxt = mapBNode((BNode) ctxt);
        }
    }

    try {
        if (enforcesContext()) {
            Resource[] ctxts = contexts;
            if (ctxt != null) {
                ctxts = combineContexts(contexts, ctxt);
            }
            con.add(subj, pred, obj, ctxts);
        } else {
            con.add(subj, pred, obj, ctxt);
        }
    } catch (RepositoryException e) {
        throw new RDFHandlerException(e);
    }
}
 
Example 24
Source Project: Wikidata-Toolkit   Source File: AbstractRdfConverter.java    License: Apache License 2.0 5 votes vote down vote up
public void writeReferences(Resource statementResource,
		List<? extends Reference> references) throws RDFHandlerException {
	for (Reference reference : references) {
		Resource resource = this.referenceRdfConverter
				.addReference(reference);
		this.rdfWriter.writeTripleValueObject(statementResource,
				RdfWriter.PROV_WAS_DERIVED_FROM, resource);
	}
}
 
Example 25
Source Project: powsybl-core   Source File: TripleStoreRDF4J.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void clear(String contextName) {
    try (RepositoryConnection conn = repo.getConnection()) {
        Resource context = context(conn, contextName);
        conn.clear(context);
    }
}
 
Example 26
@Override
public Resource export(Model model) {
	Resource implNode = super.export(model);
	if (null != this.proxiedID) {
		model.setNamespace("proxy", ProxyRepositorySchema.NAMESPACE);
		model.add(implNode, ProxyRepositorySchema.PROXIED_ID,
				SimpleValueFactory.getInstance().createLiteral(this.proxiedID));
	}
	return implNode;
}
 
Example 27
@Override
public void clear(Resource... contexts) throws SailException {
	if (Arrays.asList(contexts).contains(RDF4J.SHACL_SHAPE_GRAPH)) {
		shapesRepoConnection.clear();
		isShapeRefreshNeeded = true;
	}
	super.clear(contexts);
}
 
Example 28
private void clearContexts(Resource... contexts) throws IOException {
	logger.debug("clearing contexts...");
	luceneIndex.begin();
	try {
		luceneIndex.clearContexts(contexts);
		luceneIndex.commit();
	} catch (IOException e) {
		logger.error("Rolling back", e);
		luceneIndex.rollback();
		throw e;
	}
}
 
Example 29
private void addStatement(
    RepositoryConnection cnx,
    String property,
    PropertyBag object,
    Map<PropertyBag, IRI> objectSubject) {

    IRI predicate = cnx.getValueFactory().createIRI(objectType + "." + property);
    Literal value = cnx.getValueFactory().createLiteral(object.get(property));
    Statement st = cnx.getValueFactory().createStatement(
        subject(cnx, object, objectSubject),
        predicate,
        value);
    Resource context = cnx.getValueFactory().createIRI(qualifiedContextName);
    cnx.add(st, context);
}
 
Example 30
Source Project: rdf4j   Source File: UtilTest.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public final void testContextsInvalid() {
	String[] tokens = { "command", "invalid" };

	try {
		Resource[] ctxs = Util.getContexts(tokens, 1, repo);
		fail("No exception generated");
	} catch (IllegalArgumentException expected) {
	}
}