Skip to content

Commit 8cf8ba5

Browse files
committed
HBX-3242: Create an exporter type to generater mapping.xml files
- Create helper class HbmXmlOrigin and test HbmXmlOriginTest Signed-off-by: Koen Aers <[email protected]>
1 parent f41b7dd commit 8cf8ba5

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.hibernate.tool.internal.export.mapping;
2+
3+
import org.hibernate.boot.jaxb.Origin;
4+
import org.hibernate.boot.jaxb.SourceType;
5+
6+
import java.io.File;
7+
import java.io.Serial;
8+
9+
public class HbmXmlOrigin extends Origin {
10+
11+
@Serial
12+
private static final long serialVersionUID = 1L;
13+
14+
private final File hbmXmlFile;
15+
16+
public HbmXmlOrigin(File hbmXmlFile) {
17+
super( SourceType.FILE, hbmXmlFile.getAbsolutePath() );
18+
this.hbmXmlFile = hbmXmlFile;
19+
}
20+
21+
public File getHbmXmlFile() {
22+
return hbmXmlFile;
23+
}
24+
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.hibernate.tool.internal.export.mapping;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
6+
import java.io.File;
7+
import java.nio.file.Path;
8+
9+
import org.hibernate.boot.jaxb.SourceType;
10+
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.io.TempDir;
12+
13+
public class HbmXmlOriginTest {
14+
15+
@TempDir
16+
private Path tempDir;
17+
18+
@Test
19+
public void testHbmXmlOrigin() throws Exception {
20+
File hbmXmlFile = new File(tempDir.toFile(), "foo.hbm.xml");
21+
HbmXmlOrigin hxo = new HbmXmlOrigin(hbmXmlFile);
22+
assertNotNull(hxo);
23+
assertEquals(hbmXmlFile, hxo.getHbmXmlFile());
24+
assertEquals(hbmXmlFile.getAbsolutePath(), hxo.getName());
25+
assertEquals(SourceType.FILE, hxo.getType());
26+
}
27+
28+
}

0 commit comments

Comments
 (0)