java - Spring 4.07 Junit Test and Autowired -


Hi I am using Spring and CDI in my unit test, I want to test a range of @ etooyar annotations uses it. If I make an example of this class and call a method then all the annotated objects are empty I annotation works in the original just do not whithin my unit test

This is my unit test here. In my trial, I create an example of the DemoConsumerBean class and call the method here requestJobsFromPublishedJobsApi . Here there are also some independent announcements. All events are empty! @TontExecutionListeners ({DependencyInjectionTestExecutionListener.class, FirstbirdTestExecutionListener.class, FlywayTestExecutionListener.class}) @ContextConfiguration (places = {" Classpath: hibernate-spring.xml "}) @ Flavetest Public Sector DemoConsumerBeanTest AbstractJUnit4SpringContextTests Extended {@Autowired Private Client Manager Client Manager; @Executive Personal DemoDetailsManager demoDetailsManager; @ Before public idle setup () {Camel contact reference = new DefaultCamelContext (); Exchange = new DefaultExchange (reference); } @Test Public Zero Request JobsFrom Published GespSpastest () throws NoSuchDataException {DemoConsumerBean demoConsumerBean = new DemoConsumerBean (); Customer = new customer (); Customer.setCustomerId (15); Customer = customerManager.getCustomerById (customer); // This one works DemoDetails demoDetails = demoDetailsManager.getDemoDetailsByCustomerId (Customer); DemoConsumerBean.requestJobsFublishedJobsApi (exchange, customer); Published zebis apijobs = exchange.jet in (). Beacode (publishedjobs class); AssertNotNull (apiJobs); }

}

  Public category DemoConsumerBean {@Autowired Protected Customer Manager Customer Manager; @Atvoir Protected Demodetador Manager Demodetta Manager; @ Etoward protected message long manager message log manager; Public Zero Requests: Zobos PublisheszbsApps (Exchange Exchange, Customer Client) Throws NoSuchDataException {// This is a blank! DemoDetails demoDetails = demoDetailsManager.getDemoDetailsByCustomerId (Customer); Publish Job Jobs = Faucet; If (demoDetails == zero || StringUtils.isBlank (demoDetails.getDemoApiUrl ()) {new NoSuchDataException ("no demo data for customer was found" + client .getCustomerFirstbirdId ()); } ....}  

}

new in new democcuscanner ();

Use either a democonversion example from the spring (i.e. autowayed in the exam) or add the setters And use them as "manually in autowire" in DemoConsumerBean test:

  @Test Public Zero Requests jobsfrom has been published. Pastry Test () throws NoSuchDataException {DemoConsumerBean DemoConsumerBean = new DemoConsumerBean (); DemoConsumerBean.setCustomerManager (this.customerManager) // etc  

some readings:


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -