initial checkin

This commit is contained in:
2021-04-22 15:58:20 -04:00
commit a7fef4641b
278 changed files with 14028 additions and 0 deletions

9
beedk-ate-archetype/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
# Maven
/target
pom.xml.versionsBackup
# Eclipse
.settings
.project
.classpath

View File

@@ -0,0 +1,56 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.inteligr8.ootbee</groupId>
<artifactId>beedk-ate-archetype</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-archetype</packaging>
<name>Order of the Bee Development Kit: Project Scaffolding for an ACS Platform Module</name>
<scm>
<url>https://bitbucket.org/inteligr8/ootbee-beedk</url>
</scm>
<organization>
<name>Order of the Bee</name>
<url>https://orderofthebee.net</url>
</organization>
<developers>
<developer>
<name>Brian Long</name>
<email>brian@inteligr8.com</email>
<organization>Inteligr8</organization>
<organizationUrl>https://www.inteligr8.com</organizationUrl>
<url>https://twitter.com/brianmlong</url>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
</properties>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>3.1.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.20</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>com.inteligr8:maven-public-deploy-tile:[1.0.0,2.0.0)</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,40 @@
<archetype-descriptor name="${project.artifactId}"
xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd">
<requiredProperties>
<requiredProperty key="shortname">
<validationRegex>[A-Za-z0-9]+</validationRegex>
</requiredProperty>
<requiredProperty key="dockerRegistryHost">
<defaultValue>quay.io</defaultValue>
</requiredProperty>
<requiredProperty key="dockerImagePrefix">
<defaultValue>local</defaultValue>
</requiredProperty>
<requiredProperty key="beedkVersion">
<defaultValue>[1.0.0,2.0.0)</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true">
<directory>src/test/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true">
<directory>src</directory>
<excludes>
<exclude>main/java/**/*</exclude>
<exclude>test/java/**/*</exclude>
</excludes>
</fileSet>
</fileSets>
</archetype-descriptor>

View File

@@ -0,0 +1,9 @@
# Maven
/target
pom.xml.versionsBackup
# Eclipse
.settings
.project
.classpath

View File

