The project structure is a service provided by spring Boot to provide RPC interface, and Dubbo is used;
Recently need to use unit testing, found that the same card is there, the implementation of the test method, seemingly blocked;
Unit Test class:
@RunWith (Springrunner.class)
@SpringBootTest (webenvironment= SpringBootTest.WebEnvironment.NONE, classes = Application.class)
public class Tagtest {
@Test
public void Test () {
System.out.println ("***************");
}
}
Looking for a long time, after many practices and tracking source code analysis, found to execute into the Dubboservicelatchcommandlinerunner, in the method run blocked;
Package com.wacai.springboot.dubbo.commands;
Import Com.wacai.goodies.lifecycle.ShutdownLatch;
Import Org.springframework.boot.CommandLineRunner;
public class Dubboservicelatchcommandlinerunner implements Commandlinerunner {
private String domain = " Com.wacai.lifecycles ";
@Override public
void Run (String ... args) throws Exception {
Shutdownlatch latch = new Shutdownlatch (GetDomain () );
Latch.await (); This will cause blocking
} public
String GetDomain () {
return domain;
}
public void SetDomain (String domain) {
this.domain = domain;
}
}
Later, the following dependencies in the Maven configuration file are commented out, and then the unit test can be run.
<dependency>
<groupId>com.wacai</groupId>
<artifactId> spring-boot-starter-dubbo</artifactid>
<version>1.0.3</version>
</dependency >