// Path: src/main/java/de/jeha/s3srv/common/errors/ErrorCodes.java
// public enum ErrorCodes {
// 
//     ACCESS_DENIED(
//             "AccessDenied",
//             "Access Denied",
//             403
//     ),
//     BAD_DIGEST(
//             "BadDigest",
//             "The Content-MD5 you specified did not match what we received.",
//             400
//     ),
//     BUCKET_ALREADY_EXISTS(
//             "BucketAlreadyExists",
//             "The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.",
//             409
//     ),
//     BUCKET_NOT_EMPTY(
//             "BucketNotEmpty",
//             "The bucket you tried to delete is not empty.",
//             409
//     ),
//     INVALID_ACCESS_KEY_ID(
//             "InvalidAccessKeyId",
//             "The access key Id you provided does not exist in our records.",
//             403
//     ),
//     INVALID_BUCKET_NAME(
//             "InvalidBucketName",
//             "The specified bucket is not valid.",
//             400
//     ),
//     INTERNAL_ERROR(
//             "InternalError",
//             "We encountered an internal error. Please try again.",
//             500
//     ),
//     NO_SUCH_BUCKET(
//             "NoSuchBucket",
//             "The specified bucket does not exist.",
//             404
//     ),
//     SERVICE_UNAVAILABLE(
//             "ServiceUnavailable",
//             "Reduce your request rate.",
//             503
//     ),
//     SIGNATURE_DOES_NOT_MATCH(
//             "SignatureDoesNotMatch",
//             "The request signature we calculated does not match the signature you provided. Check your secret access key and signing method.",
//             403
//     );
// 
//     private final String code;
//     private final String description;
//     private final int statusCode;
// 
//     ErrorCodes(String code, String description, int statusCode) {
//         this.code = code;
//         this.description = description;
//         this.statusCode = statusCode;
//     }
// 
//     public String getCode() {
//         return code;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public int getStatusCode() {
//         return statusCode;
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/xml/JaxbMarshaller.java
// public class JaxbMarshaller {
// 
//     private static Marshaller MARSHALLER = null;
//     private static Unmarshaller UNMARSHALLER = null;
// 
//     static {
//         try {
//             MARSHALLER = JaxbContextHolder.getContext().createMarshaller();
//             MARSHALLER.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//             MARSHALLER.setProperty(Marshaller.JAXB_FRAGMENT, true);
//         } catch (JAXBException e) {
//             throw new RuntimeException("Unable to initialize JAXB Marshaller", e);
//         }
//         try {
//             UNMARSHALLER = JaxbContextHolder.getContext().createUnmarshaller();
//         } catch (JAXBException e) {
//             throw new RuntimeException("Unable to initialize JAXB Unmarshaller", e);
//         }
//     }
// 
//     public synchronized static String marshall(Object object) throws JAXBException, IOException {
//         StringWriter stringWriter = new StringWriter();
//         stringWriter.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//         stringWriter.append("\n");
// 
//         MARSHALLER.marshal(object, stringWriter);
//         stringWriter.close();
// 
//         return stringWriter.toString();
//     }
// 
//     public synchronized static <T> T unmarshall(String xml, Class<T> clazz) throws JAXBException, IOException {
//         return UNMARSHALLER.unmarshal(new StreamSource(new StringReader(xml)), clazz).getValue();
//     }
// 
// }


import de.jeha.s3srv.common.errors.ErrorCodes;
import de.jeha.s3srv.xml.JaxbMarshaller;
import org.junit.jupiter.api.Test;
import javax.xml.bind.JAXBException;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
package de.jeha.s3srv.api;




/**
 * @author jenshadlich@googlemail.com
 */
public class ErrorResponseSerializationTest {

