|
22 | 22 |
|
23 | 23 | package org.jboss.as.test.integration.jpa.mockprovider.classtransformer;
|
24 | 24 |
|
| 25 | +import java.io.File; |
25 | 26 | import java.lang.reflect.Proxy;
|
| 27 | +import java.net.URL; |
26 | 28 | import java.util.Map;
|
27 | 29 |
|
28 | 30 | import javax.persistence.EntityManagerFactory;
|
29 | 31 | import javax.persistence.spi.PersistenceProvider;
|
30 | 32 | import javax.persistence.spi.PersistenceUnitInfo;
|
31 | 33 | import javax.persistence.spi.ProviderUtil;
|
32 | 34 |
|
33 |
| -import org.jboss.as.jpa.container.EntityManagerUnwrappedTargetInvocationHandler; |
34 |
| - |
35 | 35 | /**
|
36 | 36 | * TestPersistenceProvider
|
37 | 37 | *
|
@@ -84,10 +84,32 @@ public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitI
|
84 | 84 | testEntityManagerFactory
|
85 | 85 | );
|
86 | 86 |
|
| 87 | + testGetPersistenceUnitRootUrl(info); |
| 88 | + |
87 | 89 | System.out.println("TestPersistenceProvider.createContainerEntityManagerFactory() is returning " + proxyEntityManagerFactory);
|
88 | 90 | return proxyEntityManagerFactory;
|
89 | 91 | }
|
90 | 92 |
|
| 93 | + private void testGetPersistenceUnitRootUrl(PersistenceUnitInfo info) { |
| 94 | + URL rootUrl = info.getPersistenceUnitRootUrl(); |
| 95 | + File topFolder = new File(rootUrl.getFile()); |
| 96 | + if (topFolder == null) { |
| 97 | + throw new RuntimeException("couldn't get root file representation of getPersistenceUnitRootUrl"); |
| 98 | + } |
| 99 | + File metainfFolder[] = topFolder.listFiles(); // META-INF |
| 100 | + File containedFiles[] = metainfFolder[0].listFiles(); |
| 101 | + |
| 102 | + for (File file :containedFiles) { |
| 103 | + |
| 104 | + System.out.println("getPersistenceUnitRootUrl contains " + file.getName()); |
| 105 | + if (file.getName().equals("persistence.xml")) { |
| 106 | + System.out.println("success: found persistence.xml"); |
| 107 | + return ; |
| 108 | + } |
| 109 | + } |
| 110 | + throw new RuntimeException("failed to find 'persistence.xml' in PersistenceUnitInfo.getPersistenceUnitRootUrl() to verify that it contains 'persistence.xml'"); |
| 111 | + } |
| 112 | + |
91 | 113 | @Override
|
92 | 114 | public ProviderUtil getProviderUtil() {
|
93 | 115 | return null;
|
|
0 commit comments