]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/ClaimIntoNewResourceAfterIntermediateClusterCollect2.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 / ClaimIntoNewResourceAfterIntermediateClusterCollect2.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.db.Resource;
16 import org.simantics.db.WriteGraph;
17 import org.simantics.db.common.request.WriteRequest;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.service.ClusterControl;
20 import org.simantics.db.testing.base.ExistingDatabaseTest;
21
22 /**
23  * 
24  * @author Antti Villberg
25  *
26  */
27 public class ClaimIntoNewResourceAfterIntermediateClusterCollect2 extends ExistingDatabaseTest {
28         
29         @Test
30         public void test() throws Exception{
31
32                 getSession().syncRequest(new WriteRequest() {
33                     @Override
34                     public void perform(WriteGraph graph) throws DatabaseException {
35
36                         // Start new cluster
37                         graph.flushCluster();
38                         // Create a resource
39                         graph.newResource();
40                         
41                     }
42                 });
43
44                 getSession().syncRequest(new WriteRequest() {
45                     @Override
46                     public void perform(WriteGraph graph) throws DatabaseException {
47
48                         // Create some resources
49                         for(int i=0;i<1000;i++) graph.newResource();
50                         
51                         // Create and store a resource
52                         Resource target = graph.newResource();
53
54                         // Flush clusters including the one just created
55                         getSession().getService(ClusterControl.class).collectClusters(Integer.MAX_VALUE);
56
57                         // Write into the stored resource
58                         graph.claim(target, target, target);
59                         
60                     }
61                 });
62                 
63         }
64
65 }