]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/ClaimIntoNewResourceAfterIntermediateClusterCollect.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 / ClaimIntoNewResourceAfterIntermediateClusterCollect.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 ClaimIntoNewResourceAfterIntermediateClusterCollect 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                         
39                         // Create some resources
40                         for(int i=0;i<1000;i++) graph.newResource();
41                         
42                         // Create and store a resource
43                         Resource target = graph.newResource();
44
45                         // Flush clusters including the one just created
46                         getSession().getService(ClusterControl.class).collectClusters(Integer.MAX_VALUE);
47
48                         // Write into the stored resource
49                         graph.claim(target, target, target);
50                         
51                     }
52                 });
53                 
54         }
55
56 }