You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2007/09/12 11:48:03 UTC

svn commit: r574865 - in /incubator/tuscany/java/sca/modules/policy-xml/src: main/java/org/apache/tuscany/sca/policy/xml/ test/java/org/apache/tuscany/sca/policy/xml/

Author: svkrish
Date: Wed Sep 12 02:48:02 2007
New Revision: 574865

URL: http://svn.apache.org/viewvc?rev=574865&view=rev
Log:
removing SCA Definitions related things, adding resolver code to policy processors

Added:
    incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestModelResolver.java
Removed:
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilder.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderException.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsResolver.java
Modified:
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
    incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
    incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java?rev=574865&r1=574864&r2=574865&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java Wed Sep 12 02:48:02 2007
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.policy.xml;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -156,54 +157,66 @@
     }
     
     public void resolve(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
+        resolveAlwaysProvidedIntents(extnType, resolver);
+        resolveMayProvideIntents(extnType, resolver);
         resolveExtensionType(extnType, resolver);
-
+        
         if ( !extnType.isUnresolved() ) {
              resolver.addModel(extnType);
         }
     }
 
-    //FIXME This method is never used
-//    private void resolveAlwaysProvidedIntents(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
-//        boolean isUnresolved = false;
-//        if (extnType != null && extnType.isUnresolved()) {
-//            //resolve alwaysProvided Intents
-//            List<Intent> alwaysProvided = new ArrayList<Intent>(); 
-//            for ( Intent providedIntent : extnType.getAlwaysProvidedIntents() ) {
-//                if ( providedIntent.isUnresolved() ) {
-//                    providedIntent = resolver.resolveModel(Intent.class, providedIntent);
-//                    alwaysProvided.add(providedIntent);
-//                    if (providedIntent.isUnresolved()) {
-//                        isUnresolved = true;
-//                    }
-//                }
-//            }
-//            extnType.getAlwaysProvidedIntents().clear();
-//            extnType.getAlwaysProvidedIntents().addAll(alwaysProvided);
-//        }
-//        extnType.setUnresolved(isUnresolved);
-//    }
-
-    //FIXME This method is never used
-//    private void resolveMayProvideIntents(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
-//        boolean isUnresolved = false;
-//        if (extnType != null && extnType.isUnresolved()) {
-//            //resolve may provide Intents
-//            List<Intent> mayProvide = new ArrayList<Intent>(); 
-//            for ( Intent providedIntent : extnType.getMayProvideIntents() ) {
-//                if ( providedIntent.isUnresolved() ) {
-//                    providedIntent = resolver.resolveModel(Intent.class, providedIntent);
-//                    mayProvide.add(providedIntent);
-//                    if (providedIntent.isUnresolved()) {
-//                        isUnresolved = true;
-//                    }
-//                }
-//            }
-//            extnType.getAlwaysProvidedIntents().clear();
-//            extnType.getAlwaysProvidedIntents().addAll(mayProvide);
-//        }
-//        extnType.setUnresolved(isUnresolved);
-//    }
+    private void resolveAlwaysProvidedIntents(IntentAttachPointType extensionType,
+                                              ModelResolver resolver) throws ContributionResolveException {
+        if (extensionType != null) {
+            // resolve all provided intents
+            List<Intent> alwaysProvided = new ArrayList<Intent>();
+            for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+                if (providedIntent.isUnresolved()) {
+                    Intent resolvedProvidedIntent = resolver.resolveModel(Intent.class, providedIntent);
+                    if (resolvedProvidedIntent != null) {
+                        alwaysProvided.add(resolvedProvidedIntent);
+                    } else {
+                        throw new ContributionResolveException(
+                                                                 "Always Provided Intent - " + providedIntent
+                                                                     + " not found for ExtensionType "
+                                                                     + extensionType);
+
+                    }
+                } else {
+                    alwaysProvided.add(providedIntent);
+                }
+            }
+            extensionType.getAlwaysProvidedIntents().clear();
+            extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+        }
+    }
+    
+    private void resolveMayProvideIntents(IntentAttachPointType extensionType,
+                                            ModelResolver resolver) throws ContributionResolveException {
+        if (extensionType != null) {
+            // resolve all provided intents
+            List<Intent> mayProvide = new ArrayList<Intent>();
+            for (Intent providedIntent : extensionType.getMayProvideIntents()) {
+                if (providedIntent.isUnresolved()) {
+                    Intent resolvedProvidedIntent = resolver.resolveModel(Intent.class, providedIntent);
+                    if (resolvedProvidedIntent != null) {
+                        mayProvide.add(resolvedProvidedIntent);
+                    } else {
+                        throw new ContributionResolveException(
+                                                                 "May Provide Intent - " + providedIntent
+                                                                     + " not found for ExtensionType "
+                                                                     + extensionType);
+
+                    }
+                } else {
+                    mayProvide.add(providedIntent);
+                }
+            }
+            extensionType.getMayProvideIntents().clear();
+            extensionType.getMayProvideIntents().addAll(mayProvide);
+        }
+    }
     
     public Class<IntentAttachPointType> getModelType() {
         return IntentAttachPointType.class;

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java?rev=574865&r1=574864&r2=574865&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java Wed Sep 12 02:48:02 2007
@@ -22,6 +22,7 @@
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -200,7 +201,63 @@
         policyIntent.setUnresolved(false);
     }
     
