Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 3, 2018
2 parents ed2f386 + 38c0226 commit b838874
Show file tree
Hide file tree
Showing 18 changed files with 356 additions and 156 deletions.
7 changes: 7 additions & 0 deletions dist/src/main/bin/midpoint.sh
Expand Up @@ -56,6 +56,13 @@ JAVA_OPTS="$JAVA_OPTS
-Djavax.net.ssl.trustStoreType=jceks
-Dmidpoint.home=$MIDPOINT_HOME"

# apply setenv.sh if it exists. This can be used for -Dmidpoint.nodeId etc.
# the script can either append or overwrite JAVA_OPTS
if [ -r "$SCRIPT_PATH/setenv.sh" ]; then
echo "Applying setenv.sh from $SCRIPT_PATH directory."
. "$SCRIPT_PATH/setenv.sh"
fi

if [ -z "$BOOT_OUT" ] ; then
BOOT_OUT="$SCRIPT_PATH"../var/log/midpoint.out
fi
Expand Down
31 changes: 31 additions & 0 deletions samples/objects/users_view_collection.tld
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<objectCollection xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
oid="d2521d0b-6784-4540-bdff-086858ae0cc7"
version="68157">
<name>Users view collection</name>
<type>c:UserType</type>
<filter>
<q:equal>
<q:path>subtype</q:path>
<q:value>EMP</q:value>
</q:equal>
</filter>
</objectCollection>
31 changes: 31 additions & 0 deletions samples/objects/users_view_configuration.tld
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- a peace of xml code which is used to configure users view -->
<adminGuiConfiguration>
<objectLists>
<objectList>
<type>c:UserType</type>
<collectionRef oid="d2521d0b-6784-4540-bdff-086858ae0cc7"
relation="org:default"
type="c:ObjectCollectionType"><!-- Users view collection --></collectionRef>
<display>
<label>Employees</label>
</display>
</objectList>
</objectLists>
</adminGuiConfiguration>
Expand Up @@ -4,6 +4,13 @@
import com.evolveum.midpoint.schrodinger.component.LoggedUser;
import com.evolveum.midpoint.schrodinger.page.LoginPage;
import org.apache.commons.lang3.Validate;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
* Created by Viliam Repan (lazyman).
*/
Expand All @@ -15,17 +22,24 @@ public class MidPoint {
public static long TIMEOUT_MEDIUM = 6000;
public static long TIMEOUT_LONG = 60000;

public MidPoint(EnvironmentConfiguration environment) {
private static final String SCHRODINGER_PROPERTIES = "./src/test/resources/configuration/schrodinger.properties";

private String webDriver;
private String webdriverLocation;

public MidPoint(EnvironmentConfiguration environment) throws IOException {
Validate.notNull(environment, "Environment configuration must not be null");

this.environment = environment;

init();
}

private void init() {
private void init() throws IOException {
environment.validate();
//System.setProperty("webdriver.chrome.driver", "C:\\Users\\matus\\chromedriver\\chromedriver.exe"); // TODO workaround, find proper way how to resolve
fetchProperties();

System.setProperty(webDriver, webdriverLocation);
System.setProperty("selenide.browser", environment.getDriver().name().toLowerCase());
System.setProperty("selenide.baseUrl", environment.getBaseUrl());

Expand All @@ -36,20 +50,26 @@ public LoginPage login() {
return new LoginPage();
}

// public static FluentWait waitWithIgnoreMissingElement() {
//
// FluentWait wait = new FluentWait(environment.getDriver())
// .withTimeout(TIMEOUT_MEDIUM, MILLISECONDS)
// .pollingEvery(100, MILLISECONDS)
// .ignoring(NoSuchElementException.class).ignoring(org.openqa.selenium.TimeoutException.class);
//
// return wait;
// }


public MidPoint logout() {
new LoggedUser().logout();

return this;
}

private void fetchProperties() throws IOException {

Properties schrodingerProperties = new Properties();
InputStream input = null;

try {
input = new FileInputStream(SCHRODINGER_PROPERTIES);
schrodingerProperties.load(input);

webDriver = schrodingerProperties.getProperty("webdriver");
webdriverLocation = schrodingerProperties.getProperty("webdriverLocation");

} catch (IOException e) {
throw new IOException("An exception was thrown during Schrodinger initialization" + e.getLocalizedMessage());
}
}
}
@@ -1,6 +1,7 @@
package com.evolveum.midpoint.schrodinger.component;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.common.DropDown;
Expand All @@ -19,8 +20,17 @@ public FocusSetAssignmentsModal(T parent, SelenideElement parentElement) {
}

public FocusSetAssignmentsModal<T> selectType(String option) {
$(By.name("mainPopup:content:popupBody:type:input"))
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT).selectOption(option);
SelenideElement tabElement = $(Schrodinger.byElementValue("a", "class", "tab-label", option))
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT);

String classActive = tabElement.attr("class");

tabElement.click();
if (!classActive.contains("active")) {
$(Schrodinger.byElementValue("a", "class", "tab-label", option))
.waitUntil(Condition.attribute("class", classActive + " active"), MidPoint.TIMEOUT_DEFAULT).exists();
}


return this;
}
Expand Down
Expand Up @@ -26,14 +26,7 @@ public PrismForm<AbstractTable<T>> clickByName(String name) {

@Override
public AbstractTable<T> selectCheckboxByName(String name) {
SelenideElement parent = $(Schrodinger.byElementValue(null, "data-s-id", "cell", name))
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT).parent();

String row = parent.getAttribute("data-s-id").toString();

System.out.println("The Parent + " + parent.innerHtml() + " The row" + row);

parent.$(Schrodinger.byElementAttributeValue("input", "name", constructCheckBoxIdBasedOnRow(row)))
$(Schrodinger.byAncestorFollowingSiblingElementValue("input", "type", "checkbox", "data-s-id", "3", name))
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT).click();

return this;
Expand Down
Expand Up @@ -179,7 +179,7 @@ private SelenideElement findProperty(String name) {

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

return element;
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.openqa.selenium.By;



import static com.codeborne.selenide.Selenide.$;

/**
Expand Down Expand Up @@ -60,21 +59,13 @@ public Table<T> selectAll() {
}

public boolean currentTableContains(String name) {
// Small time out period, might be a problem if table loads for a long time
// TODO Catching the exception in such way might be a problem, find solution with wait+pooling interval


// FluentWait wait = MidPoint.waitWithIgnoreMissingElement();
// Boolean isPresent = (Boolean) wait.until(new Function() {
// @Nullable
// @Override
// public Boolean apply(@Nullable Object o) {
//
// return $(Schrodinger.byElementValue("Span", name)).is(Condition.visible);
// }
// });

return $(Schrodinger.byElementValue("Span", name)).is(Condition.visible);
// TODO replate catch Throwable with some less generic error
try {
return $(Schrodinger.byElementValue("Span", name)).waitUntil(Condition.visible, MidPoint.TIMEOUT_MEDIUM).is(Condition.visible);
} catch (Throwable t) {
return false;
}

}

Expand Down
Expand Up @@ -6,13 +6,22 @@
import com.evolveum.midpoint.schrodinger.util.Schrodinger;
import org.openqa.selenium.By;

//import com.evolveum.midpoint.util.logging.Trace;
//import com.evolveum.midpoint.util.logging.TraceManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.codeborne.selenide.Selenide.$;

/**
* Created by Viliam Repan (lazyman).
*/
public class AboutPage extends BasicPage {

// public static Trace LOGGER = TraceManager.getTrace(AboutPage.class);

public AboutPage repositorySelfTest() {
$(Schrodinger.byDataResourceKey("PageAbout.button.testRepository")).click();
return this;
Expand Down Expand Up @@ -67,10 +76,56 @@ public String connIdFrameworkVersion() {
return $(Schrodinger.bySchrodingerDataId("provisioningDetailValue")).parent().getText();
}

public List<String> getJVMproperties() {
SelenideElement jvmProperties = $(Schrodinger.byDataId("jvmProperties"));
String jvmPropertiesText = jvmProperties.getText();

List<String> listOfProperties = new ArrayList<>();
if (jvmPropertiesText != null && !jvmPropertiesText.isEmpty()) {
String[] properties = jvmPropertiesText.split("\\r?\\n");

listOfProperties = Arrays.asList(properties);

} else {
// LOGGER.info("JVM properties not found";

}

return listOfProperties;
}

public String getJVMproperty(String property) {

List<String> listOfProperties = getJVMproperties();

if (property != null && !property.isEmpty()) {

for (String keyPair : listOfProperties) {

String[] pairs = keyPair.split("\\=");

if (pairs != null && pairs.length > 1) {
if (pairs[0].equals(property)) {
return pairs[1];
}
} else if (pairs.length == 1) {
if (pairs[0].contains(property)) {
return pairs[0];
}

}
}
}

return "";
}


public FeedbackBox<AboutPage> feedback() {
SelenideElement feedback = $(By.cssSelector("div.feedbackContainer"));

return new FeedbackBox<>(this, feedback);
}

}

21 changes: 21 additions & 0 deletions tools/schrodinger/src/test/java/schrodinger/AboutPageTest.java
Expand Up @@ -15,6 +15,9 @@ public class AboutPageTest extends TestBase {
private static final String CONNID_VERSION_EXPECTED = "1.4.3.11"; // Static value, should be changed each version change.
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 AboutPage aboutPage;

@BeforeMethod
Expand Down Expand Up @@ -95,4 +98,22 @@ public void checkReindexRepositoryObjectsDisplayName() {
.fetchDisplayName()
, REINDEX_REPO_TASK_DISPLAY_NAME_EXPECTED);
}

@Test
public void checkJVMPropertiesMidpointHome(){

Assert.assertTrue(
!aboutPage.getJVMproperty(TestBase.PROPERTY_NAME_MIDPOINT_HOME).isEmpty()
);

}

@Test
public void checkJVMPropertiesXmx(){

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

}
}

0 comments on commit b838874

Please sign in to comment.