Save point: [skip ci]

* Rename AbstractQueueTransformServiceIT to AbstractQueueTest and change names of subclasses
  Cleaned up the logic and added a comment to say what it was doing (sends messages ok, but fails the transform)
* Clean up application-default.yaml values (duplicate values)
* Renamed probe test files to be probe.???
This commit is contained in:
alandavis
2022-07-21 16:54:51 +01:00
parent ef2305eb81
commit e837feb559
31 changed files with 45 additions and 68 deletions

View File

@@ -19,8 +19,9 @@ A T-Engine project which extends this base is expected to provide the following:
* An implementation of the [TransformEngine](https://github.com/Alfresco/alfresco-transform-core/blob/master/engines/base/src/main/java/org/alfresco/transform/base/TransformEngine.java)
interface to describe the T-Engine.
* Implementations of the [CustomTransformer](engines/base/src/main/java/org/alfresco/transform/base/CustomTransformer.java)
interface with the actual transform code.
interface with the actual transform code.
* An `application-default.yaml` file to define a unique name for the message queue to the T-Engine.
The `TransformEngine` and `CustomTransformer` implementations should have an
`@Component` annotation and be in or below the`org.alfresco.transform` package, so
that they will be discovered by the base T-Engine.
@@ -72,7 +73,7 @@ public class HelloTransformEngine implements TransformEngine
@Override
public ProbeTransform getProbeTransform()
{
return new ProbeTransform("jane.txt", "text/plain", "text/plain",
return new ProbeTransform("probe.txt", "text/plain", "text/plain",
ImmutableMap.of("sourceEncoding", "UTF-8", "language", "English"),
11, 10, 150, 1024, 1, 60 * 2);
}
@@ -141,7 +142,15 @@ public class HelloTransformer implements CustomTransformer
}
```
**Example `ProbeTransform` test file** `jane.txt`
**Example properties** `resources/application-default.yaml`
As can be seen the following defines a default which can be overridden by an environment variable.
```yaml
queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.libreoffice.acs}
```
**Example ProbeTransform test file** `resources/probe.txt`
```json
Jane
```

View File

@@ -29,12 +29,7 @@ transform:
logging:
level:
# org.alfresco.util.exec.RuntimeExec: debug
org.alfresco.transformer.LibreOfficeController: debug
org.alfresco.transformer.JodConverterSharedInstance: debug
org.alfresco.transformer.AlfrescoPdfRendererController: debug
org.alfresco.transformer.ImageMagickController: debug
org.alfresco.transformer.TikaController: debug
org.alfresco.transformer.MiscellaneousTransformersController: debug
# org.alfresco.transform.base.metadataExtractors: debug
org.alfresco.transform.common.TransformerDebug: debug
fileStoreUrl: ${FILE_STORE_URL:http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file}

View File

@@ -45,13 +45,16 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.core.JmsTemplate;
/**
* Checks that a t-engine can respond to its message queue. This is really just checking that
* ${queue.engineRequestQueue} has been configured. The transform request can (and does fail).
*
* @author Lucian Tuca
* created on 15/01/2019
*/
@SpringBootTest(classes={org.alfresco.transform.base.Application.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public abstract class AbstractQueueTransformServiceIT
public abstract class AbstractQueueTest
{
@Autowired
private Queue engineRequestQueue;
@@ -79,7 +82,6 @@ public abstract class AbstractQueueTransformServiceIT
"transformerName",
request.getSourceMediaType(),
request.getTargetMediaType()));
// TransformStack.setReference(request.getInternalContext(), reference);
jmsTemplate.convertAndSend(engineRequestQueue, request, m -> {
m.setJMSCorrelationID(request.getRequestId());
@@ -89,6 +91,9 @@ public abstract class AbstractQueueTransformServiceIT
this.jmsTemplate.setReceiveTimeout(1_000);
TransformReply reply = (TransformReply) this.jmsTemplate.receiveAndConvert(testingQueue);
// The transform may fail (for example the SFS is unavailable), but we check we get a response with the
// correct id, so we know that the message was processed.
assertEquals(request.getRequestId(), reply.getRequestId());
}

View File

@@ -51,7 +51,9 @@ import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
/**
* Super class with a server test harness, which talks to the TransformController using http.
* Very basic requests to the TransformController using http. No longer extended in t-engines as all http interaction
* is now done by the base. Also see {@link TransformControllerTest} and {@link TransformHandlerTest} for more extensive
* tests.
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes={org.alfresco.transform.base.Application.class})
@@ -59,7 +61,7 @@ import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
FakeTransformEngineWithTwoCustomTransformers.class,
FakeTransformerTxT2Pdf.class,
FakeTransformerPdf2Png.class})
public class HttpRequestTest
public class HttpTest
{
@Autowired
private TestRestTemplate restTemplate;