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.regression.bugs;
14 import org.junit.After;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.Session;
20 import org.simantics.db.WriteGraph;
21 import org.simantics.db.common.request.ReadRequest;
22 import org.simantics.db.common.request.WriteRequest;
23 import org.simantics.db.exception.DatabaseException;
24 import org.simantics.db.testing.annotation.Fails;
25 import org.simantics.db.testing.base.ExistingDatabaseTest;
26 import org.simantics.db.testing.common.Terminator;
29 * Tests that sync read within sync write causes exception.
30 * Currently this tests causes deadlock.
32 public class SyncWriteReadTest1 extends ExistingDatabaseTest {
33 final boolean DEBUG = true;
34 final String resourceName = "r1";
36 private Terminator terminator;
40 public void setUp() throws Exception {
42 terminator = new Terminator(3);
47 public void tearDown() throws Exception {
54 public void testSyncWriteReadTest1() throws Exception {
55 final Session session = getSession();
57 session.syncRequest(new WriteRequest() {
59 public void perform(WriteGraph graph) throws DatabaseException {
61 session.sync(new ReadRequest() {
63 public void run(ReadGraph graph) throws DatabaseException {
64 Resource root = graph.getResource(ROOT_LIBRARY_URI);
65 assertTrue("Failed to get root library.", null == root);
68 fail("Missing exception during read request.");
69 } catch (DatabaseException e) {
71 System.out.println("Catched DatabaseException as expected.");
75 } catch (DatabaseException e) {
77 System.out.println("Catched DatabaseException as excepected:" + e.getMessage());
80 fail("Sync write failed to throw exception as expected.");