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.api.request.external;
14 import java.util.concurrent.Semaphore;
16 import org.junit.Test;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Session;
19 import org.simantics.db.procedure.Listener;
20 import org.simantics.db.request.ExternalRead;
21 import org.simantics.db.testing.annotation.Fails;
22 import org.simantics.db.testing.base.ExistingDatabaseTest;
24 public class ExternalRequestTest2 extends ExistingDatabaseTest {
28 private Error exception;
34 public void test() throws Exception {
36 Session session = getSession();
38 final Semaphore s = new Semaphore(1-COUNT);
40 session.syncRequest(new ExternalRead<String>() {
43 public void register(ReadGraph graph, final Listener<String> procedure) {
45 for(int i=0;i<COUNT;i++) {
46 System.err.println("execute: " + "String" + counter);
47 procedure.execute("String" + counter);
54 public void unregistered() {
55 System.err.println("unregistered");
58 }, new Listener<String>() {
61 public void exception(Throwable t) {
65 public void execute(String result) {
66 new Exception("execute2 " + result).printStackTrace();
71 public boolean isDisposed() {
79 if(exception != null) {
80 fail("Write transaction threw and exception (" + exception.getMessage() + ") which was not passed through ");