Examples of ResourceLoader


Examples of org.jbehave.core.io.ResourceLoader

      RESTClient client = mock(RESTClient.class);
      when(client.getType()).thenReturn(Type.JSON);
      String url = "http://wiki/page";
        String entity = "Some content";
        when(client.get(url)).thenReturn(entity);
    ResourceLoader loader = new LoadFromREST(client);
    String text = loader.loadResourceAsText(url);
    assertThat(text, containsString(entity));
  }
View Full Code Here

Examples of org.jbehave.core.io.ResourceLoader

    @Test
    public void canImportToFilesystem() throws IOException, MojoExecutionException, MojoFailureException {

        // Given
        final ResourceIndexer indexer = mock(ResourceIndexer.class);
        final ResourceLoader loader = mock(ResourceLoader.class);
        String rootURI = "http://wiki";
        Map<String, Resource> index = new HashMap<String, Resource>();
        index.put("one", new Resource(rootURI + "/one"));
        index.put("two", new Resource(rootURI + "/two"));
        when(indexer.indexResources(rootURI)).thenReturn(index);
        String text1 = "story text 1";
        when(loader.loadResourceAsText(index.get("one").getURI())).thenReturn(text1);
        String text2 = "story text 2";
        when(loader.loadResourceAsText(index.get("two").getURI())).thenReturn(text2);

        // When
        String targetPath = "target/stories";
        String targetExt = ".story";
        ImportToFilesystemMojo mojo = new ImportToFilesystemMojo(){
View Full Code Here

Examples of org.jbehave.core.io.ResourceLoader

    assertThat(index.isEmpty(), is(false));
  }

  @When("story $name text contains '$text'")
  public void storyIsLoaded(String name, String text) {
    ResourceLoader loader = resourceLoader();
    Resource resource = index.get(name);
    String asText = loader.loadResourceAsText(resource.getURI());
    assertThat(asText, containsString(text));
  }
View Full Code Here

Examples of org.jboss.modules.ResourceLoader

                };
                ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SEAM_INT_JAR), mountHandleService);
                builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
                serviceTarget = null; // our cleanup service install work is done

                ResourceLoader resourceLoader = new VFSResourceLoader(SEAM_INT_JAR, vf);
                seamIntResourceLoader = ResourceLoaderSpec.createResourceLoaderSpec(resourceLoader);
            }
            return seamIntResourceLoader;
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e);
View Full Code Here

