[Git][java-team/wildfly-client-config][upstream] New upstream version 1.0.1
Markus Koschany
gitlab at salsa.debian.org
Tue Aug 28 22:24:33 BST 2018
Markus Koschany pushed to branch upstream at Debian Java Maintainers / wildfly-client-config
Commits:
03d218d8 by Markus Koschany at 2018-08-28T21:19:22Z
New upstream version 1.0.1
- - - - -
4 changed files:
- pom.xml
- src/main/java/org/wildfly/client/config/ClientConfiguration.java
- src/main/java/org/wildfly/client/config/_private/ConfigMessages.java
- src/test/java/org/wildfly/client/config/TestSimpleConfiguration.java
Changes:
=====================================
pom.xml
=====================================
@@ -37,7 +37,7 @@
<groupId>org.wildfly.client</groupId>
<artifactId>wildfly-client-config</artifactId>
- <version>1.0.0.Final</version>
+ <version>1.0.1.Final</version>
<name>WildFly Client Configuration</name>
<description>Library for supporting WildFly common client configuration</description>
=====================================
src/main/java/org/wildfly/client/config/ClientConfiguration.java
=====================================
@@ -19,7 +19,7 @@
package org.wildfly.client.config;
import static java.lang.Boolean.FALSE;
-import static javax.xml.stream.XMLStreamConstants.*;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static org.wildfly.client.config.ConfigurationXMLStreamReader.eventToString;
import static org.wildfly.client.config._private.ConfigMessages.msg;
@@ -39,6 +39,7 @@ import java.util.Set;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
+import org.wildfly.common.Assert;
import org.wildfly.common.function.ExceptionSupplier;
/**
@@ -183,6 +184,8 @@ public class ClientConfiguration {
* @return the client configuration instance
*/
public static ClientConfiguration getInstance(URI configurationUri) {
+ Assert.checkNotNullParam("configurationUri", configurationUri);
+
return new ClientConfiguration(createXmlInputFactory(), configurationUri);
}
@@ -193,6 +196,8 @@ public class ClientConfiguration {
* @return the client configuration instance
*/
public static ClientConfiguration getInstance(URI configurationUri, ExceptionSupplier<InputStream, IOException> streamSupplier) {
+ Assert.checkNotNullParam("configurationUri", configurationUri);
+
return new ClientConfiguration(createXmlInputFactory(), configurationUri, streamSupplier);
}
@@ -251,7 +256,9 @@ public class ClientConfiguration {
if (resource == null) {
return null;
}
- } try {
+ }
+
+ try {
return new ClientConfiguration(XMLInputFactory.newFactory(), resource.toURI(), resource::openStream);
} catch (URISyntaxException e) {
return null;
@@ -259,20 +266,25 @@ public class ClientConfiguration {
}
static URI propertyUrlToUri(String wildFlyConfig) {
- try {
- URI uri = new URI(wildFlyConfig);
- if (! uri.isAbsolute()) { // URI does not include schema
- if (uri.getPath().charAt(0) != File.separatorChar && uri.getPath().charAt(0) != '/') { // relative path
- String userDir = System.getProperty("user.dir").replace(File.separatorChar, '/');
- return Paths.get(userDir, uri.getPath()).toUri();
- } else { // absolute path
- return Paths.get(uri.getPath()).toUri();
+ if (File.separator.equals("\\") && wildFlyConfig.contains("\\")) { // we are on the windows and path is for windows
+ File f = new File(wildFlyConfig);
+ return f.toPath().toUri();
+ } else {
+ try {
+ URI uri = new URI(wildFlyConfig);
+ if (!uri.isAbsolute()) { // URI does not include schema
+ if (uri.getPath().charAt(0) != File.separatorChar && uri.getPath().charAt(0) != '/') { // relative path
+ String userDir = System.getProperty("user.dir").replace(File.separatorChar, '/');
+ return Paths.get(userDir, uri.getPath()).toUri();
+ } else { // absolute path
+ return Paths.get(uri.getPath()).toUri();
+ }
}
+ return uri;
+ } catch (URISyntaxException e) {
+ // no config file there
+ return null;
}
- return uri;
- } catch (URISyntaxException e) {
- // no config file there
- return null;
}
}
=====================================
src/main/java/org/wildfly/client/config/_private/ConfigMessages.java
=====================================
@@ -89,10 +89,10 @@ public interface ConfigMessages {
@Message(id = 15, value = "Unexpected attribute \"%s\" encountered")
ConfigXMLParseException unexpectedAttribute(QName name, @Param(Location.class) XMLLocation location);
- @Message(id = 16, value = "Missing required element \"%s\" from namespace \"%s\"")
+ @Message(id = 16, value = "Missing required element \"%2$s\" from namespace \"%s\"")
ConfigXMLParseException missingRequiredElement(String namespaceUri, String localName, @Param(Location.class) XMLLocation location);
- @Message(id = 17, value = "Missing required attribute \"%s\" from namespace \"%s\"")
+ @Message(id = 17, value = "Missing required attribute \"%2$s\" from namespace \"%s\"")
ConfigXMLParseException missingRequiredAttribute(String namespaceUri, String localName, @Param(Location.class) XMLLocation location);
@Message(id = 18, value = "Failed to parse integer value of attribute \"%s\"")
=====================================
src/test/java/org/wildfly/client/config/TestSimpleConfiguration.java
=====================================
@@ -18,9 +18,18 @@
package org.wildfly.client.config;
-import static org.junit.Assert.*;
-import static javax.xml.stream.XMLStreamConstants.*;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.SPACE;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.io.File;
import java.net.URL;
import java.util.Collections;
import java.util.regex.Pattern;
@@ -313,8 +322,15 @@ public final class TestSimpleConfiguration {
assertTrue(Pattern.matches("file:///.*/relative", ClientConfiguration.propertyUrlToUri("relative").toString()));
assertTrue(
Pattern.matches("file:///absolute", ClientConfiguration.propertyUrlToUri("/absolute").toString()) ||
- Pattern.matches("file:///[A-Za-z]:/absolute", ClientConfiguration.propertyUrlToUri("/absolute").toString())
+ Pattern.matches("file:///[A-Za-z]:/absolute", ClientConfiguration.propertyUrlToUri("/absolute").toString())
);
- assertEquals("file:///C:/absolute.xml", ClientConfiguration.propertyUrlToUri("file:///C:/absolute.xml").toString());
+
+ if (File.separator.equals("\\")) {
+ // we are on the windows and we want to check windows specific behavior
+ assertTrue(Pattern.matches("file:///.*/relative", ClientConfiguration.propertyUrlToUri("..\\relative").toString()));
+ assertTrue(Pattern.matches("file:///C:/absolute.xml",
+ ClientConfiguration.propertyUrlToUri("C:\\absolute.xml").toString()));
+ assertEquals("file:///C:/absolute.xml", ClientConfiguration.propertyUrlToUri("file:///C:/absolute.xml").toString());
+ }
}
}
\ No newline at end of file
View it on GitLab: https://salsa.debian.org/java-team/wildfly-client-config/commit/03d218d89b172adc4fc4a87122e65653bac50103
--
View it on GitLab: https://salsa.debian.org/java-team/wildfly-client-config/commit/03d218d89b172adc4fc4a87122e65653bac50103
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180828/920fdfdc/attachment.html>
More information about the pkg-java-commits
mailing list