Package org.apache.hivemind

Examples of org.apache.hivemind.Resource


        assertTrue(!l1.equals(null));
    }

    public void testClasspathRelativeSamePath()
    {
        Resource l1 = new ClasspathResource(_resolver, "/foo/bar/Baz");
        Resource l2 = l1.getRelativeResource("/foo/bar/Baz");

        assertSame(l1, l2);
    }
View Full Code Here


        assertSame(l1, l2);
    }

    public void testTrailingSlash()
    {
        Resource l1 = new ClasspathResource(_resolver, "/");
        Resource expected = new ClasspathResource(_resolver, "/foo");
        Resource actual = l1.getRelativeResource("foo");

        assertEquals(expected, actual);
    }
View Full Code Here

    public Messages getMessages()
    {
        String projectRoot = System.getProperty("PROJECT_ROOT", ".");
        String path = projectRoot + "/examples/src/descriptor/META-INF/panorama.startup.xml";

        Resource r = new FileResource(path);
        MessageFinder mf = new MessageFinderImpl(r);
        ThreadLocale tl = new ThreadLocaleImpl(Locale.getDefault());

        return new ModuleMessages(mf, tl);
    }
View Full Code Here

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

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

        builder.addModuleDescriptorProvider(new XmlModuleDescriptorProvider(_resolver));
        builder.addModuleDescriptorProvider(new XmlModuleDescriptorProvider(_resolver,
                moduleResource));

        Registry r = 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());

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

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

        Resource r = new ClasspathResource(new DefaultClassResolver(), "/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 class TestPropertyUtils extends HiveMindTestCase
{
    private Location makeLocation(int line)
    {
        Resource r = new ClasspathResource(new DefaultClassResolver(), "/foo/bar");

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

        }
    }

    public void testParseExceptionWithLocation()
    {
        Resource r = getResource("MethodSubject.class");
        Location l = new LocationImpl(r, 3);

        MethodSubject s = new MethodSubject();
        s.setLocation(l);
View Full Code Here

        IScriptSource source = getScriptSource();

        // If the script path is relative, it should be relative to the Script component's
        // container (i.e., relative to a page in the application).

        Resource rootLocation = getContainer().getSpecification().getSpecificationLocation();
        Resource scriptLocation = rootLocation.getRelativeResource(scriptPath);

        try
        {
            return source.getScript(scriptLocation);
        }
View Full Code Here

    {
        // AssetType type = spec.getType();
        String path = spec.getPath();
        Location location = spec.getLocation();

        Resource specResource = location.getResource();

        // And ugly, ugly kludge. For page and component specifications in the
        // context (typically, somewhere under WEB-INF), we evaluate them
        // relative the web application root.

        if (isContextResource(specResource))
            specResource = specResource.getRelativeResource("/");

        return _assetSource.findAsset(specResource, path, _locale, location);
    }
View Full Code Here

            RequestContext requestContext = cycle.getRequestContext();
            ApplicationServlet servlet = requestContext.getServlet();
            ServletContext context = servlet.getServletContext();
            IPropertySource propertySource = cycle.getEngine().getPropertySource();

            Resource webInfLocation = new ContextResource(context, "/WEB-INF/");

            Resource webInfAppLocation =
                webInfLocation.getRelativeResource(servlet.getServletName() + "/");

            readQuestions(
                easyQuestions,
                webInfAppLocation,
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.