You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/02/14 09:49:35 UTC
[30/51] [partial] cxf git commit: Remove all trailing whitespaces
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java b/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java
index c841937..30cf74c 100644
--- a/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java
+++ b/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java
@@ -1,150 +1,150 @@
-/**
- * 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.cxf.feature.transform;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.io.CachedWriter;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/* Provides XSLT transformation of incoming message.
- * Interceptor breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
- */
-public class XSLTInterceptorsTest {
-
- private static final String TRANSFORMATION_XSL = "transformation.xsl";
- private static final String MESSAGE_FILE = "message.xml";
-
- private InputStream messageIS;
- private Message message;
- private XSLTInInterceptor inInterceptor;
- private XSLTOutInterceptor outInterceptor;
-
- @Before
- public void setUp() throws TransformerConfigurationException {
- messageIS = ClassLoaderUtils.getResourceAsStream(MESSAGE_FILE, this.getClass());
- if (messageIS == null) {
- throw new IllegalArgumentException("Cannot load message from path: " + MESSAGE_FILE);
- }
- message = new MessageImpl();
- inInterceptor = new XSLTInInterceptor(TRANSFORMATION_XSL);
- outInterceptor = new XSLTOutInterceptor(TRANSFORMATION_XSL);
- }
-
- @Test
- public void inStreamTest() throws Exception {
- message.setContent(InputStream.class, messageIS);
- inInterceptor.handleMessage(message);
- InputStream transformedIS = message.getContent(InputStream.class);
- Document doc = StaxUtils.read(transformedIS);
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- @Test
- public void inXMLStreamTest() throws XMLStreamException {
- XMLStreamReader xReader = StaxUtils.createXMLStreamReader(messageIS);
- message.setContent(XMLStreamReader.class, xReader);
- inInterceptor.handleMessage(message);
- XMLStreamReader transformedXReader = message.getContent(XMLStreamReader.class);
- Document doc = StaxUtils.read(transformedXReader);
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- @Test
- public void inReaderTest() throws Exception {
- Reader reader = new InputStreamReader(messageIS);
- message.setContent(Reader.class, reader);
- inInterceptor.handleMessage(message);
- Reader transformedReader = message.getContent(Reader.class);
- Document doc = StaxUtils.read(transformedReader);
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- @Test
- public void outStreamTest() throws Exception {
- CachedOutputStream cos = new CachedOutputStream();
- cos.holdTempFile();
- message.setContent(OutputStream.class, cos);
- outInterceptor.handleMessage(message);
- OutputStream os = message.getContent(OutputStream.class);
- IOUtils.copy(messageIS, os);
- os.close();
- cos.releaseTempFileHold();
- Document doc = StaxUtils.read(cos.getInputStream());
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- @Test
- public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException {
- CachedWriter cWriter = new CachedWriter();
- cWriter.holdTempFile();
- XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter);
- message.setContent(XMLStreamWriter.class, xWriter);
- outInterceptor.handleMessage(message);
- XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class);
- StaxUtils.copy(new StreamSource(messageIS), tXWriter);
- tXWriter.close();
- cWriter.releaseTempFileHold();
- Document doc = StaxUtils.read(cWriter.getReader());
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- @Test
- public void outWriterStreamTest() throws Exception {
- CachedWriter cWriter = new CachedWriter();
- message.setContent(Writer.class, cWriter);
- outInterceptor.handleMessage(message);
- Writer tWriter = message.getContent(Writer.class);
- IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE);
- tWriter.close();
- Document doc = StaxUtils.read(cWriter.getReader());
- Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
- }
-
- private boolean checkTransformedXML(Document doc) {
- NodeList list = doc.getDocumentElement()
- .getElementsByTagNameNS("http://customerservice.example.com/", "getCustomersByName1");
- return list.getLength() == 1;
- }
-}
+/**
+ * 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.cxf.feature.transform;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.io.CachedWriter;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/* Provides XSLT transformation of incoming message.
+ * Interceptor breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
+ */
+public class XSLTInterceptorsTest {
+
+ private static final String TRANSFORMATION_XSL = "transformation.xsl";
+ private static final String MESSAGE_FILE = "message.xml";
+
+ private InputStream messageIS;
+ private Message message;
+ private XSLTInInterceptor inInterceptor;
+ private XSLTOutInterceptor outInterceptor;
+
+ @Before
+ public void setUp() throws TransformerConfigurationException {
+ messageIS = ClassLoaderUtils.getResourceAsStream(MESSAGE_FILE, this.getClass());
+ if (messageIS == null) {
+ throw new IllegalArgumentException("Cannot load message from path: " + MESSAGE_FILE);
+ }
+ message = new MessageImpl();
+ inInterceptor = new XSLTInInterceptor(TRANSFORMATION_XSL);
+ outInterceptor = new XSLTOutInterceptor(TRANSFORMATION_XSL);
+ }
+
+ @Test
+ public void inStreamTest() throws Exception {
+ message.setContent(InputStream.class, messageIS);
+ inInterceptor.handleMessage(message);
+ InputStream transformedIS = message.getContent(InputStream.class);
+ Document doc = StaxUtils.read(transformedIS);
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ @Test
+ public void inXMLStreamTest() throws XMLStreamException {
+ XMLStreamReader xReader = StaxUtils.createXMLStreamReader(messageIS);
+ message.setContent(XMLStreamReader.class, xReader);
+ inInterceptor.handleMessage(message);
+ XMLStreamReader transformedXReader = message.getContent(XMLStreamReader.class);
+ Document doc = StaxUtils.read(transformedXReader);
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ @Test
+ public void inReaderTest() throws Exception {
+ Reader reader = new InputStreamReader(messageIS);
+ message.setContent(Reader.class, reader);
+ inInterceptor.handleMessage(message);
+ Reader transformedReader = message.getContent(Reader.class);
+ Document doc = StaxUtils.read(transformedReader);
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ @Test
+ public void outStreamTest() throws Exception {
+ CachedOutputStream cos = new CachedOutputStream();
+ cos.holdTempFile();
+ message.setContent(OutputStream.class, cos);
+ outInterceptor.handleMessage(message);
+ OutputStream os = message.getContent(OutputStream.class);
+ IOUtils.copy(messageIS, os);
+ os.close();
+ cos.releaseTempFileHold();
+ Document doc = StaxUtils.read(cos.getInputStream());
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ @Test
+ public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException {
+ CachedWriter cWriter = new CachedWriter();
+ cWriter.holdTempFile();
+ XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter);
+ message.setContent(XMLStreamWriter.class, xWriter);
+ outInterceptor.handleMessage(message);
+ XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class);
+ StaxUtils.copy(new StreamSource(messageIS), tXWriter);
+ tXWriter.close();
+ cWriter.releaseTempFileHold();
+ Document doc = StaxUtils.read(cWriter.getReader());
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ @Test
+ public void outWriterStreamTest() throws Exception {
+ CachedWriter cWriter = new CachedWriter();
+ message.setContent(Writer.class, cWriter);
+ outInterceptor.handleMessage(message);
+ Writer tWriter = message.getContent(Writer.class);
+ IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE);
+ tWriter.close();
+ Document doc = StaxUtils.read(cWriter.getReader());
+ Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
+ }
+
+ private boolean checkTransformedXML(Document doc) {
+ NodeList list = doc.getDocumentElement()
+ .getElementsByTagNameNS("http://customerservice.example.com/", "getCustomersByName1");
+ return list.getLength() == 1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
index 90ecce8..d0bc572 100644
--- a/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
@@ -24,11 +24,11 @@ import org.junit.Assert;
import org.junit.Test;
public class FileUtilsTest extends Assert {
-
-
+
+
@Test
public void testTempIODirExists() throws Exception {
-
+
String originaltmpdir = System.getProperty("java.io.tmpdir");
try {
System.setProperty("java.io.tmpdir", "dummy");
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java b/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
index 7fdb41e..09112de 100644
--- a/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
@@ -26,11 +26,11 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
- *
+ *
*/
public class HttpHeaderHelperTest {
-
- @Test
+
+ @Test
public void testMapCharset() {
String cs = HttpHeaderHelper.mapCharset("utf-8");
assertEquals(Charset.forName("utf-8").name(), cs);
@@ -41,13 +41,13 @@ public class HttpHeaderHelperTest {
cs = HttpHeaderHelper.mapCharset("'utf-8'");
assertEquals(Charset.forName("utf-8").name(), cs);
}
-
- @Test
+
+ @Test
public void testEmptyCharset() {
String cs = HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset="));
assertEquals("ISO-8859-1", cs);
}
- @Test
+ @Test
public void testEmptyCharset2() {
String cs = HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset=;"));
assertEquals("ISO-8859-1", cs);
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
index c0c8cc0..36ba44d4 100644
--- a/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
@@ -28,8 +28,8 @@ import org.junit.Assert;
import org.junit.Test;
public class IOUtilsTest extends Assert {
-
-
+
+
@Test
public void testIsEmpty() throws Exception {
assertTrue(IOUtils.isEmpty(new ByteArrayInputStream(new byte[]{})));
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java b/core/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java
index 68af96c..3860447 100644
--- a/core/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java
@@ -23,46 +23,46 @@ import org.junit.Assert;
import org.junit.Test;
public class NameSpaceTest extends Assert {
-
+
private static final String MY_URL1 = "http://test.apache.org/testurl1";
private static final String MY_URL2 = "http://test.apache.org/testurl2";
private static final String MY_CUSTOM_URL = "http://test.apache.org/custom-prefix-url";
private static final String MY_OWN_PREFIX = "myown-prefix";
-
+
@Test
public void testNSStackOperations() throws Exception {
NSStack nsStackObj = new NSStack();
-
+
nsStackObj.push();
-
+
nsStackObj.add(MY_URL1);
nsStackObj.add(MY_OWN_PREFIX, MY_CUSTOM_URL);
nsStackObj.add(MY_URL2);
-
+
assertEquals(MY_URL1, nsStackObj.getURI("ns1"));
assertEquals(MY_CUSTOM_URL, nsStackObj.getURI(MY_OWN_PREFIX));
assertEquals(MY_URL2, nsStackObj.getURI("ns2"));
assertNull(nsStackObj.getURI("non-existent-prefix"));
-
+
assertEquals("ns2", nsStackObj.getPrefix(MY_URL2));
assertEquals(MY_OWN_PREFIX, nsStackObj.getPrefix(MY_CUSTOM_URL));
assertEquals("ns1", nsStackObj.getPrefix(MY_URL1));
assertNull(nsStackObj.getPrefix("non-existent-prefix"));
-
+
nsStackObj.pop();
assertNull(nsStackObj.getPrefix("non-existent-prefix"));
assertNull(nsStackObj.getPrefix(MY_CUSTOM_URL));
}
-
+
@Test
public void testNSDeclOperaions() throws Exception {
NSDecl nsDecl1 = new NSDecl(MY_OWN_PREFIX, MY_CUSTOM_URL);
NSDecl nsDecl2 = new NSDecl("ns2", MY_URL2);
NSDecl nsDecl3 = new NSDecl(MY_OWN_PREFIX, MY_CUSTOM_URL);
-
+
assertFalse(nsDecl2.equals(nsDecl1));
assertTrue(nsDecl3.equals(nsDecl1));
-
+
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
index bb0d5ec..e9a16d0 100644
--- a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
@@ -32,49 +32,49 @@ import org.junit.Test;
public class ServiceUtilsTest extends Assert {
private IMocksControl control;
private Message msg;
-
- @Before
+
+ @Before
public void setUp() {
control = EasyMock.createNiceControl();
msg = control.createMock(Message.class);
}
-
+
@Test
public void testmakeNamespaceFromClassName() throws Exception {
String tns = ServiceUtils.makeNamespaceFromClassName("com.example.ws.Test", "http");
assertEquals("http://ws.example.com/", tns);
}
-
+
@Test
public void testRequestResponseTypes() {
// lets do server side first
setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-
+
// now client side
setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
}
-
+
@Test
public void testIsSchemaValidationEnabled() {
setupSchemaValidationValue(SchemaValidationType.NONE, false);
@@ -85,7 +85,7 @@ public class ServiceUtilsTest extends Assert {
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
setupSchemaValidationValue(SchemaValidationType.IN, false);
@@ -94,7 +94,7 @@ public class ServiceUtilsTest extends Assert {
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
setupSchemaValidationValue(SchemaValidationType.OUT, false);
@@ -103,7 +103,7 @@ public class ServiceUtilsTest extends Assert {
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
-
+
setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
setupSchemaValidationValue(SchemaValidationType.BOTH, false);
@@ -113,62 +113,62 @@ public class ServiceUtilsTest extends Assert {
setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
}
-
+
@Test
public void testGetSchemaValidationTypeBoolean() {
setupSchemaValidationValue(null, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue(Boolean.FALSE, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("false", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("FALSE", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("fAlse", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue(Boolean.TRUE, false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("true", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("TRUE", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue("tRue", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
}
-
+
@Test
public void testGetSchemaValidationType() {
for (SchemaValidationType type : SchemaValidationType.values()) {
setupSchemaValidationValue(type.name(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue(type.name().toLowerCase(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
-
+
setupSchemaValidationValue(StringUtils.capitalize(type.name()), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
}
}
-
+
private void setupSchemaValidationValue(Object value, boolean isRequestor) {
control.reset();
msg.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
EasyMock.expectLastCall().andReturn(value);
-
+
msg.get(Message.REQUESTOR_ROLE);
EasyMock.expectLastCall().andReturn(isRequestor);
-
+
control.replay();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
index 26227a7..3b3158a 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
@@ -63,7 +63,7 @@ public class LoggingOutInterceptorTest extends Assert {
control.replay();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
-
+
LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
//p.setPrettyLogging(true);
CachedOutputStream cos = new CachedOutputStream();
@@ -82,42 +82,42 @@ public class LoggingOutInterceptorTest extends Assert {
assertTrue(str.contains("<today>"));
}
-
+
@Test
public void testFormattingOverride() throws Exception {
control.replay();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
+
// create a custom logging interceptor that overrides how formatting is done
LoggingOutInterceptor p = new CustomFormatLoggingOutInterceptor(new PrintWriter(baos));
CachedOutputStream cos = new CachedOutputStream();
String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> "
+ "</and></thousand></two></january></of></second></twenty></the></is></today>";
cos.write(s.getBytes());
-
+
Message message = new MessageImpl();
message.setExchange(new ExchangeImpl());
message.put(Message.CONTENT_TYPE, "application/xml");
Logger logger = LogUtils.getL7dLogger(this.getClass());
LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
l.onClose(cos);
-
+
String str = baos.toString();
assertTrue(str.contains("<tomorrow/>"));
}
-
+
@Test
public void testFormattingOverrideLogWriter() throws Exception {
// create a custom logging interceptor that overrides how formatting is done
LoggingOutInterceptor p = new CustomFormatLoggingOutInterceptor();
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
p.setPrintWriter(new PrintWriter(baos));
-
+
StringWriter sw = new StringWriter();
sw.append("<today/>");
-
+
Endpoint endpoint = control.createMock(Endpoint.class);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
@@ -127,12 +127,12 @@ public class LoggingOutInterceptorTest extends Assert {
message.setExchange(new ExchangeImpl());
message.put(Message.CONTENT_TYPE, "application/xml");
message.setContent(Writer.class, sw);
-
+
p.handleMessage(message);
-
+
Writer w = message.getContent(Writer.class);
w.close();
-
+
String str = baos.toString();
assertTrue(str.contains("<tomorrow/>"));
}
@@ -180,11 +180,11 @@ public class LoggingOutInterceptorTest extends Assert {
CustomFormatLoggingOutInterceptor() {
super();
}
-
+
CustomFormatLoggingOutInterceptor(PrintWriter w) {
super(w);
}
-
+
@Override
protected String formatLoggingMessage(LoggingMessage loggingMessage) {
loggingMessage.getPayload().append("<tomorrow/>");
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java
index 3cb4aad..d1e40be 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java
@@ -37,18 +37,18 @@ import org.junit.Assert;
import org.junit.Test;
public class ServiceInvokerInterceptorTest extends Assert {
-
+
@Test
public void testInterceptor() throws Exception {
ServiceInvokerInterceptor intc = new ServiceInvokerInterceptor();
-
+
MessageImpl m = new MessageImpl();
Exchange exchange = new ExchangeImpl();
m.setExchange(exchange);
exchange.setInMessage(m);
-
+
exchange.setOutMessage(new MessageImpl());
-
+
TestInvoker i = new TestInvoker();
Endpoint endpoint = createEndpoint(i);
exchange.put(Endpoint.class, endpoint);
@@ -56,15 +56,15 @@ public class ServiceInvokerInterceptorTest extends Assert {
List<Object> lst = new ArrayList<>();
lst.add(input);
m.setContent(List.class, lst);
-
+
intc.handleMessage(m);
-
+
assertTrue(i.invoked);
-
+
List<?> list = exchange.getOutMessage().getContent(List.class);
assertEquals(input, list.get(0));
}
-
+
Endpoint createEndpoint(Invoker i) throws Exception {
IMocksControl control = EasyMock.createNiceControl();
Endpoint endpoint = control.createMock(Endpoint.class);
@@ -73,12 +73,12 @@ public class ServiceInvokerInterceptorTest extends Assert {
service.setInvoker(i);
service.setExecutor(new SimpleExecutor());
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
-
+
control.replay();
return endpoint;
}
-
+
static class TestInvoker implements Invoker {
boolean invoked;
public Object invoke(Exchange exchange, Object o) {
@@ -88,12 +88,12 @@ public class ServiceInvokerInterceptorTest extends Assert {
return o;
}
}
-
+
static class SimpleExecutor implements Executor {
public void execute(Runnable command) {
command.run();
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
index 191772c..f59da22 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
@@ -41,7 +41,7 @@ public class DefaultSecurityContextTest extends Assert {
s.getPrincipals().add(p);
assertFalse(new DefaultSecurityContext(p, s).isUserInRole("friend"));
}
-
+
@Test
public void testUserInRole() {
Subject s = new Subject();
@@ -50,33 +50,33 @@ public class DefaultSecurityContextTest extends Assert {
s.getPrincipals().add(new SimpleGroup("friend", p));
assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
}
-
+
@Test
public void testMultipleRoles() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
-
+
Set<Principal> roles = new HashSet<>();
roles.add(new SimpleGroup("friend", p));
roles.add(new SimpleGroup("admin", p));
s.getPrincipals().addAll(roles);
-
+
LoginSecurityContext context = new DefaultSecurityContext(p, s);
assertTrue(context.isUserInRole("friend"));
assertTrue(context.isUserInRole("admin"));
assertFalse(context.isUserInRole("bar"));
-
+
Set<Principal> roles2 = context.getUserRoles();
assertEquals(roles2, roles);
}
-
+
@Test
public void testGetSubject() {
Subject s = new Subject();
assertSame(new DefaultSecurityContext(s).getSubject(), s);
}
-
+
@Test
public void testUserInRole2() {
Subject s = new Subject();
@@ -87,7 +87,7 @@ public class DefaultSecurityContextTest extends Assert {
s.getPrincipals().add(group);
assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
}
-
+
@Test
public void testUserInRole3() {
Subject s = new Subject();
@@ -108,10 +108,10 @@ public class DefaultSecurityContextTest extends Assert {
s.getPrincipals().add(p);
Principal role = new SimplePrincipal("friend");
s.getPrincipals().add(role);
- LoginSecurityContext context = new DefaultSecurityContext(p, s);
+ LoginSecurityContext context = new DefaultSecurityContext(p, s);
assertTrue(context.isUserInRole("friend"));
assertFalse(context.isUserInRole("family"));
assertFalse(context.isUserInRole("Barry"));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/NamePasswordCallbackHandlerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/NamePasswordCallbackHandlerTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/NamePasswordCallbackHandlerTest.java
index eda0931..a971b35 100755
--- a/core/src/test/java/org/apache/cxf/interceptor/security/NamePasswordCallbackHandlerTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/NamePasswordCallbackHandlerTest.java
@@ -27,14 +27,14 @@ import org.junit.Assert;
import org.junit.Test;
/**
- *
+ *
*/
public class NamePasswordCallbackHandlerTest extends Assert {
@Test
public void testHandleCallback() throws Exception {
NamePasswordCallbackHandler handler = new NamePasswordCallbackHandler("Barry", "dog");
- Callback[] callbacks =
+ Callback[] callbacks =
new Callback[]{new NameCallback("name"), new PasswordCallback("password", false)};
handler.handle(callbacks);
assertEquals("Barry", ((NameCallback)callbacks[0]).getName());
@@ -44,7 +44,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
@Test
public void testHandleCallback2() throws Exception {
NamePasswordCallbackHandler handler = new NamePasswordCallbackHandler("Barry", "dog");
- Callback[] callbacks =
+ Callback[] callbacks =
new Callback[]{new NameCallback("name"), new ObjectCallback()};
handler.handle(callbacks);
assertEquals("Barry", ((NameCallback)callbacks[0]).getName());
@@ -56,7 +56,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
@Test
public void testHandleCallback3() throws Exception {
NamePasswordCallbackHandler handler = new NamePasswordCallbackHandler("Barry", "dog");
- Callback[] callbacks =
+ Callback[] callbacks =
new Callback[]{new NameCallback("name"), new StringObjectCallback()};
handler.handle(callbacks);
assertEquals("Barry", ((NameCallback)callbacks[0]).getName());
@@ -66,7 +66,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
@Test
public void testHandleCallback4() throws Exception {
NamePasswordCallbackHandler handler = new NamePasswordCallbackHandler("Barry", "dog", "setValue");
- Callback[] callbacks =
+ Callback[] callbacks =
new Callback[]{new NameCallback("name"), new CharArrayCallback()};
handler.handle(callbacks);
assertEquals("Barry", ((NameCallback)callbacks[0]).getName());
@@ -75,7 +75,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
static class ObjectCallback implements Callback {
private Object obj;
-
+
public Object getObject() {
return obj;
}
@@ -87,7 +87,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
static class StringObjectCallback implements Callback {
private String obj;
-
+
public String getObject() {
return obj;
}
@@ -99,7 +99,7 @@ public class NamePasswordCallbackHandlerTest extends Assert {
static class CharArrayCallback implements Callback {
private char[] obj;
-
+
public char[] getValue() {
return obj;
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java
index a0c5697..21b783a 100755
--- a/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java
@@ -42,7 +42,7 @@ public class OperationInfoAuthorizingInterceptorTest extends SimpleAuthorizingIn
ex.put(Service.class, service);
MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md).anyTimes();
-
+
BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class);
ex.put(BindingOperationInfo.class, boi);
EasyMock.expect(md.getMethod(boi)).andReturn(null);
@@ -51,12 +51,12 @@ public class OperationInfoAuthorizingInterceptorTest extends SimpleAuthorizingIn
EasyMock.expect(boi.getOperationInfo()).andReturn(opinfo).anyTimes();
EasyMock.replay(service, md, boi, opinfo);
}
-
+
@Override
protected SimpleAuthorizingInterceptor createSimpleAuthorizingInterceptor() {
return new OperationInfoAuthorizingInterceptor();
}
-
+
@Override
protected SimpleAuthorizingInterceptor createSimpleAuthorizingInterceptorWithDenyRoles(final String role) {
SimpleAuthorizingInterceptor in = new OperationInfoAuthorizingInterceptor() {
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/RolePrefixSecurityContextImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/RolePrefixSecurityContextImplTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/RolePrefixSecurityContextImplTest.java
index 428f5c4..5083b2d 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/security/RolePrefixSecurityContextImplTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/RolePrefixSecurityContextImplTest.java
@@ -39,7 +39,7 @@ public class RolePrefixSecurityContextImplTest extends Assert {
s.getPrincipals().add(p);
assertFalse(new RolePrefixSecurityContextImpl(s, "").isUserInRole("friend"));
}
-
+
@Test
public void testUserInRole() {
Subject s = new Subject();
@@ -49,7 +49,7 @@ public class RolePrefixSecurityContextImplTest extends Assert {
assertTrue(new RolePrefixSecurityContextImpl(s, "role_")
.isUserInRole("role_friend"));
}
-
+
@Test
public void testUserInRoleWithRolePrincipal() {
Subject s = new Subject();
@@ -59,42 +59,42 @@ public class RolePrefixSecurityContextImplTest extends Assert {
assertTrue(new RolePrefixSecurityContextImpl(s, "RolePrincipal", "classname")
.isUserInRole("friend"));
}
-
-
+
+
@Test
public void testMultipleRoles() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
-
+
Set<Principal> roles = new HashSet<>();
roles.add(new SimplePrincipal("role_friend"));
roles.add(new SimplePrincipal("role_admin"));
s.getPrincipals().addAll(roles);
-
+
LoginSecurityContext context = new RolePrefixSecurityContextImpl(s, "role_");
assertTrue(context.isUserInRole("role_friend"));
assertTrue(context.isUserInRole("role_admin"));
assertFalse(context.isUserInRole("role_bar"));
-
+
Set<Principal> roles2 = context.getUserRoles();
assertEquals(roles2, roles);
}
-
+
@Test
public void testGetSubject() {
Subject s = new Subject();
assertSame(new RolePrefixSecurityContextImpl(s, "").getSubject(), s);
}
-
+
private static class RolePrincipal implements Principal {
- private String roleName;
+ private String roleName;
RolePrincipal(String roleName) {
this.roleName = roleName;
}
public String getName() {
return roleName;
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java
index aa02d2e..60cff9e 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java
@@ -45,67 +45,67 @@ public class SecureAnnotationsInterceptorTest extends Assert {
private Method method;
private Message message = new MessageImpl();
-
+
@Before
public void setUp() throws Exception {
method = TestService.class.getMethod("echo", new Class[]{});
message.put(SecurityContext.class, new TestSecurityContext());
Exchange ex = new ExchangeImpl();
message.setExchange(ex);
-
+
Service service = EasyMock.createMock(Service.class);
ex.put(Service.class, service);
MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
service.get(MethodDispatcher.class.getName());
EasyMock.expectLastCall().andReturn(md);
-
+
BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class);
ex.put(BindingOperationInfo.class, boi);
md.getMethod(boi);
EasyMock.expectLastCall().andReturn(method);
EasyMock.replay(service, md);
}
-
+
@Test
public void testPermitWithNoRoles() {
- new SecureAnnotationsInterceptor().handleMessage(message);
+ new SecureAnnotationsInterceptor().handleMessage(message);
}
-
+
@Test
public void testPermitWithMethodRoles() {
SecureAnnotationsInterceptor in = new SecureAnnotationsInterceptor();
in.setAnnotationClassName(SecureRolesAllowed.class.getName());
in.setSecuredObject(new TestService());
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testAccessDeniedMethodRoles() {
SecureAnnotationsInterceptor in = new SecureAnnotationsInterceptor();
in.setAnnotationClassName(SecureRolesAllowed.class.getName());
in.setSecuredObject(new TestService2());
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
-
+
+
@Retention (RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD })
public @interface SecureRolesAllowed {
String[] value();
}
-
+
private static class TestService {
@SecureRolesAllowed("testRole")
public void echo() {
}
}
-
+
private static class TestService2 {
@SecureRolesAllowed("baz")
public void echo() {
}
}
-
+
private static class TestSecurityContext implements SecurityContext {
public Principal getUserPrincipal() {
@@ -115,6 +115,6 @@ public class SecureAnnotationsInterceptorTest extends Assert {
public boolean isUserInRole(String role) {
return "testRole".equals(role);
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
index ad9b5c0..73e79cd 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
@@ -42,7 +42,7 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
protected Message message = new MessageImpl();
private Method method;
-
+
@Before
public void setUp() throws Exception {
method = TestService.class.getMethod("echo", new Class[]{});
@@ -52,25 +52,25 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
service.get(MethodDispatcher.class.getName());
EasyMock.expectLastCall().andReturn(md);
-
+
BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class);
ex.put(BindingOperationInfo.class, boi);
md.getMethod(boi);
EasyMock.expectLastCall().andReturn(method);
EasyMock.replay(service, md);
}
-
+
protected Exchange setUpExchange() {
message.put(SecurityContext.class, new TestSecurityContext());
Exchange ex = new ExchangeImpl();
message.setExchange(ex);
return ex;
}
-
+
protected SimpleAuthorizingInterceptor createSimpleAuthorizingInterceptor() {
return new SimpleAuthorizingInterceptor();
}
-
+
protected SimpleAuthorizingInterceptor createSimpleAuthorizingInterceptorWithDenyRoles(final String role) {
SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor() {
@Override
@@ -80,7 +80,7 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
};
return in;
}
-
+
@Test(expected = AccessDeniedException.class)
public void testNoSecurityContext() {
message.put(SecurityContext.class, null);
@@ -88,7 +88,7 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
in.setAllowAnonymousUsers(false);
in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testNoSecurityContextAnonymousUserRoles() {
message.put(SecurityContext.class, null);
@@ -102,7 +102,7 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testIncompleteSecurityContext() {
message.put(SecurityContext.class, new IncompleteSecurityContext());
@@ -110,98 +110,98 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
in.setAllowAnonymousUsers(false);
in.handleMessage(message);
}
-
+
@Test
public void testPermitWithNoRoles() {
- createSimpleAuthorizingInterceptor().handleMessage(message);
+ createSimpleAuthorizingInterceptor().handleMessage(message);
}
-
+
@Test
public void testPermitWithMethodRoles() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setMethodRolesMap(Collections.singletonMap("echo", "role1 testRole"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test
public void testPermitWithMethodRolesConfigurationOnly() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setCheckConfiguredRolesOnly(true);
in.setUserRolesMap(Collections.singletonMap("testUser", "role1"));
in.setMethodRolesMap(Collections.singletonMap("echo", "role1 role2"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testDenyWithMethodRolesConfigurationOnly() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setCheckConfiguredRolesOnly(true);
in.setUserRolesMap(Collections.singletonMap("testUser", "role1"));
in.setMethodRolesMap(Collections.singletonMap("echo", "role2 role3"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testEmptyRolesConfigurationOnly() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setCheckConfiguredRolesOnly(true);
in.setMethodRolesMap(Collections.singletonMap("echo", "role1 role2"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test
public void testPermitAll() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setMethodRolesMap(Collections.singletonMap("echo", "*"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test
public void testPermitWithClassRoles() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setGlobalRoles("role1 testRole");
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testDenyWithMethodRoles() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setMethodRolesMap(Collections.singletonMap("echo", "role1 role2"));
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testDenyWithClassRoles() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptor();
in.setGlobalRoles("role1 role2");
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test
public void testPermitWithDenyRoles() {
SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptorWithDenyRoles("frogs");
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testDenyWithDenyRoles() {
SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptorWithDenyRoles("testRole");
- in.handleMessage(message);
+ in.handleMessage(message);
}
-
+
@Test(expected = AccessDeniedException.class)
public void testDenyAll() {
- SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptorWithDenyRoles("*");
- in.handleMessage(message);
+ SimpleAuthorizingInterceptor in = createSimpleAuthorizingInterceptorWithDenyRoles("*");
+ in.handleMessage(message);
}
-
+
private static class TestService {
@SuppressWarnings("unused")
public void echo() {
-
+
}
}
-
+
private static class IncompleteSecurityContext implements SecurityContext {
public Principal getUserPrincipal() {
@@ -211,9 +211,9 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
public boolean isUserInRole(String role) {
return false;
}
-
+
}
-
+
private static class TestSecurityContext implements SecurityContext {
public Principal getUserPrincipal() {
@@ -227,6 +227,6 @@ public class SimpleAuthorizingInterceptorTest extends Assert {
public boolean isUserInRole(String role) {
return "testRole".equals(role);
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java b/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
index f8f61f8..54c525a 100644
--- a/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
+++ b/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
@@ -23,13 +23,13 @@ import org.junit.Assert;
import org.junit.Test;
/**
- *
+ *
*/
public class CXFAPINamespaceHandlerTest extends Assert {
@Test
public void testGetSchemaLocation() {
CXFAPINamespaceHandler handler = new CXFAPINamespaceHandler();
-
+
assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/beans"));
assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/parameterized-types"));
assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/security"));
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/io/CacheAndWriteOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/io/CacheAndWriteOutputStreamTest.java b/core/src/test/java/org/apache/cxf/io/CacheAndWriteOutputStreamTest.java
index 6b95eb3..32d3e8f 100644
--- a/core/src/test/java/org/apache/cxf/io/CacheAndWriteOutputStreamTest.java
+++ b/core/src/test/java/org/apache/cxf/io/CacheAndWriteOutputStreamTest.java
@@ -33,7 +33,7 @@ public class CacheAndWriteOutputStreamTest extends CachedOutputStreamTest {
isClosed = true;
}
};
-
+
@Override
protected Object createCache() {
return new CacheAndWriteOutputStream(baos);
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java b/core/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
index b54c3cf..7d4366a 100644
--- a/core/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
+++ b/core/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
@@ -24,24 +24,24 @@ import java.io.IOException;
import java.io.InputStream;
public class CachedOutputStreamTest extends CachedStreamTestBase {
-
+
@Override
protected void reloadDefaultProperties() {
CachedOutputStream.setDefaultThreshold(-1);
CachedOutputStream.setDefaultMaxSize(-1);
CachedOutputStream.setDefaultCipherTransformation(null);
}
-
+
@Override
protected Object createCache() {
return new CachedOutputStream();
}
-
+
@Override
protected Object createCache(long threshold) {
return createCache(threshold, null);
}
-
+
@Override
protected Object createCache(long threshold, String transformation) {
CachedOutputStream cos = new CachedOutputStream();
@@ -49,16 +49,16 @@ public class CachedOutputStreamTest extends CachedStreamTestBase {
cos.setCipherTransformation(transformation);
return cos;
}
-
+
@Override
protected String getResetOutValue(String result, Object cache) throws IOException {
CachedOutputStream cos = (CachedOutputStream)cache;
cos.write(result.getBytes());
ByteArrayOutputStream out = new ByteArrayOutputStream();
cos.resetOut(out, true);
- return out.toString();
+ return out.toString();
}
-
+
@Override
protected File getTmpFile(String result, Object cache) throws IOException {
CachedOutputStream cos = (CachedOutputStream)cache;
@@ -72,7 +72,7 @@ public class CachedOutputStreamTest extends CachedStreamTestBase {
protected Object getInputStreamObject(Object cache) throws IOException {
return ((CachedOutputStream)cache).getInputStream();
}
-
+
@Override
protected String readFromStreamObject(Object obj) throws IOException {
return readFromStream((InputStream)obj);
@@ -83,5 +83,5 @@ public class CachedOutputStreamTest extends CachedStreamTestBase {
return readPartiallyFromStream((InputStream)cache, len);
}
}
-
-
+
+
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java b/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
index 9d69fe3..e898f00 100755
--- a/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
+++ b/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
@@ -49,7 +49,7 @@ public abstract class CachedStreamTestBase extends Assert {
protected abstract Object getInputStreamObject(Object cache) throws IOException;
protected abstract String readFromStreamObject(Object cache) throws IOException;
protected abstract String readPartiallyFromStreamObject(Object cache, int len) throws IOException;
-
+
@Test
public void testResetOut() throws IOException {
String result = initTestData(16);
@@ -58,7 +58,7 @@ public abstract class CachedStreamTestBase extends Assert {
assertEquals("The test stream content isn't same ", test, result);
close(cache);
}
-
+
@Test
public void testDeleteTmpFile() throws IOException {
Object cache = createCache();
@@ -90,7 +90,7 @@ public abstract class CachedStreamTestBase extends Assert {
//assert tmp file is deleted after the input stream is closed
assertFalse(tempFile.exists());
}
-
+
@Test
public void testEncryptAndDecryptWithDeleteOnClose() throws IOException {
// need a 8-bit cipher so that all bytes are flushed when the stream is flushed.
@@ -98,7 +98,7 @@ public abstract class CachedStreamTestBase extends Assert {
verifyEncryptAndDecryptWithDeleteOnClose(cipher);
}
}
-
+
private void verifyEncryptAndDecryptWithDeleteOnClose(String cipher) throws IOException {
Object cache = createCache(4, cipher);
final String text = "Hello Secret World!";
@@ -111,7 +111,7 @@ public abstract class CachedStreamTestBase extends Assert {
Object fin = getInputStreamObject(cache);
assertTrue("file is deleted", tmpfile.exists());
-
+
final String dectext = readFromStreamObject(fin);
assertEquals("text is not decoded correctly", text, dectext);
@@ -134,7 +134,7 @@ public abstract class CachedStreamTestBase extends Assert {
final String text = "Hello Secret World!";
File tmpfile = getTmpFile(text, cache);
assertNotNull(tmpfile);
-
+
final String enctext = readFromStream(new FileInputStream(tmpfile));
assertFalse("text is not encoded", text.equals(enctext));
@@ -142,7 +142,7 @@ public abstract class CachedStreamTestBase extends Assert {
close(cache);
assertTrue("file is deleted", tmpfile.exists());
-
+
// the file is deleted when cos is closed while all the associated inputs are closed
final String dectext = readFromStreamObject(fin);
assertEquals("text is not decoded correctly", text, dectext);
@@ -195,7 +195,7 @@ public abstract class CachedStreamTestBase extends Assert {
File tmpfile = getTmpFile("Hello World!", cache);
assertNull("expects no tmp file", tmpfile);
close(cache);
-
+
System.setProperty("org.apache.cxf.io.CachedOutputStream.Threshold", "4");
reloadDefaultProperties();
cache = createCache();
@@ -214,22 +214,22 @@ public abstract class CachedStreamTestBase extends Assert {
@Test
public void testUseBusProps() throws Exception {
- Bus oldbus = BusFactory.getThreadDefaultBus(false);
+ Bus oldbus = BusFactory.getThreadDefaultBus(false);
try {
Object cache = createCache(64);
File tmpfile = getTmpFile("Hello World!", cache);
assertNull("expects no tmp file", tmpfile);
close(cache);
-
+
IMocksControl control = EasyMock.createControl();
-
+
Bus b = control.createMock(Bus.class);
EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.Threshold")).andReturn("4");
EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.MaxSize")).andReturn(null);
EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.CipherTransformation")).andReturn(null);
-
+
BusFactory.setThreadDefaultBus(b);
-
+
control.replay();
cache = createCache();
@@ -238,13 +238,13 @@ public abstract class CachedStreamTestBase extends Assert {
assertTrue("expects a tmp file", tmpfile.exists());
close(cache);
assertFalse("expects no tmp file", tmpfile.exists());
-
+
control.verify();
} finally {
BusFactory.setThreadDefaultBus(oldbus);
}
}
-
+
private static void close(Object obj) throws IOException {
if (obj instanceof Closeable) {
((Closeable)obj).close();
@@ -264,21 +264,21 @@ public abstract class CachedStreamTestBase extends Assert {
return new String(buf.toByteArray(), StandardCharsets.UTF_8);
}
}
-
+
protected static String readFromReader(Reader is) throws IOException {
try (StringWriter writer = new StringWriter()) {
IOUtils.copyAndCloseInput(is, writer);
return writer.toString();
}
}
-
+
protected static String readPartiallyFromReader(Reader is, int len) throws IOException {
try (StringWriter writer = new StringWriter()) {
IOUtils.copyAtLeast(is, writer, len);
return writer.toString();
}
}
-
+
private static String initTestData(int packetSize) {
String temp = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+?><[]/0123456789";
String result = new String();
@@ -288,5 +288,5 @@ public abstract class CachedStreamTestBase extends Assert {
return result;
}
}
-
-
+
+
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/io/CachedWriterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/io/CachedWriterTest.java b/core/src/test/java/org/apache/cxf/io/CachedWriterTest.java
index 7a4c846..e15b78d 100644
--- a/core/src/test/java/org/apache/cxf/io/CachedWriterTest.java
+++ b/core/src/test/java/org/apache/cxf/io/CachedWriterTest.java
@@ -35,12 +35,12 @@ public class CachedWriterTest extends CachedStreamTestBase {
protected Object createCache() {
return new CachedWriter();
}
-
+
@Override
protected Object createCache(long threshold) {
return createCache(threshold, null);
}
-
+
@Override
protected Object createCache(long threshold, String transformation) {
CachedWriter cos = new CachedWriter();
@@ -48,7 +48,7 @@ public class CachedWriterTest extends CachedStreamTestBase {
cos.setCipherTransformation(transformation);
return cos;
}
-
+
@Override
protected String getResetOutValue(String result, Object cache) throws IOException {
CachedWriter cos = (CachedWriter)cache;
@@ -57,7 +57,7 @@ public class CachedWriterTest extends CachedStreamTestBase {
cos.resetOut(out, true);
return out.toString();
}
-
+
@Override
protected File getTmpFile(String result, Object cache) throws IOException {
CachedWriter cos = (CachedWriter)cache;
@@ -82,5 +82,5 @@ public class CachedWriterTest extends CachedStreamTestBase {
return readPartiallyFromReader((Reader)cache, len);
}
}
-
-
+
+
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java b/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
index 1a24849..a8fa5ec 100644
--- a/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
+++ b/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
@@ -75,10 +75,10 @@ public class PhaseInterceptorChainTest extends Assert {
@Test
public void testState() throws Exception {
AbstractPhaseInterceptor<? extends Message> p = setUpPhaseInterceptor("phase1", "p1");
-
+
control.replay();
chain.add(p);
-
+
assertSame("Initial state is State.EXECUTING",
InterceptorChain.State.EXECUTING, chain.getState());
chain.pause();
@@ -91,34 +91,34 @@ public class PhaseInterceptorChainTest extends Assert {
assertSame("Aborting chain should lead to State.ABORTED",
InterceptorChain.State.ABORTED, chain.getState());
}
-
+
@Test
public void testSuspendedException() throws Exception {
- CountingPhaseInterceptor p1 =
+ CountingPhaseInterceptor p1 =
new CountingPhaseInterceptor("phase1", "p1");
- SuspendedInvocationInterceptor p2 =
+ SuspendedInvocationInterceptor p2 =
new SuspendedInvocationInterceptor("phase2", "p2");
-
+
message.getInterceptorChain();
EasyMock.expectLastCall().andReturn(chain).anyTimes();
control.replay();
-
+
chain.add(p1);
chain.add(p2);
-
+
try {
chain.doIntercept(message);
fail("Suspended invocation swallowed");
} catch (SuspendedInvocationException ex) {
// ignore
}
-
+
assertSame("No previous interceptor selected", p1, chain.iterator().next());
assertSame("Suspended invocation should lead to State.PAUSED",
InterceptorChain.State.PAUSED, chain.getState());
}
-
+
@Test
public void testAddOneInterceptor() throws Exception {
AbstractPhaseInterceptor<? extends Message> p = setUpPhaseInterceptor("phase1", "p1");
@@ -128,7 +128,7 @@ public class PhaseInterceptorChainTest extends Assert {
assertSame(p, it.next());
assertTrue(!it.hasNext());
}
-
+
@Test
public void testForceAddSameInterceptor() throws Exception {
@@ -143,9 +143,9 @@ public class PhaseInterceptorChainTest extends Assert {
it = chain.iterator();
assertSame(p, it.next());
assertSame(p, it.next());
- assertTrue(!it.hasNext());
+ assertTrue(!it.hasNext());
}
-
+
@Test
public void testForceAddSameInterceptorType() throws Exception {
@@ -161,7 +161,7 @@ public class PhaseInterceptorChainTest extends Assert {
it = chain.iterator();
assertSame(p1, it.next());
assertSame(p2, it.next());
- assertTrue(!it.hasNext());
+ assertTrue(!it.hasNext());
}
@Test
@@ -179,7 +179,7 @@ public class PhaseInterceptorChainTest extends Assert {
assertSame("Unexpected interceptor at this position.", p2, it.next());
assertTrue(!it.hasNext());
}
-
+
@Test
public void testThreeInterceptorSamePhaseWithOrder() throws Exception {
AbstractPhaseInterceptor<? extends Message> p1 = setUpPhaseInterceptor("phase1", "p1");
@@ -193,7 +193,7 @@ public class PhaseInterceptorChainTest extends Assert {
chain.add(p3);
chain.add(p1);
chain.add(p2);
-
+
Iterator<Interceptor<? extends Message>> it = chain.iterator();
assertSame("Unexpected interceptor at this position.", p3, it.next());
assertSame("Unexpected interceptor at this position.", p2, it.next());
@@ -391,20 +391,20 @@ public class PhaseInterceptorChainTest extends Assert {
assertEquals(0, p2.invoked);
assertEquals(1, p3.invoked);
}
-
+
AbstractPhaseInterceptor<Message> setUpPhaseInterceptor(String phase, String id) throws Exception {
return setUpPhaseInterceptor(phase, id, null, null);
}
- AbstractPhaseInterceptor<Message> setUpPhaseInterceptor(final String phase,
+ AbstractPhaseInterceptor<Message> setUpPhaseInterceptor(final String phase,
final String id,
Set<String> b,
Set<String> a) throws Exception {
-
+
@SuppressWarnings("unchecked")
AbstractPhaseInterceptor<Message> p = control
.createMock(AbstractPhaseInterceptor.class);
-
+
if (a == null) {
a = new SortedArraySet<String>();
}
@@ -414,7 +414,7 @@ public class PhaseInterceptorChainTest extends Assert {
Field f = AbstractPhaseInterceptor.class.getDeclaredField("before");
ReflectionUtil.setAccessible(f);
f.set(p, b);
-
+
f = AbstractPhaseInterceptor.class.getDeclaredField("after");
ReflectionUtil.setAccessible(f);
f.set(p, a);
@@ -429,7 +429,7 @@ public class PhaseInterceptorChainTest extends Assert {
return p;
}
-
+
void setUpPhaseInterceptorInvocations(AbstractPhaseInterceptor<Message> p,
boolean fail, boolean expectFault) {
p.handleMessage(message);
@@ -447,8 +447,8 @@ public class PhaseInterceptorChainTest extends Assert {
}
}
- private void setUpCustomLogger(boolean useCustomLogger,
- boolean expectFault,
+ private void setUpCustomLogger(boolean useCustomLogger,
+ boolean expectFault,
boolean returnFromCustomLogger) {
if (useCustomLogger) {
FaultListener customLogger = control.createMock(FaultListener.class);
@@ -456,7 +456,7 @@ public class PhaseInterceptorChainTest extends Assert {
EasyMock.expectLastCall().andReturn(customLogger);
if (expectFault) {
customLogger.faultOccurred(EasyMock.isA(Exception.class),
- EasyMock.isA(String.class),
+ EasyMock.isA(String.class),
EasyMock.isA(Message.class));
EasyMock.expectLastCall().andReturn(returnFromCustomLogger);
if (returnFromCustomLogger) {
@@ -513,7 +513,7 @@ public class PhaseInterceptorChainTest extends Assert {
invoked++;
}
}
-
+
public class WrapperingPhaseInterceptor extends CountingPhaseInterceptor {
public WrapperingPhaseInterceptor(String phase, String id) {
super(phase, id);
@@ -526,11 +526,11 @@ public class PhaseInterceptorChainTest extends Assert {
}
public class SuspendedInvocationInterceptor extends AbstractPhaseInterceptor<Message> {
-
+
public SuspendedInvocationInterceptor(String phase, String id) {
super(id, phase);
}
-
+
public void handleMessage(Message m) {
m.getInterceptorChain().suspend();
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/resource/ClassLoaderResolverTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/resource/ClassLoaderResolverTest.java b/core/src/test/java/org/apache/cxf/resource/ClassLoaderResolverTest.java
index 0d953de..aaef891 100644
--- a/core/src/test/java/org/apache/cxf/resource/ClassLoaderResolverTest.java
+++ b/core/src/test/java/org/apache/cxf/resource/ClassLoaderResolverTest.java
@@ -35,15 +35,15 @@ import org.junit.Test;
public class ClassLoaderResolverTest extends Assert {
- private static final String RESOURCE_DATA = "this is the resource data";
+ private static final String RESOURCE_DATA = "this is the resource data";
private String resourceName;
- private ClassLoaderResolver clr;
+ private ClassLoaderResolver clr;
@Before
- public void setUp() throws IOException {
+ public void setUp() throws IOException {
File resource = File.createTempFile("test", "resource");
- resource.deleteOnExit();
+ resource.deleteOnExit();
resourceName = resource.getName();
FileWriter writer = new FileWriter(resource);
@@ -52,34 +52,34 @@ public class ClassLoaderResolverTest extends Assert {
writer.close();
URL[] urls = {resource.getParentFile().toURI().toURL()};
- ClassLoader loader = new URLClassLoader(urls);
+ ClassLoader loader = new URLClassLoader(urls);
assertNotNull(loader.getResourceAsStream(resourceName));
assertNull(ClassLoader.getSystemResourceAsStream(resourceName));
clr = new ClassLoaderResolver(loader);
- }
-
+ }
+
@After
public void tearDown() {
clr = null;
resourceName = null;
}
-
+
@Test
- public void testResolve() {
+ public void testResolve() {
assertNull(clr.resolve(resourceName, null));
assertNotNull(clr.resolve(resourceName, URL.class));
- }
+ }
@Test
- public void testGetAsStream() throws IOException {
+ public void testGetAsStream() throws IOException {
InputStream in = clr.getAsStream(resourceName);
- assertNotNull(in);
+ assertNotNull(in);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String content = reader.readLine();
+ String content = reader.readLine();
assertEquals("resource content incorrect", RESOURCE_DATA, content);
reader.close();
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java b/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java
index d5b60ff..21c9427 100644
--- a/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java
+++ b/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java
@@ -27,20 +27,20 @@ import org.junit.Assert;
import org.junit.Test;
public class URIResolverTest extends Assert {
-
+
private URIResolver uriResolver;
-
+
private URL resourceURL = getClass().getResource("resources/helloworld.bpr");
-
-
+
+
@Test
public void testJARProtocol() throws Exception {
uriResolver = new URIResolver();
-
+
byte[] barray = new byte[]{0};
- byte[] barray2 = new byte[]{1};
+ byte[] barray2 = new byte[]{1};
String uriStr = "jar:" + resourceURL.toString() + "!/wsdl/hello_world.wsdl";
-
+
// Check standard Java API's work with "jar:"
URL jarURL = new URL(uriStr);
InputStream is = jarURL.openStream();
@@ -50,43 +50,43 @@ public class URIResolverTest extends Assert {
is.read(barray);
is.close();
}
-
+
uriResolver.resolve("baseUriStr", uriStr, null);
-
+
InputStream is2 = uriResolver.getInputStream();
- assertNotNull(is2);
+ assertNotNull(is2);
if (is2 != null) {
barray2 = new byte[is2.available()];
is2.read(barray2);
is2.close();
-
- }
+
+ }
assertEquals(IOUtils.newStringFromBytes(barray), IOUtils.newStringFromBytes(barray2));
}
@Test
public void testJARResolver() throws Exception {
uriResolver = new URIResolver();
-
+
String uriStr = "jar:" + resourceURL.toString() + "!/wsdl/hello_world.wsdl";
-
+
URL jarURL = new URL(uriStr);
InputStream is = jarURL.openStream();
assertNotNull(is);
String uriStr2 = "jar:" + resourceURL.toString() + "!/wsdl/hello_world_2.wsdl";
-
+
URL jarURL2 = new URL(uriStr2);
InputStream is2 = jarURL2.openStream();
assertNotNull(is2);
-
+
uriResolver.resolve(uriStr, "hello_world_2.wsdl", null);
-
+
InputStream is3 = uriResolver.getInputStream();
- assertNotNull(is3);
+ assertNotNull(is3);
}
-
-
+
+
@Test
public void testResolveRelativeFile() throws Exception {
URIResolver wsdlResolver = new URIResolver();
@@ -94,23 +94,23 @@ public class URIResolverTest extends Assert {
// resolve the wsdl
wsdlResolver.resolve(null, "wsdl/foo.wsdl", this.getClass());
assertTrue(wsdlResolver.isResolved());
-
+
// get the base uri from the resolved wsdl location
String baseUri = wsdlResolver.getURI().toString();
-
+
// resolve the schema using relative location
String schemaLocation = "../schemas/configuration/bar.xsd";
URIResolver xsdResolver = new URIResolver();
xsdResolver.resolve(baseUri, schemaLocation, this.getClass());
assertNotNull(xsdResolver.getInputStream());
-
+
// resolve the schema using relative location with base uri fragment
xsdResolver = new URIResolver();
xsdResolver.resolve(baseUri + "#type2", schemaLocation, this.getClass());
assertNotNull(xsdResolver.getInputStream());
-
+
}
-
+
@Test
public void testResolvePathWithSpace() throws Exception {
URIResolver wsdlResolver = new URIResolver();
@@ -118,21 +118,21 @@ public class URIResolverTest extends Assert {
// resolve the wsdl
wsdlResolver.resolve(null, "wsdl/foo.wsdl", this.getClass());
assertTrue(wsdlResolver.isResolved());
-
+
// get the base uri from the resolved wsdl location
String baseUri = wsdlResolver.getURI().toString();
-
+
// resolve the schema using relative location
String schemaLocation = "../schemas/configuration/folder with spaces/bar.xsd";
URIResolver xsdResolver = new URIResolver();
xsdResolver.resolve(baseUri, schemaLocation, this.getClass());
assertNotNull(xsdResolver.getInputStream());
-
+
// resolve the schema using relative location with base uri fragment
xsdResolver = new URIResolver();
xsdResolver.resolve(baseUri + "#type2", schemaLocation, this.getClass());
assertNotNull(xsdResolver.getInputStream());
-
+
}
@Test
@@ -142,7 +142,7 @@ public class URIResolverTest extends Assert {
wsdlResolver.resolve(null, "wsdl/folder with spaces/foo.wsdl", this.getClass());
assertTrue(wsdlResolver.isResolved());
}
-
+
@Test
public void testBasePathWithEncodedSpace() throws Exception {
URIResolver wsdlResolver = new URIResolver();
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/service/model/BindingFaultInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/service/model/BindingFaultInfoTest.java b/core/src/test/java/org/apache/cxf/service/model/BindingFaultInfoTest.java
index a4e4bbe..ae60554 100644
--- a/core/src/test/java/org/apache/cxf/service/model/BindingFaultInfoTest.java
+++ b/core/src/test/java/org/apache/cxf/service/model/BindingFaultInfoTest.java
@@ -26,9 +26,9 @@ import org.junit.Before;
import org.junit.Test;
public class BindingFaultInfoTest extends Assert {
-
+
private BindingFaultInfo bindingFaultInfo;
-
+
@Before
public void setUp() throws Exception {
FaultInfo faultInfo = new FaultInfo(new QName("http://faultns/", "fault"), new QName(
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java b/core/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
index d646cf8..aef5312 100644
--- a/core/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
+++ b/core/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
@@ -28,7 +28,7 @@ import org.junit.Test;
public class BindingOperationInfoTest extends Assert {
private static final String TEST_NS = "urn:test:ns";
private BindingOperationInfo bindingOperationInfo;
-
+
@Before
public void setUp() throws Exception {
OperationInfo operationInfo = new OperationInfo(null, new QName(TEST_NS, "operationTest"));
@@ -36,7 +36,7 @@ public class BindingOperationInfoTest extends Assert {
"http://apache.org/hello_world_soap_http", "testInputMessage"),
MessageInfo.Type.INPUT);
operationInfo.setInput("input", inputMessage);
-
+
MessageInfo outputMessage = operationInfo.createMessage(new QName(
"http://apache.org/hello_world_soap_http", "testOutputMessage"),
MessageInfo.Type.OUTPUT);
@@ -45,17 +45,17 @@ public class BindingOperationInfoTest extends Assert {
"http://apache.org/hello_world_soap_http", "faultMessage"));
bindingOperationInfo = new BindingOperationInfo(null, operationInfo);
}
-
+
@Test
public void testName() throws Exception {
assertEquals(bindingOperationInfo.getName(), new QName(TEST_NS, "operationTest"));
}
-
+
@Test
public void testBinding() throws Exception {
assertNull(bindingOperationInfo.getBinding());
}
-
+
@Test
public void testOperation() throws Exception {
assertEquals(bindingOperationInfo.getOperationInfo().getName(), new QName(TEST_NS, "operationTest"));
@@ -67,25 +67,25 @@ public class BindingOperationInfoTest extends Assert {
new QName(TEST_NS, "fault"));
assertEquals(1, bindingOperationInfo.getFaults().size());
}
-
+
@Test
public void testInputMessage() throws Exception {
BindingMessageInfo inputMessage = bindingOperationInfo.getInput();
assertNotNull(inputMessage);
assertEquals(inputMessage.getMessageInfo().getName().getLocalPart(), "testInputMessage");
- assertEquals(inputMessage.getMessageInfo().getName().getNamespaceURI(),
+ assertEquals(inputMessage.getMessageInfo().getName().getNamespaceURI(),
"http://apache.org/hello_world_soap_http");
}
-
+
@Test
public void testOutputMessage() throws Exception {
BindingMessageInfo outputMessage = bindingOperationInfo.getOutput();
assertNotNull(outputMessage);
assertEquals(outputMessage.getMessageInfo().getName().getLocalPart(), "testOutputMessage");
- assertEquals(outputMessage.getMessageInfo().getName().getNamespaceURI(),
+ assertEquals(outputMessage.getMessageInfo().getName().getNamespaceURI(),
"http://apache.org/hello_world_soap_http");
}
-
+
@Test
public void testFaultMessage() throws Exception {
BindingFaultInfo faultMessage = bindingOperationInfo.getFaults().iterator().next();
http://git-wip-us.apache.org/repos/asf/cxf/blob/8cea7c87/core/src/test/java/org/apache/cxf/service/model/FaultInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/service/model/FaultInfoTest.java b/core/src/test/java/org/apache/cxf/service/model/FaultInfoTest.java
index caa7f99..7dca73a 100644
--- a/core/src/test/java/org/apache/cxf/service/model/FaultInfoTest.java
+++ b/core/src/test/java/org/apache/cxf/service/model/FaultInfoTest.java
@@ -26,22 +26,22 @@ import org.junit.Before;
import org.junit.Test;
public class FaultInfoTest extends Assert {
-
+
private FaultInfo faultInfo;
-
+
@Before
public void setUp() throws Exception {
faultInfo = new FaultInfo(new QName("urn:test:ns", "fault"), new QName(
"http://apache.org/hello_world_soap_http", "faultMessage"), null);
}
-
+
@Test
public void testName() throws Exception {
assertEquals(faultInfo.getFaultName(), new QName("urn:test:ns", "fault"));
assertEquals(faultInfo.getName().getLocalPart(), "faultMessage");
assertEquals(faultInfo.getName().getNamespaceURI(),
"http://apache.org/hello_world_soap_http");
-
+
faultInfo.setFaultName(new QName("urn:test:ns", "fault"));
assertEquals(faultInfo.getFaultName(), new QName("urn:test:ns", "fault"));
}