Skip to content

Commit

Permalink
[JBWS-4387]:Fix more test failures after CXF 4.0.4 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jimma committed Nov 16, 2023
1 parent fbbad3c commit 769b18a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public class JBossWSBusFactory extends CXFBusFactory
{
private static final Map<ClassLoader, Bus> classLoaderBusses = new WeakHashMap<ClassLoader, Bus>();
private static final boolean forceURLConnectionConduit = Boolean.getBoolean(Constants.FORCE_URL_CONNECTION_CONDUIT);
private final boolean forceURLConnectionConduit = Boolean.getBoolean(Constants.FORCE_URL_CONNECTION_CONDUIT);
@Override
public Bus createBus(Map<Class<?>, Object> extensions, Map<String, Object> properties) {
if (extensions == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@

public class SOAPConnectionImpl extends SOAPConnection
{
private volatile boolean closed = false;
private static final boolean forceURLConnectionConduit = Boolean.getBoolean(Constants.FORCE_URL_CONNECTION_CONDUIT);
private volatile boolean closed = false;
private boolean forceURLConnectionConduit = Boolean.getBoolean(Constants.FORCE_URL_CONNECTION_CONDUIT);

@Override
public SOAPMessage call(SOAPMessage msgOut, Object addressObject) throws SOAPException
Expand All @@ -77,7 +77,7 @@ public SOAPMessage call(SOAPMessage msgOut, Object addressObject) throws SOAPExc
outMessage.setExchange(exch);
exch.put("org.apache.cxf.transport.process_fault_on_http_400", true); //JBWS-3945
if (forceURLConnectionConduit) {
exch.put("Constants.FORCE_URL_CONNECTION_CONDUIT)", true);
exch.put(Constants.FORCE_URL_CONNECTION_CONDUIT, true);
}

// sent SOAPMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testHttpProxy() throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains(testHost));
assertTrue(baos.toString().contains("UnresolvedAddressException"));
}

//then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
Expand All @@ -121,7 +121,7 @@ public void testHttpProxy() throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
assertTrue(baos.toString().contains("407"));
}

//finally setup everything
Expand Down Expand Up @@ -156,7 +156,7 @@ public void testHttpProxyUsingHTTPClientPolicy() throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains(testHost));
assertTrue(baos.toString().contains("UnresolvedAddressException"));
}

//then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
Expand All @@ -175,7 +175,7 @@ public void testHttpProxyUsingHTTPClientPolicy() throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
assertTrue(baos.toString().contains("407"));
}

//finally setup authorization info too
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void testUndeclaredRole() throws Exception
} catch (Exception e) {
//expected web layer exception
assertTrue(e.getMessage().contains("Could not send Message"));
assertTrue("Exception Cause message: " + e.getCause().getMessage(), e.getCause().getMessage().contains("403: Forbidden"));
assertTrue("Exception Cause message: " + e.getCause().getMessage(), e.getCause().getMessage().contains("403"));
}
}
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.wsf.test.JBossWSTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -70,6 +72,16 @@ public static WebArchive createDeployments() {
.setWebXML(new File(getTestResourcesDir() + "/saaj/jbws3084/WEB-INF/web.xml"));
return archive;
}
@BeforeClass
public static void forceURLConnection() {
//The new HttpClientConduit doesn't work for disabling the chunk mode
//https://issues.redhat.com/browse/JBWS-4388
System.setProperty("force.urlconnection.http.conduit", "true");
}
@AfterClass
public static void cleanupSystemProperty() {
System.clearProperty("force.urlconnection.http.conduit");
}

@Test
@RunAsClient
Expand Down Expand Up @@ -118,7 +130,6 @@ private void doTestSoapConnection(boolean disableChunking) throws Exception
SOAPConnection con = conFac.createConnection();

final String serviceURL = baseURL.toString();

URL endpoint = new URL(serviceURL);
SOAPMessage response = con.call(msg, endpoint);
QName sayHiResp = new QName("http://www.jboss.org/jbossws/saaj", "sayHelloResponse");
Expand Down

0 comments on commit 769b18a

Please sign in to comment.