Skip to Content
Former Member
Apr 16, 2015 at 11:56 AM

Tomcat & port settings in unit test


I wish to have a junit test to verify the content of returned xml data on REST web services.

JUnit test tries to connect e.g. to https://localhost:PORT/rest/v2/electronics/languages and check the result.

I've extended my test class from ServicelayerTest. Hybrisserver is started and the console shows some sign of Tomcat

  [yunitint] INFO  [main] (junit) [hybrisserver] Starting up hybris server
  [yunitint] INFO  [main] (junit) [hybrisserver] Configuration:
  [yunitint] INFO  [main] (junit) [hybrisserver] Cluster:     disabled
  [yunitint] INFO  [main] (junit) [hybrisserver] Tenant:      junit
  [yunitint] INFO  [main] (junit) [hybrisserver] OS:          Windows 7 6.1, amd64
  [yunitint] INFO  [main] (junit) [hybrisserver] Platform:
  [yunitint] INFO  [main] (junit) [hybrisserver] Java:        Oracle Corporation
  [yunitint] INFO  [main] (junit) [hybrisserver]              Java(TM) SE Runtime Environment, 1.7.0_75-b13
  [yunitint] INFO  [main] (junit) [hybrisserver] VM Locale:   language=en,country=US,region=null
  [yunitint] INFO  [main] (junit) [hybrisserver] Cache:       RegionCache is not yet initialized. [de.hybris.platform.cache.impl.RegionCacheAdapter]
  [yunitint] INFO  [main] (junit) [hybrisserver] Server type: tomcat

However Tomcat seems not to be started. It's not running on the ports I define in


I've also tried the default ports 9001, 9002, and the embedded server port defined found in platformwebservices test classes (9998). They all produce the same exception:

  [yunitint] Connection refused: connect

Do I need to make additional settings for starting Tomcat? Or is junit using some other port for Tomcat?

As a workaround I checked how the platformwebservices/AbstractWebServicesTest is initializing server and tried to follow same process, but this reference is not found for my unit test (located in my extension)

 private EmbeddedServerBuilder tomcatEmbeddedServerBuilder;   

Am I possibly missing some dependencies or bean configurations?