    @Test
    public void test() throws JAXBException, IOException {
        ErrorResponse response =
                new ErrorResponse(ErrorCodes.SERVICE_UNAVAILABLE.getCode(), ErrorCodes.SERVICE_UNAVAILABLE.getDescription(), null, null);

        final String responseXml = JaxbMarshaller.marshall(response);

        System.out.println(responseXml);

        String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
// Path: src/main/java/de/jeha/s3srv/common/errors/ErrorCodes.java
// public enum ErrorCodes {
// 
//     ACCESS_DENIED(
//             "AccessDenied",
//             "Access Denied",
//             403
//     ),
//     BAD_DIGEST(
//             "BadDigest",
//             "The Content-MD5 you specified did not match what we received.",
//             400
//     ),
//     BUCKET_ALREADY_EXISTS(
//             "BucketAlreadyExists",
//             "The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.",
//             409
//     ),
//     BUCKET_NOT_EMPTY(
//             "BucketNotEmpty",
//             "The bucket you tried to delete is not empty.",
//             409
//     ),
//     INVALID_ACCESS_KEY_ID(
//             "InvalidAccessKeyId",
//             "The access key Id you provided does not exist in our records.",
//             403
//     ),
//     INVALID_BUCKET_NAME(
//             "InvalidBucketName",
//             "The specified bucket is not valid.",
//             400
//     ),
//     INTERNAL_ERROR(
//             "InternalError",
//             "We encountered an internal error. Please try again.",
//             500
//     ),
//     NO_SUCH_BUCKET(
//             "NoSuchBucket",
//             "The specified bucket does not exist.",
//             404
//     ),
//     SERVICE_UNAVAILABLE(
//             "ServiceUnavailable",
//             "Reduce your request rate.",
//             503
//     ),
//     SIGNATURE_DOES_NOT_MATCH(
//             "SignatureDoesNotMatch",
//             "The request signature we calculated does not match the signature you provided. Check your secret access key and signing method.",
//             403
//     );
// 
//     private final String code;
//     private final String description;
//     private final int statusCode;
// 
//     ErrorCodes(String code, String description, int statusCode) {
//         this.code = code;
//         this.description = description;
//         this.statusCode = statusCode;
//     }
// 
//     public String getCode() {
//         return code;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public int getStatusCode() {
//         return statusCode;
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/xml/JaxbMarshaller.java
// public class JaxbMarshaller {
// 
//     private static Marshaller MARSHALLER = null;
//     private static Unmarshaller UNMARSHALLER = null;
// 
//     static {
//         try {
//             MARSHALLER = JaxbContextHolder.getContext().createMarshaller();
//             MARSHALLER.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//             MARSHALLER.setProperty(Marshaller.JAXB_FRAGMENT, true);
//         } catch (JAXBException e) {
//             throw new RuntimeException("Unable to initialize JAXB Marshaller", e);
//         }
//         try {
//             UNMARSHALLER = JaxbContextHolder.getContext().createUnmarshaller();
//         } catch (JAXBException e) {
//             throw new RuntimeException("Unable to initialize JAXB Unmarshaller", e);
//         }
//     }
// 
//     public synchronized static String marshall(Object object) throws JAXBException, IOException {
//         StringWriter stringWriter = new StringWriter();
//         stringWriter.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//         stringWriter.append("\n");
// 
//         MARSHALLER.marshal(object, stringWriter);
//         stringWriter.close();
// 
//         return stringWriter.toString();
//     }
// 
//     public synchronized static <T> T unmarshall(String xml, Class<T> clazz) throws JAXBException, IOException {
//         return UNMARSHALLER.unmarshal(new StreamSource(new StringReader(xml)), clazz).getValue();
//     }
// 
// }


// Path: src/test/java/de/jeha/s3srv/api/ErrorResponseSerializationTest.java
import de.jeha.s3srv.common.errors.ErrorCodes;
import de.jeha.s3srv.xml.JaxbMarshaller;
import org.junit.jupiter.api.Test;
import javax.xml.bind.JAXBException;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;

package de.jeha.s3srv.api;




/**
 * @author jenshadlich@googlemail.com
 */
public class ErrorResponseSerializationTest {

    @Test
    public void test() throws JAXBException, IOException {
        ErrorResponse response =
                new ErrorResponse(ErrorCodes.SERVICE_UNAVAILABLE.getCode(), ErrorCodes.SERVICE_UNAVAILABLE.getDescription(), null, null);

        final String responseXml = JaxbMarshaller.marshall(response);

        System.out.println(responseXml);

        String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<Error xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n" +