Skip to content

Commit

Permalink
Add aboutPage getSystemProperties, some additinal changes for test ex…
Browse files Browse the repository at this point in the history
…ecution
  • Loading branch information
matusmacik committed Aug 10, 2018
1 parent f63be8e commit 6af49d7
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 42 deletions.
5 changes: 5 additions & 0 deletions gui/admin-gui/pom.xml
Expand Up @@ -902,6 +902,11 @@
<version>3.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>repo-cache</artifactId>
<version>3.9-SNAPSHOT</version>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
Expand Up @@ -22,6 +22,7 @@
import com.evolveum.midpoint.init.InitialDataImport;
import com.evolveum.midpoint.model.api.ModelPublicConstants;
import com.evolveum.midpoint.model.api.WorkflowService;
import com.evolveum.midpoint.model.common.SystemObjectCache;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.query.AllFilter;
Expand All @@ -32,6 +33,8 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.TypeFilter;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.api.RepositoryServiceFactory;
import com.evolveum.midpoint.schema.LabeledString;
import com.evolveum.midpoint.schema.ProvisioningDiag;
import com.evolveum.midpoint.schema.RepositoryDiag;
Expand Down Expand Up @@ -65,6 +68,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import com.evolveum.midpoint.repo.cache.RepositoryCache;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -74,6 +79,7 @@
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -141,6 +147,9 @@ public class PageAbout extends PageAdminConfiguration {
private IModel<RepositoryDiag> repoDiagModel;
private IModel<ProvisioningDiag> provisioningDiagModel;

@Autowired RepositoryCache repositoryCache;
@Autowired protected SystemObjectCache systemObjectCache;

public PageAbout() {
repoDiagModel = new LoadableModel<RepositoryDiag>(false) {

Expand Down Expand Up @@ -507,27 +516,28 @@ public Object run() {
return null;
}

});

InitialDataImport initialDataImport = new InitialDataImport();
});


InitialDataImport initialDataImport = new InitialDataImport();
initialDataImport.setModel(getModelService());
initialDataImport.setTaskManager(getTaskManager());
initialDataImport.setPrismContext(getPrismContext());
initialDataImport.setConfiguration(getMidpointConfiguration());
initialDataImport.init();

getModelService().postInit(result);

} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't import initial objects.", ex);

LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import initial objects", ex);
}



showResult(result);
getModelService().postInit(result);

} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't import initial objects.", ex);

LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import initial objects", ex);
}



showResult(result);
target.add(getFeedbackPanel());
}

Expand Down
Expand Up @@ -16,14 +16,15 @@

package com.evolveum.midpoint.testing.schrodinger;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.testng.BrowserPerClass;
import com.evolveum.midpoint.schrodinger.EnvironmentConfiguration;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.page.BasicPage;
import com.evolveum.midpoint.schrodinger.page.LoginPage;
import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage;
import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage;
import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage;
import com.evolveum.midpoint.schrodinger.page.resource.ViewResourcePage;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -47,6 +48,8 @@ public abstract class TestBase {
//public static final String PASSWORD = "5ecr3t";

public static final String PROPERTY_NAME_MIDPOINT_HOME = "-Dmidpoint.home";
public static final String PROPERTY_NAME_USER_HOME = "user.home";
public static final String PROPERTY_NAME_FILE_SEPARATOR = "file.separator";

private static final Logger LOG = LoggerFactory.getLogger(TestBase.class);
protected static File CSV_TARGET_DIR;
Expand Down Expand Up @@ -82,8 +85,8 @@ public void afterClass() {
LOG.info("Finished tests from class {}", getClass().getName());
AboutPage aboutPage = basicPage.aboutPage();
aboutPage
.clickSwitchToFactoryDefaults()
.clickYes();
.clickSwitchToFactoryDefaults();
//.clickYes();
}

@BeforeMethod
Expand Down Expand Up @@ -122,18 +125,22 @@ protected void importObject(File source) {
protected String fetchMidpointHome() throws ConfigurationException {

AboutPage aboutPage = basicPage.aboutPage();
String homeDir = aboutPage.getJVMproperty(PROPERTY_NAME_MIDPOINT_HOME);
String mpHomeDir = aboutPage.getJVMproperty(PROPERTY_NAME_MIDPOINT_HOME);

if (homeDir != null && !homeDir.isEmpty()) {
if (mpHomeDir != null && !mpHomeDir.isEmpty() && !PROPERTY_NAME_MIDPOINT_HOME.equalsIgnoreCase(mpHomeDir)) {

return homeDir;
return mpHomeDir;
} else {

LOG.error("Midpoint home parameter is empty!");
throw new ConfigurationException("Midpoint home parameter is empty ,please add the -Dmidpoint.home parameter to the jvm configuration");
mpHomeDir = new StringBuilder(aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME))
.append(aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR)).append("midpoint").toString();

LOG.info("Midpoint home parameter is empty! Using defaults: "+ mpHomeDir);

}


}
return mpHomeDir;
}

