dnet40/modules/cnr-test-utils/tags/cnr-test-utils-1.0.0/src/main/java/eu/dnetlib/test/utils/MockBeanFactory.java @ 45684
1 |
package eu.dnetlib.test.utils; |
---|---|
2 |
|
3 |
|
4 |
import static org.mockito.Mockito.mock; |
5 |
|
6 |
import org.springframework.beans.factory.FactoryBean; |
7 |
|
8 |
/**
|
9 |
* Return a mockito mock for a given class.
|
10 |
* This class should be updated according to new Spring4 factory Bean
|
11 |
*
|
12 |
* @author marko
|
13 |
*
|
14 |
*/
|
15 |
@Deprecated
|
16 |
public class MockBeanFactory implements FactoryBean { |
17 |
|
18 |
/**
|
19 |
* class to mock.
|
20 |
*/
|
21 |
private Class<?> clazz; |
22 |
|
23 |
/**
|
24 |
* {@inheritDoc}
|
25 |
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
26 |
*/
|
27 |
public Object getObject() throws Exception { |
28 |
return mock(clazz); |
29 |
}
|
30 |
|
31 |
/**
|
32 |
* {@inheritDoc}
|
33 |
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
34 |
*/
|
35 |
public Class<?> getObjectType() { |
36 |
return clazz; |
37 |
}
|
38 |
|
39 |
/**
|
40 |
* {@inheritDoc}
|
41 |
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
|
42 |
*/
|
43 |
public boolean isSingleton() { |
44 |
return true; |
45 |
}
|
46 |
|
47 |
public Class<?> getClazz() { |
48 |
return clazz; |
49 |
}
|
50 |
|
51 |
public void setClazz(final Class<?> clazz) { |
52 |
this.clazz = clazz; |
53 |
}
|
54 |
|
55 |
}
|
- « Previous
- 1
- 2
- Next »