我想看看使用http://anti-xml.org而不是Scala XML 重写bellow脚本.
这是第10章的摘录.在Scala中使用XML格式 - http://ofps.oreilly.com/titles/9780596155957/HerdingXMLInScalaDSLs.html
// code-examples/XML/reading/pattern-matching-script.scala
import scala.xml._
val someXML =
<sammich>
<bread>wheat</bread>
<meat>salami</meat>
<condiments>
<condiment expired="true">mayo</condiment>
<condiment expired="false">mustard</condiment>
</condiments>
</sammich>
someXML match {
case <sammich>{ingredients @ _*}</sammich> => {
for (cond @ <condiments>{_*}</condiments> <- ingredients)
println("condiments: " + cond.text)
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
为什么此测试失败,并显示“ java.lang.AssertionError:mock:// destino收到的消息计数。应为:<12>,但为:<0>”?我只是想测试骆驼是否真的可以重新排序邮件。
进口:
import java.util.ArrayList;
import java.util.List;
import org.apache.camel.CamelContext;
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.guice.CamelModuleWithRouteTypes;
import org.jukito.JukitoModule;
import org.jukito.JukitoRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.google.inject.Inject;
Run Code Online (Sandbox Code Playgroud)
考试:
@RunWith(JukitoRunner.class) public class ResequenceTest {
@Inject protected CamelContext context;
@Produce protected ProducerTemplate template;
public static class Module extends JukitoModule {
@SuppressWarnings("unchecked") protected void configureTest() {
install(new CamelModuleWithRouteTypes(OrderingTestRouteBuilder.class));
}
}
@Test public void testDozenMsgsOrderByIntegerBody() throws Exception {
// fail();
Integer[] input = new Integer[] {12, 11, 10, 9, 8, 7, …Run Code Online (Sandbox Code Playgroud)