+    private void resolveProfileIntent(ProfileIntent policyIntent, ModelResolver resolver)
+        throws ContributionResolveException {
+        // FIXME: Need to check for cyclic references first i.e an A requiring B
+        // and then B requiring A...
+        if (policyIntent != null) {
+            // resolve all required intents
+            List<Intent> requiredIntents = new ArrayList<Intent>();
+            for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+                if (requiredIntent.isUnresolved()) {
+                    Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
+                    if (resolvedRequiredIntent != null) {
+                        requiredIntents.add(resolvedRequiredIntent);
+                    } else {
+                        throw new ContributionResolveException(
+                                                                 "Required Intent - " + requiredIntent
+                                                                     + " not found for ProfileIntent "
+                                                                     + policyIntent);
+
+                    }
+                } else {
+                    requiredIntents.add(requiredIntent);
+                }
+            }
+            policyIntent.getRequiredIntents().clear();
+            policyIntent.getRequiredIntents().addAll(requiredIntents);
+        }
+    }
+
+    private void resolveQualifiedIntent(QualifiedIntent policyIntent, ModelResolver resolver)
+        throws ContributionResolveException {
+        if (policyIntent != null) {
+            //resolve the qualifiable intent
+            Intent qualifiableIntent = policyIntent.getQualifiableIntent();
+            if (qualifiableIntent.isUnresolved()) {
+                Intent resolvedQualifiableIntent = resolver.resolveModel(Intent.class, qualifiableIntent);
+    
+                if (resolvedQualifiableIntent != null) {
+                    policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
+                } else {
+                    throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
+                        + " not found for QualifiedIntent "
+                        + policyIntent);
+                }
+    
+            }
+        }
+    }
+    
     public void resolve(T policyIntent, ModelResolver resolver) throws ContributionResolveException {
+        if (policyIntent instanceof ProfileIntent) {
+            resolveProfileIntent((ProfileIntent)policyIntent, resolver);
+        }
+
+        if (policyIntent instanceof QualifiedIntent) {
+            resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver);
+        }
+        
         resolveContrainedArtifacts(policyIntent, resolver);
         
         if ( !policyIntent.isUnresolved() ) {

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java?rev=574865&r1=574864&r2=574865&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java Wed Sep 12 02:48:02 2007
@@ -23,6 +23,7 @@
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -269,16 +270,7 @@
        policySet.setUnresolved(unresolved);
    }
    
-   public void resolve(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
-       if ( policySet.isUnresolved() ) {
-           //resolve the policy attachments
-           resolvePolicies(policySet, resolver);
-            
-           if ( !policySet.isUnresolved() ) {
-                resolver.addModel(policySet);
-           }
-       }
-    }   
+   
     
     public QName getArtifactType() {
         return POLICY_SET_QNAME;
@@ -340,4 +332,99 @@
         }
     }
     
