Spring Framework UrlResource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework UrlResource class.

This code example shows how to use the following methods:
This code example shows how to use the following methods:
    @Ignore 
    public void dwOpenConnectionURL() throws IOException {
         
        URL url = new URL(DNS_URL);
         
        UrlResource resource = new UrlResource(url);
 
        MockForeignSourceRepository fsr = new MockForeignSourceRepository();
        Requisition r = fsr.importResourceRequisition(resource);
         
        Assert.assertTrue("Number of nodes in Model Import > 1", 1 == r.getNodeCount());
        Assert.assertTrue("NodeLabel isn't localhost", "localhost".equals(r.getNodes().get(0).getNodeLabel()));
        Assert.assertTrue("127.0.0.1".equals(r.getNodes().get(0).getInterfaces().get(0).getIpAddr()));
    } 
 
    @Test
    public void dwParseURL() throws MalformedURLException {
         
        String urlString = "dns://localhost:53/opennms";
 
5
CodeRank
This code example shows how to use the following methods:
		factory.setBasePath("classpath:org/springframework/webflow/"); 
		assertEquals("sample", factory.getFlowId(resource)); 
	} 
 
	public void testGetFlowIdUrlResourceNoBasePathMatch() throws MalformedURLException { 
		Resource resource = new UrlResource("file:/the/path/on/the/file/system/sample-flow.xml"); 
		factory.setBasePath("classpath:org/springframework/webflow/"); 
		assertEquals("the/path/on/the/file/system", factory.getFlowId(resource)); 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:
 
	@Test
	public void testReadFile() throws Exception {
		Map<String, ExecutionContext> partition = partitioner.partition(0);
		String url = partition.get("partition0").getString("fileName");
		assertTrue(new UrlResource(url).exists());
	} 
 
	@Test
	public void testSetKeyName() { 
		partitioner.setKeyName("foo");
		Map<String, ExecutionContext> partition = partitioner.partition(0);
		assertTrue(partition.get("partition0").containsKey("foo"));
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:
//        manager = (GeofenceAccessManager) applicationContext.getBean("geofenceRuleAccessManager"); 
//        geofenceService = (RuleReaderService) applicationContext.getBean("ruleReaderService"); 
        manager = (GeoFenceConfigurationManager) applicationContext.getBean("geofenceConfigurationManager");
 
        configurer = (GeoFencePropertyPlaceholderConfigurer) applicationContext.getBean("geofence-configurer");
        configurer.setLocation(new UrlResource(this.getClass().getResource("/test-config.properties")));
    } 
 
 
    public void testSave() throws IOException, URISyntaxException {
        GeofenceTestUtils.emptyFile("test-config.properties"); 
        
        GeoFenceConfiguration config = new GeoFenceConfiguration();
        config.setInstanceName("TEST_INSTANCE");
        config.setServicesUrl("http://fakeservice");
        config.setAllowDynamicStyles(true);
        config.setAllowRemoteAndInlineLayers(true);
        config.setGrantWriteToWorkspacesToAuthenticatedUsers(true);
        config.setUseRolesToFilter(true);
        config.setAcceptedRoles("A,B");
5
CodeRank
This code example shows how to use the following methods:
	@Qualifier("job2") 
	private Job job2;
 
	public LdifReaderTests() throws MalformedURLException {
		expected = new ClassPathResource("/expectedOutput.ldif");
		actual = new UrlResource("file:target/test-outputs/output.ldif");
	} 
 
	@Before 
	public void checkFiles() { 
		Assert.isTrue(expected.exists(), "Expected does not exist.");
	} 
 
	@Test
	public void testValidRun() throws Exception {
		JobExecution jobExecution = jobLauncher.run(job1, new JobParameters());
 
		//Ensure job completed successfully. 
		Assert.isTrue(jobExecution.getExitStatus().equals(ExitStatus.COMPLETED), "Step Execution did not complete normally: " + jobExecution.getExitStatus());
 
5
CodeRank
This code example shows how to use the following methods:
        super( uri ); 
    } 
 
    public GzippedResource( URL url ) 
    { 
        super( url ); 
    } 
 
    @Override 
    public InputStream getInputStream() throws IOException 
    { 
        try 
        { 
            return new GZIPInputStream( super.getInputStream() ); 
        } 
        catch (UnknownHostException e) 
        { 
            return new ByteArrayInputStream( new byte[0] ); 
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:
	@Qualifier("job2") 
	private Job job2;
 
	public MappingLdifReaderTests() throws MalformedURLException {
		expected = new ClassPathResource("/expectedOutput.ldif");
		actual = new UrlResource("file:target/test-outputs/output.ldif");
	} 
 
	@Before 
	public void checkFiles() { 
		Assert.isTrue(expected.exists(), "Expected does not exist.");
	} 
 
	@Test
	public void testValidRun() throws Exception {
		JobExecution jobExecution = launcher.run(job1, new JobParameters());
 
		//Ensure job completed successfully. 
		Assert.isTrue(jobExecution.getExitStatus().equals(ExitStatus.COMPLETED), "Step Execution did not complete normally: " + jobExecution.getExitStatus());
 
5
CodeRank
This code example shows how to use the following methods:
    protected void onSetUp(SystemTestData testData) throws Exception {
        super.onSetUp(testData);
 
        // get the beans we use for testing 
        configurer = (GeoFencePropertyPlaceholderConfigurer) applicationContext.getBean("geofence-configurer");
        configurer.setLocation(new UrlResource(this.getClass().getResource("/test-config.properties")));
    } 
 
    @Before 
    public void before() { 
        login(); 
        tester.startPage(GeofencePage.class); 
    } 
 
    /** 
     * @FIXME 
     * This test fails in 2.6 
     */ 
    @Ignore 
    @Test
5
CodeRank
This code example shows how to use the following methods:
    if (resourceLocation.startsWith(FILE_URL_PREFIX)) {
      return new FileSystemResource(resourceLocation.substring(FILE_URL_PREFIX.length()));
    } 
    try { 
      URL url = new URL(resourceLocation);
      return new UrlResource(url);
    } catch (MalformedURLException ex) {
      return new FileSystemResource(resourceLocation);
    } 
  } 
 
  /** 
   * Creates a resource locator from a resource. 
   * <p> 
   * This converts the resource back to a string. 
   * Any class loader will be lost. 
   *  
   * @param resource  the resource to convert, not null 
   * @return the resource locator, not null 
   */ 
5
CodeRank
See Code Examples for Spring Framework UrlResource Methods: