Java tutorial
/* * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others. * * Licensed 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. * * Contributors: * */ package org.nuxeo.docusign.core.test; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.InputStreamEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.nuxeo.ecm.automation.test.AutomationFeature; import org.nuxeo.ecm.core.test.annotations.Granularity; import org.nuxeo.ecm.core.test.annotations.RepositoryConfig; import org.nuxeo.ecm.webengine.test.WebEngineFeature; import org.nuxeo.runtime.test.runner.*; import java.io.IOException; @RunWith(FeaturesRunner.class) @Features({ AutomationFeature.class, WebEngineFeature.class }) @Jetty(port = 18090) @RepositoryConfig(cleanup = Granularity.METHOD) @Deploy({ "nuxeo-docusign-core", "org.nuxeo.ecm.platform.oauth", "org.nuxeo.ecm.automation.scripting" }) @LocalDeploy({ "nuxeo-docusign-core:OSGI-INF/test-chain-contrib.xml" }) public class TestDocuSignCallback { @Test public void testReceiveCallback() throws IOException { String url = "http://localhost:18090/docusign"; HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(url); post.setEntity(new InputStreamEntity(getClass().getResourceAsStream("/files/callback.xml"))); HttpResponse response = client.execute(post); Assert.assertEquals(200, response.getStatusLine().getStatusCode()); } @Test public void testReceiveCallbackWithURLParam() throws IOException { String url = "http://localhost:18090/docusign/javascript.workflow"; HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(url); post.setEntity(new InputStreamEntity(getClass().getResourceAsStream("/files/callback.xml"))); HttpResponse response = client.execute(post); Assert.assertEquals(200, response.getStatusLine().getStatusCode()); } }