当前位置: 首页>>代码示例>>Java>>正文


Java ClassPathResource.getFile方法代码示例

本文整理汇总了Java中org.springframework.core.io.ClassPathResource.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPathResource.getFile方法的具体用法?Java ClassPathResource.getFile怎么用?Java ClassPathResource.getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.io.ClassPathResource的用法示例。


在下文中一共展示了ClassPathResource.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProjectTrivialDiffProjectFiles

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
/**
 * Open and close of a project file changes certain header properties.
 * Test File 1 has been opened and closed.
 * @throws Exception
 */
public void testProjectTrivialDiffProjectFiles() throws Exception
{
    CIFSContentComparator contentComparator = new CIFSContentComparator();
    contentComparator.init();
    
    ClassPathResource file0Resource = new ClassPathResource("filesys/ContentComparatorTest0.mpp");
    assertNotNull("unable to find test resource filesys/ContentComparatorTest0.mpp", file0Resource);
    
    ClassPathResource file1Resource = new ClassPathResource("filesys/ContentComparatorTest1.mpp");
    assertNotNull("unable to find test resource filesys/ContentComparatorTest1.mpp", file1Resource);
            
    /**
     * Compare trivially different project files, should ignore trivial differences and be equal 
     */
    {
        File file0 = file0Resource.getFile();
        File file1 = file1Resource.getFile();

        ContentReader reader = new FileContentReader(file0);
        reader.setMimetype("application/vnd.ms-project");
        reader.setEncoding("UTF-8");
        boolean result = contentComparator.isContentEqual(reader, file1);
        assertTrue("compare trivially different project file, should be equal", result);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:CIFSContentComparatorTest.java

示例2: verifyTrustStoreLoadingSuccessfullyWithCertAvailable

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test
 public void verifyTrustStoreLoadingSuccessfullyWithCertAvailable() throws Exception {
    final ClassPathResource resource = new ClassPathResource("truststore.jks");
    final FileTrustStoreSslSocketFactory factory = new FileTrustStoreSslSocketFactory(resource.getFile(), "changeit");
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(factory);
    final HttpClient client = clientFactory.getObject();
    assertTrue(client.isValidEndPoint("https://www.cacert.org"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:FileTrustStoreSslSocketFactoryTests.java

示例3: verifyTrustStoreLoadingSuccessfullyWithCertAvailable2

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test
public void verifyTrustStoreLoadingSuccessfullyWithCertAvailable2() throws Exception {
    final ClassPathResource resource = new ClassPathResource("truststore.jks");
    final FileTrustStoreSslSocketFactory factory = new FileTrustStoreSslSocketFactory(resource.getFile(), "changeit");
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(factory);
    final HttpClient client = clientFactory.getObject();
    assertTrue(client.isValidEndPoint("https://test.scaldingspoon.org/idp/shibboleth"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:FileTrustStoreSslSocketFactoryTests.java

示例4: verifyTrustStoreLoadingSuccessfullyWihInsecureEndpoint

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test
public void verifyTrustStoreLoadingSuccessfullyWihInsecureEndpoint() throws Exception {
    final ClassPathResource resource = new ClassPathResource("truststore.jks");
    final FileTrustStoreSslSocketFactory factory = new FileTrustStoreSslSocketFactory(resource.getFile(), "changeit");
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(factory);
    final HttpClient client = clientFactory.getObject();
    assertTrue(client.isValidEndPoint("http://wikipedia.org"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:FileTrustStoreSslSocketFactoryTests.java

示例5: verifyTrustStoreLoadingSuccessfullyForValidEndpointWithNoCert

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test
public void verifyTrustStoreLoadingSuccessfullyForValidEndpointWithNoCert() throws Exception {
    final ClassPathResource resource = new ClassPathResource("truststore.jks");
    final FileTrustStoreSslSocketFactory factory = new FileTrustStoreSslSocketFactory(resource.getFile(), "changeit");
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(factory);
    final HttpClient client = clientFactory.getObject();
    assertTrue(client.isValidEndPoint("https://www.google.com"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:FileTrustStoreSslSocketFactoryTests.java

示例6: getPackageTemplate

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
public File getPackageTemplate () {

		// Loading resources has some corner cases, using spring to manage toURI
		// location
		File result = null;
		ClassPathResource cp = new ClassPathResource( "/releasePackageTemplate.json" );
		try {
			result = cp.getFile();
		} catch (IOException e) {
			logger.error( "Failed to find template", e );
		}

		return result;
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:15,代码来源:DefinitionParser.java

示例7: badSpringApp

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
/**
 * Returns a bad spring application that will cause crashes.
 *
 * @return the bad-spring-app WAR file
 * @throws IOException
 */
public static File badSpringApp() throws IOException {
    ClassPathResource cpr = new ClassPathResource("bad-spring-app.war");
    File file = cpr.getFile();
    assertTrue("Expected test app at " + file.getCanonicalPath(), file.exists());
    return file;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:13,代码来源:SampleProjects.java

示例8: sampleServiceBrokerApp

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
/**
 * Returns a sample CF service broker app.
 *
 * @return the haash-broker JAR file
 * @throws IOException
 */
public static File sampleServiceBrokerApp() throws IOException {
    ClassPathResource cpr = new ClassPathResource("haash-broker.jar");
    File file = cpr.getFile();
    assertTrue("Expected test app at " + file.getCanonicalPath(), file.exists());
    return file;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:13,代码来源:SampleProjects.java

示例9: simpleSpringApp

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
/**
 * Returns a simple spring application.
 *
 * @return the simple-spring-app WAR file
 * @throws IOException
 */
public static File simpleSpringApp() throws IOException {
    ClassPathResource cpr = new ClassPathResource("simple-spring-app.war");
    File file = cpr.getFile();
    assertTrue("Expected test app at " + file.getCanonicalPath(), file.exists());
    return file;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:13,代码来源:SampleProjects.java

示例10: uploadSinatraApp

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test
public void uploadSinatraApp() throws IOException {
    String appName = namespacedAppName("env");
    ClassPathResource cpr = new ClassPathResource("apps/env/");
    File explodedDir = cpr.getFile();
    Staging staging = new Staging();
    createAndUploadExplodedTestApp(appName, explodedDir, staging);
    connectedClient.startApplication(appName);
    CloudApplication env = connectedClient.getApplication(appName);
    assertEquals(CloudApplication.AppState.STARTED, env.getState());
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:12,代码来源:CloudFoundryClientTest.java

示例11: importInternal

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
private void importInternal(String acpName, NodeRef space) throws IOException
{
    // Importing IMAP test acp
    ClassPathResource acpResource = new ClassPathResource(acpName);
    ACPImportPackageHandler acpHandler = new ACPImportPackageHandler(acpResource.getFile(), null);
    Location importLocation = new Location(space);
    importerService.importView(acpHandler, importLocation, null, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:ImapMessageTest.java

示例12: importInternal

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
private void importInternal(String acpName, NodeRef space)
        throws IOException
{
    ClassPathResource acpResource = new ClassPathResource(acpName);
    ACPImportPackageHandler acpHandler = new ACPImportPackageHandler(acpResource.getFile(), null);
    Location importLocation = new Location(space);
    importerService.importView(acpHandler, importLocation, null, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:ImapServiceImplTest.java

示例13: testAttachmentExtraction

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
/**
 * Test attachment extraction with a TNEF message
 * @throws Exception
 */
public void testAttachmentExtraction() throws Exception
{
    AuthenticationUtil.setRunAsUserSystem();
    /**
     * Load a TNEF message
     */
    ClassPathResource fileResource = new ClassPathResource("imap/test-tnef-message.eml");
    assertNotNull("unable to find test resource test-tnef-message.eml", fileResource);
    InputStream is = new FileInputStream(fileResource.getFile());
    MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()), is);

    NodeRef companyHomeNodeRef = findCompanyHomeNodeRef();

    FileInfo f1 = fileFolderService.create(companyHomeNodeRef, "ImapServiceImplTest", ContentModel.TYPE_FOLDER);
    FileInfo f2 = fileFolderService.create(f1.getNodeRef(), "test-tnef-message.eml", ContentModel.TYPE_CONTENT);
    
    ContentWriter writer = fileFolderService.getWriter(f2.getNodeRef());
    writer.putContent(new FileInputStream(fileResource.getFile()));
    
    imapService.extractAttachments(f2.getNodeRef(), message);

    List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(f2.getNodeRef(), ImapModel.ASSOC_IMAP_ATTACHMENTS_FOLDER);
    assertTrue("attachment folder is found", targetAssocs.size() == 1);
    NodeRef attachmentFolderRef = targetAssocs.get(0).getTargetRef();
    
    assertNotNull(attachmentFolderRef);

    List<FileInfo> files = fileFolderService.listFiles(attachmentFolderRef);
    assertTrue("three files not found", files.size() == 3);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:ImapServiceImplTest.java

示例14: importTestData

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
private void importTestData(String acpName, NodeRef space) throws IOException
{
    ClassPathResource acpResource = new ClassPathResource(acpName);
    ACPImportPackageHandler acpHandler = new ACPImportPackageHandler(acpResource.getFile(), null);
    Location importLocation = new Location(space);
    importerService.importView(acpHandler, importLocation, null, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:LoadTester.java

示例15: verifyTrustStoreBadPassword

import org.springframework.core.io.ClassPathResource; //导入方法依赖的package包/类
@Test(expected = RuntimeException.class)
public void verifyTrustStoreBadPassword() throws Exception {
    final ClassPathResource resource = new ClassPathResource("truststore.jks");
    new FileTrustStoreSslSocketFactory(resource.getFile(), "invalid");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:6,代码来源:FileTrustStoreSslSocketFactoryTests.java


注:本文中的org.springframework.core.io.ClassPathResource.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。