-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added IT test for action and preprocessor user function in maven plugin
- Loading branch information
Showing
7 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
jcp-tests/jcp-test-maven-action/jcp-test-maven-action-action/pom.xml
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,14 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>jcp-test-maven-action</artifactId> | ||
<version>0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jcp-test-maven-action-action</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
</project> |
35 changes: 35 additions & 0 deletions
35
...aven-action-action/src/main/java/com/igormaznitsa/jcp/it/CustomPreprocessorExtension.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,35 @@ | ||
package com.igormaznitsa.jcp.it; | ||
|
||
import com.igormaznitsa.jcp.context.PreprocessorContext; | ||
import com.igormaznitsa.jcp.expression.Value; | ||
import com.igormaznitsa.jcp.extension.PreprocessorExtension; | ||
import java.util.Arrays; | ||
|
||
public class CustomPreprocessorExtension implements PreprocessorExtension { | ||
@Override | ||
public boolean processAction(PreprocessorContext context, Value[] parameters) { | ||
System.out.println("Called action for parameters: " + Arrays.toString(parameters)); | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getUserFunctionArity(String functionName) { | ||
if (functionName.equals("hellofunc")) { | ||
return 1; | ||
} else { | ||
throw new IllegalArgumentException("Unexpected user function: " + functionName); | ||
} | ||
} | ||
|
||
@Override | ||
public Value processUserFunction( | ||
PreprocessorContext context, | ||
String functionName, | ||
Value[] arguments) { | ||
if (functionName.equals("hellofunc")) { | ||
return Value.valueOf("Hello " + arguments[0].toString() + "!"); | ||
} else { | ||
throw new IllegalArgumentException("Unexpected user function call: " + functionName); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
jcp-tests/jcp-test-maven-action/jcp-test-maven-action-plugin-call/pom.xml
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,57 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>jcp-test-maven-action</artifactId> | ||
<version>0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jcp-test-maven-action-plugin-call</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>jcp</artifactId> | ||
<version>${jcp.test.version}</version> | ||
<configuration> | ||
<eol>\r\n</eol> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>preprocess-sources</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>preprocess</goal> | ||
</goals> | ||
<configuration> | ||
<allowWhitespaces>true</allowWhitespaces> | ||
<eol>\r\n</eol> | ||
<extensions> | ||
<extension>java</extension> | ||
</extensions> | ||
<keepAttributes>true</keepAttributes> | ||
<keepComments>true</keepComments> | ||
<keepLines>true</keepLines> | ||
<actionPreprocessorExtension>com.igormaznitsa.jcp.it.CustomPreprocessorExtension | ||
</actionPreprocessorExtension> | ||
<sourceEncoding>UTF-8</sourceEncoding> | ||
<targetEncoding>UTF-8</targetEncoding> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>jcp-test-maven-action-action</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...-action/jcp-test-maven-action-plugin-call/src/main/java/com/igormaznitsa/jcp/it/Main.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,13 @@ | ||
package com.igormaznitsa.jcp.it; | ||
|
||
public class Main { | ||
|
||
public static void main(String ... args) { | ||
//#action "Huzzaa" | ||
System.out.println("Started"); | ||
} | ||
|
||
public static String makeHello() { | ||
return /*$"\""+$hellofunc("jcp")+"\";"$*/ /*-*/ ""; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ion/jcp-test-maven-action-plugin-call/src/test/java/com/igormaznitsa/jcp/it/MainTest.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,11 @@ | ||
package com.igormaznitsa.jcp.it; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class MainTest { | ||
@Test | ||
void testMain() { | ||
Assertions.assertEquals("Hello jcp!", Main.makeHello()); | ||
} | ||
} |
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,19 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>jcp-tests</artifactId> | ||
<version>0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jcp-test-maven-action</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>jcp-test-maven-action-action</module> | ||
<module>jcp-test-maven-action-plugin-call</module> | ||
</modules> | ||
|
||
</project> |
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