Skip to content

Commit

Permalink
CAMEL-13474: Move dataformats out of camel-core. And camel3 - modular…
Browse files Browse the repository at this point in the history
…ize a bit
  • Loading branch information
davsclaus committed May 2, 2019
1 parent 2c325c4 commit 0799b2f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Expand Up @@ -14,21 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.impl;
package org.apache.camel.dataformat.deflater;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.converter.IOConverter;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

/**
* Unit test of the gzip data format.
*/
public class GzipDataFormatTest extends ContextTestSupport {
public class GzipDataFormatTest extends CamelTestSupport {
private static final String TEXT = "Hamlet by William Shakespeare\n"
+ "To be, or not to be: that is the question:\n"
+ "Whether 'tis nobler in the mind to suffer\n"
Expand All @@ -42,7 +43,7 @@ public boolean isUseRouteBuilder() {
}

private byte[] sendText() throws Exception {
return (byte[]) template.requestBody("direct:start", TEXT.getBytes("UTF-8"));
return (byte[]) template.requestBody("direct:start", TEXT.getBytes(StandardCharsets.UTF_8));
}

@Test
Expand Down Expand Up @@ -71,8 +72,10 @@ public void configure() {
context.start();

MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class);
result.expectedBodiesReceived(TEXT.getBytes("UTF-8"));
result.expectedBodiesReceived(TEXT.getBytes(StandardCharsets.UTF_8));

sendText();

result.assertIsSatisfied();
}
}
Expand Up @@ -23,9 +23,9 @@

import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.language.simple.SimpleLanguage;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.LanguageSupport;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.Scanner;
Expand Down Expand Up @@ -104,12 +104,12 @@ protected Object doEvaluate(Exchange exchange, boolean closeStream) {
*/
protected Iterator<?> createIterator(Exchange exchange, InputStream in, String charset) {
String start = startToken;
if (start != null && SimpleLanguage.hasSimpleFunction(start)) {
start = SimpleLanguage.expression(start).evaluate(exchange, String.class);
if (LanguageSupport.hasSimpleFunction(start)) {
start = exchange.getContext().resolveLanguage("simple").createExpression(start).evaluate(exchange, String.class);
}
String end = endToken;
if (end != null && SimpleLanguage.hasSimpleFunction(end)) {
end = SimpleLanguage.expression(end).evaluate(exchange, String.class);
if (LanguageSupport.hasSimpleFunction(end)) {
end = exchange.getContext().resolveLanguage("simple").createExpression(end).evaluate(exchange, String.class);
}
TokenPairIterator iterator = new TokenPairIterator(start, end, includeTokens, in, charset);
iterator.init();
Expand Down
Expand Up @@ -74,7 +74,7 @@ protected Iterator<?> createIterator(Exchange exchange, InputStream in, String c
tag = exchange.getContext().resolveLanguage("simple").createExpression(tag).evaluate(exchange, String.class);
}
String inherit = inheritNamespaceToken;
if (inherit != null && LanguageSupport.hasSimpleFunction(tag)) {
if (LanguageSupport.hasSimpleFunction(inherit)) {
inherit = exchange.getContext().resolveLanguage("simple").createExpression(inherit).evaluate(exchange, String.class);
}

Expand Down

0 comments on commit 0799b2f

Please sign in to comment.