From 32d17447a258188b2d534bcb0bf65a659ba7b7d0 Mon Sep 17 00:00:00 2001 From: mcentner Date: Fri, 29 Aug 2008 12:11:34 +0000 Subject: Initial import. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../bku/binding/BindingProcessorManagerTest.java | 46 +++ .../gv/egiz/bku/binding/DataUrlConnectionTest.java | 186 ++++++++++++ .../at/gv/egiz/bku/binding/DummyStalFactory.java | 30 ++ .../at/gv/egiz/bku/binding/ExpiryRemoverTest.java | 65 +++++ .../egiz/bku/binding/HttpBindingProcessorTest.java | 315 +++++++++++++++++++++ .../java/at/gv/egiz/bku/binding/IdFactoryTest.java | 63 +++++ .../egiz/bku/binding/InputDecoderFactoryTest.java | 96 +++++++ .../bku/binding/MultiTestDataUrlConnection.java | 49 ++++ .../egiz/bku/binding/MultipartSLRequestTest.java | 57 ++++ .../at/gv/egiz/bku/binding/NullOperationTest.java | 52 ++++ .../at/gv/egiz/bku/binding/RequestFactory.java | 116 ++++++++ .../egiz/bku/binding/SSLDataUrlConnectionTest.java | 39 +++ .../gv/egiz/bku/binding/TestDataUrlConnection.java | 123 ++++++++ 13 files changed, 1237 insertions(+) create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/IdFactoryTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/InputDecoderFactoryTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/MultiTestDataUrlConnection.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/RequestFactory.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/SSLDataUrlConnectionTest.java create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java (limited to 'bkucommon/src/test/java/at/gv/egiz/bku/binding') diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java new file mode 100644 index 00000000..16d5451a --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java @@ -0,0 +1,46 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class BindingProcessorManagerTest { + + @Before + public void setUp() { + IdFactory.getInstance().setNumberOfBits(24*10); + } + + + @Test(expected = UnsupportedOperationException.class) + public void basicCreationTest() { + BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl()); + BindingProcessor bp = manager.createBindingProcessor("http", null); + assertNotNull(bp.getId().toString()); + assertEquals(40, bp.getId().toString().length()); + String hansi = "Hansi"; + bp = manager.createBindingProcessor("http",hansi); + assertEquals(hansi, bp.getId().toString()); + bp = manager.createBindingProcessor("HtTp", null); + assertNotNull(bp); + manager.createBindingProcessor("seppl", null); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java new file mode 100644 index 00000000..d9995fdd --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java @@ -0,0 +1,186 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package at.gv.egiz.bku.binding; + +import at.gv.egiz.bku.slcommands.SLCommandFactory; +import at.gv.egiz.bku.slcommands.SLResult; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.InetSocketAddress; +import java.net.URL; +import java.net.URLConnection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import static org.junit.Assert.*; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author clemens + */ +public class DataUrlConnectionTest { + + public static final String REQUEST_RESOURCE = "at/gv/egiz/bku/binding/NOPMultipartDataUrl.txt"; + + private static final Log log = LogFactory.getLog(DataUrlConnectionTest.class); + + static HttpServer server; + static BindingProcessor bindingProcessor; + static BindingProcessorManager manager; + + protected InputStream requestStream; + + @BeforeClass + public static void setUpHTTPServer() throws IOException { + log.debug("setting up HTTPServer"); + InetSocketAddress addr = new InetSocketAddress("localhost", 8081); + server = HttpServer.create(addr, 0); + server.createContext("/", new DataUrlHandler()); + server.start(); + + log.debug("setting up HTTPBindingProcessor"); + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + bindingProcessor = (HTTPBindingProcessor) manager.createBindingProcessor( + "http", null); + Map headers = new HashMap(); + headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA + + ";boundary=---------------------------2330864292941"); + ((HTTPBindingProcessor) bindingProcessor).setHTTPHeaders(headers); + } + + @Before + public void setUp() { + requestStream = getClass().getClassLoader().getResourceAsStream( + REQUEST_RESOURCE); + } + + @AfterClass + public static void stopServer() { + if (server != null) { + log.debug("stopping HTTPServer"); + server.stop(0); + } + } + + @Test + public void testBasicNop() { + bindingProcessor.consumeRequestStream(requestStream); + // manager.process(bindingProcessor); + bindingProcessor.run(); + } + +// @Test + public void openConnectionTest() throws Exception { + + URL dataUrl = new URL("http://localhost:8081/"); + + log.debug("creating DataUrlConnection " + dataUrl.toString()); + DataUrlConnectionImpl c = new DataUrlConnectionImpl(); + c.init(dataUrl); + + c.setHTTPHeader("httpHeader_1", "001"); + ByteArrayInputStream bais = new ByteArrayInputStream("Hello, world!" + .getBytes()); + c.setHTTPFormParameter("formParam_1", bais, "text/plain", "UTF-8", null); + + log.debug("open dataUrl connection"); + c.connect(); + //TODO mock SLResult and c.transmit(result); + } + + static class DataUrlHandler implements HttpHandler { + + public DataUrlHandler() { + log.debug("setting up DataUrlHandler"); + } + + @Override + public void handle(HttpExchange exchange) throws IOException { + log.debug("handling incoming request"); + logHTTPHeaders(exchange.getRequestHeaders()); + logRequest(exchange.getRequestBody()); + + log.debug("sending dummy response"); + exchange.getResponseHeaders().add("Content-type", "text/html"); + String response = "" + new Date() + " for " + + exchange.getRequestURI(); + exchange.sendResponseHeaders(200, response.length()); + + OutputStream os = exchange.getResponseBody(); + os.write(response.getBytes()); + os.close(); + } + + private void logRequest(InputStream in) throws IOException { + StringBuilder reqLogMsg = new StringBuilder("HTTP request: \n"); + int c = 0; + while ((c = in.read()) != -1) { + reqLogMsg.append((char) c); + } + log.debug(reqLogMsg.toString()); + in.close(); + } + + private void logHTTPHeaders(Headers headers) { + StringBuilder headersLogMsg = new StringBuilder("HTTP headers: \n"); + Set keys = headers.keySet(); + Iterator keysIt = keys.iterator(); + while (keysIt.hasNext()) { + String key = keysIt.next(); + List values = headers.get(key); + Iterator valuesIt = values.iterator(); + headersLogMsg.append(' '); + headersLogMsg.append(key); + headersLogMsg.append(": "); + while (valuesIt.hasNext()) { + headersLogMsg.append(valuesIt.next()); + headersLogMsg.append(' '); + } + headersLogMsg.append('\n'); + } + log.debug(headersLogMsg.toString()); + } + } +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java new file mode 100644 index 00000000..45dcdc3a --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java @@ -0,0 +1,30 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALFactory; + +public class DummyStalFactory implements STALFactory { + + @Override + public STAL createSTAL() { + // TODO Auto-generated method stub + return new at.gv.egiz.stal.dummy.DummySTAL(); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java new file mode 100644 index 00000000..41c69a1d --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java @@ -0,0 +1,65 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ExpiryRemoverTest { + + @Test + public void testMe() throws InterruptedException { + BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + BindingProcessor bp = manager.createBindingProcessor("http", null); + ExpiryRemover remover = new ExpiryRemover(); + remover.setBindingProcessorManager(manager); + remover.execute(); + manager.process(bp); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 1); + remover.setMaxAcceptedAge(1000); + Thread.sleep(500); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 1); + Thread.sleep(510); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 0); + } + + @Test + public void testMe2() throws InterruptedException { + BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + BindingProcessor bp = manager.createBindingProcessor("http", null); + ExpiryRemover remover = new ExpiryRemover(); + remover.setBindingProcessorManager(manager); + remover.execute(); + manager.process(bp); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 1); + remover.setMaxAcceptedAge(1000); + Thread.sleep(500); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 1); + bp.updateLastAccessTime(); + Thread.sleep(510); + remover.execute(); + assertTrue(manager.getManagedIds().size() == 1); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java new file mode 100644 index 00000000..38f61aa2 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java @@ -0,0 +1,315 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import at.gv.egiz.bku.binding.MultiTestDataUrlConnection.DataSourceProvider; +import at.gv.egiz.bku.utils.StreamUtil; + +public class HttpBindingProcessorTest { + + public static class TestDataSource implements DataSourceProvider { + + private List responseCodes = new ArrayList(); + private List content = new ArrayList(); + private List> responseHeaders = new ArrayList>(); + private int counter = -1; + + public void resetCounter() { + counter = -1; + } + + public void addResponse(int responseCode, String content, + Map headerMap) { + responseCodes.add(new Integer(responseCode)); + this.content.add(content); + this.responseHeaders.add(headerMap); + } + + @Override + public int getResponseCode() { + return responseCodes.get(counter); + } + + @Override + public String getResponseContent() { + return content.get(counter); + } + + @Override + public Map getResponseHeaders() { + return responseHeaders.get(counter); + } + + @Override + public void nextEvent() { + if (++counter >= responseCodes.size()) { + counter = 0; + } + } + } + + protected BindingProcessorManager manager; + protected HTTPBindingProcessor bindingProcessor; + protected Map serverHeaderMap; + protected Map clientHeaderMap; + protected TestDataUrlConnection server; + + @Before + public void setUp() throws IOException { + server = new TestDataUrlConnection(); + DataUrl.setDataUrlConnectionClass(server); + serverHeaderMap = new HashMap(); + serverHeaderMap.put("Content-Type", HttpUtil.TXT_XML); + server.setResponseCode(200); + server.setResponseContent(""); + server.setResponseHeaders(serverHeaderMap); + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + bindingProcessor = (HTTPBindingProcessor) manager.createBindingProcessor( + "http", null); + clientHeaderMap = new HashMap(); + clientHeaderMap.put("Content-Type", + "application/x-www-form-urlencoded;charset=utf8"); + bindingProcessor.setHTTPHeaders(clientHeaderMap); + } + + protected String resultAsString(String encoding) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + bindingProcessor.writeResultTo(baos, encoding); + return new String(baos.toByteArray(), encoding); + } + + @Test + public void testWithoutDataUrlWithoutStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm("Haßnsi", "Wüurzel"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationResponse") != -1); + assertEquals(200, bindingProcessor.getResponseCode()); + assertEquals(0, bindingProcessor.getResponseHeaders().size()); + } + + @Test + public void testWithoutDataUrlWithStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm("Hansi", "Wurzel"); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_HTML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullKommaJosef") != -1); + assertEquals(200, bindingProcessor.getResponseCode()); + assertEquals(0, bindingProcessor.getResponseHeaders().size()); + } + + @Test + public void testWithDataUrl301WithStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(301); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationRequest") != -1); + assertEquals(301, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() > 0); + } + + @Test + public void testWithDataUrl302WithStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(302); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationRequest") != -1); + assertEquals(302, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() > 0); + } + + @Test + public void testWithDataUrl303WithStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(303); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationRequest") != -1); + assertEquals(303, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() > 0); + } + + @Test + public void testWithDataUrl306WithStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(306); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("ErrorResponse") != -1); + assertEquals(200, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() == 0); + } + + @Test + public void testWithDataUrl307NonXML() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(307); + serverHeaderMap.put("Content-Type", HttpUtil.TXT_PLAIN); + server.setResponseHeaders(serverHeaderMap); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_PLAIN, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationRequest") != -1); + assertEquals(307, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() > 0); + } + + @Test + public void testWithInvalidDataUrl307XML() throws IOException { + RequestFactory rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(307); + serverHeaderMap.put("Content-Type", HttpUtil.TXT_XML); + serverHeaderMap.put("Location", "noUrl"); + server.setResponseHeaders(serverHeaderMap); + rf = new RequestFactory(); + server.setResponseContent(rf.getNullOperationXML()); + bindingProcessor.run(); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("ErrorResponse") != -1); + assertEquals(200, bindingProcessor.getResponseCode()); + assertTrue(bindingProcessor.getResponseHeaders().size() == 0); + } + + @Test + public void testWithValidDataUrl307XML() throws IOException, InterruptedException { + server = new MultiTestDataUrlConnection(); + DataUrl.setDataUrlConnectionClass(server); + TestDataSource tds = new TestDataSource(); + ((MultiTestDataUrlConnection)server).setDataSource(tds); + + // first server response with 307 xml and location + RequestFactory rf = new RequestFactory(); + serverHeaderMap = new HashMap(); + serverHeaderMap.put("Location", "http://localhost:8080"); + serverHeaderMap.put("Content-Type", HttpUtil.TXT_XML); + tds.addResponse(307, rf.getNullOperationXML(), serverHeaderMap); + + // 2nd response with 200 text/plain and != + String testString = "CheckMe"; + serverHeaderMap = new HashMap(); + serverHeaderMap.put("Content-Type", HttpUtil.TXT_PLAIN); + String testHeader ="DummyHeader"; + String testHeaderVal ="DummyHeaderVal"; + serverHeaderMap.put(testHeader, testHeaderVal); + tds.addResponse(200, testString, serverHeaderMap); + + rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + bindingProcessor.run(); + + assertTrue(bindingProcessor.getResponseHeaders().size()>0); + assertEquals(testHeaderVal, bindingProcessor.getResponseHeaders().get(testHeader)); + assertEquals(200,bindingProcessor.getResponseCode()); + assertEquals(HttpUtil.TXT_PLAIN, bindingProcessor.getResultContentType()); + assertEquals(testString ,resultAsString("UTF-8")); + } + + @Test + public void testWithValidDataUrl200Urlencoded() throws IOException { + RequestFactory rf = new RequestFactory(); + rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(200); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + serverHeaderMap.put("Content-Type", HttpUtil.APPLICATION_URL_ENCODED); + server.setResponseHeaders(serverHeaderMap); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertTrue(bindingProcessor.getResponseHeaders().size()==0); + assertEquals(200,bindingProcessor.getResponseCode()); + assertEquals(HttpUtil.TXT_XML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullOperationResponse") != -1); + } + + @Test + public void testWithValidDataUrl200UrlencodedAndStylesheet() throws IOException { + RequestFactory rf = new RequestFactory(); + rf = new RequestFactory(); + rf.addForm(RequestFactory.DATAURL, "http://localhost:8080"); + bindingProcessor.consumeRequestStream(rf.getURLencoded()); + server.setResponseCode(200); + rf = new RequestFactory(); + rf.addFormAsResource("Styleshit", "at/gv/egiz/bku/binding/stylesheet.xslt"); + rf.addForm(RequestFactory.STYLESHEETURL, "formdata:Styleshit"); + serverHeaderMap.put("Content-Type", HttpUtil.APPLICATION_URL_ENCODED); + server.setResponseHeaders(serverHeaderMap); + server.setResponseContent(rf.getURLencodedAsString()); + bindingProcessor.run(); + assertTrue(bindingProcessor.getResponseHeaders().size()==0); + assertEquals(200,bindingProcessor.getResponseCode()); + assertEquals(HttpUtil.TXT_HTML, bindingProcessor.getResultContentType()); + assertTrue(resultAsString("UTF-8").indexOf("NullKommaJosef") != -1); + } + + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/IdFactoryTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/IdFactoryTest.java new file mode 100644 index 00000000..cd75ec38 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/IdFactoryTest.java @@ -0,0 +1,63 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class IdFactoryTest { + + @Before + public void setUp() { + IdFactory.getInstance().setNumberOfBits(168); + + } + + @Test + public void testWithString() { + String testString = "Hansi"; + Id hansi = IdFactory.getInstance().createId(testString); + assertEquals(hansi.toString(), testString); + } + + @Test(expected = NullPointerException.class) + public void testFactory() { + IdFactory.getInstance().setSecureRandom(null); + } + + @Test + public void testRandom() { + IdFactory fab = IdFactory.getInstance(); + Id id = fab.createId(); + assertEquals(id.toString().length(), 28); + fab.setNumberOfBits(24); + id = fab.createId(); + assertEquals(id.toString().length(), 4); + } + + @Test + public void testEquals() { + String idString = "Hansi"; + IdFactory fab = IdFactory.getInstance(); + Id id1 = fab.createId(idString); + Id id2 = fab.createId(idString); + assertEquals(id1, id2); + assertEquals(id1.hashCode(), id2.hashCode()); + } +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/InputDecoderFactoryTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/InputDecoderFactoryTest.java new file mode 100644 index 00000000..7d79889d --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/InputDecoderFactoryTest.java @@ -0,0 +1,96 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; + +import org.junit.Before; +import org.junit.Test; + +import at.gv.egiz.bku.utils.StreamUtil; + +public class InputDecoderFactoryTest { + + protected String resourceName = "at/gv/egiz/bku/binding/Multipart.txt.bin"; + protected byte[] data; + + @Before + public void setUp() throws IOException { + InputStream is = getClass().getClassLoader().getResourceAsStream( + resourceName); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int i; + + while ((i = is.read(buffer)) != -1) { + bos.write(buffer, 0, i); + } + is.close(); + data = bos.toByteArray(); + } + + @Test + public void testPrefix() { + InputDecoder dec = InputDecoderFactory.getDecoder( + "multipart/form-data; boundary=AaB03x", null); + assertTrue(dec instanceof MultiPartFormDataInputDecoder); + } + + @Test + public void testMultipart() throws IOException { + InputDecoder dec = InputDecoderFactory + .getDecoder( + "multipart/form-data; boundary=---------------------------15671293698853", + new ByteArrayInputStream(data)); + assertNotNull(dec); + for (Iterator fpi = dec.getFormParameterIterator(); fpi + .hasNext();) { + FormParameter fp = fpi.next(); + if (fp.getFormParameterName().equals("XMLRequest")) { + assertEquals("text/xml", fp.getFormParameterContentType()); + return; + } + } + assertTrue(false); + } + + @Test + public void testUrlEncoded() throws IOException { + InputDecoder dec = InputDecoderFactory.getDecoder( + "application/x-www-form-urlencoded", null); + assertTrue(dec instanceof XWWWFormUrlInputDecoder); + dec = InputDecoderFactory.getDecoder( + "application/x-WWW-form-urlencoded;charset=UTF-8", + new ByteArrayInputStream( + "your_name=hansi+wurzel&userid=123&form_name=wasinet".getBytes())); + assertTrue(dec instanceof XWWWFormUrlInputDecoder); + Iterator fpi = dec.getFormParameterIterator(); + FormParameter fp = fpi.next(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + StreamUtil.copyStream(fp.getFormParameterValue(), os); + String value = new String(os.toByteArray(), "UTF-8"); + assertEquals("hansi wurzel", value); + } +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultiTestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultiTestDataUrlConnection.java new file mode 100644 index 00000000..5d2a7544 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultiTestDataUrlConnection.java @@ -0,0 +1,49 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import java.io.IOException; +import java.util.Map; + +public class MultiTestDataUrlConnection extends TestDataUrlConnection { + + public static interface DataSourceProvider { + public Map getResponseHeaders(); + public String getResponseContent(); + public int getResponseCode(); + public void nextEvent(); + } + + + protected DataSourceProvider dataSource; + + public void setDataSource(DataSourceProvider dataSource) { + this.dataSource = dataSource; + } + + public DataUrlResponse getResponse() throws IOException { + if (dataSource == null) { + return super.getResponse(); + } + dataSource.nextEvent(); + responseHeaders = dataSource.getResponseHeaders(); + responseCode = dataSource.getResponseCode(); + responseContent = dataSource.getResponseContent(); + return super.getResponse(); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java new file mode 100644 index 00000000..7ef1a9bf --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java @@ -0,0 +1,57 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class MultipartSLRequestTest { + + protected String resourceName = "at/gv/egiz/bku/binding/MultipartFromTutorial.txt"; + + protected BindingProcessor bindingProcessor; + protected InputStream dataStream; + protected BindingProcessorManager manager; + + @Before + public void setUp() { + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + HTTPBindingProcessor http = (HTTPBindingProcessor) manager + .createBindingProcessor("http", null); + Map headers = new HashMap(); + headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA + + ";boundary=---------------------------2330864292941"); + http.setHTTPHeaders(headers); + dataStream = getClass().getClassLoader().getResourceAsStream(resourceName); + bindingProcessor = http; + } + + @Test + public void testBasicNop() { + bindingProcessor.consumeRequestStream(dataStream); + // manager.process(bindingProcessor); + bindingProcessor.run(); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java new file mode 100644 index 00000000..66b9dffb --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java @@ -0,0 +1,52 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class NullOperationTest { + + protected String resourceName = "at/gv/egiz/bku/binding/NulloperationRequest.txt.bin"; + + protected BindingProcessor bindingProcessor; + protected InputStream dataStream; + protected BindingProcessorManager manager; + + @Before + public void setUp() { + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl()); + HTTPBindingProcessor http = (HTTPBindingProcessor) manager.createBindingProcessor("http", null); + Map headers = new HashMap(); + headers.put("Content-Type", "application/x-www-form-urlencoded"); + http.setHTTPHeaders(headers); + dataStream = getClass().getClassLoader().getResourceAsStream(resourceName); + bindingProcessor = http; + } + + @Test + public void testBasicNop() { + bindingProcessor.consumeRequestStream(dataStream); + //manager.process(bindingProcessor); + bindingProcessor.run(); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/RequestFactory.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/RequestFactory.java new file mode 100644 index 00000000..77157a41 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/RequestFactory.java @@ -0,0 +1,116 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import at.gv.egiz.bku.utils.StreamUtil; + +public class RequestFactory implements FixedFormParameters { + + protected String requestResourceName = "at/gv/egiz/bku/binding/Nulloperation.xml"; + + protected Map formString = new HashMap(); + protected Map formResources = new HashMap(); + + public RequestFactory() { + formResources.put(XMLREQUEST, requestResourceName); + } + + public void addForm(String formName, String content) { + formString.put(formName, content); + } + + public void addFormAsResource(String formName, String resourceName) { + formResources.put(formName, resourceName); + } + + public InputStream getURLencoded() throws IOException { + StringBuffer sb = new StringBuffer(); + for (Iterator si = formString.keySet().iterator(); si.hasNext();) { + String formName = si.next(); + String formVal = formString.get(formName); + sb.append(URLEncoder.encode(formName, "UTF-8")); + sb.append("="); + sb.append(URLEncoder.encode(formVal, "UTF-8")); + if (si.hasNext()) { + sb.append("&"); + } else { + if (formResources.keySet().iterator().hasNext()) { + sb.append("&"); + } + } + } + + for (Iterator si = formResources.keySet().iterator(); si.hasNext();) { + String formName = si.next(); + String formVal = URLEncoder.encode(StreamUtil.asString(getClass() + .getClassLoader().getResourceAsStream(formResources.get(formName)), + "UTF-8"), "UTF-8"); + sb.append(URLEncoder.encode(formName, "UTF-8")); + sb.append("="); + sb.append(formVal); + if (si.hasNext()) { + sb.append("&"); + } + } + return new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); + } + + public String getURLencodedAsString() throws IOException { + StringBuffer sb = new StringBuffer(); + for (Iterator si = formString.keySet().iterator(); si.hasNext();) { + String formName = si.next(); + String formVal = formString.get(formName); + sb.append(URLEncoder.encode(formName, "UTF-8")); + sb.append("="); + sb.append(URLEncoder.encode(formVal, "UTF-8")); + if (si.hasNext()) { + sb.append("&"); + } else { + if (formResources.keySet().iterator().hasNext()) { + sb.append("&"); + } + } + } + + for (Iterator si = formResources.keySet().iterator(); si.hasNext();) { + String formName = si.next(); + String formVal = URLEncoder.encode(StreamUtil.asString(getClass() + .getClassLoader().getResourceAsStream(formResources.get(formName)), + "UTF-8"), "UTF-8"); + sb.append(URLEncoder.encode(formName, "UTF-8")); + sb.append("="); + sb.append(formVal); + if (si.hasNext()) { + sb.append("&"); + } + } + return sb.toString(); + } + + public String getNullOperationXML() throws IOException { + return StreamUtil.asString(getClass().getClassLoader().getResourceAsStream( + requestResourceName), "UTF-8"); + } +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/SSLDataUrlConnectionTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/SSLDataUrlConnectionTest.java new file mode 100644 index 00000000..407a556a --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/SSLDataUrlConnectionTest.java @@ -0,0 +1,39 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.net.URL; + +import org.junit.Test; + + +public class SSLDataUrlConnectionTest { + + @Test + public void testVerisign() throws IOException { + URL url = new URL("https://www.verisign.com:443"); + DataUrlConnectionImpl uc = new DataUrlConnectionImpl(); + uc.init(url); + uc.connect(); + assertNotNull(uc.getServerCertificate()); + //uc.transmit(null); + } + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java new file mode 100644 index 00000000..e644f964 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java @@ -0,0 +1,123 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* 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. +*/ +package at.gv.egiz.bku.binding; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Ignore; + +import at.gv.egiz.bku.slcommands.SLResult; + +@Ignore +public class TestDataUrlConnection implements DataUrlConnectionSPI { + + + protected Log log = LogFactory.getLog(TestDataUrlConnection.class); + protected X509Certificate serverCertificate; + protected Map responseHeaders = Collections.EMPTY_MAP; + protected Map requestHeaders = new HashMap(); + protected String responseContent = ""; + protected int responseCode = 200; + + protected URL url; + + @Override + public void init(URL url) { + log.debug("Init Testdataurlconnection to url: " + url); + this.url = url; + } + + @Override + public void connect() throws SocketTimeoutException, IOException { + log.debug("Dummy connect to Testdataurlconnection to url: " + url); + + } + + @Override + public String getProtocol() { + return url.getProtocol(); + } + + @Override + public DataUrlResponse getResponse() throws IOException { + String ct = responseHeaders.get(HttpUtil.HTTP_HEADER_CONTENT_TYPE); + if (ct != null) { + ct = HttpUtil.getCharset(ct, true); + } else { + ct = HttpUtil.DEFAULT_CHARSET; + } + DataUrlResponse response = new DataUrlResponse(url.toString(), responseCode, new ByteArrayInputStream(responseContent.getBytes(ct))); + response.setResponseHttpHeaders(responseHeaders); + return response; + } + + @Override + public X509Certificate getServerCertificate() { + return serverCertificate; + } + + @Override + public void setHTTPFormParameter(String name, InputStream data, + String contentType, String charSet, String transferEncoding) { + // TODO Auto-generated method stub + } + + @Override + public void setHTTPHeader(String key, String value) { + requestHeaders.put(key, value); + } + + @Override + public void transmit(SLResult slResult) throws IOException { + log.debug("Dummy transmit to url: " + url); + } + + public void setServerCertificate(X509Certificate serverCertificate) { + this.serverCertificate = serverCertificate; + } + + public void setResponseHeaders(Map responseHeaders) { + this.responseHeaders = responseHeaders; + } + + public void setResponseContent(String responseContent) { + this.responseContent = responseContent; + } + + public void setResponseCode(int responseCode) { + this.responseCode = responseCode; + } + + public Map getRequestHeaders() { + return requestHeaders; + } + + @Override + public DataUrlConnectionSPI newInstance() { + return this; + } + } -- cgit v1.2.3