Buggy code:
@ RunAsClient @ RunWith ( Arquillian . class ) public class HttpDeploymentUploadUnitTestCase { private static final String BOUNDARY_PARAM = "NeAG1QNIHHOyB5joAS7Rox!!" ; private static final String BOUNDARY = "--" + ( HttpDeploymentUploadUnitTestCase . BOUNDARY_PARAM ) ; private static final String CRLF = "\r\n" ; private static final String POST_REQUEST_METHOD = "POST" ; public static final String MANAGEMENT_URL_PART = "management" ; private static final String UPLOAD_URL_PART = "add-content" ; @ ContainerResource private ManagementClient managementClient ; @ Test public void testHttpDeploymentUpload ( ) throws Exception { Authentication . setupDefaultAuthenticator ( ) ; HttpURLConnection connection = null ; BufferedOutputStream os = null ; BufferedInputStream is = null ; final String basicUrl = ( ( "http:////" + ( managementClient . getMgmtAddress ( ) ) ) + ":9990//" ) + ( HttpDeploymentUploadUnitTestCase . MANAGEMENT_URL_PART ) ; String uploadUrl = ( basicUrl + "//" ) + ( HttpDeploymentUploadUnitTestCase . UPLOAD_URL_PART ) ; try { connection = getHttpURLConnection ( uploadUrl , ( "multipart//form-data;<seq2seq4repair_space>boundary=" + ( HttpDeploymentUploadUnitTestCase . BOUNDARY_PARAM ) ) ) ; final JavaArchive archive = ShrinkWrap . create ( JavaArchive . class , "test-http-deployment.sar" ) . addPackage ( Simple . class . getPackage ( ) ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; is = new BufferedInputStream ( archive . as ( ZipExporter . class ) . exportAsInputStream ( ) ) ; writeUploadRequest ( is , os ) ; <START_BUG> assertEquals ( "text//html;utf-8" , connection . getHeaderField ( "Content-Type" ) ) ; <END_BUG> ModelNode node = readResult ( connection . getInputStream ( ) ) ; assertNotNull ( node ) ; System . out . println ( node ) ; assertEquals ( SUCCESS , node . require ( OUTCOME ) . asString ( ) ) ; byte [ ] hash = node . require ( RESULT ) . asBytes ( ) ; connection . disconnect ( ) ; connection = getHttpURLConnection ( basicUrl , "application//json" ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; writeAddRequest ( os , hash ) ; node = readResult ( connection . getInputStream ( ) ) ; assertNotNull ( node ) ; System . out . println ( node ) ; assertEquals ( SUCCESS , node . require ( OUTCOME ) . asString ( ) ) ; connection . disconnect ( ) ; } finally { closeQuietly ( is ) ; closeQuietly ( os ) ; try { connection = getHttpURLConnection ( basicUrl , "application//json" ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; writeRemoveRequest ( os ) ; ModelNode node = readResult ( connection . getInputStream ( ) ) ; System . out . println ( node ) ; connection . disconnect ( ) ; } catch ( Exception ignored ) { ignored . printStackTrace ( ) ; } finally { closeQuietly ( os ) ; } } } private HttpURLConnection getHttpURLConnection ( final String url , final String contentType ) throws IOException { } private void writeUploadRequest ( final InputStream is , final OutputStream os ) throws IOException { } private void writeAddRequest ( BufferedOutputStream os , byte [ ] hash ) throws IOException { } private void writeRemoveRequest ( BufferedOutputStream os ) throws IOException { } private ModelNode readResult ( final InputStream is ) throws IOException , NoSuchElementException { } private byte [ ] buildUploadPostRequestHeader ( ) { } private String buildPostRequestHeaderSection ( final String contentDisposition , final String contentType , final String content ) { } private void writePostRequestPayload ( final InputStream is , final OutputStream os ) throws IOException { } private void closeQuietly ( final Closeable closeable ) { } }

Fix:
assertEquals ( "text//html;<seq2seq4repair_space>charset=utf-8" , connection . getHeaderField ( "Content-Type" ) ) ;