Skip to content

Commit

Permalink
Added EBCDIC example.
Browse files Browse the repository at this point in the history
  • Loading branch information
hekonsek committed Jan 24, 2014
1 parent fcc2a7a commit 2799262
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
40 changes: 40 additions & 0 deletions fuse-pocs-camel-ebcdic/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>fuse-pocs</groupId>
<artifactId>fuse-pocs-camel-ebcdic</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<camel.version>2.12.2</camel.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${camel.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package fuse.pocs.camel.ebcdic;

import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

import java.io.InputStream;


public class EbcdicConsumerTest extends CamelTestSupport {

// Routing fixtures

@Produce(uri = "direct:test")
ProducerTemplate producerTemplate;

@EndpointInject(uri = "mock:test")
MockEndpoint mockEndpoint;

/**
* Charsets supported by Oracle JVM - http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html
*/
String ebcdicCharsetName = "Cp1047";

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:test").
unmarshal().string(ebcdicCharsetName).
to(mockEndpoint);
}
};
}

@Test
public void shouldDecodeEbcdic() throws Exception {
// Given
InputStream ebcdicMessage = getClass().getResourceAsStream("ebcdicMessage");
mockEndpoint.expectedMessageCount(1);
mockEndpoint.message(0).body().contains("order-items");

// When
producerTemplate.sendBody(ebcdicMessage);

// Then
assertMockEndpointsSatisfied();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
L�����n@@@@L������n@@@@@@@@L����n慄@Ֆ�@��@��z��z��@���@����La����n@@@@@@@@L��������@������~������nі�La��������n@@@@La������n@@@@L�����`�����n@@@@@@@@L�����`����n@@@@@@@@@@@@L�������n�La�������n@@@@@@@@@@@@L��������n�La��������n@@@@@@@@@@@@L�����n�K��La�����n@@@@@@@@La�����`����n@@@@@@@@L�����`����n@@@@@@@@@@@@L�������n�La�������n@@@@@@@@@@@@L��������n�La��������n@@@@@@@@@@@@L�����n�K��La�����n@@@@@@@@La�����`����n@@@@La�����`�����nLa�����n

0 comments on commit 2799262

Please sign in to comment.