Examples of PathMatchingResourcePatternResolver


Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    assertEquals(0, info[0].getProperties().keySet().size());
  }

  public void testExample3() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example3.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertNotNull(info);
    assertEquals(1, info.length);

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
    DataSource ds = new DriverManagerDataSource();
    builder.bind("java:comp/env/jdbc/MyDB", ds);

    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example4.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertNotNull(info);
    assertEquals(1, info.length);

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    builder.clear();
  }

  public void testExample5() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example5.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertNotNull(info);
    assertEquals(1, info.length);

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    Map<String, DataSource> dataSources = new HashMap<String, DataSource>();
    dataSources.put("jdbc/MyPartDB", ds);
    dataSources.put("jdbc/MyDB", ds);
    dataSourceLookup.setDataSources(dataSources);
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), dataSourceLookup);
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertEquals(2, info.length);

    PersistenceUnitInfo pu1 = info[0];

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    assertEquals(ds, pu2.getNonJtaDataSource());
  }

  public void testExample6() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example6.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
    assertEquals(1, info.length);
    assertEquals("pu", info[0].getPersistenceUnitName());
    assertEquals(0, info[0].getProperties().keySet().size());

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    assertEquals(0, info[0].getProperties().keySet().size());
  }

  public void testInvalidPersistence() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-invalid.xml";
    try {
      reader.readPersistenceUnitInfos(resource);
      fail("expected invalid document exception");
    }

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    }
  }

  public void testNoSchemaPersistence() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-no-schema.xml";
    try {
      reader.readPersistenceUnitInfos(resource);
      fail("expected invalid document exception");
    }

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    }
  }

  public void testPersistenceUnitRootUrl() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());

    URL url = reader.determinePersistenceUnitRootUrl(new ClassPathResource(
        "/org/springframework/orm/jpa/persistence-no-schema.xml"));
    assertNull(url);

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

    assertTrue("the containing folder should have been returned", url.toString().endsWith("/org/springframework/orm/jpa/"));
  }
 
  public void testPersistenceUnitRootUrlWithJar() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());

    ClassPathResource archive = new ClassPathResource("/org/springframework/orm/jpa/jpa-archive.jar");
    String newRoot = "jar:" + archive.getURL().toExternalForm() + "!/META-INF/persist.xml";
    Resource insideArchive = new UrlResource(newRoot);
    // make sure the location actually exists

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver

  public static URL checkImportExistence(String candidate, String extension,
          ClassLoader classloader) throws IOException {
    String p = candidate.replaceAll("[.]", "/");
    p += "." + extension;
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(
            classloader);
    String prefix = "classpath*:";
    String pattern = prefix + p;
    Resource[] resources = resolver.getResources(pattern);
    if(resources == null || resources.length == 0) {
      return null;
    } else {
      Resource resource = resources[0];
      URL url = resource.getURL();
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.