Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 6cedd04

Browse files
committed
Added configuration tests
1 parent e58985a commit 6cedd04

File tree

12 files changed

+386
-43
lines changed

12 files changed

+386
-43
lines changed

webtester-core/src/main/java/info/novatec/testit/webtester/browser/WebDriverBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public Browser build() {
218218
if (customConfiguration != null) {
219219
configuration = customConfiguration;
220220
} else {
221-
configuration = DefaultConfigurationBuilder.create();
221+
configuration = new DefaultConfigurationBuilder().build();
222222
}
223223
return new WebDriverBrowser(configuration, webDriver);
224224
}

webtester-core/src/main/java/info/novatec/testit/webtester/config/BaseConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public boolean isEventSystemEnabled() {
6868
}
6969

7070
@Override
71-
public Configuration setEventSystem(boolean enabled) {
71+
public Configuration setEventSystemEnabled(boolean enabled) {
7272
return setProperty(key(NamedProperties.EVENTS), enabled);
7373
}
7474

@@ -118,7 +118,7 @@ public boolean isMarkingsEnabled() {
118118
}
119119

120120
@Override
121-
public BaseConfiguration setMarkings(boolean activated) {
121+
public BaseConfiguration setMarkingsEnabled(boolean activated) {
122122
return setProperty(key(NamedProperties.MARKINGS), activated);
123123
}
124124

@@ -129,7 +129,7 @@ public Color getMarkingsColorUsedBackground() {
129129

130130
@Override
131131
public BaseConfiguration setMarkingsColorUsedBackground(Color color) {
132-
return setProperty(key(NamedProperties.MARKINGS_USED_BACKGROUND), color.toString());
132+
return setProperty(key(NamedProperties.MARKINGS_USED_BACKGROUND), color.asHex());
133133
}
134134

135135
@Override
@@ -139,7 +139,7 @@ public Color getMarkingsColorUsedOutline() {
139139

140140
@Override
141141
public BaseConfiguration setMarkingsColorUsedOutline(Color color) {
142-
return setProperty(key(NamedProperties.MARKINGS_USED_OUTLINE), color.toString());
142+
return setProperty(key(NamedProperties.MARKINGS_USED_OUTLINE), color.asHex());
143143
}
144144

145145
@Override
@@ -149,7 +149,7 @@ public Color getMarkingsColorReadBackground() {
149149

150150
@Override
151151
public Configuration setMarkingsColorReadBackground(Color color) {
152-
return setProperty(key(NamedProperties.MARKINGS_READ_BACKGROUND), color.toString());
152+
return setProperty(key(NamedProperties.MARKINGS_READ_BACKGROUND), color.asHex());
153153
}
154154

155155
@Override
@@ -159,7 +159,7 @@ public Color getMarkingsColorReadOutline() {
159159

160160
@Override
161161
public Configuration setMarkingsColorReadOutline(Color color) {
162-
return setProperty(key(NamedProperties.MARKINGS_READ_OUTLINE), color.toString());
162+
return setProperty(key(NamedProperties.MARKINGS_READ_OUTLINE), color.asHex());
163163
}
164164

165165
@Override

webtester-core/src/main/java/info/novatec/testit/webtester/config/Configuration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public interface Configuration {
8484
* @see EventSystem
8585
* @since 2.0
8686
*/
87-
Configuration setEventSystem(boolean active);
87+
Configuration setEventSystemEnabled(boolean active);
8888

8989
/**
9090
* Returns the default entry point of the application under test if set.
@@ -177,7 +177,7 @@ public interface Configuration {
177177
* @return the same configuration for fluent API
178178
* @since 2.0
179179
*/
180-
Configuration setMarkings(boolean activated);
180+
Configuration setMarkingsEnabled(boolean activated);
181181

182182
/**
183183
* Returns the color to use for the background of elements marked as 'used' on a page.

webtester-core/src/main/java/info/novatec/testit/webtester/config/adapters/AbstractPropertiesConfigurationAdapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package info.novatec.testit.webtester.config.adapters;
22

3-
import java.io.File;
43
import java.io.IOException;
54
import java.io.InputStreamReader;
65
import java.net.URL;
@@ -21,10 +20,6 @@
2120
*/
2221
public abstract class AbstractPropertiesConfigurationAdapter implements ConfigurationAdapter {
2322

24-
protected void loadPropertiesFromResource(File resource, Properties properties) throws IOException {
25-
loadPropertiesFromResource(resource.toURI().toURL(), properties);
26-
}
27-
2823
protected void loadPropertiesFromResource(URL resource, Properties properties) throws IOException {
2924
try(InputStreamReader isr = new InputStreamReader(resource.openStream(), Charsets.UTF_8)) {
3025
properties.load(isr);

webtester-core/src/main/java/info/novatec/testit/webtester/config/adapters/ClasspathPropertiesFileConfigurationAdapter.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import java.net.URL;
55
import java.util.Properties;
66

7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
7+
import lombok.extern.slf4j.Slf4j;
98

109
import info.novatec.testit.webtester.config.Configuration;
1110
import info.novatec.testit.webtester.config.ConfigurationAdapter;
@@ -21,10 +20,9 @@
2120
* @see AbstractPropertiesConfigurationAdapter
2221
* @since 2.0
2322
*/
23+
@Slf4j
2424
public class ClasspathPropertiesFileConfigurationAdapter extends AbstractPropertiesConfigurationAdapter {
2525

26-
private static final Logger logger = LoggerFactory.getLogger(ClasspathPropertiesFileConfigurationAdapter.class);
27-
2826
private String propertyFilePath;
2927

3028
public ClasspathPropertiesFileConfigurationAdapter(String propertyFilePath) {
@@ -34,11 +32,11 @@ public ClasspathPropertiesFileConfigurationAdapter(String propertyFilePath) {
3432
@Override
3533
public boolean adapt(Configuration configuration) {
3634

37-
logger.debug("loading properties from classpath resource: {}", propertyFilePath);
35+
log.debug("loading properties from classpath resource: {}", propertyFilePath);
3836

3937
URL resource = getClass().getClassLoader().getResource(propertyFilePath);
4038
if (resource == null) {
41-
logger.warn("Could not load configuration file! {} file is not on the classpath.", propertyFilePath);
39+
log.warn("Could not load configuration file! {} file is not on the classpath.", propertyFilePath);
4240
return false;
4341
}
4442

@@ -47,13 +45,13 @@ public boolean adapt(Configuration configuration) {
4745
try {
4846
loadPropertiesFromResource(resource, properties);
4947
} catch (IOException e) {
50-
logger.error("exception while loading property file " + propertyFilePath, e);
48+
log.error("exception while loading property file " + propertyFilePath, e);
5149
return false;
5250
}
5351

54-
logger.debug("...merging with current configuration...");
52+
log.debug("...merging with current configuration...");
5553
copyInto(properties, configuration);
56-
logger.debug("finished loading properties from classpath resource: {}", propertyFilePath);
54+
log.debug("finished loading properties from classpath resource: {}", propertyFilePath);
5755

5856
return true;
5957

webtester-core/src/main/java/info/novatec/testit/webtester/config/builders/DefaultConfigurationBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
*/
3232
public class DefaultConfigurationBuilder extends BaseConfigurationBuilder {
3333

34-
public static Configuration create() {
35-
return new DefaultConfigurationBuilder().build();
36-
}
37-
3834
public DefaultConfigurationBuilder() {
3935
withAdapter(new DefaultFileConfigurationAdapter());
4036
withAdapter(new GlobalFileConfigurationAdapter());

webtester-core/src/test/java/features/DebugMarkingsFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public class DebugMarkingsFeatureTest extends BaseIntegrationTest {
2121
public void openPage() {
2222
open("html/features/debug-markings.html");
2323
markingsWere = browser().configuration().isMarkingsEnabled();
24-
browser().configuration().setMarkings(true);
24+
browser().configuration().setMarkingsEnabled(true);
2525
}
2626

2727
@After
2828
public void deactivateMarkings() {
29-
browser().configuration().setMarkings(markingsWere);
29+
browser().configuration().setMarkingsEnabled(markingsWere);
3030
}
3131

3232
@Test

0 commit comments

Comments
 (0)