Uploaded image for project: 'ZATS'
  1. ZATS
  2. ZATS-31

Could you please add getEmulator() or getServletContext() to EmulatorClient, so that i can get SpringContext and conveniently change the service behavior

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 1.2.0
    • Mimic
    • None

      For example,i let zats to load zats-web/web.xml whose spring config is mock-beans.xml like this:

      <bean id="xxxService" class="org.mockito.Mockito" factory-method="mock">
      		<constructor-arg value="com.xxx.life.service.XxxCancelService" />
      	</bean>
      

      and i want to control the xxxService's behavior in my zats tests,
      but i found that ,i can not get the same xxxService instance in jetty ServletContext.

      And i simply decompile the EmulatorClient.java and add

      public Emulator getEmulator() {
      		return emulator;
      	}

      and in zats tests :

      EmulatorClient client = (EmulatorClient) env.newClient();
      WebApplicationContext wac = WebApplicationContextUtils
      				.getWebApplicationContext(client.getEmulator().getServletContext());
      XxxCancelService xxxCancelService=(XxxCancelService) wac.getBean("xxxCancelService");
      Mockito.when(xxxCancelService.getXxList(Mockito.anyMap(),Mockito.anyString())).thenReturn(policyList);
      

            Unassigned Unassigned
            daquan198163 daquan198163
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: