Search in sources :

Example 1 with StartupCommand

use of org.apache.ofbiz.base.start.StartupCommand in project ofbiz-framework by apache.

the class RunTestEvents method runTest.

public static String runTest(HttpServletRequest request, HttpServletResponse response) throws ContainerException {
    String component = request.getParameter("compName");
    String suiteName = request.getParameter("suiteName");
    String caseName = request.getParameter("caseName");
    String result = null;
    List<StartupCommand> ofbizCommands = new ArrayList<StartupCommand>();
    if (caseName == null) {
        ofbizCommands.add(new StartupCommand.Builder("test").properties(UtilMisc.toMap("component", component, "suitename", suiteName)).build());
    } else {
        ofbizCommands.add(new StartupCommand.Builder("test").properties(UtilMisc.toMap("component", component, "suitename", suiteName, "case", caseName)).build());
    }
    TestRunContainer testRunContainer = new TestRunContainer();
    testRunContainer.init(ofbizCommands, "frontend test run", "   ");
    if (testRunContainer.start() == false) {
        result = "error";
    } else {
        result = "success";
    }
    return result;
}
Also used : StartupCommand(org.apache.ofbiz.base.start.StartupCommand) TestRunContainer(org.apache.ofbiz.testtools.TestRunContainer) ArrayList(java.util.ArrayList)

Example 2 with StartupCommand

use of org.apache.ofbiz.base.start.StartupCommand in project ofbiz-framework by apache.

the class EntityDataLoadContainer method init.

@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
    this.name = name;
    // get the data-load properties passed by the user in the command line
    Map<String, String> loadDataProps = ofbizCommands.stream().filter(command -> command.getName().equals(StartupCommandUtil.StartupOption.LOAD_DATA.getName())).map(command -> command.getProperties()).findFirst().get();
    /* disable job scheduler, JMS listener and startup services
         * FIXME: This is not thread-safe. */
    ServiceDispatcher.enableJM(false);
    ServiceDispatcher.enableJMS(false);
    ServiceDispatcher.enableSvcs(false);
    Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
    Property delegatorNameProp = configuration.getProperty("delegator-name");
    String overrideDelegator = loadDataProps.get(DELEGATOR_NAME);
    if ("all-tenants".equals(overrideDelegator)) {
        // load data for all tenants
        for (GenericValue tenant : getTenantList(delegatorNameProp)) {
            String tenantDelegator = delegatorNameProp.value + "#" + tenant.getString("tenantId");
            loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, tenantDelegator);
        }
    } else {
        // load data for a single delegator
        loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, overrideDelegator);
    }
}
Also used : EntityCondition(org.apache.ofbiz.entity.condition.EntityCondition) Arrays(java.util.Arrays) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) EntityDataLoader(org.apache.ofbiz.entity.util.EntityDataLoader) URL(java.net.URL) EntityQuery(org.apache.ofbiz.entity.util.EntityQuery) UtilURL(org.apache.ofbiz.base.util.UtilURL) ContainerException(org.apache.ofbiz.base.container.ContainerException) UtilValidate(org.apache.ofbiz.base.util.UtilValidate) EntityExpr(org.apache.ofbiz.entity.condition.EntityExpr) DelegatorFactory(org.apache.ofbiz.entity.DelegatorFactory) NumberFormat(java.text.NumberFormat) TreeSet(java.util.TreeSet) StartupCommandUtil(org.apache.ofbiz.base.start.StartupCommandUtil) ArrayList(java.util.ArrayList) ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) EntityOperator(org.apache.ofbiz.entity.condition.EntityOperator) Locale(java.util.Locale) Map(java.util.Map) ServiceDispatcher(org.apache.ofbiz.service.ServiceDispatcher) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) Delegator(org.apache.ofbiz.entity.Delegator) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) EntityUtil(org.apache.ofbiz.entity.util.EntityUtil) DatabaseUtil(org.apache.ofbiz.entity.jdbc.DatabaseUtil) StartupCommand(org.apache.ofbiz.base.start.StartupCommand) GenericValue(org.apache.ofbiz.entity.GenericValue) GenericHelperInfo(org.apache.ofbiz.entity.datasource.GenericHelperInfo) Collection(java.util.Collection) StringUtil(org.apache.ofbiz.base.util.StringUtil) ModelEntity(org.apache.ofbiz.entity.model.ModelEntity) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) Debug(org.apache.ofbiz.base.util.Debug) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) Optional(java.util.Optional) Container(org.apache.ofbiz.base.container.Container) GenericValue(org.apache.ofbiz.entity.GenericValue) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)

Example 3 with StartupCommand

use of org.apache.ofbiz.base.start.StartupCommand in project ofbiz-framework by apache.

the class TestRunContainer method init.

@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
    this.name = name;
    new File(logDir).mkdir();
    // get the test properties passed by the user in the command line
    Map<String, String> testProps = ofbizCommands.stream().filter(command -> command.getName().equals(StartupCommandUtil.StartupOption.TEST.getName())).map(command -> command.getProperties()).findFirst().get();
    // set selected log level if passed by user
    setLoggerLevel(testProps.get("loglevel"));
    this.jsWrapper = prepareJunitSuiteWrapper(testProps);
}
Also used : OutputStream(java.io.OutputStream) StartupCommand(org.apache.ofbiz.base.start.StartupCommand) Test(junit.framework.Test) Enumeration(java.util.Enumeration) FileOutputStream(java.io.FileOutputStream) TestFailure(junit.framework.TestFailure) HashMap(java.util.HashMap) ContainerException(org.apache.ofbiz.base.container.ContainerException) BuildException(org.apache.tools.ant.BuildException) AssertionFailedError(junit.framework.AssertionFailedError) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) StartupCommandUtil(org.apache.ofbiz.base.start.StartupCommandUtil) TestSuite(junit.framework.TestSuite) List(java.util.List) JUnitTest(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest) Debug(org.apache.ofbiz.base.util.Debug) TestListener(junit.framework.TestListener) Map(java.util.Map) TestResult(junit.framework.TestResult) XMLJUnitResultFormatter(org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter) TestCase(junit.framework.TestCase) Container(org.apache.ofbiz.base.container.Container) File(java.io.File)

Aggregations

StartupCommand (org.apache.ofbiz.base.start.StartupCommand)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Container (org.apache.ofbiz.base.container.Container)2 ContainerException (org.apache.ofbiz.base.container.ContainerException)2 StartupCommandUtil (org.apache.ofbiz.base.start.StartupCommandUtil)2 Debug (org.apache.ofbiz.base.util.Debug)2 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 NumberFormat (java.text.NumberFormat)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Optional (java.util.Optional)1