You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/05/31 04:11:34 UTC
svn commit: r1344533 -
/camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java
Author: ningjiang
Date: Thu May 31 02:11:34 2012
New Revision: 1344533
URL: http://svn.apache.org/viewvc?rev=1344533&view=rev
Log:
CAMEL-5321 Added the file which I missed
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java?rev=1344533&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorSchemaImportTest.java Thu May 31 02:11:34 2012
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.validator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class ValidatorSchemaImportTest extends ContextTestSupport {
+
+ protected MockEndpoint validEndpoint;
+ protected MockEndpoint finallyEndpoint;
+ protected MockEndpoint invalidEndpoint;
+
+ /**
+ * Test for the valid schema location
+ * @throws Exception
+ */
+ public void testRelativeParentSchemaImport() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .doTry()
+ .to("validator:org/apache/camel/component/validator/relativeparent/child/child.xsd")
+ .to("mock:valid")
+ .doCatch(ValidationException.class)
+ .to("mock:invalid")
+ .doFinally()
+ .to("mock:finally")
+ .end();
+ }
+ });
+ validEndpoint.expectedMessageCount(1);
+ finallyEndpoint.expectedMessageCount(1);
+
+ template.sendBody("direct:start",
+ "<childuser xmlns='http://foo.com/bar'><user><id>1</id><username>Test User</username></user></childuser>");
+
+ MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+ }
+
+ /**
+ * Test for the invalid schema import location.
+ *
+ * @throws Exception
+ */
+ public void testDotSlashSchemaImport() throws Exception {
+ this.context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").doTry()
+ .to("validator:org/apache/camel/component/validator/dotslash/child.xsd").to("mock:valid")
+ .doCatch(ValidationException.class).to("mock:invalid").doFinally().to("mock:finally")
+ .end();
+ }
+ });
+ validEndpoint.expectedMessageCount(1);
+ finallyEndpoint.expectedMessageCount(1);
+
+ template
+ .sendBody("direct:start",
+ "<childuser xmlns='http://foo.com/bar'><user><id>1</id><username>Test User</username></user></childuser>");
+
+ MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+ }
+
+ /**
+ * Test for the invalid schema import location.
+ *
+ * @throws Exception
+ */
+ public void testRelativeDoubleSlashSchemaImport() throws Exception {
+ this.context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").doTry()
+ .to("validator:org/apache/camel/component/validator/doubleslash/child.xsd")
+ .to("mock:valid").doCatch(ValidationException.class).to("mock:invalid").doFinally()
+ .to("mock:finally").end();
+ }
+ });
+ validEndpoint.expectedMessageCount(1);
+ finallyEndpoint.expectedMessageCount(1);
+
+ template
+ .sendBody("direct:start",
+ "<childuser xmlns='http://foo.com/bar'><user><id>1</id><username>Test User</username></user></childuser>");
+
+ MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ validEndpoint = resolveMandatoryEndpoint("mock:valid", MockEndpoint.class);
+ invalidEndpoint = resolveMandatoryEndpoint("mock:invalid", MockEndpoint.class);
+ finallyEndpoint = resolveMandatoryEndpoint("mock:finally", MockEndpoint.class);
+ }
+}