Package org.geoserver.catalog

Examples of org.geoserver.catalog.NamespaceInfo


    }
   
    public void testModifyNamespace() {
        catalog.add( ns );
       
        NamespaceInfo ns2 = catalog.getNamespaceByPrefix(ns.getPrefix());
        ns2.setPrefix( null );
        ns2.setURI( null );
       
        try {
            catalog.save(ns2);
            fail( "setting prefix to null should throw exception");
        }
        catch( Exception e ) {
        }
       
        ns2.setPrefix( "ns2Prefix" );
        try {
            catalog.save(ns2);
            fail( "setting uri to null should throw exception");
        }
        catch( Exception e ) {
        }
       
        ns2.setURI( "ns2URI");
       
        NamespaceInfo ns3 = catalog.getNamespaceByPrefix(ns.getPrefix());
        assertEquals( "nsPrefix", ns3.getPrefix() );
        assertEquals( "nsURI", ns3.getURI() );
       
        catalog.save( ns2 );
        ns3 = catalog.getNamespaceByPrefix(ns.getPrefix());
        assertEquals(ns2, ns3);
        assertEquals( "ns2Prefix", ns3.getPrefix() );
        assertEquals( "ns2URI", ns3.getURI() );
    }
View Full Code Here


   
    public void testNamespaceEvents() {
        TestListener l = new TestListener();
        catalog.addListener( l );
       
        NamespaceInfo ns = catalog.getFactory().createNamespace();
        ns.setPrefix( "ns2Prefix" );
        ns.setURI( "ns2URI");
       
        assertTrue( l.added.isEmpty() );
        assertTrue( l.modified.isEmpty() );
        catalog.add( ns );
        assertEquals( 1, l.added.size() );
        assertEquals( ns, l.added.get(0).getSource());
        assertEquals( 1, l.modified.size() );
        assertEquals( catalog, l.modified.get(0).getSource());
        assertEquals( "defaultNamespace", l.modified.get(0).getPropertyNames().get(0));
       
        ns = catalog.getNamespaceByPrefix( "ns2Prefix" );
        ns.setURI( "changed");
        catalog.save( ns );
       
        assertEquals( 2, l.modified.size() );
        assertTrue(l.modified.get(1).getPropertyNames().contains( "uRI" ));
        assertTrue(l.modified.get(1).getOldValues().contains( "ns2URI" ));
View Full Code Here

       
        assertNotNull(ft2);
        assertFalse( ft == ft2 );
        assertEquals( ft, ft2 );
       
        NamespaceInfo ns2 = catalog.getFactory().createNamespace();
        ns2.setPrefix( "ns2Prefix" );
        ns2.setURI( "ns2URI" );
        catalog.add( ns2 );
       
        FeatureTypeInfo ft3 = catalog.getFactory().createFeatureType();
        ft3.setName( "ft3Name" );
        ft3.setStore( ds );
        ft3.setNamespace( ns2 );
        catalog.add( ft3 );
       
        FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ns2.getPrefix(), ft3.getName() );
        assertNotNull(ft4);
        assertFalse( ft4 == ft3 );
        assertEquals( ft3, ft4 );
       
        ft4 = catalog.getFeatureTypeByName(ns2.getURI(), ft3.getName() );
        assertNotNull(ft4);
        assertFalse( ft4 == ft3 );
        assertEquals( ft3, ft4 );
    }
View Full Code Here

        final WorkspaceInfo newWorkspace = (WorkspaceInfo) validatable.getValue();
        if (previousWorkspace.equals(newWorkspace)) {
            return;
        }

        final NamespaceInfo newNamespace = catalog.getNamespaceByPrefix(newWorkspace.getName());

        List<ResourceInfo> configuredResources = catalog.getResourcesByStore(store,
                ResourceInfo.class);

        // The datastore namespace may have changed and resources with the same name may already
View Full Code Here

        WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
        ws.setName(ws.getName() + "abcd");
        getCatalog().save(ws);
       
        // check the corresponding namespace has been modified
        NamespaceInfo ns = getCatalog().getDefaultNamespace();
        assertNotNull(ns);
        assertEquals(ws.getName(), ns.getPrefix());
    }
View Full Code Here

        assertNotNull(ns);
        assertEquals(ws.getName(), ns.getPrefix());
    }
   
    public void testChangeNamespace() {
        NamespaceInfo ns = getCatalog().getDefaultNamespace();
        ns.setPrefix(ns.getPrefix() + "abcd");
        getCatalog().save(ns);
       
        // check the corresponding namespace has been modified
        WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
        assertNotNull(ws);
        assertEquals(ns.getPrefix(), ws.getName());
    }
View Full Code Here

        workspaces.remove(getCatalog().getDefaultWorkspace());
        WorkspaceInfo newDefault = workspaces.get(0);
        getCatalog().setDefaultWorkspace(newDefault);
       
        // check the default namespace changed accordingly
        NamespaceInfo ns = getCatalog().getDefaultNamespace();
        assertNotNull(ns);
        assertEquals(newDefault.getName(), ns.getPrefix());
    }
View Full Code Here

    }
   
    public void testChangeDefaultNamespace() {
        List<NamespaceInfo> namespaces = getCatalog().getNamespaces();
        namespaces.remove(getCatalog().getDefaultNamespace());
        NamespaceInfo newDefault = namespaces.get(0);
        getCatalog().setDefaultNamespace(newDefault);
       
        // check the default namespace changed accordingly
        WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
        assertNotNull(ws);
        assertEquals(newDefault.getName(), ws.getName());
    }
View Full Code Here

   
    public void testChangeNamespaceURI() {
        // gran a workspace that has stores in it
        WorkspaceInfo ws = getCatalog().getStores(DataStoreInfo.class).get(0).getWorkspace();
        // alter the namespace uri
        NamespaceInfo ns = getCatalog().getNamespaceByPrefix(ws.getName());
        ns.setURI("http://www.geoserver.org/newNamespace");
        getCatalog().save(ns);
       
        List<DataStoreInfo> stores = getCatalog().getDataStoresByWorkspace(ws);
        assertTrue(stores.size() > 0);
        for (DataStoreInfo ds : stores) {
            String nsURI = (String) ds.getConnectionParameters().get("namespace");
            if(nsURI != null) {
                assertEquals(ns.getURI(), nsURI);
            }
        }
    }
View Full Code Here

      
            String types = (String) params.get( "typename");
            assertNotNull(types);
               
            Catalog cat =  getCatalog();
            NamespaceInfo ns = cat.getNamespaceByURI(namespace);
            System.out.println(ns.getPrefix());
            // %2c == , (url-encoded, comma is not considered a safe char)
            assertEquals( cat.getFeatureTypesByNamespace(ns).size(), types.split("%2c").length);
        }
       
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.NamespaceInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.