Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 202064 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/cdo/tests/InitialTest.java (+81 lines)
Lines 14-19 Link Here
14
import org.eclipse.emf.cdo.CDOState;
14
import org.eclipse.emf.cdo.CDOState;
15
import org.eclipse.emf.cdo.CDOTransaction;
15
import org.eclipse.emf.cdo.CDOTransaction;
16
import org.eclipse.emf.cdo.eresource.CDOResource;
16
import org.eclipse.emf.cdo.eresource.CDOResource;
17
import org.eclipse.emf.cdo.protocol.CDOID;
17
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
18
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
18
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
19
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
19
import org.eclipse.emf.cdo.tests.model1.Supplier;
20
import org.eclipse.emf.cdo.tests.model1.Supplier;
Lines 22-32 Link Here
22
import org.eclipse.net4j.IBufferHandler;
23
import org.eclipse.net4j.IBufferHandler;
23
import org.eclipse.net4j.IChannel;
24
import org.eclipse.net4j.IChannel;
24
25
26
import org.eclipse.emf.common.notify.Notification;
25
import org.eclipse.emf.common.util.EList;
27
import org.eclipse.emf.common.util.EList;
26
import org.eclipse.emf.common.util.URI;
28
import org.eclipse.emf.common.util.URI;
27
import org.eclipse.emf.ecore.EObject;
29
import org.eclipse.emf.ecore.EObject;
28
import org.eclipse.emf.ecore.resource.ResourceSet;
30
import org.eclipse.emf.ecore.resource.ResourceSet;
29
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
31
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
32
import org.eclipse.emf.ecore.util.EContentAdapter;
33
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
34
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
30
35
31
import java.util.Date;
36
import java.util.Date;
32
37
Lines 624-627 Link Here
624
    msg("Verifying name");
629
    msg("Verifying name");
625
    assertEquals("Stepper", s.getName());
630
    assertEquals("Stepper", s.getName());
626
  }
631
  }
632
633
  public void testContentAdapterUsingCDOResource() throws Exception
634
  {
635
	final boolean notified[] = new boolean[1];
636
	
637
	EContentAdapter contentAdapter = new EContentAdapter()
638
	{
639
	  public void notifyChanged(Notification notification)
640
	  {
641
	  	    super.notifyChanged(notification);
642
	  	    notified[0] = true;
643
	  }
644
	  protected boolean resolve()
645
	  {
646
	    return false;
647
	  }	  
648
	};
649
	CDOID supplierID = null;
650
	{
651
		CDOSession session = openModel1Session();
652
		CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
653
		 
654
		CDOResource resource = transaction.createResource("/test2");
655
	
656
	    resource.eAdapters().add( contentAdapter );
657
	    
658
	    Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
659
	    
660
	    resource.getContents().add( supplier );
661
	    notified[0] = false;
662
	    
663
	    // contentAdapter should receive notification
664
	    supplier.setName("HELLO");
665
	    
666
	    assertEquals(true, notified[0]);
667
	    
668
	    supplierID = supplier.cdoID();
669
	    
670
	    transaction.commit();
671
	    
672
	    supplierID = supplier.cdoID();
673
	    
674
	    transaction.close();
675
	    session.close();
676
	}
677
	{
678
		CDOSessionImpl session = (CDOSessionImpl)openModel1Session();
679
		
680
		CDOFetchRuleManagerInfo info = new CDOFetchRuleManagerInfo();
681
		session.getRevisionManager().setRuleManager(info);
682
		
683
		CDOTransactionImpl transaction = session.openTransaction(new ResourceSetImpl());
684
		CDOResource resource = transaction.getResource("/test2");
685
		
686
		// I don't want to fetch my objects!!
687
688
	    resource.eAdapters().add( contentAdapter );
689
	    
690
	    // By adding an adapter, we shouldn`t fetch objects
691
	    assertEquals(false, info.getOIDSet().contains(supplierID));
692
	    
693
	    Supplier supplier = (Supplier)transaction.getObject(supplierID);
694
	    
695
	    notified[0] = false;
696
	    
697
	    // contentAdapter should receive notification
698
	    supplier.setName("HELLO");
699
	    
700
	    // Should have been notified!!
701
	    assertEquals(true, notified[0]);
702
	    
703
	    transaction.commit();
704
	    transaction.close();
705
	}
706
  }
707
        
627
}
708
}
(-)src/org/eclipse/emf/cdo/tests/CDOFetchRuleManagerInfo.java (+60 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Simon McDuff - initial API and implementation
10
 **************************************************************************/
11
12
package org.eclipse.emf.cdo.tests;
13
14
import java.util.Collection;
15
import java.util.HashSet;
16
import java.util.List;
17
18
import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager;
19
import org.eclipse.emf.cdo.internal.protocol.CDOIDNull;
20
import org.eclipse.emf.cdo.protocol.CDOID;
21
import org.eclipse.emf.cdo.protocol.analyzer.CDOFetchRule;
22
/**
23
 * @author Simon McDuff
24
 */
25
public class CDOFetchRuleManagerInfo implements CDOFetchRuleManager 
26
{
27
28
	private HashSet<CDOID> objectFetchs = new HashSet<CDOID>(); 
29
	
30
	public CDOID getContext() 
31
	{
32
		// TODO Auto-generated method stub
33
		return CDOIDNull.NULL;
34
	}
35
	
36
	public void clear()
37
	{
38
		objectFetchs.clear();
39
	}
40
	public HashSet<CDOID> getOIDSet()
41
	{
42
		return objectFetchs;
43
	}
44
	public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) 
45
	{
46
		// accumulate changes
47
		for (CDOID id : ids)
48
		{
49
			objectFetchs.add(id);
50
		}	
51
		return null;
52
	}
53
54
	public int getLoadRevisionCollectionChunkSize() 
55
	{
56
		// TODO Auto-generated method stub
57
		return 0;
58
	}
59
60
}

Return to bug 202064