Package org.apache.hivemind.util

Examples of org.apache.hivemind.util.ClasspathResource


    public void testResourceTranslator() throws Exception
    {
        RegistryBuilder builder = new RegistryBuilder();

        Resource moduleResource =
            new ClasspathResource(_resolver, "/hivemind/test/config/ResourceTranslator.xml");

        builder.processModules(_resolver);
        builder.processModule(_resolver, moduleResource);

        Registry r = (Registry) builder.constructRegistry(Locale.FRENCH);

        List l = r.getConfiguration("hivemind.test.config.ResourceTranslator");

        interceptLogging();

        assertEquals(4, l.size());

        ResourceHolder h = (ResourceHolder) l.get(0);

        assertEquals(moduleResource.getRelativeResource("Empty.xml"), h.getResource());

        h = (ResourceHolder) l.get(1);

        assertEquals(
            moduleResource.getRelativeResource("Localized_fr.properties"),
            h.getResource());

        h = (ResourceHolder) l.get(2);
        assertNull(h.getResource());
View Full Code Here


    public void testAddDupeSchema() throws Exception
    {
        ModuleDescriptor md = new ModuleDescriptor(getClassResolver(), new DefaultErrorHandler());
        md.setModuleId("foo");

        Resource r = new ClasspathResource(getClassResolver(), "/foo/bar");
        Location l1 = new LocationImpl(r, 20);
        Location l2 = new LocationImpl(r, 97);

        SchemaImpl s1 = new SchemaImpl("test");
        s1.setId("bar");
View Full Code Here

    protected Location fabricateLocation(int line)
    {
        String path = "/" + getClass().getName().replace('.', '/');

        Resource r = new ClasspathResource(new DefaultClassResolver(), path);

        return new LocationImpl(r, line);
    }
View Full Code Here

     * @param moduleFileName  filename of module. For format see {@link ClassLoader#getResource(String)} 
     * @throws ApplicationRuntimeException  if module wasn't found
     */
    public void readClassPathModule(String moduleFileName)
    {
        readModule(new ClasspathResource(_classResolver, moduleFileName));
    }
View Full Code Here

            throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModulesError(_classResolver, ex),
                    ex);
        }
       
        if (!foundResources.hasMoreElements())
            throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModuleResource(new ClasspathResource(_classResolver, moduleFileName)));

        while (foundResources.hasMoreElements())
        {
            URL descriptorURL = (URL) foundResources.nextElement();
View Full Code Here

     */
    protected Location createModuleLocation(Class moduleClass)
    {
        String path = "/" + moduleClass.getName().replace('.', '/');

        Resource r = new ClasspathResource(_classResolver, path);

        return new AnnotatedModuleLocation(r, moduleClass);
    }
View Full Code Here

   
    private static Location createLocation()
    {
        String path = "/" + SimpleModule.class.getName().replace('.', '/');

        Resource r = new ClasspathResource(new DefaultClassResolver(), path);

        return new LocationImpl(r, 1);
    }
View Full Code Here

{
    public void testDefaultErrorHandlerWithLocation()
    {
        Log log = (Log) newMock(Log.class);

        Resource r = new ClasspathResource(getClassResolver(), "/foo/bar/Baz.module");
        Location l = new LocationImpl(r, 13);

        Throwable ex = new IllegalArgumentException();

        log.error("Error at classpath:/foo/bar/Baz.module, line 13: Bad frob value.", ex);
View Full Code Here

    public static Location getClassLocation(Class theClass, ClassResolver classResolver)
    {
        String path = "/" + theClass.getName().replace('.', '/');

        Resource r = new ClasspathResource(classResolver, path);

        return new LocationImpl(r);
    }
View Full Code Here

     */
    protected Location fabricateLocation(int line)
    {
        String path = "/" + getClass().getName().replace('.', '/');

        Resource r = new ClasspathResource(getClassResolver(), path);

        return new LocationImpl(r, line);
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.util.ClasspathResource

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.