FileOutputStream saveStream = new FileOutputStream(tempFile);
ArrayList<RepositoryEntry> repositoryEntries = new ArrayList<RepositoryEntry>();
repositoryEntries.add(repository.getConfiguration());
RepositoryServiceConfiguration newRepositoryServiceConfiguration =
new RepositoryServiceConfiguration(repositoryService.getConfig().getDefaultRepositoryName(),
repositoryEntries);
mctx.marshalDocument(newRepositoryServiceConfiguration, "ISO-8859-1", null, saveStream);
saveStream.close();
// 1st unmarshal
factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
IUnmarshallingContext uctx = factory.createUnmarshallingContext();
RepositoryServiceConfiguration conf =
(RepositoryServiceConfiguration)uctx
.unmarshalDocument(PrivilegedFileHelper.fileInputStream(tempFile), null);
// 1st check
RepositoryEntry unmarshledRepositoryEntry =
conf.getRepositoryConfiguration(repository.getConfiguration().getName());
assertEquals(lockManagerTimeOut, unmarshledRepositoryEntry.getWorkspaceEntries().get(0).getLockManager()
.getParameterLong("time-out").longValue());
// 2nd marshal configuration
tempFile = PrivilegedFileHelper.createTempFile("test-config", "xml");
PrivilegedFileHelper.deleteOnExit(tempFile);
factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
mctx = factory.createMarshallingContext();
saveStream = new FileOutputStream(tempFile);
repositoryEntries = new ArrayList<RepositoryEntry>();
repositoryEntries.add(repository.getConfiguration());
newRepositoryServiceConfiguration =
new RepositoryServiceConfiguration(repositoryService.getConfig().getDefaultRepositoryName(),
repositoryEntries);
mctx.marshalDocument(newRepositoryServiceConfiguration, "ISO-8859-1", null, saveStream);
saveStream.close();
// 2nd unmarshal
factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
uctx = factory.createUnmarshallingContext();
conf =
(RepositoryServiceConfiguration)uctx
.unmarshalDocument(PrivilegedFileHelper.fileInputStream(tempFile), null);
// 2nd check
unmarshledRepositoryEntry = conf.getRepositoryConfiguration(repository.getConfiguration().getName());
assertEquals(lockManagerTimeOut, unmarshledRepositoryEntry.getWorkspaceEntries().get(0).getLockManager()
.getParameterLong("time-out").longValue());
}
finally
{