@@ -0,0 +1,85 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
<name>${shortname} Alfresco T-Engine</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<ats.version>2.3.6</ats.version>
<spring-boot.version>2.3.5.RELEASE</spring-boot.version>
<docker.image.registry>${dockerRegistryHost}</docker.image.registry>
<docker.image.name>${dockerImagePrefix}/${project.artifactId}</docker.image.name>
<docker.image.tag>${project.version}</docker.image.tag>
</properties>
<dependencies>
<dependency>
<groupId>com.inteligr8.ootbee</groupId>
<artifactId>beedk-ate-springboot</artifactId>
<version>${beedkVersion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.inteligr8.ootbee</groupId>
<artifactId>beedk-ate-springboot-test</artifactId>
<version>${beedkVersion}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.20</version>
<extensions>true</extensions>
<configuration>
<tiles>
<!-- Documentation: https://bitbucket.org/inteligr8/ootbee-beedk/src/stable/beedk-ate-docker-tile -->
<tile>com.inteligr8.ootbee:beedk-ate-docker-tile:${beedkVersion}</tile>
<!-- Documentation: https://bitbucket.org/inteligr8/ootbee-beedk/src/stable/beedk-ate-springboot-tile -->
<tile>com.inteligr8.ootbee:beedk-ate-springboot-tile:${beedkVersion}</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>inteligr8-releases</id>
<url>http://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
</repository>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>inteligr8-releases</id>
<url>http://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,28 @@
FROM docker.inteligr8.com/inteligr8/ubuntu-jdk:20.04-11
# Set default user information
ARG JAR_FILE
ARG APPGROUPNAME=alfresco
ARG APPGROUPID=1000
ARG APPUSERNAME=atengine
ARG APPUSERID=33001
ENV JAVA_OPTS="-Xmx128m"
ENV JAR_PATH=/usr/local/bin/${project.artifactId}.jar
COPY ${JAR_FILE} ${JAR_PATH}
# Install your engine's dependencies here
#RUN apt update && \
# apt -y install {dependency names in APT repository}
RUN groupadd -g ${APPGROUPID} ${APPGROUPNAME} && \
useradd -u ${APPUSERID} -G ${APPGROUPNAME} ${APPUSERNAME} && \
chown ${APPUSERNAME}:${APPGROUPNAME} ${JAR_PATH}
EXPOSE 8090
USER ${APPUSERNAME}
ENTRYPOINT java ${JAVA_OPTS} -jar ${JAR_PATH}

View File

@@ -0,0 +1,67 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package ${groupId};
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.event.EventListener;
import io.micrometer.core.instrument.MeterRegistry;
@SpringBootApplication
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
@ImportResource({"classpath*:application-context.xml"})
public class Application {
private final Logger logger = LoggerFactory.getLogger(Application.class);
@Value("${container.name}")
private String containerName;
@Bean
public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> registry.config().commonTags("containerName", this.containerName);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@EventListener(ApplicationReadyEvent.class)
public void startup() {
this.logger.info("Starting application components... Done");
}
}

View File

@@ -0,0 +1,145 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*
* Copyright (C) 2020 - 2021 Inteligr8
*/
package ${groupId};
import java.io.File;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.PostConstruct;
import org.alfresco.transformer.AbstractTransformerController;
import org.alfresco.transformer.probes.ProbeTestTransform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
/**
* Controller for the Spring Boot transformer.
*
* Status Codes:
*
* 200 Success
* 400 Bad Request: Request parameter <name> is missing (missing mandatory parameter)
* 400 Bad Request: Request parameter <name> is of the wrong type
* 400 Bad Request: Transformer exit code was not 0 (possible problem with the source file)
* 400 Bad Request: The source filename was not supplied
* 500 Internal Server Error: (no message with low level IO problems)
* 500 Internal Server Error: The target filename was not supplied (should not happen as targetExtension is checked)
* 500 Internal Server Error: Transformer version check exit code was not 0
* 500 Internal Server Error: Transformer version check failed to create any output
* 500 Internal Server Error: Could not read the target file
* 500 Internal Server Error: The target filename was malformed (should not happen because of other checks)
* 500 Internal Server Error: Transformer failed to create an output file (the exit code was 0, so there should be some content)
* 500 Internal Server Error: Filename encoding error
* 507 Insufficient Storage: Failed to store the source file
*/
@Controller
public class TransformerController extends AbstractTransformerController {
private final Logger logger = LoggerFactory.getLogger(TransformerController.class);
private final Pattern fileext = Pattern.compile("\\.([^\\.]+)$");
@Autowired
private TransformerImpl transformer;
#set( $dollar = '$' )
@Value("${dollar}{transform.${shortname}.version}")
private String version;
private ProbeTestTransform probe;
@Override
public String getTransformerName() {
return "${shortname}";
}
@Override
public String version() {
return this.version;
}
@PostConstruct
public void initProbe() {
this.probe = new ProbeTestTransform(this, "quick.src", "quick.trgt",
7455L, 1024L, 150, 10240L, 60L * 20L + 1L, 60L * 15L - 15L) {
@Override
protected void executeTransformCommand(File sourceFile, File targetFile) {
if (logger.isTraceEnabled())
logger.trace("getProbeTestTransform().executeTransformCommand('" + sourceFile + "', '" + targetFile + "')");
// TODO test a transformation
}
};
}
@Override
public ProbeTestTransform getProbeTestTransform() {
if (this.logger.isTraceEnabled())
this.logger.trace("getProbeTestTransform()");
return this.probe;
}
@Override
protected String getTransformerName(final File sourceFile, final String sourceMimetype, final String targetMimetype, final Map<String, String> transformOptions) {
if (this.logger.isTraceEnabled())
this.logger.trace("getTransformerName('" + sourceFile + "', '" + sourceMimetype + "', '" + targetMimetype + "', " + transformOptions + ")");
// does not matter what value is returned, as it is not used because there is only one.
return this.getTransformerName();
}
@Override
public void transformImpl(String transformName, String sourceMimetype, String targetMimetype, Map<String, String> transformOptions, File sourceFile, File targetFile) {
if (this.logger.isTraceEnabled())
this.logger.trace("transformImpl('" + transformName + "', '" + sourceMimetype + "', '" + targetMimetype + "', " + transformOptions.keySet() + ", '" + sourceFile + "', '" + targetFile + "')");
if (sourceMimetype == null) {
Matcher matcher = this.fileext.matcher(sourceFile.getAbsolutePath());
sourceMimetype = matcher.find() ? this.ext2mime(matcher.group(1)) : null;
}
if (targetMimetype == null) {
Matcher matcher = this.fileext.matcher(targetFile.getAbsolutePath());
targetMimetype = matcher.find() ? this.ext2mime(matcher.group(1)) : MediaType.TEXT_PLAIN_VALUE;
}
this.transformer.transform(transformName, sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
}
private String ext2mime(String ext) {
switch (ext.toLowerCase()) {
// add applicable extensions here
case "text":
case "txt": return MediaType.TEXT_PLAIN_VALUE;
default: return null;
}
}
}

View File

@@ -0,0 +1,45 @@
package ${groupId};
import java.io.File;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.alfresco.transformer.executors.Transformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class TransformerImpl implements Transformer {
private final Logger logger = LoggerFactory.getLogger(TransformerImpl.class);
private final String id = "${shortname}";
@PostConstruct
public void init() throws Exception {
if (this.logger.isDebugEnabled())
this.logger.debug("init()");
}
@Override
public String getTransformerId() {
return this.id;
}
@Override
public void extractMetadata(String transformName, String sourceMimetype, String targetMimetype, Map<String, String> transformOptions, File sourceFile, File targetFile) {
if (this.logger.isTraceEnabled())
this.logger.trace("extractMetadata('" + transformName + "', '" + sourceMimetype + "', '" + targetMimetype + "', " + transformOptions.keySet() + ", '" + sourceFile + "', '" + targetFile + "')");
this.transform(transformName, sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
}
@Override
public void transform(String transformName, String sourceMimetype, String targetMimetype, Map<String, String> transformOptions, File sourceFile, File targetFile) {
if (this.logger.isTraceEnabled())
this.logger.trace("transform('" + transformName + "', '" + sourceMimetype + "', '" + targetMimetype + "', " + transformOptions.keySet() + ", '" + sourceFile + "', '" + targetFile + "')");
// TODO implement your transformation logic here
}
}

View File

@@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean autowire-candidate="true" class="org.alfresco.transformer.clients.AlfrescoSharedFileStoreClient" />
<bean autowire-candidate="true" class="org.springframework.web.client.RestTemplate" />
<bean autowire-candidate="true" class="org.alfresco.transform.client.model.TransformRequestValidator" />
<bean autowire-candidate="true" class="org.alfresco.transformer.TransformRegistryImpl" />
</beans>

View File

@@ -0,0 +1,14 @@
queue:
#set( $dollar = '$' )
engineRequestQueue: ${dollar}{TRANSFORM_ENGINE_REQUEST_QUEUE:${groupId}.${shortname}.acs}
transform:
core:
config:
location: classpath:this_engine_config.json
${shortname}:
version: ${project.version}
logging:
level:
${groupId}: ${dollar}{LOG_LEVEL:info}

View File

@@ -0,0 +1,21 @@
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div>
<h2>${shortname} Test Transformation</h2>
<form method="POST" enctype="multipart/form-data" action="/transform">
<table>
<tr><td><div style="text-align:right">file *</div></td><td><input type="file" name="file" /></td></tr>
<tr><td><div style="text-align:right">targetExtension *</div></td><td><input type="text" name="targetExtension" value="" /></td></tr>
<!-- Add a row for each of your transform options -->
<tr><td></td><td><input type="submit" value="Transform" /></td></tr>
</table>
</form>
</div>
<div>
<a href="/log">Log entries</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,18 @@
{
"transformOptions": {
"${shortname}Options": [
// {"value": {"name": "profile"}},
]
},
"transformers": [
{
"transformerName": "${shortname}",
"supportedSourceAndTargetList": [
// {"sourceMediaType": "text/plain", "priority": 10, "targetMediaType": "text/plain" }
],
"transformOptions": [
"${shortname}Options"
]
}
]
}

View File

@@ -0,0 +1,174 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package ${groupId};
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.HttpStatusCodeException;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class HttpRequestIT {
private final Logger logger = LoggerFactory.getLogger(HttpRequestIT.class);
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
protected String baseUrl;
@PostConstruct
public void init() {
this.baseUrl = "http://localhost:" + this.port;
}
@Test
public void testRootPath() {
String result = this.restTemplate.getForObject(this.baseUrl, String.class);
if (this.logger.isDebugEnabled())
this.logger.debug("testRootPath(): result: " + result);
Assert.assertNotNull("A result from the HTTP GET was expected", result);
Document htmldoc = Jsoup.parse(result);
Assert.assertNotNull("An HTML compliant result was expected: " + result.substring(0, 50), htmldoc);
Elements elements = htmldoc.select("html body h2");
Assert.assertFalse("The HTML body is expected to have an h2 element: html: " + htmldoc.toString(), elements.isEmpty());
Assert.assertEquals("The HTML body is expected to have just one h2 element", 1, elements.size());
Assert.assertEquals("The HTML body header is not what was expected", "${shortname} Test Transformation", elements.html());
elements = htmldoc.select("html input");
Set<String> inputs = new HashSet<String>();
for (Element element : elements)
inputs.add(element.attr("name"));
Assert.assertTrue("The HTML is expected to have a form input for 'file': " + inputs.toString(), inputs.contains("file"));
Assert.assertTrue("The HTML is expected to have a form input for 'targetExtension': " + inputs.toString(), inputs.contains("targetExtension"));
}
@Test
public void testLogPath() {
String result = this.restTemplate.getForObject(this.baseUrl + "/log", String.class);
if (this.logger.isDebugEnabled())
this.logger.debug("testLogPath(): result: " + result);
Assert.assertNotNull("A result from the HTTP GET was expected", result);
Document htmldoc = Jsoup.parse(result);
Assert.assertNotNull("An HTML compliant result was expected: " + result.substring(0, 50), htmldoc);
Elements elements = htmldoc.select("html body div h2");
Assert.assertFalse("The HTML is expected to have an html/body/div/h2 element: html: " + htmldoc.select("html").toString(), elements.isEmpty());
Assert.assertEquals("The HTML is expected to have just one html/body/div/h2 element", 1, elements.size());
Assert.assertEquals("The HTML body header is not what was expected", "${shortname} Log Entries", elements.html());
}
@Test
public void testNoPath() {
try {
ResponseEntity<String> response = this.restTemplate.getForEntity(this.baseUrl + "/doesnotexist", String.class);
Assert.assertEquals("An unexpected path must return a 404 error", 404, response.getStatusCodeValue());
} catch (HttpStatusCodeException hsce) {
Assert.assertEquals("An unexpected path must return a 404 error", 404, hsce.getRawStatusCode());
}
}
@Test
public void testServiceGet() {
try {
ResponseEntity<String> response = this.restTemplate.getForEntity(this.baseUrl + "/transform", String.class);
Assert.assertEquals("An unexpected path must return a 405 error", 405, response.getStatusCodeValue());
} catch (HttpStatusCodeException hsce) {
Assert.assertEquals("An unexpected path must return a 405 error", 405, hsce.getRawStatusCode());
}
}
@Test
public void testServiceNoFile() {
try {
ResponseEntity<String> response = this._testService(null, "trgt");
Assert.assertEquals("An unexpected path must return a 400 error", 400, response.getStatusCodeValue());
} catch (HttpStatusCodeException hsce) {
Assert.assertEquals("An unexpected path must return a 400 error", 400, hsce.getRawStatusCode());
}
}
@Test @Ignore
public void testServiceNoTargetExtension() {
try {
ResponseEntity<String> response = this._testService("quick.src", null);
Assert.assertEquals("An unexpected path must return a 400 error", 400, response.getStatusCodeValue());
} catch (HttpStatusCodeException hsce) {
Assert.assertEquals("An unexpected path must return a 400 error", 400, hsce.getRawStatusCode());
}
}
@Test @Ignore
public void testServiceQuick() {
this._testService("quick.src", "trgt");
}
protected ResponseEntity<String> _testService(String filename, String targetExtension) {
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
if (filename != null)
parameters.add("file", new ClassPathResource(filename));
if (targetExtension != null)
parameters.add("targetExtension", targetExtension);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<>(parameters, headers);
return this.restTemplate.postForEntity(this.baseUrl + "/transform", entity, String.class);
}
}

View File

@@ -0,0 +1,22 @@
package ${groupId};
import org.alfresco.transformer.AbstractTransformerController;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = TransformerController.class)
public class TransformerControllerTest {
@Autowired
protected AbstractTransformerController controller;
@Test @Ignore
public void test() {
}
}

View File

@@ -0,0 +1,14 @@
queue:
#set( $dollar = '$' )
engineRequestQueue: ${dollar}{TRANSFORM_ENGINE_REQUEST_QUEUE:${groupId}.${shortname}.acs}
transform:
core:
config:
location: classpath:this_engine_config.json
${shortname}:
version: ${project.version}
logging:
level:
${groupId}: ${dollar}{LOG_LEVEL:trace}