2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.core
.execution
;
18 import junit
.framework
.TestCase
;
20 import org
.apache
.commons
.logging
.Log
;
21 import org
.apache
.commons
.logging
.LogFactory
;
22 import org
.argeo
.slc
.core
.test
.SimpleTestResult
;
23 import org
.argeo
.slc
.execution
.ExecutionFlow
;
24 import org
.argeo
.slc
.test
.TestResultPart
;
25 import org
.argeo
.slc
.test
.TestStatus
;
26 import org
.springframework
.context
.ConfigurableApplicationContext
;
27 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
29 public abstract class AbstractExecutionFlowTestCase
extends TestCase
{
31 protected final Log log
= LogFactory
.getLog(getClass());
33 protected void logException(Throwable ex
) {
34 log
.info("Got Exception of class " + ex
.getClass().toString()
35 + " with message '" + ex
.getMessage() + "'.");
38 protected void validateTestResult(SimpleTestResult testResult
) {
39 validateTestResult(testResult
, TestStatus
.PASSED
);
42 protected void validateTestResult(SimpleTestResult testResult
,
44 for (TestResultPart part
: testResult
.getParts()) {
45 if (part
.getStatus() != expectedStatus
) {
46 fail("Error found in TestResult: " + part
.getMessage());
51 protected ConfigurableApplicationContext
createApplicationContext(
52 String applicationContextSuffix
) {
53 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(
54 inPackage(applicationContextSuffix
));
55 // applicationContext.start();
56 return applicationContext
;
59 protected void configureAndExecuteSlcFlow(String applicationContextSuffix
,
61 ConfigurableApplicationContext applicationContext
= createApplicationContext(applicationContextSuffix
);
62 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
65 applicationContext
.close();
68 protected String
inPackage(String suffix
) {
69 String prefix
= getClass().getPackage().getName().replace('.', '/');
70 return prefix
+ '/' + suffix
;