Hybris Learning Note: Trail ~ Testing the Services

Source: Internet
Author: User

DAO interface and class implementation---> Service Class (Invoke DAO class and interface)--facade Class (Call service Class)


In this exercise,

This time, the test code was written first, and then the service class code needed in the test code was written.


Interestingly, there are two kinds of test code.

1) One is the integration test code, which invokes the service class code (the service Class code calls the DAO interface and Class).

2) The other is the unit test code, which also calls the service class code, but the service class code is called the DAO interface and the mock implementation.


1 fully tested DAO interface and class implementation---> Service class (Call DAO class and interface) two stages of code

2 is testing the service class code without relying on/Not testing the DAO interface and class implementation



Note: The code for Defaultstadiumservice implements Stadiumservice is not @Component (value = "xxxxx")

So for other code to use Defaultstadiumservice, such as Stadiumservice's spring bean, it needs to be declared in the Spring Config file: <alias name= " Defaultstadiumservice "alias=" Stadiumservice "/>
<bean id= "Defaultstadiumservice" class= "De.hybris.platform.cuppytrail.impl.DefaultStadiumService" >
<property name= "Stadiumdao" ref= "Stadiumdao"/>
</bean>



The test code Defaultstadiumserviceintegrationtest.java can be declared, and then directly applicable to the Stadiumservice bean.

@Resource//Here is the declaration to use the Stadiumservice bean
Private Stadiumservice Stadiumservice;

...  ...

@Test
public void Teststadiumservice ()
{
list<stadiummodel> stadiummodels = Stadiumservice.getstadiums (); Open this stadiumservice bean right here.



Defaultstadiumservice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.