-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
237 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/ProductInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.aim42.htmlsanitycheck; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Provides the current product version, | ||
* as configured in src/main/resources/product-version.properties. | ||
* Code proposed by René Gröschke of Gradleware in | ||
* <a href="https://discuss.gradle.org/t/access-constant-from-groovy-class-in-gradle-buildfile/10571/5">...</a> | ||
*/ | ||
public class ProductInformation { | ||
private ProductInformation() { | ||
|
||
} | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(ProductInformation.class); | ||
|
||
public static final Properties PRODUCT_PROPERTIES = getProperties("product-version.properties"); | ||
public static final String VERSION = PRODUCT_PROPERTIES.getProperty("version") == null | ||
? "[unknown]" | ||
: PRODUCT_PROPERTIES.getProperty("version"); | ||
public static final Properties GIT_PROPERTIES = getProperties("git.properties"); | ||
|
||
public static String getGitProperty (final String propertyKey) { | ||
return GIT_PROPERTIES.getProperty(propertyKey); | ||
} | ||
|
||
private static Properties getProperties(final String propertyFilename) { | ||
Properties props = new Properties(); | ||
try { | ||
final URL resource = ProductInformation.class.getClassLoader().getResource(propertyFilename); | ||
if (resource != null) { | ||
props.load(resource.openConnection().getInputStream()); | ||
} else { | ||
logger.warn("Couldn't obtain URL resource for '{}'", propertyFilename); | ||
} | ||
} catch (IOException E) { | ||
logger.warn("'{}' cannot be obtained due to IOException.", propertyFilename); | ||
} | ||
return props; | ||
} | ||
} | ||
|
||
/************************************************************************ | ||
* This is free software - without ANY guarantee! | ||
* | ||
* | ||
* Copyright Dr. Gernot Starke, arc42.org | ||
* | ||
* 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. | ||
* | ||
*********************************************************************** */ | ||
|
53 changes: 0 additions & 53 deletions
53
htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/ProductVersion.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/ProductInformationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.aim42.htmlsanitycheck | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class ProductInformationTest extends Specification { | ||
|
||
final static String BAD_VERSION = "--.--.--" | ||
|
||
def "can get Version"() { | ||
String version | ||
|
||
when: | ||
version = ProductInformation.VERSION | ||
|
||
then: | ||
version != BAD_VERSION | ||
version != "version" | ||
version != "@version@" | ||
version != null | ||
} | ||
|
||
@Unroll | ||
def "can get git property #propertyKey"() { | ||
setup: | ||
String propertyValue = ProductInformation.getGitProperty(propertyKey) | ||
|
||
expect: | ||
propertyValue != null | ||
|
||
where: | ||
propertyKey << [ | ||
'git.branch', | ||
'git.build.host', | ||
'git.build.user.email', | ||
'git.build.user.name', | ||
'git.build.version', | ||
'git.closest.tag.commit.count', | ||
'git.closest.tag.name', | ||
'git.commit.id', | ||
'git.commit.id.abbrev', | ||
'git.commit.id.describe', | ||
'git.commit.message.full', | ||
'git.commit.message.short', | ||
'git.commit.time', | ||
'git.commit.user.email', | ||
'git.commit.user.name', | ||
'git.dirty', | ||
'git.remote.origin.url', | ||
'git.tags', | ||
'git.total.commit.count' | ||
] | ||
} | ||
} | ||
|
||
/************************************************************************ | ||
* This is free software - without ANY guarantee! | ||
* | ||
* | ||
* Copyright Dr. Gernot Starke, arc42.org | ||
* | ||
* 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. | ||
* | ||
*********************************************************************** */ | ||
|
Oops, something went wrong.