on 12-04-2014 7:40 PM
@RunWith(HybrisJUnit4ClassRunner.class)
@IntegrationTest
@Transactional(noRollback = false)
public class ProductConsolidationServiceTest extends ServicelayerTransactionalTest {
@test
public void test() {
CatalogModel productCatalog = modelService.create(CatalogModel.class);
MyProductModel p = modelService.create(MyProductModel.class);
}
}
The line that creates the CatalogModel works fine.
The line that creates the MyProductModel throws a ClassCastException: java.lang.ClassCastException:
de.hybris.platform.core.model.product.ProductModel
cannot be cast to com.my.generated.core.model.MyProductModel
This line works fine in Master tenant, just not in JUnit tests.
Why is this happening?
Thanks
Hi Chao,
As you mentioned, test runs fine in Ant but not in Ee, If this is the case, you probably do not have all configured extensions of your localextensions.xml file registered at the classpath of the Ee JUnit test configuration. Please try the following steps:
Open the Run menu -> click Run Configurations to open Run Configurations dialog box.
In the Run Configurations dialog box, select your test configuration.
Navigate to the Classpath tab.
Select the platform folder.
Click the Add Projects button. In the Project Selection dialog box, select all extensions you have configured in the localextensions.xml file.
Regards,
Reena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you run ant junitinit or updated the junit tenant from the hac? I understand the test passes with ant but I'm questioning that pnyway because the symptom is similar to what you get with a non existing MyProductModel
itemtype in the database. Or is ee using the same database as ant?
do you have warnings in the logs of the junit test execution containing MyProductModel
keyword?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chao I reproduced the exact same thing on my platform, everything seems ok and the test runs with out any problems.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also in DefaultModelService
's converterRegistry
doesn't contain MyProductModel...is that a problem? This causes my DefaultModelService.create
method to return a ProductModel instead of a MyProductModel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The test runs fine with with Ant, just not in Ee. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Will you refresh your platform project and search for MyProductModel.class? is it created? Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hu Can you send me your item.xml file?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.