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.client;
15 import org.junit.Test;
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.DebugSupport;
20 import org.simantics.db.testing.base.TestCommonNoVirtual;
21 import org.simantics.db.testing.common.Client;
22 import org.simantics.db.testing.common.ClientFactory;
24 @SuppressWarnings("deprecation") // No replacement given so now way to fix this error.
25 public class ReserveIdsTest2 extends TestCommonNoVirtual {
27 private String nextId;
30 public void test() throws DatabaseException {
31 // ServerAddress serverAddress = getSessionContext().getAddress();
32 String clientId = getRandomString();
33 Client client1 = ClientFactory.create(clientId);
35 client1.getSession().syncRequest(new WriteRequest() {
37 public void perform(WriteGraph graph) throws DatabaseException {
40 nextId = graph.getService(DebugSupport.class).query(graph, "print nextId");
46 Client client2 = ClientFactory.create(clientId);
48 client2.getSession().syncRequest(new WriteRequest() {
50 public void perform(WriteGraph graph) throws DatabaseException {
51 String nextId = graph.getService(DebugSupport.class).query(graph, "print nextId");
52 //assertTrue(nextId.equals(ReserveIdsTest2.this.nextId));
53 int i1 = Integer.parseInt(nextId.substring(0, nextId.indexOf('#')));
54 String t = ReserveIdsTest2.this.nextId;
55 int i2 = Integer.parseInt(t.substring(0, t.indexOf('#')));
56 assertTrue(i1 == i2+1);