mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
Add methods to mock stores with raw xml data
This commit is contained in:
@@ -30,6 +30,7 @@ import sonia.scm.security.UUIDKeyGenerator;
|
||||
import javax.xml.bind.JAXB;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -68,6 +69,14 @@ public class InMemoryByteConfigurationEntryStore<V> implements ConfigurationEntr
|
||||
store.put(id, baos.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be used to mock stores with raw xml data to test update steps or otherwise the compatability of
|
||||
* objects with old versions.
|
||||
*/
|
||||
public void putRawXml(String id, String xml) {
|
||||
store.put(id, xml.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, V> getAll() {
|
||||
Map<String, V> all = new HashMap<>();
|
||||
|
||||
@@ -27,6 +27,7 @@ package sonia.scm.store;
|
||||
import javax.xml.bind.JAXB;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* In memory store implementation of {@link ConfigurationStore} using a byte array to store the serialized object.
|
||||
@@ -64,4 +65,12 @@ public class InMemoryByteConfigurationStore<T> implements ConfigurationStore<T>
|
||||
JAXB.marshal(object, baos);
|
||||
store = baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be used to mock stores with raw xml data to test update steps or otherwise the compatability of
|
||||
* objects with old versions.
|
||||
*/
|
||||
public void setRawXml(String xml) {
|
||||
store = xml.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import sonia.scm.security.UUIDKeyGenerator;
|
||||
import javax.xml.bind.JAXB;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -68,6 +69,14 @@ public class InMemoryByteDataStore<T> implements DataStore<T> {
|
||||
store.put(id, baos.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be used to mock stores with raw xml data to test update steps or otherwise the compatability of
|
||||
* objects with old versions.
|
||||
*/
|
||||
public void putRawXml(String id, String xml) {
|
||||
store.put(id, xml.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, T> getAll() {
|
||||
Map<String, T> all = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user