Aehm....Are you asking how to get your route into its own class
so that you could use it in a container ?
Andreas
On 10/11/2013 01:22 PM, richie.rivi...@gmail.com wrote:
Hi guys,
I was wondering if someone could give me some help out how to re-write this
camel test into a proper camel program. The issue is I know how to write a
simple route and then execute it. But after the route is executed and I want
to grab the parsed xml in a fashion similar to testStaxExpression how would
I do this in a real Camel application. I know the configure method in the
route is not the right place to do it.
Where is the right place. Sorry for the easy questions. I am a beginner.
package org.apache.camel.component.stax;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.stax.model.Record;
import org.apache.camel.component.stax.model.RecordsUtil;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.apache.camel.component.stax.StAXBuilder.stax;
public class StAXJAXBIteratorExpressionTest extends CamelTestSupport {
@EndpointInject(uri = "mock:records")
private MockEndpoint recordsEndpoint;
@BeforeClass
public static void initRouteExample() {
RecordsUtil.createXMLFile();
}
@Override
public RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
log.info("Doing route");
// START SNIPPET: e1
from("file:target/in")
// split the file using StAX (the stax method is from
StAXBuilder)
// and use streaming mode in the splitter
.split(stax(Record.class)).streaming()
.to("mock:records");
// END SNIPPET: e1
}
};
}
@Test
public void testStaxExpression() throws InterruptedException {
recordsEndpoint.expectedMessageCount(10);
recordsEndpoint.allMessages().body().isInstanceOf(Record.class);
recordsEndpoint.assertIsSatisfied();
Record five =
recordsEndpoint.getReceivedExchanges().get(4).getIn().getBody(Record.class);
assertEquals("4", five.getKey());
assertEquals("#4", five.getValue());
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Help-to-re-write-route-tp5741339.html
Sent from the Camel - Users mailing list archive at Nabble.com.
--
Andreas Gies
WoQ -- Way of Quality UG
Geschäftsführer & CTO
/eMail:/andr...@wayofquality.de <mailto:andr...@wayofquality.de>
/Tel:/ +49 151 23470823
/Fax:/ +49 1805 006534 2114
/Twitter:/ andreasgies /Skype:/ giessonic
/LinkedIn:/ <http://de.linkedin.com/pub/andreas-gies/0/594/aa5/>
(http://de.linkedin.com/pub/andreas-gies/0/594/aa5/)
/Xing:/ <http://www.xing.com/profile/Andreas_Gies>
(http://www.xing.com/profile/Andreas_Gies)
/Blog:/ <http://www.wayofquality.de/index.php/en/blog>
(http://www.wayofquality.de/index.php/en/blog)
/Github:/ <https://github.com/atooni> (https://github.com/atooni)
/Amtsgericht Landshut:/HRB 8352//
//
/Ust.-Id.:/ DE274771254
Haftungsausschluss
Diese Email kann vertrauliche und/oder rechtlich geschützte
Informationen enthalten und ist ausschließlich für den/die benannten
Adressaten bestimmt. Sollten Sie nicht der beabsichtigte Empfänger sein
oder diese Email irrtümlich erhalten haben, ist es Ihnen nicht gestattet
diese Mail oder einen Teil davon ohne unsere Erlaubnis zu verbreiten, zu
kopieren, unbefugt weiterzuleiten oder zu behalten. Informieren Sie
bitte sofort den Absender telefonisch oder per Email und löschen Sie
diese Email und alle Kopien aus Ihrem System. Wir haften nicht für die
Unversehrtheit von Emails, nachdem sie unseren Einflussbereich verlassen
haben.
Disclaimer
This email may contain confidential and/or privileged information and is
intended solely for the attention and use of the named addressee(s). If
you are not the intended recipient, or a person responsible for
delivering it to the intended recipient, you are not authorized to and
must not disclose, copy, distribute, or retain this message or any part
of it without our authority. Please contact the sender by call or reply
email immediately and destroy all copies and the original message. We
are not responsible for the integrity of emails after they have left our
sphere of control.
//