Skip to content

Commit

Permalink
[jgitflow-maven-plugin] merging 'release/1.2.4' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 15, 2018
2 parents 5d9d59c + 4e6dc5f commit 64bd804
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ script:
# Remove wcm.io artefacts from repository before cache
- rm -rf $HOME/.m2/repository/io/wcm

# exlude release tags like xyz-1.0.0 or xyz-1
# exlude release tags like 1.0.0
branches:
except:
- /^.*\-\d+(\.\d+\.\d+)?(\..*|\-.*)?$/
- /^\d+(\.\d+\.\d+)?(\..*|\-.*)?$/

# Cache Maven Repository
cache:
Expand Down
6 changes: 6 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
<body>

<release version="1.2.4" date="2018-01-15">
<action type="update" dev="sseifert">
Update to latest CONGA SPI.
</action>
</release>

<release version="1.2.2" date="2017-04-04">
<action type="update" dev="sseifert">
Always use BufferedInputStream to wrap FileInputStream.
Expand Down
6 changes: 3 additions & 3 deletions conga-sling-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm.devops</groupId>
<artifactId>io.wcm.devops.parent_toplevel</artifactId>
<version>1.0.6</version>
<version>1.0.10</version>
<relativePath />
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.sling</artifactId>
<version>1.2.2</version>
<version>1.2.4</version>
<packaging>jar</packaging>

<name>CONGA Sling Plugin</name>
Expand All @@ -53,7 +53,7 @@
<dependency>
<groupId>io.wcm.devops.conga</groupId>
<artifactId>io.wcm.devops.conga.generator</artifactId>
<version>1.3.2</version>
<version>1.5.0</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.text.translate.AggregateTranslator;
import org.apache.commons.lang3.text.translate.CharSequenceTranslator;
import org.apache.commons.lang3.text.translate.LookupTranslator;
import org.apache.commons.text.translate.AggregateTranslator;
import org.apache.commons.text.translate.CharSequenceTranslator;
import org.apache.commons.text.translate.LookupTranslator;

import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin;
import io.wcm.devops.conga.generator.spi.handlebars.context.EscapingStrategyContext;
import io.wcm.devops.conga.generator.util.FileUtil;

/**
Expand All @@ -47,40 +50,23 @@ public class OsgiConfigEscapingStrategy implements EscapingStrategyPlugin {
* http://svn.apache.org/repos/asf/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java
* method 'writeQuoted'.
*/
private static final Map<CharSequence, CharSequence> ESCAPE_OSGI_CONFIG_TRANSLATION = new HashMap<>();
static {
ESCAPE_OSGI_CONFIG_TRANSLATION.put(" ", "\\ ");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\"", "\\\"");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\\", "\\\\");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("=", "\\=");
// well known escapes
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\b", "\\b");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\t", "\\t");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\n", "\\n");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\f", "\\f");
ESCAPE_OSGI_CONFIG_TRANSLATION.put("\r", "\\r");
}
static final CharSequenceTranslator ESCAPE_OSGI_CONFIG =
new AggregateTranslator(
new LookupTranslator(
new String[][] {
{
" ", "\\ "
},
{
"\"", "\\\""
},
{
"\\", "\\\\"
},
{
"=", "\\="
},
// well known escapes
{
"\b", "\\b"
},
{
"\t", "\\t"
},
{
"\n", "\\n"
},
{
"\f", "\\f"
},
{
"\r", "\\r"
}
}),
new CharSequenceTranslator() {
new LookupTranslator(ESCAPE_OSGI_CONFIG_TRANSLATION),
new CharSequenceTranslator() {
@Override
public int translate(CharSequence input, int index, Writer out) throws IOException {
char c = input.charAt(index);
Expand All @@ -92,20 +78,20 @@ public int translate(CharSequence input, int index, Writer out) throws IOExcepti
return 0;
}
}
);
);

@Override
public String getName() {
return NAME;
}