Examples of org.jboss.weld.resources.spi.ResourceLoader

    public EjbDescriptorImpl(EJBComponentDescription componentDescription, BeanDeploymentArchiveImpl beanDeploymentArchive, final DeploymentReflectionIndex reflectionIndex) {
        final SessionBeanComponentDescription description = componentDescription instanceof SessionBeanComponentDescription ? (SessionBeanComponentDescription) componentDescription : null;
        final Set<BusinessInterfaceDescriptor<?>> localInterfaces = new HashSet<BusinessInterfaceDescriptor<?>>();
        final Set<BusinessInterfaceDescriptor<?>> remoteInterfaces = new HashSet<BusinessInterfaceDescriptor<?>>();
        final ResourceLoader loader = beanDeploymentArchive.getServices().get(ResourceLoader.class);

        ejbClass = (Class<T>) loader.classForName(componentDescription.getEJBClassName());

        if (componentDescription.getViews() != null) {
            for (ViewDescription view : componentDescription.getViews()) {

                if (description == null || getMethodIntf(view) == MethodIntf.LOCAL) {
                    final String viewClassName = view.getViewClassName();
                    localInterfaces.add(new BusinessInterfaceDescriptorImpl<Object>(beanDeploymentArchive, viewClassName));
                } else if (getMethodIntf(view) == MethodIntf.REMOTE) {
                    remoteInterfaces.add(new BusinessInterfaceDescriptorImpl<Object>(beanDeploymentArchive, view.getViewClassName()));
                }
            }
        }
        if(componentDescription instanceof StatefulComponentDescription) {
            Set<Method> removeMethods = new HashSet<Method>();
            final Collection<StatefulComponentDescription.StatefulRemoveMethod> methods = ((StatefulComponentDescription) componentDescription).getRemoveMethods();
            for(final StatefulComponentDescription.StatefulRemoveMethod method : methods) {
                Class<?> c = ejbClass;
                while (c != null && c != Object.class) {
                    ClassReflectionIndex<?> index = reflectionIndex.getClassIndex(c);
                    Method m = index.getMethod(method.getMethodIdentifier());
                    if(m != null) {
                        removeMethods.add(m);
                        break;
                    }
                }
            }
            this.removeMethods = Collections.unmodifiableSet(removeMethods);
        } else {
            removeMethods = Collections.emptySet();
        }


        this.ejbName = componentDescription.getEJBName();
        Map<Class<?>, ServiceName> viewServices = new HashMap<Class<?>, ServiceName>();
        for (ViewDescription view : componentDescription.getViews()) {
            viewServices.put(loader.classForName(view.getViewClassName()), view.getServiceName());
        }
        this.viewServices = Collections.unmodifiableMap(viewServices);
        this.localInterfaces = localInterfaces;
        this.remoteInterfaces = remoteInterfaces;
        this.baseName = componentDescription.getServiceName();
View Full Code Here

Examples of org.jboss.weld.resources.spi.ResourceLoader

   }

   @Override
   public void start(Addon addon) throws Exception
   {
      ResourceLoader resourceLoader = new AddonResourceLoader(addon);
      ModularURLScanner scanner = new ModularURLScanner(resourceLoader, "META-INF/beans.xml");
      ModuleScanResult scanResult = scanner.scan();

      if (!scanResult.getDiscoveredResourceUrls().isEmpty())
      {
View Full Code Here

Examples of org.jitterbit.application.ui.resources.ResourceLoader

    }
   
    private static final StringResources STRINGS = load();

    private static StringResources load() {
        ResourceLoader loader = new ResourceLoader();
        return loader.loadStringsFromResourceBundle(
            "org.jitterbit.integration.client.ui.interchange.entity.transformation.tree.resources.Strings");
    }
View Full Code Here

Examples of org.ontospread.model.resources.ResourceLoader

import org.ontospread.model.resources.ExternalizeFilesResourceLoader;
import org.ontospread.model.resources.ResourceLoader;

public class DAOUtils {
  public static OntoSpreadModelWrapper createOntoModelWrapper(String []filenames){
    ResourceLoader resource = new ExternalizeFilesResourceLoader(filenames);
    JenaOWLModelWrapper model = new JenaOWLModelWrapper(resource);
    return model;
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceLoader

    super.setUp();
  }

  public void testSerialize() throws Exception
  {
    final ResourceLoader resourceLoader = new ClassloaderResourceLoader();
    final ResourceManager manager = new ResourceManager();
    manager.registerDefaults();

    // Test failure - null key
    try
    {
      resourceLoader.serialize(null, null);
      fail("Serialization of a null key should throw an exception");
    }
    catch (NullPointerException npe)
    {
      // success
    }
   
    // Test failure - not a Classloader resource key
    try
    {
      final File tempFile = File.createTempFile("junit-test", ".tmp");
      final ResourceKey tempKey = manager.createKey(tempFile);
      resourceLoader.serialize(null, tempKey);
      fail("The Classloader Resource Loader should fail when handling a non-classloader resource key");
    }
    catch(IllegalArgumentException iae)
    {
      // success
    }

    // Create key
    final String key1source = "res://org/pentaho/reporting/libraries/resourceloader/test1.properties";
    final ResourceKey key1 = manager.createKey(key1source);
    assertNotNull(key1);

    // Serialize the key
    final String serKey1 = resourceLoader.serialize(null, key1);
    assertNotNull("The returned key should not be null", serKey1); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serKey1.startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serKey1.startsWith(DESERIALIZE_PREFIX));
    assertTrue("Serialized version should contain the identifier intact", serKey1.endsWith(key1.getIdentifier().toString()));

    // Serialize a key created from a derived key
    final String key2source = "test2.properties";
    final ResourceKey key2 = manager.deriveKey(key1, key2source);
    assertNotNull(key2);

    final String serKey2 = resourceLoader.serialize(null, key2);
    assertNotNull("The returned key should not be null", serKey2); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serKey2.startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serKey2.startsWith(DESERIALIZE_PREFIX));
    assertTrue("Serialized version should contain the identifier intact", serKey2.endsWith(";res://org/pentaho/reporting/libraries/resourceloader/test2.properties"));

    // Serialize a key with factory parameters
    final Map<ParameterKey, Object> factoryParams = new HashMap<ParameterKey, Object>();
    factoryParams.put(new FactoryParameterKey("this"), "that");
    factoryParams.put(new FactoryParameterKey("null"), null);
    final ResourceKey key3 = manager.createKey(key1source, factoryParams);
    assertNotNull(key3);

    final String serKey3 = resourceLoader.serialize(null, key3);
    assertEquals("resourcekey:org.pentaho.reporting.libraries.resourceloader" +
        ".loader.resource.ClassloaderResourceLoader;" +
        "res://org/pentaho/reporting/libraries/resourceloader/" +
        "test1.properties;\"\"\"f:this=that\"\":\"\"f:null=\"\"\"", serKey3);
View Full Code Here

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceLoader

  }

  public void testDeserializer() throws Exception
  {
    final ResourceLoader resourceLoader = new ClassloaderResourceLoader();
   
    // Test failure - null input
    try {
      resourceLoader.deserialize(null, null);
      fail("Deserialize should throw an exception on null parameter");
    } catch (IllegalArgumentException iae) {
      // success
    }
   
    // Test failure - invalid input
    try {
      resourceLoader.deserialize(null, "junk");
      fail("Deserialize should throw an exception on bad parameter");
    } catch (ResourceKeyCreationException rkce) {
      // success
    }
   
    // Test failure - wrong schema
    try {
      resourceLoader.deserialize(null, "resourcekey:org.pentaho.reporting.libraries.resourceloader.loader.resource.Junk;stuff");
      fail("Deserialize should throw an exception on bad parameter");
    } catch (ResourceKeyCreationException rkce) {
      // success
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.