-}
+    private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+        if (policySet != null) {
+            //resolve all provided intents
+            List<Intent> providedIntents = new ArrayList<Intent>();
+            for (Intent providedIntent : policySet.getProvidedIntents()) {
+                if (providedIntent.isUnresolved()) {
+                    Intent resolvedProvidedIntent = resolver.resolveModel(Intent.class, providedIntent);
+                    if (resolvedProvidedIntent != null) {
+                        providedIntents.add(resolvedProvidedIntent);
+                    } else {
+                        throw new ContributionResolveException("Provided Intent - " + providedIntent
+                            + " not found for PolicySet "
+                            + policySet);
+
+                    }
+                } else {
+                    providedIntents.add(providedIntent);
+                }
+            }
+            policySet.getProvidedIntents().clear();
+            policySet.getProvidedIntents().addAll(providedIntents);
+        }
+     }
+    
+    private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+        Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
+        for (Map.Entry<Intent, List<Object>> entry : policySet.getMappedPolicies().entrySet()) {
+            Intent mappedIntent = entry.getKey();
+            if (mappedIntent.isUnresolved()) {
+                Intent resolvedMappedIntent = resolver.resolveModel(Intent.class, mappedIntent);
+    
+                if (resolvedMappedIntent != null) {
+                    mappedPolicies.put(resolvedMappedIntent, entry.getValue());
+                } else {
+                    throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+                        + " not found for PolicySet "
+                        + policySet);
+    
+                }
+            } else {
+                mappedPolicies.put(mappedIntent, entry.getValue());
+            }
+        }
+
+        policySet.getMappedPolicies().clear();
+        policySet.getMappedPolicies().putAll(mappedPolicies);
+    }
+    
+    private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+    
+        List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+        for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+            if (referredPolicySet.isUnresolved()) {
+                PolicySet resolvedReferredPolicySet = resolver.resolveModel(PolicySet.class, referredPolicySet);
+                if (resolvedReferredPolicySet != null) {
+                    referredPolicySets.add(resolvedReferredPolicySet);
+                } else {
+                    throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
+                        + "not found for PolicySet - "
+                        + policySet);
+                }
+            } else {
+                referredPolicySets.add(referredPolicySet);
+            }
+        }
+        policySet.getReferencedPolicySets().clear();
+        policySet.getReferencedPolicySets().addAll(referredPolicySets);
+    }
+    
+    private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+        for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+            includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+        }
+        policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+        policySet.getMappedPolicies().putAll(referredPolicySet.getMappedPolicies());
+    }
+    
+    public void resolve(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+        resolveProvidedIntents(policySet, resolver);
+        resolveIntentsInMappedPolicies(policySet, resolver);
+        resolveReferredPolicySets(policySet, resolver);
+        
+        for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+            includeReferredPolicySets(policySet, referredPolicySet);
+        }
+        
+        if ( policySet.isUnresolved() ) {
+            //resolve the policy attachments
+            resolvePolicies(policySet, resolver);
+             
+            if ( !policySet.isUnresolved() ) {
+                 resolver.addModel(policySet);
+            }
+        }
+     }   
+ }

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java?rev=574865&r1=574864&r2=574865&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java Wed Sep 12 02:48:02 2007
@@ -19,7 +19,9 @@
 
 package org.apache.tuscany.sca.policy.xml;
 
-import java.net.URI;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.io.InputStream;
 import java.net.URL;
 import java.util.Hashtable;
 import java.util.Map;
@@ -27,6 +29,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
 
 import junit.framework.TestCase;
 
@@ -43,7 +46,8 @@
 import org.apache.tuscany.sca.policy.PolicySet;
 import org.apache.tuscany.sca.policy.ProfileIntent;
 import org.apache.tuscany.sca.policy.QualifiedIntent;
-import org.apache.tuscany.sca.policy.SCADefinitions;
+import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
+import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
 
 /**
  * Test reading SCA XML assembly documents.
@@ -52,9 +56,12 @@
  */
 public class ReadDocumentTestCase extends TestCase {
 
-    //private ModelResolver resolver; 
-    private SCADefinitionsDocumentProcessor scaDefnDocProcessor = null;
-    private SCADefinitions scaDefinitions;
+    //private ModelResolver resolver;
+    PolicySetProcessor policySetProcessor;
+    TestModelResolver resolver = null;
+    ExtensibleStAXArtifactProcessor staxProcessor = null;
+    
+        
     Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
     Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
     Map<QName, IntentAttachPointType> bindingTypesTable = new Hashtable<QName, IntentAttachPointType>();
@@ -77,23 +84,13 @@
 
     @Override
     public void setUp() throws Exception {
+        resolver = new TestModelResolver();
         XMLInputFactory inputFactory = XMLInputFactory.newInstance();
         PolicyFactory policyFactory = new DefaultPolicyFactory();
         IntentAttachPointTypeFactory intentAttachPointFactory = new DefaultIntentAttachPointTypeFactory();
-        
-        // Create Stax processors
         DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint());
-        ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
-        staxProcessors.addArtifactProcessor(new MockPolicyProcessor());
-        
-        scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, 
-                                                                  staxProcessor, 
-                                                                  inputFactory, 
-                                                                  policyFactory);
+        staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
         
-        /*scaDefnProcessor = new SCADefinitionsProcessor(policyFactory, staxProcessor, resolver);
-        
-        staxProcessors.addArtifactProcessor(scaDefnProcessor);
         staxProcessors.addArtifactProcessor(new SimpleIntentProcessor(policyFactory, staxProcessor));
         staxProcessors.addArtifactProcessor(new ProfileIntentProcessor(policyFactory, staxProcessor));
         staxProcessors.addArtifactProcessor(new QualifiedIntentProcessor(policyFactory, staxProcessor));
@@ -101,37 +98,52 @@
         staxProcessors.addArtifactProcessor(new ImplementationTypeProcessor(policyFactory, intentAttachPointFactory, staxProcessor));
         staxProcessors.addArtifactProcessor(new BindingTypeProcessor(policyFactory, intentAttachPointFactory, staxProcessor));
         staxProcessors.addArtifactProcessor(new MockPolicyProcessor());
-        */
         
         URL url = getClass().getResource("test_definitions.xml");
