Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ff0fcea2e29cdd3d975fb2cca29d61ba1be9418b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/***************************************************************************
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, Germany.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/
package org.eclipse.emf.cdo.tests.model1;


import org.eclipse.emf.ecore.resource.Resource;

import testmodel1.TreeNode;
import junit.framework.ComparisonFailure;


public class NotificationTest extends AbstractModel1Test
{
  public void testOneConnection() throws Exception
  {
    final String RESOURCE = "/test/res";
    final String ROOT = "root";
    final String NEW_ROOT = "new root";
    final long TIME_LIMIT = 100;

    // Client1 creates resource
    TreeNode root = createNode(ROOT);
    saveRoot(root, RESOURCE);

    // Client2 loads resource
    TreeNode loaded = (TreeNode) loadRoot(RESOURCE);

    // Client1 modifies and commits resource
    root.setStringFeature(NEW_ROOT);
    Resource resource = root.eResource();
    resource.save(null);

    // Give server and client2 enough time to get notified
    long start = System.currentTimeMillis();
    try
    {
      assertNode(NEW_ROOT, loaded);
    }
    catch (ComparisonFailure ex)
    {
      long duration = System.currentTimeMillis() - start;
      if (duration > TIME_LIMIT) throw ex;
      Thread.sleep(1);
    }
  }
}

Back to the top