From c1a8ed191e57b6c068d9a2733cca40dd4c209b9f Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 14 Aug 2009 11:14:32 +0000 Subject: [#354] HTTPBindingProcessor: MAX_DATAURL_HOPS not configurable git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@436 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../bku/binding/BindingProcessorManagerTest.java | 63 ++++++++-------- .../gv/egiz/bku/binding/DataUrlConnectionTest.java | 4 +- .../bku/binding/EmptyMultipartSLRequestTest.java | 6 +- .../at/gv/egiz/bku/binding/ExpiryRemoverTest.java | 7 +- .../egiz/bku/binding/HttpBindingProcessorTest.java | 4 +- .../egiz/bku/binding/MultipartSLRequestTest.java | 83 +++++++++++----------- .../at/gv/egiz/bku/binding/NullOperationTest.java | 73 +++++++++---------- .../at/gv/egiz/bku/conf/DummyConfiguration.java | 32 +++++++++ 8 files changed, 159 insertions(+), 113 deletions(-) create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/conf/DummyConfiguration.java (limited to 'bkucommon/src/test') 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 index 9481f0bc..22a7aa3b 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/BindingProcessorManagerTest.java @@ -14,35 +14,38 @@ * 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.*; +package at.gv.egiz.bku.binding; + +import at.gv.egiz.bku.conf.Configuration; +import at.gv.egiz.bku.conf.DummyConfiguration; +import static org.junit.Assert.*; import java.net.MalformedURLException; - -import org.junit.Before; -import org.junit.Test; - -public class BindingProcessorManagerTest { - - @Before - public void setUp() { - IdFactory.getInstance().setNumberOfBits(24*10); - } - - - @Test(expected = MalformedURLException.class) - public void basicCreationTest() throws MalformedURLException { - BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl()); - BindingProcessor bp = manager.createBindingProcessor("http://www.at/", null); - assertNotNull(bp.getId().toString()); - assertEquals(40, bp.getId().toString().length()); - String hansi = "Hansi"; - bp = manager.createBindingProcessor("http://www.iaik.at",hansi); - assertEquals(hansi, bp.getId().toString()); - bp = manager.createBindingProcessor("HtTp://www.iaik.at", null); - assertNotNull(bp); - manager.createBindingProcessor("seppl", null); - } - -} + +import org.junit.Before; +import org.junit.Test; + +public class BindingProcessorManagerTest { + + @Before + public void setUp() { + IdFactory.getInstance().setNumberOfBits(24*10); + } + + + @Test(expected = MalformedURLException.class) + public void basicCreationTest() throws MalformedURLException { + //TODO for the moment empty config sufficient (currently only maxDataURLHops configured) + BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl(), new DummyConfiguration()); + BindingProcessor bp = manager.createBindingProcessor("http://www.at/", null); + assertNotNull(bp.getId().toString()); + assertEquals(40, bp.getId().toString().length()); + String hansi = "Hansi"; + bp = manager.createBindingProcessor("http://www.iaik.at",hansi); + assertEquals(hansi, bp.getId().toString()); + bp = manager.createBindingProcessor("HtTp://www.iaik.at", 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 index 87726c49..6e48e6fa 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DataUrlConnectionTest.java @@ -20,6 +20,8 @@ */ package at.gv.egiz.bku.binding; +import at.gv.egiz.bku.conf.Configuration; +import at.gv.egiz.bku.conf.DummyConfiguration; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -71,7 +73,7 @@ public class DataUrlConnectionTest { log.debug("setting up HTTPBindingProcessor"); manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); + new SLCommandInvokerImpl(), new DummyConfiguration()); bindingProcessor = (HTTPBindingProcessor) manager.createBindingProcessor( "http://www.iaik.at", null); Map headers = new HashMap(); diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java index dd315f7f..ee17f5e9 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java @@ -16,6 +16,7 @@ */ package at.gv.egiz.bku.binding; +import at.gv.egiz.bku.conf.Configuration; import iaik.security.ecc.provider.ECCProvider; import iaik.security.provider.IAIK; import iaik.xml.crypto.XSecProvider; @@ -35,6 +36,7 @@ import org.junit.Before; import org.junit.Test; import at.gv.egiz.bku.conf.Configurator; +import at.gv.egiz.bku.conf.DummyConfiguration; import at.gv.egiz.bku.slcommands.SLCommandFactory; import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; @@ -51,7 +53,7 @@ public class EmptyMultipartSLRequestTest { @Before public void setUp() throws MalformedURLException, ClassNotFoundException { manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); + new SLCommandInvokerImpl(), new DummyConfiguration()); HTTPBindingProcessor http = (HTTPBindingProcessor) manager .createBindingProcessor("http://www.at/", null); Map headers = new HashMap(); @@ -89,7 +91,7 @@ public class EmptyMultipartSLRequestTest { @Test public void testBasicNop() { bindingProcessor.consumeRequestStream(dataStream); - // manager.process(bindingProcessor); + // manager.process(bindingProcessor); bindingProcessor.run(); } 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 index 18ccc11a..faf08c54 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java @@ -16,6 +16,8 @@ */ package at.gv.egiz.bku.binding; +import at.gv.egiz.bku.conf.Configuration; +import at.gv.egiz.bku.conf.DummyConfiguration; import java.net.MalformedURLException; import org.junit.Test; @@ -25,8 +27,9 @@ public class ExpiryRemoverTest { @Test public void testMe() throws InterruptedException, MalformedURLException { + //TODO for the moment empty config sufficient (currently only maxDataURLHops configured) BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); + new SLCommandInvokerImpl(), new DummyConfiguration()); BindingProcessor bp = manager.createBindingProcessor("http://www.at", null); ExpiryRemover remover = new ExpiryRemover(); remover.setBindingProcessorManager(manager); @@ -46,7 +49,7 @@ public class ExpiryRemoverTest { @Test public void testMe2() throws InterruptedException, MalformedURLException { BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); + new SLCommandInvokerImpl(), new DummyConfiguration()); BindingProcessor bp = manager.createBindingProcessor("http://www.iaik.at", null); ExpiryRemover remover = new ExpiryRemover(); remover.setBindingProcessorManager(manager); 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 index 2130e7f1..d03e1807 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java @@ -33,6 +33,8 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import at.gv.egiz.bku.binding.MultiTestDataUrlConnection.DataSourceProvider; +import at.gv.egiz.bku.conf.Configuration; +import at.gv.egiz.bku.conf.DummyConfiguration; import at.gv.egiz.bku.utils.StreamUtil; public class HttpBindingProcessorTest { @@ -102,7 +104,7 @@ public class HttpBindingProcessorTest { server.setResponseContent(""); server.setResponseHeaders(serverHeaderMap); manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); + new SLCommandInvokerImpl(), new DummyConfiguration()); bindingProcessor = (HTTPBindingProcessor) manager.createBindingProcessor( "http://www.iaik.at", null); clientHeaderMap = new HashMap(); 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 index 2c48bf4e..1a9a6a70 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java @@ -14,45 +14,46 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.bku.binding; - -import java.io.InputStream; +package at.gv.egiz.bku.binding; + +import at.gv.egiz.bku.conf.DummyConfiguration; +import java.io.InputStream; import java.net.MalformedURLException; -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() throws MalformedURLException { - manager = new BindingProcessorManagerImpl(new DummyStalFactory(), - new SLCommandInvokerImpl()); - HTTPBindingProcessor http = (HTTPBindingProcessor) manager - .createBindingProcessor("http://www.at/", 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(); - } - -} +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() throws MalformedURLException { + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl(), new DummyConfiguration()); + HTTPBindingProcessor http = (HTTPBindingProcessor) manager + .createBindingProcessor("http://www.at/", 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 index b2a7d387..58c82c49 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java @@ -14,40 +14,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.bku.binding; - -import java.io.InputStream; +package at.gv.egiz.bku.binding; + +import at.gv.egiz.bku.conf.DummyConfiguration; +import java.io.InputStream; import java.net.MalformedURLException; -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() throws MalformedURLException { - manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl()); - HTTPBindingProcessor http = (HTTPBindingProcessor) manager.createBindingProcessor("http://www.at/", 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(); - } - -} +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() throws MalformedURLException { + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl(), new DummyConfiguration()); + HTTPBindingProcessor http = (HTTPBindingProcessor) manager.createBindingProcessor("http://www.at/", 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/conf/DummyConfiguration.java b/bkucommon/src/test/java/at/gv/egiz/bku/conf/DummyConfiguration.java new file mode 100644 index 00000000..1e0e5aa9 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/conf/DummyConfiguration.java @@ -0,0 +1,32 @@ +/* + * 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.conf; + +/** + * + * @author Clemens Orthacker + */ +public class DummyConfiguration extends Configuration { + + public DummyConfiguration() { + this.setMaxDataUrlHops(MAX_DATAURL_HOPS_DEFAULT); + //this.set... + } + + +} -- cgit v1.2.3