-        URI uri = URI.create("definitions.xml");
-        scaDefinitions = scaDefnDocProcessor.read(null, uri, url);
-        
-        for ( Intent intent : scaDefinitions.getPolicyIntents() ) {
-            intentTable.put(intent.getName(), intent);
-        }
-        
-        for ( PolicySet policySet : scaDefinitions.getPolicySets() ) {
-            policySetTable.put(policySet.getName(), policySet);
-        }
-        
-        for ( IntentAttachPointType bindingType : scaDefinitions.getBindingTypes() ) {
-            bindingTypesTable.put(bindingType.getName(), bindingType);
-        }
-        
-        for ( IntentAttachPointType implType : scaDefinitions.getImplementationTypes() ) {
-            implTypesTable.put(implType.getName(), implType);
+        InputStream urlStream = url.openStream();
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+        QName name = null;
+        reader.next();
+        while ( true ) {
+            int event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT: {
+                    Object artifact = staxProcessor.read(reader);
+                    if ( artifact instanceof PolicySet ) {
+                        PolicySet policySet = (PolicySet)artifact;
+                        policySetTable.put(policySet.getName(), policySet);
+                    } else if ( artifact instanceof Intent ) {
+                        Intent intent = (Intent)artifact;
+                        intentTable.put(intent.getName(), intent);
+                    } else if ( artifact instanceof BindingTypeImpl ) {
+                        IntentAttachPointType bindingType = (IntentAttachPointType)artifact;
+                        bindingTypesTable.put(bindingType.getName(), bindingType);
+                    } else if ( artifact instanceof ImplementationTypeImpl ) {
+                        IntentAttachPointType implType = (IntentAttachPointType)artifact;
+                        implTypesTable.put(implType.getName(), implType);
+                    }
+                    
+                    if ( artifact != null ) {
+                        resolver.addModel(artifact);
+                    }
+                    
+                    break;
+                }
+            }
+            if ( reader.hasNext() ) {
+                reader.next();
+            } else {
+                break;
+            }
         }
+        urlStream.close();
     }
 
     @Override
     public void tearDown() throws Exception {
-        scaDefnDocProcessor = null;
     }
 
     public void testReadSCADefinitions() throws Exception {
-        assertNotNull(scaDefinitions);
-        
         assertNotNull(intentTable.get(confidentiality));
         assertNotNull(intentTable.get(messageProtection));
         assertNotNull(intentTable.get(confidentiality_transport));
@@ -151,7 +163,7 @@
         assertNotNull(implTypesTable.get(javaImpl));
     }
     
-    public void testResolveSCADefinitions() throws Exception {
+    public void testResolution() throws Exception {
         assertTrue(intentTable.get(messageProtection) instanceof ProfileIntent);
         ProfileIntent profileIntent = (ProfileIntent)intentTable.get(new QName(namespace, "messageProtection"));
         assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
@@ -183,8 +195,23 @@
         assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
         assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
         
-        scaDefnDocProcessor.resolve(scaDefinitions, null);
-        //builder.build(scaDefinitions);
+        for ( Intent intent : intentTable.values() ) {
+            staxProcessor.resolve(intent, resolver);
+        }
+        
+        for ( PolicySet policySet : policySetTable.values() ) {
+            staxProcessor.resolve(policySet, resolver);
+        }
+        
+        for (  IntentAttachPointType bindingType : bindingTypesTable.values() ) {
+            staxProcessor.resolve(bindingType, resolver);
+        }
+        
+        for ( IntentAttachPointType implType : implTypesTable.values() ) {
+            staxProcessor.resolve(implType, resolver);
+        }
+        
+        
         
         //testing if policy intents have been linked have property been linked up 
         assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());

Added: incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestModelResolver.java?rev=574865&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestModelResolver.java (added)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestModelResolver.java Wed Sep 12 02:48:02 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev: 560306 $ $Date: 2007-07-27 22:01:44 +0530 (Fri, 27 Jul 2007) $
+ */
+public class TestModelResolver implements ModelResolver {
+    private static final long serialVersionUID = -7826976465762296634L;
+    
+    private Map<Object, Object> map = new HashMap<Object, Object>();
+    
+    public TestModelResolver() {
+    }
+
+    public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+        Object resolved = map.get(unresolved);
+        if (resolved != null) {
+            
+            // Return the resolved object
+            return modelClass.cast(resolved);
+            
+        } else {
+            
+            // Return the unresolved object
+            return unresolved;
+        }
+    }
+    
+    public void addModel(Object resolved) {
+        map.put(resolved, resolved);
+    }
+    
+    public Object removeModel(Object resolved) {
+        return map.remove(resolved);
+    }
+    
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org