]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/QueryCollectedResourceTest.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / support / clusterControl / QueryCollectedResourceTest.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.support.clusterControl;
13
14 import org.junit.Test;
15 import org.simantics.databoard.Bindings;
16 import org.simantics.db.Resource;
17 import org.simantics.db.WriteGraph;
18 import org.simantics.db.common.primitiverequest.HasStatementSubject;
19 import org.simantics.db.service.ClusterControl;
20 import org.simantics.db.testing.base.ExistingDatabaseTest;
21 import org.simantics.db.testing.common.WriteQuery;
22 import org.simantics.layer0.Layer0;
23 import org.simantics.utils.DataContainer;
24
25 /**
26  * Creates large amount of instances in multiple transactions
27  * and the tries to verify that instances are written into the database.
28  * 
29  * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
30  *
31  */
32 public class QueryCollectedResourceTest extends ExistingDatabaseTest {
33
34         @Test
35     public void test() throws Exception{
36
37         final Resource rootLib = getSession().getRootLibrary();
38         final DataContainer<Resource> foreign = new DataContainer<Resource>();
39
40         getSession().syncRequest(new HasStatementSubject(rootLib));
41
42         getSession().syncRequest(new WriteQuery(this) {
43             @Override
44             public void run(WriteGraph g) throws Throwable {
45
46                 Layer0 b = Layer0.getInstance(g);
47                 g.flushCluster();
48                 Resource f = g.newResource();
49                 g.claim(f, b.InstanceOf, b.Type);
50                 g.claimValue(f, "", Bindings.STRING);
51                 foreign.set(f);
52
53             }
54
55         });
56
57         ClusterControl support = getSession().getService(ClusterControl.class);
58         support.collectClusters(Integer.MAX_VALUE);
59
60         getSession().syncRequest(new WriteQuery(this) {
61             @Override
62             public void run(WriteGraph g) throws Throwable {
63
64                 g.getValue(foreign.get(), Bindings.STRING);
65
66             }
67
68         });
69
70         checkException();
71
72     }
73
74 }