1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.api.write.claimLiteral;
14 import org.junit.Test;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.Session;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.common.request.ReadRequest;
20 import org.simantics.db.common.request.WriteResultRequest;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.testing.base.ExistingDatabaseTest;
23 import org.simantics.layer0.Layer0;
26 public class WriteUntypedL0Literal extends ExistingDatabaseTest {
29 public void test() throws Exception {
31 Session session = getSession();
33 final Resource literal = session.syncRequest(new WriteResultRequest<Resource>() {
36 public Resource perform(WriteGraph graph) throws DatabaseException {
38 Resource literal = graph.newResource();
39 Layer0 b = Layer0.getInstance(graph);
40 graph.claimLiteral(literal, b.HasProperty, new String("test"));
47 session.syncRequest(new ReadRequest() {
50 public void run(ReadGraph graph) throws DatabaseException {
51 Layer0 b = Layer0.getInstance(graph);
52 String s = graph.getRelatedValue(literal, b.HasProperty);
54 assert(s.equals("test"));