JaxbJsonSerializer { public String serialize(T object) throws IOException { StringWriter writer = new StringWriter(); mapper.writeValue(writer, object); return writer.toString(); } JaxbJsonSerializer(Class<T> type); String serialize(T object); T deserialize(String json);  }
@Test public void testSerialize() throws Exception { JaxbJsonSerializer<TestConfig> serializer = new JaxbJsonSerializer<>(TestConfig.class); StorageProviderCredential s3Cred = new StorageProviderCredential( StorageProviderCredential.ProviderType.AMAZON_S3, new SimpleCredential("amazon-user", "amazon-pass")); TestConfig testConfig = new TestConfig(); testConfig.addProviderCredential(s3Cred); testConfig.setQueueName("queue-name"); testConfig.setTestEndPoint(new TestEndPoint()); testConfig.setAdminCredential(new SimpleCredential("testuser", "password")); testConfig.setRootCredential(new SimpleCredential("testuser", "password")); testConfig.setUserCredential(new SimpleCredential("testuser", "password")); testConfig.setSwiftEndpoint("https: testConfig.setSwiftSignerType("S3SignerType"); String json = serializer.serialize(testConfig); Assert.assertEquals(jsonTestConfig.replaceAll("\\s", ""), json.replaceAll("\\s", "")); }