@Override
public boolean accepts(String fileExtension) {
public boolean accepts(String fileExtension, EscapingStrategyContext pluginContext) {
return FileUtil.matchesExtension(fileExtension, FILE_EXTENSION);
}

@Override
public String escape(CharSequence value) {
public String escape(CharSequence value, EscapingStrategyContext pluginContext) {
return value == null ? null : ESCAPE_OSGI_CONFIG.translate(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.wcm.devops.conga.plugins.sling.handlebars.escaping;

import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin;
import io.wcm.devops.conga.generator.spi.handlebars.context.EscapingStrategyContext;
import io.wcm.devops.conga.generator.util.FileUtil;
import io.wcm.devops.conga.plugins.sling.util.ProvisioningUtil;

Expand All @@ -39,13 +40,13 @@ public String getName() {
}

@Override
public boolean accepts(String fileExtension) {
public boolean accepts(String fileExtension, EscapingStrategyContext pluginContext) {
// currently only provisioning files with explicit extension are supported, not with "txt"
return FileUtil.matchesExtension(fileExtension, ProvisioningUtil.FILE_EXTENSION);
}

@Override
public String escape(CharSequence value) {
public String escape(CharSequence value, EscapingStrategyContext pluginContext) {
// use same escaping rules as for OSGi configurations
return value == null ? null : OsgiConfigEscapingStrategy.ESCAPE_OSGI_CONFIG.translate(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Dictionary;
import java.util.List;

import org.apache.commons.lang3.CharEncoding;
import org.apache.felix.cm.file.ConfigurationHandler;
import org.apache.sling.provisioning.model.Model;

Expand Down Expand Up @@ -94,7 +94,7 @@ public FileContext accept(String path, Dictionary<String, Object> properties) th
ConfigurationHandler.write(os, properties);
}

return new FileContext().file(confFile).charset(CharEncoding.UTF_8);
return new FileContext().file(confFile).charset(StandardCharsets.UTF_8);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -53,7 +53,7 @@ public void setUp() {
@Test
public void testApply() throws Exception {
File file = new File("target/generation-test/fileHeader.config");
FileUtils.write(file, "myscript", CharEncoding.UTF_8);
FileUtils.write(file, "myscript", StandardCharsets.UTF_8);

List<String> lines = ImmutableList.of("**********", "", "Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.", "**********");
FileHeaderContext context = new FileHeaderContext().commentLines(lines);
Expand All @@ -62,7 +62,7 @@ public void testApply() throws Exception {
assertTrue(underTest.accepts(fileContext, context));
underTest.apply(fileContext, context);

assertTrue(StringUtils.contains(FileUtils.readFileToString(file, CharEncoding.UTF_8),
assertTrue(StringUtils.contains(FileUtils.readFileToString(file, StandardCharsets.UTF_8),
"# Der Jodelkaiser aus dem Oetztal ist wieder daheim."));

FileHeaderContext extractContext = underTest.extract(fileContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -59,7 +59,7 @@ public void testApply() throws Exception {
assertTrue(underTest.accepts(fileContext, context));
underTest.apply(fileContext, context);

assertTrue(StringUtils.contains(FileUtils.readFileToString(file, CharEncoding.UTF_8),
assertTrue(StringUtils.contains(FileUtils.readFileToString(file, StandardCharsets.UTF_8),
"# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));

FileHeaderContext extractContext = underTest.extract(fileContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public void setUp() {

@Test
public void testValid() {
assertTrue(underTest.accepts("config"));
assertTrue(underTest.accepts("config", null));
}

@Test
public void testInvalid() {
assertFalse(underTest.accepts("txt"));
assertFalse(underTest.accepts("txt", null));
}

@Test
public void testEscape() {
assertEquals("\\ \\\"\\\\", underTest.escape(" \"\\"));
assertEquals("äöü߀/", underTest.escape("äöü߀/"));
assertEquals("aa\\=bb", underTest.escape("aa=bb"));
assertEquals("\\b\\t\\n\\f\\r", underTest.escape("\b\t\n\f\r"));
assertEquals("ab\\u0005c\\u0006", underTest.escape("ab\u0005c\u0006"));
assertEquals("\\ \\\"\\\\", underTest.escape(" \"\\", null));
assertEquals("äöü߀/", underTest.escape("äöü߀/", null));
assertEquals("aa\\=bb", underTest.escape("aa=bb", null));
assertEquals("\\b\\t\\n\\f\\r", underTest.escape("\b\t\n\f\r", null));
assertEquals("ab\\u0005c\\u0006", underTest.escape("ab\u0005c\u0006", null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public void setUp() {

@Test
public void testValid() {
assertTrue(underTest.accepts("provisioning"));
assertEquals("\\ \\\"\\\\", underTest.escape(" \"\\"));
assertEquals("äöü߀/", underTest.escape("äöü߀/"));
assertTrue(underTest.accepts("provisioning", null));
assertEquals("\\ \\\"\\\\", underTest.escape(" \"\\", null));
assertEquals("äöü߀/", underTest.escape("äöü߀/", null));
}

@Test
public void testInvalid() {
assertFalse(underTest.accepts("txt"));
assertFalse(underTest.accepts("txt", null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Dictionary;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.CharEncoding;
import org.apache.felix.cm.file.ConfigurationHandler;
import org.junit.After;
import org.junit.Before;
Expand All @@ -43,6 +43,7 @@

import io.wcm.devops.conga.generator.spi.PostProcessorPlugin;
import io.wcm.devops.conga.generator.spi.context.FileContext;
import io.wcm.devops.conga.generator.spi.context.PluginContextOptions;
import io.wcm.devops.conga.generator.spi.context.PostProcessorContext;
import io.wcm.devops.conga.generator.util.PluginManagerImpl;

Expand Down Expand Up @@ -100,7 +101,7 @@ public void testSimpleConfig() throws Exception {

// post process provisioning example
File provisioningFile = new File(targetDir, "simpleConfig.txt");
FileUtils.write(provisioningFile, PROVISIONING_FILE, CharEncoding.UTF_8);
FileUtils.write(provisioningFile, PROVISIONING_FILE, StandardCharsets.UTF_8);
postProcess(provisioningFile);

// validate generated configs
Expand All @@ -119,7 +120,7 @@ public void testSimpleConfigWithNewline() throws Exception {

// post process provisioning example
File provisioningFile = new File(targetDir, "simpleConfigWithNewline.txt");
FileUtils.write(provisioningFile, PROVISIONING_FILE, CharEncoding.UTF_8);
FileUtils.write(provisioningFile, PROVISIONING_FILE, StandardCharsets.UTF_8);
postProcess(provisioningFile);

// validate generated configs
Expand All @@ -132,10 +133,12 @@ private void postProcess(File provisioningFile) {
// post-process
FileContext fileContext = new FileContext()
.file(provisioningFile)
.charset(CharEncoding.UTF_8);
PostProcessorContext context = new PostProcessorContext()
.charset(StandardCharsets.UTF_8);
PluginContextOptions pluginContextOptions = new PluginContextOptions()
.pluginManager(new PluginManagerImpl())
.logger(LoggerFactory.getLogger(ProvisioningOsgiConfigPostProcessor.class));
PostProcessorContext context = new PostProcessorContext()
.pluginContextOptions(pluginContextOptions);

assertTrue(underTest.accepts(fileContext, context));
underTest.apply(fileContext, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.nio.charset.StandardCharsets;

import org.apache.commons.lang3.CharEncoding;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -45,23 +45,23 @@ public void setUp() {
@Test
public void testValid() throws Exception {
File file = new File(getClass().getResource("/validProvisioning.txt").toURI());
FileContext fileContext = new FileContext().file(file).charset(CharEncoding.UTF_8);
FileContext fileContext = new FileContext().file(file).charset(StandardCharsets.UTF_8);
assertTrue(underTest.accepts(fileContext, null));
underTest.apply(fileContext, null);
}

@Test(expected = ValidationException.class)
public void testInvalid() throws Exception {
File file = new File(getClass().getResource("/invalidProvisioning.txt").toURI());
FileContext fileContext = new FileContext().file(file).charset(CharEncoding.UTF_8);
FileContext fileContext = new FileContext().file(file).charset(StandardCharsets.UTF_8);
assertTrue(underTest.accepts(fileContext, null));
underTest.apply(fileContext, null);
}

@Test
public void testInvalidFileExtension() throws Exception {
File file = new File(getClass().getResource("/noProvisioning.txt").toURI());
FileContext fileContext = new FileContext().file(file).charset(CharEncoding.UTF_8);
FileContext fileContext = new FileContext().file(file).charset(StandardCharsets.UTF_8);
assertFalse(underTest.accepts(fileContext, null));
}

Expand Down
Loading

0 comments on commit 64bd804

Please sign in to comment.