diff --git a/test-mule4-cps-connector/.gitignore b/test-mule4-cps-connector/.gitignore new file mode 100644 index 0000000..823f5f7 --- /dev/null +++ b/test-mule4-cps-connector/.gitignore @@ -0,0 +1,48 @@ +# ------------------------------------------------------------------------------ # +# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) # +# ------------------------------------------------------------------------------ # +*.class + +# Package Files # +*.jar +*.war +*.ear + +# ------------------------------------------------------------------------------------------- # +# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) # +# ------------------------------------------------------------------------------------------- # +*.pydevproject +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.project +.classpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +# --------------- # +# Studio-specific # +# --------------- # +target/ +.mule/** +.mule/**/* +.DS_Store +velocity.log \ No newline at end of file diff --git a/test-mule4-cps-connector/README.md b/test-mule4-cps-connector/README.md new file mode 100644 index 0000000..8f28a5a --- /dev/null +++ b/test-mule4-cps-connector/README.md @@ -0,0 +1,33 @@ +# mule4-skeleton-cps-project +The skeleton-cps-project is an example application that can be used as a template for building a Mule application. + +Note, the scope features of minimal-logging are not displayed correctly by Studio 7.1 or 7.2. Support for displaying SDK connector scopes is expected in Studio 7.3. + +## Uses + +The project contains examples using: + +* The minimal-logging connector, +* The cps (configuration property service) connector, +* Maven deployment using the mule-maven-plugin descriptor. + +## Purpose +This project is an example only. It contains a scheduling component to periodically (every ten minutes), use the minimal-logging operations to generate a new transaction id, display three (enter, warning and exit) log messages. + + +## Runtime properties + +The properties mule.env and mule.key need to be set in the Mule runtime in order for the property configurations to be located. +For Studio, add the following VM command line values when running the API: + + -Dmule.env=local -Dmule.key=Mulesoft12345678 + +## Maven Settingss + +The Mule deployment assumes that certain deployment properties will come from profiles specified when the mvn command is executed. An example-settings.xml is provided as a reference +for creating your own settings.xml file. This is a standard feature of Maven and is described in its online documentation. Once the settings.xml file has been created, export a u and a p shell environment variables containing your Anypoint user name and password. Then use this maven command to deploy the API project: + +``` +mvn clean install deploy -Denv=xxx -DmuleDeploy +``` +Replacing the xxx's with the appropriate values. diff --git a/test-mule4-cps-connector/mule-artifact.json b/test-mule4-cps-connector/mule-artifact.json new file mode 100644 index 0000000..27bc728 --- /dev/null +++ b/test-mule4-cps-connector/mule-artifact.json @@ -0,0 +1,3 @@ +{ + "minMuleVersion": "4.1.1" +} \ No newline at end of file diff --git a/test-mule4-cps-connector/pom.xml b/test-mule4-cps-connector/pom.xml new file mode 100644 index 0000000..c61920d --- /dev/null +++ b/test-mule4-cps-connector/pom.xml @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.mycompany</groupId> + <artifactId>test-mule4-cps-connector</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>mule-application</packaging> + + <name>test-mule4-cps-connector</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + + <app.runtime>4.1.1</app.runtime> + <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version> + <mule.maven.plugin.version>3.1.7</mule.maven.plugin.version> + + <!-- <attachMuleSources>true</attachMuleSources> --> + + <project.name>mule4-skeleton-project</project.name> + <type>example</type> + </properties> + + <build> + <resources> + <resource> + <directory>src/main/resources-filtered/</directory> + <filtering>true</filtering> + </resource> + <resource> + <directory>src/main/resources/</directory> + <filtering>false</filtering> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.mule.tools.maven</groupId> + <artifactId>mule-maven-plugin</artifactId> + <version>${mule.maven.plugin.version}</version> + <extensions>true</extensions> + <configuration> + <armDeployment> + <uri>https://anypoint.mulesoft.com</uri> + <server>anypoint-platform</server> + <target>${deploy.target}</target> + <targetType>${deploy.targetType}</targetType> + <environment>${deploy.environment}</environment> + <muleVersion>${app.runtime}</muleVersion> + <businessGroup>${deploy.businessGroup}</businessGroup> + <applicationName>${artifactId}-${instance.id}-${deploy.app.suffix}</applicationName> + </armDeployment> + </configuration> + <executions> + <execution> + <id>deploy</id> + <phase>deploy</phase> + <goals> + <goal>deploy</goal> + </goals> + <configuration> + <classifier>mule-application</classifier> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.mule.connectors</groupId> + <artifactId>mule-http-connector</artifactId> + <version>1.2.0</version> + <classifier>mule-plugin</classifier> + </dependency> + <dependency> + <groupId>org.mule.cps</groupId> + <artifactId>cps-connector</artifactId> + <classifier>mule-plugin</classifier> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>org.mule.consulting.logging</groupId> + <artifactId>minimal-logging</artifactId> + <version>1.0.1</version> + <classifier>mule-plugin</classifier> + </dependency> + </dependencies> + +</project> diff --git a/test-mule4-cps-connector/src/main/mule/config.xml b/test-mule4-cps-connector/src/main/mule/config.xml new file mode 100644 index 0000000..e937447 --- /dev/null +++ b/test-mule4-cps-connector/src/main/mule/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<mule xmlns:cps="http://www.mulesoft.org/schema/mule/cps" + xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" + xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd +http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd +http://www.mulesoft.org/schema/mule/cps http://www.mulesoft.org/schema/mule/cps/current/mule-cps.xsd"> + + <cps:config name="Configuration_properties_service_Config" + doc:name="Configuration-properties-service Config" doc:id="b994fefb-59ee-48f9-aa88-c9cc40b4c0b8" + configServerBaseUrl="http://localhost:9184/configuration-property-service/v1/config" + insecure="true" projectName="test-mule4-cps-connector" branchName="base" + instanceId="base" envName="${mule.env}" keyId="key1" clientId="x" + clientSecret="x" configId="cps-config" /> + + <http:listener-config name="api-httpListenerConfig" + doc:description="This is not used if a shared domain is configured in the listener..in that case remove this config to prevent this port from showing in the server's port scan." + doc:name="HTTP Listener config"> + <http:listener-connection host="0.0.0.0" + port="${http.port:8081}" /> + </http:listener-config> + +</mule> diff --git a/test-mule4-cps-connector/src/main/mule/test-mule4-cps-connector.xml b/test-mule4-cps-connector/src/main/mule/test-mule4-cps-connector.xml new file mode 100644 index 0000000..aca1ec1 --- /dev/null +++ b/test-mule4-cps-connector/src/main/mule/test-mule4-cps-connector.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" + xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" + xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd +http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd +http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"> + + <flow name="test-mule4-cps-connectorFlow" doc:id="72a74211-241c-4354-8974-ae0d8ce0dca5" > + <http:listener doc:name="Listener" doc:id="71dddb64-c6e8-4327-8039-4e0a4a567680" config-ref="api-httpListenerConfig" + path="/test-mule4-cps-connector/v1"> + <ee:repeatable-file-store-stream /> + </http:listener> + <logger level="INFO" doc:name="Logger" doc:id="8c507c38-5123-421c-88e8-1063d3351155" + message='#["\nI am ${my.second.property} of ${parentage} globally: ${global.one} and defaulted ${myStdDefault:Is Default:)} ${example.project.property32:default}"]'/> + </flow> + <flow name="test-mule4-cps-connectorFlow1" doc:id="837207cd-f9e9-4804-aa9d-ea49f68611df" > + <scheduler doc:name="Scheduler" doc:id="032f342e-217a-47db-bcc1-efe574f77311" > + <scheduling-strategy > + <fixed-frequency frequency="10" timeUnit="SECONDS"/> + </scheduling-strategy> + </scheduler> + <logger level="INFO" doc:name="Logger" doc:id="8c507c38-5123-421c-88e8-1063d3351155" + message='#["\nFrom my config: ${my.second.property}\nImported from Shared: ${parentage}\nImported From Shared/Global: ${global.one}\nUse default value: ${myStdDefault:this is a default value, smiley:)} and this was not a default value: ${example.project.property32:oops used default}"]'/> + </flow> + +</mule> diff --git a/test-mule4-cps-connector/src/main/resources-filtered/cps-boot.properties b/test-mule4-cps-connector/src/main/resources-filtered/cps-boot.properties new file mode 100644 index 0000000..d60cee6 --- /dev/null +++ b/test-mule4-cps-connector/src/main/resources-filtered/cps-boot.properties @@ -0,0 +1,3 @@ +#project.properties is equivalent to the same name with .yaml extension +# This file must include properties that are common for different instances of the application installation. +example.project.property32=exampleProjectProperty32Value diff --git a/test-mule4-cps-connector/src/main/resources-filtered/log4j2.xml b/test-mule4-cps-connector/src/main/resources-filtered/log4j2.xml new file mode 100644 index 0000000..f8265b4 --- /dev/null +++ b/test-mule4-cps-connector/src/main/resources-filtered/log4j2.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<Configuration> + + <!--These are some of the loggers you can enable. + There are several more you can find in the documentation. + Besides this log4j configuration, you can also use Java VM environment variables + to enable other logs like network (-Djavax.net.debug=ssl or all) and + Garbage Collector (-XX:+PrintGC). These will be append to the console, so you will + see them in the mule_ee.log file. --> + + <Appenders> + <RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}${project.artifactId}-${instance.id}-${deploy.app.suffix}.log" + filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}${project.artifactId}-${instance.id}-${deploy.app.suffix}%i.log"> + <PatternLayout pattern="%d [%t] %-5p %c - %m%n" /> + <SizeBasedTriggeringPolicy size="10 MB" /> + <DefaultRolloverStrategy max="10"/> + </RollingFile> + </Appenders> + <Loggers> + <!-- Http Logger shows wire traffic on DEBUG. --> + <!--AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG" /--> + <AsyncLogger name="org.mule.service.http" level="WARN"/> + <AsyncLogger name="org.mule.extension.http" level="WARN"/> + + <!-- Mule classes --> + <AsyncLogger name="org.mule" level="INFO"/> + <AsyncLogger name="com.mulesoft" level="INFO"/> + + <AsyncLogger name="applicationDebug" level="OFF"/> + <AsyncLogger name="applicationInfo" level="INFO"/> + + <AsyncLogger name="org.apache.cxf" level="INFO" /> + <AsyncLogger name="com.ning" level="INFO" /> + <AsyncLogger name="org.glassfish.grizzly" level="INFO" /> + + <AsyncRoot level="INFO"> + <AppenderRef ref="file" /> + </AsyncRoot> + </Loggers> +</Configuration> diff --git a/test-mule4-cps-connector/src/test/resources/archive.json b/test-mule4-cps-connector/src/test/resources/archive.json new file mode 100644 index 0000000..1ccbb7d --- /dev/null +++ b/test-mule4-cps-connector/src/test/resources/archive.json @@ -0,0 +1,160 @@ +{ + "configs": [ + { + "imports": [ + { + "projectName": "Globals", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "QA" + }, + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "keyTwo", + "envName": "QA" + } + ], + "properties": { + "a.b.c": "myvalue", + "my.second.property": "another value", + "another.property": "Third value, why not?", + "cipher.text.properties": "base64 encoded cipher text" + }, + "projectName": "base", + "branchName": "base", + "instanceId": "base", + "envName": "base", + "keyId": "base" + }, + { + "projectName": "Globals", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "QA", + "properties": { + "global.one": "myvalue", + "global.two": "another value", + "another.global.property": "Third value, why not?" + } + }, + { + "projectName": "Globals", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV", + "properties": { + "global.one": "global DEV", + "global.two": "another value", + "another.global.property": "Third value, why not?" + } + }, + { + "projectName": "test-mule4-cps-connector", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV", + "imports": [ + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV" + } + ], + "properties": { + "a.b.c": "myvalue", + "my.second.property": "test-mule4-cps-connector base base DEV base", + "another.property": "Third value, why not?", + "cipher.text.properties": "base64 encoded cipher text" + } + }, + { + "projectName": "test-mule4-cps-connector", + "branchName": "base", + "instanceId": "base", + "keyId": "key1", + "envName": "DEV", + "imports": [ + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV" + } + ], + "properties": { + "a.b.c": "myvalue", + "my.second.property": "test-mule4-cps-connector base base DEV key1", + "another.property": "Third value, why not?", + "cipher.text.properties": "base64 encoded cipher text" + } + }, + { + "projectName": "a-test", + "branchName": "master", + "instanceId": "01", + "keyId": "keyOne", + "envName": "QA", + "imports": [ + { + "projectName": "Globals", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "QA" + }, + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "keyTwo", + "envName": "QA" + } + ], + "properties": { + "a.b.c": "myvalue", + "my.second.property": "another value", + "another.property": "Third value, why not?", + "cipher.text.properties": "base64 encoded cipher text" + } + }, + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV", + "imports": [ + { + "projectName": "Globals", + "branchName": "base", + "instanceId": "base", + "keyId": "base", + "envName": "DEV" + } + ], + "properties": { + "cipher.text.properties": "base64 encoded cipher text", + "parentage": "DEV Shared base base base" + } + }, + { + "projectName": "Shared", + "branchName": "base", + "instanceId": "base", + "keyId": "keyTwo", + "envName": "QA", + "properties": { + "cipher.text.properties": "base64 encoded cipher text" + } + } + ] +} \ No newline at end of file diff --git a/test-mule4-cps-connector/src/test/resources/cps-keystore.jks b/test-mule4-cps-connector/src/test/resources/cps-keystore.jks new file mode 100644 index 0000000..001a09c Binary files /dev/null and b/test-mule4-cps-connector/src/test/resources/cps-keystore.jks differ diff --git a/test-mule4-cps-connector/src/test/resources/log4j2-test.xml b/test-mule4-cps-connector/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..e636919 --- /dev/null +++ b/test-mule4-cps-connector/src/test/resources/log4j2-test.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%-5p %d [%t] %c: %m%n"/> + </Console> + </Appenders> + + <Loggers> + + <!-- Http Logger shows wire traffic on DEBUG. --> + <Logger name="org.mule.service.http" level="WARN"/> + <Logger name="org.mule.extension.http" level="WARN"/> + + <!-- Mule classes --> + <Logger name="org.mule" level="INFO"/> + <Logger name="com.mulesoft" level="INFO"/> + + <AsyncRoot level="INFO"> + <AppenderRef ref="Console"/> + </AsyncRoot> + </Loggers> + +</Configuration> \ No newline at end of file diff --git a/test-mule4-cps-connector/src/test/resources/studio-run-arguments.txt b/test-mule4-cps-connector/src/test/resources/studio-run-arguments.txt new file mode 100644 index 0000000..4403215 --- /dev/null +++ b/test-mule4-cps-connector/src/test/resources/studio-run-arguments.txt @@ -0,0 +1,5 @@ +-M-XX:-UseBiasedLocking +-Dmule_cps_keystore_filename=/usr/local/cps-keystore.jks +-Dmule_cps_keystore_password=changeit +-Dmule_cps_key_password=changeit +-Dmule.env=DEV \ No newline at end of file