]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getSingleStatement/GetSingleStatementTest23.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / readGraph / getSingleStatement / GetSingleStatementTest23.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.tests.api.readGraph.getSingleStatement;
13
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;
20
21 /**
22  * Tests cases where a non-functional relation uses
23  * {@link ReadGraph#getSingleObject(org.simantics.db.Resource, org.simantics.db.Resource)}
24  * with > 1 objects.
25  * 
26  * <p>
27  * Should throw {@link NoSingleResultException}, at the time of writing this
28  * test, AsyncBarrierImpl refcounting is trashed and DB client is stuck.
29  */
30 public class GetSingleStatementTest23 extends WriteReadTest {
31         private Resource subject1;
32         private Resource relation1;
33         private Resource object1;
34
35         @Override
36         protected void write(WriteGraph graph) throws DatabaseException {
37
38                 relation1 = graph.newResource();
39                 graph.claim(relation1, L0.SubrelationOf, L0.IsRelatedTo);
40
41                 //Resource rel2 = graph.newResource();
42                 //graph.claim(rel2, L0.SubrelationOf, relation1);
43
44                 subject1 = graph.newResource();
45                 graph.claim(subject1, L0.InstanceOf, L0.Entity);
46
47                 object1 = graph.newResource();
48                 Resource o2 = graph.newResource();
49
50                 graph.claim(subject1, relation1, object1);
51                 graph.claim(subject1, relation1, o2);
52         }
53
54         @Override
55         protected void read(ReadGraph graph) throws DatabaseException {
56                 try {
57
58                         assertNotNull("Null not allowed", graph.getSingleStatement(subject1, relation1));
59                         //assertTrue("Wrong object was returned", (object1.equals(object)));
60
61                 } catch (NoSingleResultException e) {
62                         //System.out.println("Read transaction threw an expected exception "
63                         //              + e);
64                         return;
65                 } catch (Throwable e) {
66                         fail("Read transaction threw an unexpected exception " + e);
67                 }
68                 fail("Should throw");
69
70                 /*
71                  * try {
72                  * 
73                  * graph.claim(subject1, relation1, relation1);
74                  * 
75                  * } catch (Throwable e) {
76                  * fail("Write transaction threw an unknown exception " + e); }
77                  */
78         }
79
80 }