You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2016/11/10 17:30:29 UTC
camel git commit: Add missing test case
Repository: camel
Updated Branches:
refs/heads/camel-2.18.x fd41114dd -> 7ed2c514a
Add missing test case
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7ed2c514
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7ed2c514
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7ed2c514
Branch: refs/heads/camel-2.18.x
Commit: 7ed2c514a2b51376e908113eaa32c11e2b0a627e
Parents: fd41114
Author: lburgazzoli <lb...@gmail.com>
Authored: Thu Nov 10 18:29:49 2016 +0100
Committer: lburgazzoli <lb...@gmail.com>
Committed: Thu Nov 10 18:29:49 2016 +0100
----------------------------------------------------------------------
.../ServiceNowTestWithDeprecatedConstants.java | 111 -------------------
...rviceNowTestWithDeprecatedConstantsTest.java | 111 +++++++++++++++++++
2 files changed, 111 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7ed2c514/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstants.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstants.java
deleted file mode 100644
index 793bdf0..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstants.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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.servicenow;
-
-import java.util.UUID;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-
-public class ServiceNowTestWithDeprecatedConstants extends ServiceNowTestSupport {
-
- @Test
- public void testExceptions() throws Exception {
- // 404
- try {
- template().sendBodyAndHeaders(
- "direct:servicenow",
- null,
- new KVBuilder()
- .put(ServiceNowConstants.RESOURCE, "table")
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.SYSPARM_QUERY, "number=" + UUID.randomUUID().toString())
- .put(ServiceNowConstants.TABLE, "incident")
- .build()
- );
- } catch (CamelExecutionException e) {
- assertTrue(e.getCause() instanceof ServiceNowException);
-
- ServiceNowException sne = (ServiceNowException)e.getCause();
- assertEquals("failure", sne.getStatus());
- assertTrue(sne.getMessage().contains("No Record found"));
- assertTrue(sne.getDetail().contains("Records matching query not found"));
- }
-
- // 400
- try {
- template().sendBodyAndHeaders(
- "direct:servicenow",
- null,
- new KVBuilder()
- .put(ServiceNowConstants.RESOURCE, "table")
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.SYSPARM_QUERY, "number=" + UUID.randomUUID().toString())
- .put(ServiceNowConstants.TABLE, "notExistingTable")
- .build()
- );
- } catch (CamelExecutionException e) {
- assertTrue(e.getCause() instanceof ServiceNowException);
-
- ServiceNowException sne = (ServiceNowException)e.getCause();
- assertEquals("failure", sne.getStatus());
- assertTrue(sne.getMessage().contains("Invalid table notExistingTable"));
- assertNull(sne.getDetail());
- }
- }
-
- @Test
- public void testBodyMismatch() throws Exception {
- try {
- template().sendBodyAndHeaders(
- "direct:servicenow",
- "NotAnIncidentObject",
- new KVBuilder()
- .put(ServiceNowConstants.RESOURCE, "table")
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CREATE)
- .put(ServiceNowConstants.TABLE, "incident")
- .build()
- );
-
- fail("Should fail as body is not compatible with model defined in route for table incident");
- } catch (CamelExecutionException e) {
- assertTrue(e.getCause() instanceof IllegalArgumentException);
- }
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:servicenow")
- .to("servicenow:{{env:SERVICENOW_INSTANCE}}"
- + "?userName={{env:SERVICENOW_USERNAME}}"
- + "&password={{env:SERVICENOW_PASSWORD}}"
- //+ "&oauthClientId={{env:SERVICENOW_OAUTH2_CLIENT_ID}}"
- //+ "&oauthClientSecret={{env:SERVICENOW_OAUTH2_CLIENT_SECRET}}"
- + "&model.incident=org.apache.camel.component.servicenow.model.Incident")
- .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
- .to("mock:servicenow");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ed2c514/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstantsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstantsTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstantsTest.java
new file mode 100644
index 0000000..e322217
--- /dev/null
+++ b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestWithDeprecatedConstantsTest.java
@@ -0,0 +1,111 @@
+/**
+ * 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.servicenow;
+
+import java.util.UUID;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class ServiceNowTestWithDeprecatedConstantsTest extends ServiceNowTestSupport {
+
+ @Test
+ public void testExceptions() throws Exception {
+ // 404
+ try {
+ template().sendBodyAndHeaders(
+ "direct:servicenow",
+ null,
+ new KVBuilder()
+ .put(ServiceNowConstants.RESOURCE, "table")
+ .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
+ .put(ServiceNowConstants.SYSPARM_QUERY, "number=" + UUID.randomUUID().toString())
+ .put(ServiceNowConstants.TABLE, "incident")
+ .build()
+ );
+ } catch (CamelExecutionException e) {
+ assertTrue(e.getCause() instanceof ServiceNowException);
+
+ ServiceNowException sne = (ServiceNowException)e.getCause();
+ assertEquals("failure", sne.getStatus());
+ assertTrue(sne.getMessage().contains("No Record found"));
+ assertTrue(sne.getDetail().contains("Records matching query not found"));
+ }
+
+ // 400
+ try {
+ template().sendBodyAndHeaders(
+ "direct:servicenow",
+ null,
+ new KVBuilder()
+ .put(ServiceNowConstants.RESOURCE, "table")
+ .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
+ .put(ServiceNowConstants.SYSPARM_QUERY, "number=" + UUID.randomUUID().toString())
+ .put(ServiceNowConstants.TABLE, "notExistingTable")
+ .build()
+ );
+ } catch (CamelExecutionException e) {
+ assertTrue(e.getCause() instanceof ServiceNowException);
+
+ ServiceNowException sne = (ServiceNowException)e.getCause();
+ assertEquals("failure", sne.getStatus());
+ assertTrue(sne.getMessage().contains("Invalid table notExistingTable"));
+ assertNull(sne.getDetail());
+ }
+ }
+
+ @Test
+ public void testBodyMismatch() throws Exception {
+ try {
+ template().sendBodyAndHeaders(
+ "direct:servicenow",
+ "NotAnIncidentObject",
+ new KVBuilder()
+ .put(ServiceNowConstants.RESOURCE, "table")
+ .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CREATE)
+ .put(ServiceNowConstants.TABLE, "incident")
+ .build()
+ );
+
+ fail("Should fail as body is not compatible with model defined in route for table incident");
+ } catch (CamelExecutionException e) {
+ assertTrue(e.getCause() instanceof IllegalArgumentException);
+ }
+ }
+
+ // *************************************************************************
+ //
+ // *************************************************************************
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:servicenow")
+ .to("servicenow:{{env:SERVICENOW_INSTANCE}}"
+ + "?userName={{env:SERVICENOW_USERNAME}}"
+ + "&password={{env:SERVICENOW_PASSWORD}}"
+ //+ "&oauthClientId={{env:SERVICENOW_OAUTH2_CLIENT_ID}}"
+ //+ "&oauthClientSecret={{env:SERVICENOW_OAUTH2_CLIENT_SECRET}}"
+ + "&model.incident=org.apache.camel.component.servicenow.model.Incident")
+ .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
+ .to("mock:servicenow");
+ }
+ };
+ }
+}