-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #603 from npetzall/376_always_create_diagrams
Always produce table diagram
- Loading branch information
Showing
31 changed files
with
2,205 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
src/test/java/org/schemaspy/integrationtesting/mysql/MysqlHTMLOrphanIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Copyright (C) 2018 Nils Petzaell | ||
* | ||
* This file is part of SchemaSpy. | ||
* | ||
* SchemaSpy is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* SchemaSpy is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with SchemaSpy. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.schemaspy.integrationtesting.mysql; | ||
|
||
import com.github.npetzall.testcontainers.junit.jdbc.JdbcContainerRule; | ||
import org.assertj.core.api.SoftAssertions; | ||
import org.junit.Before; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.schemaspy.cli.SchemaSpyRunner; | ||
import org.schemaspy.integrationtesting.MysqlSuite; | ||
import org.schemaspy.testing.HtmlOutputValidator; | ||
import org.schemaspy.testing.SuiteOrTestJdbcContainerRule; | ||
import org.schemaspy.testing.XmlOutputDiff; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import org.testcontainers.containers.MySQLContainer; | ||
import org.xmlunit.builder.Input; | ||
import org.xmlunit.diff.Diff; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardOpenOption; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static com.github.npetzall.testcontainers.junit.jdbc.JdbcAssumptions.assumeDriverIsPresent; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Nils Petzaell | ||
*/ | ||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
@DirtiesContext | ||
public class MysqlHTMLOrphanIT { | ||
|
||
private static URL expectedXML = MysqlHTMLOrphanIT.class.getResource("/integrationTesting/mysql/expecting/mysqlhtmlorphan/htmlorphanit.htmlorphanit.xml"); | ||
private static URL expectedDeletionOrder = MysqlHTMLOrphanIT.class.getResource("/integrationTesting/mysql/expecting/mysqlhtmlorphan/deletionOrder.txt"); | ||
private static URL expectedInsertionOrder = MysqlHTMLOrphanIT.class.getResource("/integrationTesting/mysql/expecting/mysqlhtmlorphan/insertionOrder.txt"); | ||
|
||
@ClassRule | ||
public static JdbcContainerRule<MySQLContainer> jdbcContainerRule = | ||
new SuiteOrTestJdbcContainerRule<>( | ||
MysqlSuite.jdbcContainerRule, | ||
new JdbcContainerRule<MySQLContainer>(() -> new MySQLContainer<>("mysql:5")) | ||
.assumeDockerIsPresent().withAssumptions(assumeDriverIsPresent()) | ||
.withQueryString("?useSSL=false") | ||
.withInitScript("integrationTesting/mysql/dbScripts/htmlorphanit.sql") | ||
.withInitUser("root", "test") | ||
); | ||
|
||
@Autowired | ||
private SchemaSpyRunner schemaSpyRunner; | ||
|
||
private static final AtomicBoolean shouldRun = new AtomicBoolean(true); | ||
|
||
@Before | ||
public synchronized void generateHTML() throws Exception { | ||
if (shouldRun.get()) { | ||
String[] args = new String[]{ | ||
"-t", "mysql", | ||
"-db", "htmlorphanit", | ||
"-s", "htmlorphanit", | ||
"-host", jdbcContainerRule.getContainer().getContainerIpAddress() + ":" + String.valueOf(jdbcContainerRule.getContainer().getMappedPort(3306)), | ||
"-port", String.valueOf(jdbcContainerRule.getContainer().getMappedPort(3306)), | ||
"-u", jdbcContainerRule.getContainer().getUsername(), | ||
"-p", jdbcContainerRule.getContainer().getPassword(), | ||
"-o", "target/mysqlhtmlorphanit", | ||
"-connprops", "useSSL\\=false" | ||
}; | ||
schemaSpyRunner.run(args); | ||
shouldRun.set(false); | ||
} | ||
} | ||
|
||
@Test | ||
public void verifyXML() { | ||
Diff d = XmlOutputDiff.diffXmlOutput( | ||
Input.fromFile("target/mysqlhtmlorphanit/htmlorphanit.htmlorphanit.xml"), | ||
Input.fromURL(expectedXML) | ||
); | ||
assertThat(d.getDifferences()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void verifyDeletionOrder() throws IOException { | ||
assertThat(Files.newInputStream(Paths.get("target/mysqlhtmlorphanit/deletionOrder.txt"), StandardOpenOption.READ)).hasSameContentAs(expectedDeletionOrder.openStream()); | ||
} | ||
|
||
@Test | ||
public void verifyInsertionOrder() throws IOException { | ||
assertThat(Files.newInputStream(Paths.get("target/mysqlhtmlorphanit/insertionOrder.txt"), StandardOpenOption.READ)).hasSameContentAs(expectedInsertionOrder.openStream()); | ||
} | ||
|
||
@Test | ||
public void producesSameContent() throws IOException { | ||
SoftAssertions softAssertions = HtmlOutputValidator | ||
.hasProducedValidOutput( | ||
Paths.get("target","mysqlhtmlorphanit"), | ||
Paths.get("src","test","resources","integrationTesting","mysql","expecting","mysqlhtmlorphan") | ||
); | ||
softAssertions.assertThat(softAssertions.wasSuccess()).isTrue(); | ||
softAssertions.assertAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...nTesting/mssqlserver/expecting/mssqlserverhtmlit/diagrams/tables/userAndGroup.1degree.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
digraph "oneDegreeRelationshipsDiagram" { | ||
graph [ | ||
rankdir="RL" | ||
bgcolor="#ffffff" | ||
label="\nGenerated by SchemaSpy" | ||
labeljust="l" | ||
nodesep="0.18" | ||
ranksep="0.46" | ||
fontname="Helvetica" | ||
fontsize="11" | ||
ration="compress" | ||
]; | ||
node [ | ||
fontname="Helvetica" | ||
fontsize="11" | ||
shape="plaintext" | ||
]; | ||
edge [ | ||
arrowsize="0.8" | ||
]; | ||
"userAndGroup" [ | ||
label=< | ||
<TABLE BORDER="2" CELLBORDER="1" CELLSPACING="0" BGCOLOR="#ffffff"> | ||
<TR><TD COLSPAN="4" BGCOLOR="#f5f5f5"><TABLE BORDER="0" CELLSPACING="0"><TR><TD ALIGN="LEFT"><B>userAndGroup</B></TD><TD ALIGN="RIGHT">[view]</TD></TR></TABLE></TD></TR> | ||
<TR><TD PORT="UserName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">UserName</TD></TR></TABLE></TD><TD PORT="UserName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
<TR><TD PORT="GroupName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">GroupName</TD></TR></TABLE></TD><TD PORT="GroupName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
</TABLE>> | ||
URL="userAndGroup.html" | ||
target="_top" | ||
tooltip="userAndGroup" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/resources/integrationTesting/mysql/dbScripts/htmlorphanit.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE DATABASE `htmlorphanit`; | ||
|
||
CREATE TABLE `htmlorphanit`.`group` ( | ||
groupId INTEGER AUTO_INCREMENT, | ||
name VARCHAR(16) NOT NULL, | ||
description VARCHAR(80) NOT NULL, | ||
PRIMARY KEY (groupId), | ||
UNIQUE name_unique (name) | ||
) engine=InnoDB COMMENT 'Orphan Groups'; | ||
|
||
GRANT SELECT, EXECUTE, SHOW VIEW on `htmlorphanit`.* to test@`%`; | ||
FLUSH PRIVILEGES; |
32 changes: 32 additions & 0 deletions
32
...ces/integrationTesting/mysql/expecting/mysqlhtml/diagrams/tables/userAndGroup.1degree.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
digraph "oneDegreeRelationshipsDiagram" { | ||
graph [ | ||
rankdir="RL" | ||
bgcolor="#ffffff" | ||
label="\nGenerated by SchemaSpy" | ||
labeljust="l" | ||
nodesep="0.18" | ||
ranksep="0.46" | ||
fontname="Helvetica" | ||
fontsize="11" | ||
ration="compress" | ||
]; | ||
node [ | ||
fontname="Helvetica" | ||
fontsize="11" | ||
shape="plaintext" | ||
]; | ||
edge [ | ||
arrowsize="0.8" | ||
]; | ||
"userAndGroup" [ | ||
label=< | ||
<TABLE BORDER="2" CELLBORDER="1" CELLSPACING="0" BGCOLOR="#ffffff"> | ||
<TR><TD COLSPAN="4" BGCOLOR="#f5f5f5"><TABLE BORDER="0" CELLSPACING="0"><TR><TD ALIGN="LEFT"><B>userAndGroup</B></TD><TD ALIGN="RIGHT">[view]</TD></TR></TABLE></TD></TR> | ||
<TR><TD PORT="UserName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">UserName</TD></TR></TABLE></TD><TD PORT="UserName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
<TR><TD PORT="GroupName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">GroupName</TD></TR></TABLE></TD><TD PORT="GroupName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
</TABLE>> | ||
URL="userAndGroup.html" | ||
target="_top" | ||
tooltip="userAndGroup" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...egrationTesting/mysql/expecting/mysqlhtml_gv_svg/diagrams/tables/userAndGroup.1degree.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
digraph "oneDegreeRelationshipsDiagram" { | ||
graph [ | ||
rankdir="RL" | ||
bgcolor="#ffffff" | ||
label="\nGenerated by SchemaSpy" | ||
labeljust="l" | ||
nodesep="0.18" | ||
ranksep="0.46" | ||
fontname="Helvetica" | ||
fontsize="11" | ||
ration="compress" | ||
]; | ||
node [ | ||
fontname="Helvetica" | ||
fontsize="11" | ||
shape="plaintext" | ||
]; | ||
edge [ | ||
arrowsize="0.8" | ||
]; | ||
"userAndGroup" [ | ||
label=< | ||
<TABLE BORDER="2" CELLBORDER="1" CELLSPACING="0" BGCOLOR="#ffffff"> | ||
<TR><TD COLSPAN="4" BGCOLOR="#f5f5f5"><TABLE BORDER="0" CELLSPACING="0"><TR><TD ALIGN="LEFT"><B>userAndGroup</B></TD><TD ALIGN="RIGHT">[view]</TD></TR></TABLE></TD></TR> | ||
<TR><TD PORT="UserName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">UserName</TD></TR></TABLE></TD><TD PORT="UserName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
<TR><TD PORT="GroupName" COLSPAN="2" ALIGN="LEFT"><TABLE BORDER="0" CELLSPACING="0" ALIGN="LEFT"><TR ALIGN="LEFT"><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="15" HEIGHT="16"></TD><TD ALIGN="LEFT" FIXEDSIZE="TRUE" WIDTH="97" HEIGHT="16">GroupName</TD></TR></TABLE></TD><TD PORT="GroupName.type" ALIGN="LEFT">varchar[16]</TD></TR> | ||
</TABLE>> | ||
URL="../../tables/userAndGroup.html" | ||
target="_top" | ||
tooltip="userAndGroup" | ||
]; | ||
} |
Oops, something went wrong.