-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestSpringConfiguration.java
More file actions
64 lines (53 loc) · 2.24 KB
/
TestSpringConfiguration.java
File metadata and controls
64 lines (53 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.easetech.easytest.spring.example;
import java.beans.PropertyEditorManager;
import java.util.List;
import junit.framework.Assert;
import org.easetech.easytest.annotation.Intercept;
import org.easetech.easytest.annotation.Param;
import org.easetech.easytest.annotation.TestPolicy;
import org.easetech.easytest.runner.SpringTestRunner;
import org.easetech.easytest.samples.Item;
import org.easetech.easytest.samples.ItemId;
import org.easetech.easytest.samples.ItemIdEditor;
import org.easetech.easytest.samples.ItemService;
import org.easetech.easytest.spring.config.XmlBusinessConfig;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringTestRunner.class)
@ContextConfiguration(classes = { XmlBusinessConfig.class }, loader = AnnotationConfigContextLoader.class)
@TransactionConfiguration(transactionManager="transactionManager" )
@Transactional
@TestPolicy(SpringPolicy.class)
public class TestSpringConfiguration {
@Autowired
@Intercept
private ItemService testSubject;
/**
* Example showing the usage of propertyEditors for getting custom object.
*/
@BeforeClass
public static void setUp() {
PropertyEditorManager.registerEditor(ItemId.class, ItemIdEditor.class);
}
@Test
public void testSimple(){
Assert.fail("This is a deliberate failure");
}
@Test
public void testThrowException(){
throw new RuntimeException("Error occured");
}
@Test
public void getItemsDataUsingXMLLoader(@Param(name="searchText") String searchText, @Param(name="itemType") String itemType, ItemId itemId , @Param(name="expectedItems") int expectedItems) {
System.out.println(testSubject == null);
List<Item> items = testSubject.getItems(itemId, searchText, itemType);
Assert.assertNotNull(items);
Assert.assertEquals(expectedItems, items.size());
}
}