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.readGraph.getSingleStatement;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.WriteGraph;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.exception.NoSingleResultException;
19 import org.simantics.db.testing.base.WriteReadTest;
22 * Tests cases where a non-functional relation uses
23 * {@link ReadGraph#getSingleObject(org.simantics.db.Resource, org.simantics.db.Resource)}
27 * Should throw {@link NoSingleResultException}, at the time of writing this
28 * test, AsyncBarrierImpl refcounting is trashed and DB client is stuck.
30 public class GetSingleStatementTest23 extends WriteReadTest {
31 private Resource subject1;
32 private Resource relation1;
33 private Resource object1;
36 protected void write(WriteGraph graph) throws DatabaseException {
38 relation1 = graph.newResource();
39 graph.claim(relation1, L0.SubrelationOf, L0.IsRelatedTo);
41 //Resource rel2 = graph.newResource();
42 //graph.claim(rel2, L0.SubrelationOf, relation1);
44 subject1 = graph.newResource();
45 graph.claim(subject1, L0.InstanceOf, L0.Entity);
47 object1 = graph.newResource();
48 Resource o2 = graph.newResource();
50 graph.claim(subject1, relation1, object1);
51 graph.claim(subject1, relation1, o2);
55 protected void read(ReadGraph graph) throws DatabaseException {
58 assertNotNull("Null not allowed", graph.getSingleStatement(subject1, relation1));
59 //assertTrue("Wrong object was returned", (object1.equals(object)));
61 } catch (NoSingleResultException e) {
62 //System.out.println("Read transaction threw an expected exception "
65 } catch (Throwable e) {
66 fail("Read transaction threw an unexpected exception " + e);
73 * graph.claim(subject1, relation1, relation1);
75 * } catch (Throwable e) {
76 * fail("Write transaction threw an unknown exception " + e); }