WorkspaceInfo ws = cFactory.createWorkspace();
ws.setName( "foo" );
catalog.add( ws );
NamespaceInfo ns = cFactory.createNamespace();
ns.setPrefix( "acme" );
ns.setURI( "http://acme.org" );
catalog.add( ns );
DataStoreInfo ds = cFactory.createDataStore();
ds.setWorkspace( ws );
ds.setName( "foo" );
catalog.add( ds );
CoverageStoreInfo cs = cFactory.createCoverageStore();
cs.setWorkspace( ws );
cs.setName( "bar" );
catalog.add( cs );
StyleInfo s = cFactory.createStyle();
s.setName( "style" );
s.setFilename( "style.sld" );
catalog.add(s);
ByteArrayOutputStream out = out();
persister.save( catalog, out );
catalog = persister.load( in(out), Catalog.class );
assertNotNull(catalog);
assertEquals( 1, catalog.getWorkspaces().size() );
assertNotNull( catalog.getDefaultWorkspace() );
ws = catalog.getDefaultWorkspace();
assertEquals( "foo", ws.getName() );
assertEquals( 1, catalog.getNamespaces().size() );
assertNotNull( catalog.getDefaultNamespace() );
ns = catalog.getDefaultNamespace();
assertEquals( "acme", ns.getPrefix() );
assertEquals( "http://acme.org", ns.getURI() );
assertEquals( 1, catalog.getDataStores().size() );
ds = catalog.getDataStores().get( 0 );
assertEquals( "foo", ds.getName() );
assertNotNull( ds.getWorkspace() );