Package org.apache.hivemind

Examples of org.apache.hivemind.Resource


    public void testCreateWithLocale() throws Exception
    {
        String path = getFrameworkPath(DIR + "/localizable_fr.properties");

        Resource r = new FileResource(path, Locale.CANADA_FRENCH);

        assertEquals(path, r.getPath());
        assertEquals(Locale.CANADA_FRENCH, r.getLocale());
    }
View Full Code Here


    public void testGetLocalization()
    {
        String path = getFrameworkPath(BASEFILE);

        Resource base = new FileResource(path);
        Resource localized = base.getLocalization(Locale.FRANCE);

        String expected = getFrameworkPath(DIR + "/localizable_fr.properties");

        assertEquals(expected, localized.getPath());
    }
View Full Code Here

    public void testLocalizationMissing()
    {
        String path = getFrameworkPath(BASEFILE);

        Resource base = new FileResource(path);
        Resource localized = base.getLocalization(Locale.CHINA);

        assertSame(base, localized);
    }
View Full Code Here

    public void testToString()
    {
        String path = getFrameworkPath(BASEFILE);

        Resource r = new FileResource(path);

        assertEquals(path, r.toString());
    }
View Full Code Here

      String path = getFrameworkPath(DIR);
      // Remove the ./ at the beginning to remove any dot from the path
      if (path.startsWith("./"))
        path = path.substring(2);
     
        Resource r = new FileResource(path);
        Resource localized = r.getLocalization(Locale.CHINA);

        assertSame(r, localized);
    }
View Full Code Here

        RegistryBuilder builder = new RegistryBuilder();
        builder.autoDetectModules();

        for (int i = 0; i < files.length; i++)
        {
            Resource resource = getResource(files[i]);

            org.apache.hivemind.impl.XmlModuleReader reader = new org.apache.hivemind.impl.XmlModuleReader(builder.getRegistryDefinition(),
                    resolver, builder.getErrorHandler());
            reader.readModule(resource);
        }
View Full Code Here

    }
   
    protected ModuleDescriptor parse(String file)
        throws Exception
    {
        Resource location = getResource(file);
        DefaultErrorHandler eh = new DefaultErrorHandler();

        XmlResourceProcessor p = new XmlResourceProcessor(_resolver, eh);

        ModuleDescriptor result = p.processResource(location);
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

    /*
     * FIXME Test disabled until GROOVY-726 is resolved.
     */
    public void _testLinePreciseErrorReporting() throws Exception
    {
        Resource resource = getResource("missingModuleId.groovy");

        ErrorHandler handler = new DefaultErrorHandler();
        DescriptorParser parser = new DescriptorParser(handler);

        parser.initialize(resource, getClassResolver());

        GroovyCodeSource source = new GroovyCodeSource(resource.getResourceURL());

        Script script = new GroovyShell().parse(source);

        try
        {
View Full Code Here

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

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

        XmlModuleReader reader = new XmlModuleReader(builder.getRegistryDefinition(),
                _resolver, builder.getErrorHandler());
        reader.readModule(moduleResource);

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

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

        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());

        h = (ResourceHolder) l.get(3);
View Full Code Here

TOP

Related Classes of org.apache.hivemind.Resource

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.