-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests configuration (disabled jBPM exec service for unit tests)
- Also started to design configuration separation between Unit and Integration tests
- Loading branch information
1 parent
251dfc6
commit 8024938
Showing
16 changed files
with
280 additions
and
211 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/test/java/it/reply/orchestrator/command/BaseRankCloudProviderCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
src/test/java/it/reply/orchestrator/config/WebAppConfigurationAware.java
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package it.reply.orchestrator.config.specific; | ||
|
||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; | ||
|
||
import com.github.springtestdbunit.DbUnitTestExecutionListener; | ||
|
||
import it.reply.orchestrator.config.ApplicationConfig; | ||
import it.reply.orchestrator.config.PersistenceConfigTest; | ||
import it.reply.orchestrator.config.WebAppInitializer; | ||
import it.reply.orchestrator.config.WebMvcConfig; | ||
import it.reply.orchestrator.config.WorkflowConfigProducerBean; | ||
import it.reply.orchestrator.config.WorklfowPersistenceConfigTest; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.ContextHierarchy; | ||
import org.springframework.test.context.TestExecutionListeners; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; | ||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import javax.inject.Inject; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@WebAppConfiguration | ||
@ContextHierarchy({ | ||
@ContextConfiguration(name = "baseContext", | ||
classes = { ApplicationConfig.class, WebAppInitializer.class, WebMvcConfig.class, | ||
PersistenceConfigTest.class, WorklfowPersistenceConfigTest.class }), | ||
@ContextConfiguration(name = "workflowContext", | ||
classes = { WebAppConfigurationAware.Config.class }) }) | ||
@TestPropertySource(locations = { "classpath:application-test.properties" }) | ||
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, | ||
TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) | ||
public abstract class WebAppConfigurationAware { | ||
|
||
private static final Logger LOG = LogManager.getLogger(WebAppConfigurationAware.class); | ||
|
||
@Inject | ||
protected WebApplicationContext wac; | ||
protected MockMvc mockMvc; | ||
|
||
@BeforeClass | ||
public static void generalSetup() { | ||
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, | ||
"bitronix.tm.jndi.BitronixInitialContextFactory"); | ||
} | ||
|
||
@AfterClass | ||
public static void generalCleanup() { | ||
System.clearProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY); | ||
} | ||
|
||
@Before | ||
public void before() { | ||
this.mockMvc = webAppContextSetup(this.wac).build(); | ||
} | ||
|
||
@Configuration | ||
static class Config { | ||
@Bean | ||
@Primary | ||
public WorkflowConfigProducerBean produceWorkflowConfigProducerBean() { | ||
return new WorkflowConfigProducerBean() { | ||
|
||
@Override | ||
public int getExecutorServiceThreadPoolSize() { | ||
// Disable jBPM Executor Service during Unit Tests (to avoid transaction/concurrency | ||
// issues) | ||
LOG.warn( | ||
"Disable jBPM Executor Service during Unit Tests (to avoid transaction/concurrency issues)"); | ||
return 0; | ||
} | ||
|
||
}; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAwareIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package it.reply.orchestrator.config.specific; | ||
|
||
import it.reply.orchestrator.IntegrationTest; | ||
|
||
import org.junit.experimental.categories.Category; | ||
|
||
@Category(IntegrationTest.class) | ||
// @ContextHierarchy({ @ContextConfiguration(name = "workflowContext", | ||
// classes = { WebAppConfigurationAwareIT.Config.class }, inheritLocations = false) }) | ||
public abstract class WebAppConfigurationAwareIT extends WebAppConfigurationAware { | ||
|
||
/** | ||
* The override is not working - enable in the future. | ||
*/ | ||
// private static final Logger LOG = LogManager.getLogger(WebAppConfigurationAware.class); | ||
// | ||
// @Configuration | ||
// static class Config { | ||
// @Bean | ||
// @Primary | ||
// public WorkflowConfigProducerBean produceWorkflowConfigProducerBean() { | ||
// return new WorkflowConfigProducerBean() { | ||
// | ||
// @Override | ||
// public int getExecutorServiceThreadPoolSize() { | ||
// // Enable jBPM Executor Service during Integration Tests | ||
// LOG.warn("Enable jBPM Executor Service during Integration Tests"); | ||
// return 2; | ||
// } | ||
// | ||
// }; | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 25 additions & 25 deletions
50
src/test/java/it/reply/orchestrator/service/ChronosServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
package it.reply.orchestrator.service; | ||
|
||
import it.reply.orchestrator.config.WebAppConfigurationAware; | ||
import it.reply.orchestrator.service.commands.chronos.DeployOnChronos; | ||
|
||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class ChronosServiceTest extends WebAppConfigurationAware { | ||
|
||
@Autowired | ||
private DeployOnChronos service; | ||
|
||
private String deploymentId = "deployment_id"; | ||
|
||
@Test | ||
public void customizeTemplateWithDeplymentIdSuccessfully() throws Exception { | ||
|
||
// service.chronosHelloWorld(deploymentId, false); | ||
// service.chronosHelloWorld(deploymentId, true); | ||
|
||
// assertEquals(deploymentId, templateDeploymentId); | ||
} | ||
|
||
} | ||
// package it.reply.orchestrator.service; | ||
// | ||
// import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; | ||
// import it.reply.orchestrator.service.commands.chronos.DeployOnChronos; | ||
// | ||
// import org.junit.Test; | ||
// import org.springframework.beans.factory.annotation.Autowired; | ||
// | ||
// public class ChronosServiceTest extends WebAppConfigurationAwareIT { | ||
// | ||
// @Autowired | ||
// private DeployOnChronos service; | ||
// | ||
// private String deploymentId = "deployment_id"; | ||
// | ||
// @Test | ||
// public void customizeTemplateWithDeplymentIdSuccessfully() throws Exception { | ||
// | ||
// // service.chronosHelloWorld(deploymentId, false); | ||
// // service.chronosHelloWorld(deploymentId, true); | ||
// | ||
// // assertEquals(deploymentId, templateDeploymentId); | ||
// } | ||
// | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.