Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public interface BindingProviderFactory<M extends Binding> extends ProviderFactory<M> {

    /**
     * Creates a new reference binding provider for the given endpoint reference
     * 
     * @param endpointReference defines the component/reference/binding against which to create the provider
     * @return The binding provider
     */
    ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference);

    /**
     * Creates a new service binding provider for the given component and
     * service.
     * 
     * @param endpoint defines the component/service/binding against which to create the provider
     * @return The binding provider
     */
    ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint);

}

...

Code Block
public class AtomReferenceBindingProvider implements ReferenceBindingProvider {

    private RuntimeComponentReference reference;
    private AtomBinding binding;
    
    public AtomReferenceBindingProvider(EndpointReference endpointReference,
                                        AtomBinding binding) {
        
    	this.reference = (RuntimeComponentReference) endpointReference.getReference();
        this.binding = (AtomBinding) endpointReference.getBinding();
    }
    
    ...
}

public class AtomServiceBindingProvider implements ServiceBindingProvider {
    
    
    private MessageFactory messageFactory;
    
    private Endpoint endpoint;
    private RuntimeComponent component;
    private RuntimeComponentService service;
    private InterfaceContract serviceContract;
    private AtomBinding binding;
    private ServletHost servletHost;

    ...

    public AtomServiceBindingProvider(Endpoint endpoint,
                                         MessageFactory messageFactory,
                                         ServletHost servletHost) {
        this.endpoint = endpoint;
        this.component = (RuntimeComponent)endpoint.getComponent();
        this.service = (RuntimeComponentService)endpoint.getService();
        this.binding = (AtomBinding) endpoint.getBinding();
        this.messageFactory = messageFactory;
        this.servletHost = servletHost;

    }

    ....

Converting test cases

In 2.x we removed the Host-Embedded module and the SCADomain, and the recommended way is to use the Node SPI to build your test cases. We also are recommending using JUnit 4.5 test styles. See below a quick

1.x Style

Code Block

public class AtomTestCase {

	private SCADomain domain;

	@Before
	public void setUp() throws Exception {
		domain = SCADomain.newInstance("AtomBinding.composite");
	}

	@After
	public void tearDown() throws Exception {
		domain.close();
	}

        ....
}

2.x Style

Code Block

public class AtomTestCase {

	private static Node node;

	@BeforeClass
	public static void setUp() throws Exception {
		try {
    		String contribution = ContributionLocationHelper.getContributionLocation(AtomTestCase.class);
    		node = NodeFactory.newInstance().createNode("AtomBinding.composite", new Contribution("test", contribution));
    		node.start();
    	} catch (Exception e) {
    		e.printStackTrace();
    	}
	}

	@AfterClass
	public static void tearDown() throws Exception {
		node.stop();
    	node.destroy();
	}

        ...
}

NOTE You will need to add the node-impl as test dependency to your modules

Code Block

        <dependency>
            <groupId>org.apache.tuscany.sca</groupId>
            <artifactId>tuscany-node-impl</artifactId>
            <version>2.0-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>