protected File initTestDirectory(String dir) throws ConfigurationException, IOException {
Expand All @@ -153,9 +160,20 @@ protected File initTestDirectory(String dir) throws ConfigurationException, IOEx
return CSV_TARGET_DIR;
} else {

throw new IOException("Creation of directory \"" + CSV_TARGET_DIR.getName() + "\" unsuccessful");
throw new IOException("Creation of directory \"" + CSV_TARGET_DIR.getAbsolutePath() + "\" unsuccessful");
}
}
}

// TODO workaround -> factory reset during clean up seems to leave some old cached information breaking the resource until version change
public ViewResourcePage refreshResourceSchema(String resourceName){

ListResourcesPage listResourcesPage = basicPage.listResources();
ViewResourcePage resourcePage= listResourcesPage
.table()
.clickByName(resourceName)
.refreshSchema();
return resourcePage;
}

}
Expand Up @@ -17,7 +17,7 @@ public class AboutPageTest extends TestBase {
private static final String REINDEX_REPO_TASK_CATEGORY_EXPECTED = "Utility";
private static final String REINDEX_REPO_TASK_DISPLAY_NAME_EXPECTED = "Reindex repository objects";

private static final String PROPERTY_NAME_XMX = "-Xmx";
private static final String PROPERTY_JVM_NAME_XMX = "-Xmx";

private AboutPage aboutPage;

Expand Down Expand Up @@ -113,8 +113,14 @@ public void checkJVMPropertiesMidpointHome(){
public void checkJVMPropertiesXmx(){

Assert.assertTrue(
!aboutPage.getJVMproperty(PROPERTY_NAME_XMX).isEmpty()
!aboutPage.getJVMproperty(PROPERTY_JVM_NAME_XMX).isEmpty()
);

}
@Test
public void checkSystemProperty(){
Assert.assertTrue(
!aboutPage.getSystemProperty(TestBase.PROPERTY_NAME_USER_HOME).isEmpty()
);
}
}
Expand Up @@ -40,6 +40,11 @@ public class AccountTests extends TestBase {

protected static final String CSV_RESOURCE_NAME= "Test CSV: username";

protected static final String CSV_RESOURCE_ATTR_FILE_PATH= "File path";

//TODO seems that some problems with property files in the csv resource which is being used for tests, replace value after resolution
protected static final String CSV_RESOURCE_ATTR_UNIQUE= "UI_CSV_NAME_ATTRIBUTE";

protected static final String TEST_USER_MIKE_NAME= "michelangelo";
protected static final String TEST_USER_MIKE_LAST_NAME_OLD= "di Lodovico Buonarroti Simoni";
protected static final String TEST_USER_MIKE_LAST_NAME_NEW= "di Lodovico Buonarroti Simoni Il Divino";
Expand Down Expand Up @@ -94,15 +99,17 @@ public void changeResourceFilePath(){

Assert.assertTrue(listResourcesPage
.table()
.clickByName("Test CSV: username")
.clickByName(CSV_RESOURCE_NAME)
.clickEditResourceConfiguration()
.form()
.changeAttributeValue("File path",CSV_SOURCE_OLDVALUE,CSV_TARGET_FILE.getAbsolutePath())
.changeAttributeValue(CSV_RESOURCE_ATTR_FILE_PATH,CSV_SOURCE_OLDVALUE,CSV_TARGET_FILE.getAbsolutePath())
.changeAttributeValue(CSV_RESOURCE_ATTR_UNIQUE,"","username")
.and()
.and()
.clickSaveAndTestConnection()
.isTestSuccess()
);
refreshResourceSchema(CSV_RESOURCE_NAME);
}

@Test(dependsOnMethods = {CREATE_MP_USER_DEPENDENCY,CHANGE_RESOURCE_FILE_PATH_DEPENDENCY},groups = TEST_GROUP_BEFORE_USER_DELETION)
Expand Down
@@ -1,5 +1,6 @@
package com.evolveum.midpoint.testing.schrodinger.scenarios;

import com.codeborne.selenide.Selenide;
import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage;
import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
Expand Down Expand Up @@ -42,6 +43,8 @@ public class OrganizationStructureTests extends TestBase {
private static final String DIRECTORY_CURRENT_TEST = "organizationStructureTests";
private static final String FILE_RESOUCE_NAME = "midpoint-advanced-sync.csv";

//TODO seems that some problems with property files in the csv resource which is being used for tests, replace value after resolution
protected static final String CSV_RESOURCE_ATTR_UNIQUE= "UI_CSV_NAME_ATTRIBUTE";

@Test
public void importOrgStructure() throws IOException, ConfigurationException {
Expand All @@ -56,13 +59,14 @@ public void importOrgStructure() throws IOException, ConfigurationException {
importPage
.getObjectsFromFile()
.chooseFile(ORG_MONKEY_ISLAND_SOURCE_FILE)
.checkOverwriteExistingObject()
.clickImport()
.feedback()
.isSuccess()
);
}

@Test (dependsOnMethods ={IMPORT_ORG_STRUCT_DEPENDENCY})
// @Test (dependsOnMethods ={IMPORT_ORG_STRUCT_DEPENDENCY})
public void assignOrgUnit(){
ListUsersPage users = basicPage.listUsers();
users
Expand Down Expand Up @@ -94,7 +98,7 @@ public void assignOrgUnit(){

}

@Test (dependsOnMethods ={ASSIGN_ORG_UNIT_DEPENDENCY})
// @Test (dependsOnMethods ={ASSIGN_ORG_UNIT_DEPENDENCY})
public void unassignOrgUnit(){
ListUsersPage users = basicPage.listUsers();
users
Expand All @@ -116,9 +120,9 @@ public void unassignOrgUnit(){
.isSuccess();
}

@Test
@Test ///(dependsOnMethods ={ASSIGN_ORG_UNIT_DEPENDENCY})
public void orgUnitAccountInducement(){
importObject(CSV_RESOURCE_ADVANCED_SYNC);
importObject(CSV_RESOURCE_ADVANCED_SYNC,true);
importObject(ORG_ACCOUNT_INDUCEMENT_FILE);
importObject(USER_TEST_RAPHAEL_FILE);

Expand Down Expand Up @@ -161,11 +165,13 @@ public void changeResourceFilePath(){
.clickEditResourceConfiguration()
.form()
.changeAttributeValue("File path",AccountTests.CSV_SOURCE_OLDVALUE, CSV_TARGET_FILE.getAbsolutePath())
.changeAttributeValue(CSV_RESOURCE_ATTR_UNIQUE,"","login")
.and()
.and()
.clickSaveAndTestConnection()
.isTestSuccess()
);
// Selenide.sleep(11000);
}


Expand Down
9 changes: 7 additions & 2 deletions testing/schrodingertest/testng-integration-schrodinger.xml
Expand Up @@ -18,8 +18,13 @@
<suite name="integration" parallel="false" verbose="1">
<test name="Schrodinger" preserve-order="true" parallel="false" verbose="10" enabled="true">
<classes>
<class name="com.evolveum.midpoint.testing.schrodinger.TestSuiteConfig"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.UserPhotoTests"/>
<class name="com.evolveum.midpoint.testing.schrodinger.TestSuiteConfig"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.OrganizationStructureTests"/>
<!--<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.UserAccountTests"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.OrganizationStructureTests"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.PolyStringTests"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.SynchronizationTests"/>
<class name="com.evolveum.midpoint.testing.schrodinger.scenarios.UserPhotoTests"/>-->
</classes>
</test>
</suite>
5 changes: 5 additions & 0 deletions tools/schrodinger/pom.xml
Expand Up @@ -115,6 +115,11 @@
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.tools</groupId>
<artifactId>schrodinger</artifactId>
<version>3.9-SNAPSHOT</version>
</dependency>
</dependencies>
<!-- POSSIBLY OBSOLETE END-->
<dependencyManagement>
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.Component;
Expand Down Expand Up @@ -168,18 +169,20 @@ private SelenideElement findProperValueContainer() {

private SelenideElement findProperty(String name) {

Selenide.sleep(5000);

SelenideElement element = null;

boolean doesElementAttrValueExist = $(Schrodinger.byElementAttributeValue(null, "contains",
Schrodinger.DATA_S_QNAME, "#" + name)).exists();

if (doesElementAttrValueExist) {
element = $(Schrodinger.byElementAttributeValue(null, "contains",
Schrodinger.DATA_S_QNAME, "#" + name)).waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT);
Schrodinger.DATA_S_QNAME, "#" + name)).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT);

} else {
element = $(By.xpath("//span[@data-s-id=\"label\"][contains(.,\"" + name + "\")]/.."))
.parent().waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT);
element = $(By.xpath("//span[@data-s-id=\"label\"][contains(.,\"" + name + "\")]/..")).waitUntil(Condition.visible, MidPoint.TIMEOUT_MEDIUM)
.parent().waitUntil(Condition.visible, MidPoint.TIMEOUT_MEDIUM);
}

return element;
Expand Down
Expand Up @@ -17,7 +17,6 @@ public InputTable(T parent, SelenideElement parentElement) {
}

public InputTable<T> addAttributeValue(String attributeName, String attributeValue){
System.out.println("The inner html: " + getParentElement().innerHtml());

SelenideElement element = $(Schrodinger.byAncestorPrecedingSiblingElementValue("input","type","text",null,null,attributeName))
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT).setValue(attributeValue);
Expand Down

0 comments on commit 6af49d7

Please sign in to comment.