我有一个带有我运行的测试用例的pb。我通过一个接口设置了一个obj。在接口和类之间是一个抽象类,其中obj的getter是。当我为该obj调用getter时。它返回null .......?我认为它是代理obj的东西,但我不知道代理obj如何工作
public interface RequestHandler{
public void setRequest(ImporterRequest request);}
public abstract class AbstractRequestHandler implements RequestHandler{
private ImporterRequest request;
public ImporterRequest getRequest() {
return request;
}
@Override
public void setRequest(ImporterRequest request) {
this.request = request;
}
@Component("WBRequestHandler")
@Scope(value= "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class WBRequestHandler extends AbstractRequestHandler implements RequestHandler{
// here only implemented methods from the AbstrcCllass for read/write csv
@Override
public List<Object> getData(ExportRequest request1) {...}
@Override
public CellProcessor[] createExportCellProcessor(ExportRequest request1) {...}
@Override
protected void parseLines(CsvPreference preferences, StringReader reader,
LngDTO LngDTO, String username) throws IOException {....}
@Override
protected CellProcessor[] createProcessors(ImporterRequest request1) {.....}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/META-INF/spring-config.xml" })
public class Test{
@Resource
private RequestHandler WBRequestHandler;
@Resource
private ImporterFactory importerFactoryImpl;
@Test
@Transactional
public void CSVReadTest() {
//the importerRequest obj is a simple one - non-annotated
ImporterRequest ir = new ImporterRequest();
ir.setImportTyp(RequestTyp.Artikel);
//this instantiation works, i made a test case for a export file with the same line
WBRequestHandler = importerFactoryImpl.getHandler(ir);
WBRequestHandler.setRequest(ir);
//in the test the req is null,
ImporterRequest req = ((AbstractRequestHandler) WBRequestHandler).getRequest();
}
}