Skip to content

Commit

Permalink
Merge pull request #807 from jeffgbutler/ui-tests
Browse files Browse the repository at this point in the history
Add UI Test Fragment
  • Loading branch information
jeffgbutler committed Jan 18, 2022
2 parents a1221b1 + da6dc90 commit f2ca1ca
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 1 deletion.
Expand Up @@ -87,6 +87,11 @@ <h2>Other Projects</h2>
<td>This project is a plugin fragment that holds unit tests for the
org.mybatis.generator.eclipse.core plugin.</td>
</tr>
<tr>
<td><code>org.mybatis.generator.eclipse.ui.tests</code></td>
<td>This project is a plugin fragment that holds unit tests for the
org.mybatis.generator.eclipse.ui plugin.</td>
</tr>
<tr>
<td><code>org.mybatis.generator.eclipse.tests.harness</code></td>
<td>This project is a plugin that contains specialized AST visitors and custom
Expand Down
Expand Up @@ -55,6 +55,8 @@ <h1>Publishing a New Version</h1>
<li><code>org.mybatis.generator.eclipse.tests.harness/pom.xml</code></li>
<li><code>org.mybatis.generator.eclipse.ui/META-INF/MANIFEST.MF</code></li>
<li><code>org.mybatis.generator.eclipse.ui/pom.xml</code></li>
<li><code>org.mybatis.generator.eclipse.ui.tests/META-INF/MANIFEST.MF</code></li>
<li><code>org.mybatis.generator.eclipse.ui.tests/pom.xml</code></li>
</ul>
<p>This can be easily accomplished with the Tycho versions plugin:
<code>mvn tycho-versions:set-version -DnewVersion=1.4.1-SNAPSHOT</code></p>
Expand Down
1 change: 1 addition & 0 deletions eclipse/org.mybatis.generator.eclipse.parent/pom.xml
Expand Up @@ -13,6 +13,7 @@
<module>../org.mybatis.generator.eclipse.core</module>
<module>../org.mybatis.generator.eclipse.doc</module>
<module>../org.mybatis.generator.eclipse.ui</module>
<module>../org.mybatis.generator.eclipse.ui.tests</module>
<module>../org.mybatis.generator.eclipse.site</module>
<module>../org.mybatis.generator.eclipse.core.tests</module>
<module>../org.mybatis.generator.eclipse.tests.harness</module>
Expand Down
1 change: 1 addition & 0 deletions eclipse/org.mybatis.generator.eclipse.ui.tests/.gitignore
@@ -0,0 +1 @@
/target/
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests
Bundle-SymbolicName: org.mybatis.generator.eclipse.ui.tests
Bundle-Version: 1.4.1.qualifier
Fragment-Host: org.mybatis.generator.eclipse.ui;bundle-version="1.4.1"
Automatic-Module-Name: org.mybatis.generator.eclipse.ui.tests
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.junit;bundle-version="4.12.0"
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
25 changes: 25 additions & 0 deletions eclipse/org.mybatis.generator.eclipse.ui.tests/pom.xml
@@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>org.mybatis.generator.eclipse.ui.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<parent>
<groupId>org.mybatis.generator</groupId>
<artifactId>org.mybatis.generator.eclipse.parent</artifactId>
<version>1.4.1-SNAPSHOT</version>
<relativePath>../org.mybatis.generator.eclipse.parent</relativePath>
</parent>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<argLine>${jacoco.agent.arg}</argLine>
</configuration>
</plugin>
</plugins>
</build>
<name>Core UI Tests</name>
</project>
@@ -0,0 +1,30 @@
package org.mybatis.generator.eclipse.ui.content;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.io.InputStream;

import org.junit.Test;

public class ConfigVerifyerTest {

@Test
public void testValidFile() {
ConfigVerifyer cf = new ConfigVerifyer((File) null);
InputStream resource = getClass()
.getResourceAsStream("/org/mybatis/generator/eclipse/ui/content/GoodConfigFile.xml");

assertThat(cf.isConfigFile(resource), is(true));
}

@Test
public void testInvalidFile() {
ConfigVerifyer cf = new ConfigVerifyer((File) null);
InputStream resource = getClass()
.getResourceAsStream("/org/mybatis/generator/eclipse/ui/content/NotAConfigFile.xml");

assertThat(cf.isConfigFile(resource), is(false));
}
}
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<context id="context1" targetRuntime="MyBatis3Simple" >
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
connectionURL="${jdbcUrl}"
userId="sa" >
</jdbcConnection>
<javaModelGenerator targetPackage="gen.model" targetProject="MBGTest" >
<!--
<property name="rootClass" value="base.BaseModel" />
-->
</javaModelGenerator>
<sqlMapGenerator targetPackage="gen.mapper" targetProject="MBGTest" />
<javaClientGenerator targetPackage="gen.mapper" targetProject="MBGTest" type="XMLMAPPER" />
<table tableName="a" />
</context>

<context id="context2" targetRuntime="MyBatis3Simple" >
<commentGenerator>
<property name="suppressAllComments" value="false"/>
</commentGenerator>

<connectionFactory type="DEFAULT" >
<property name="driverClass" value="org.hsqldb.jdbcDriver" />
<property name="connectionURL" value="jdbc:hsqldb:mem:aname" />
<property name="userId" value="sa" />
</connectionFactory>
<javaModelGenerator targetPackage="gen.src.model" targetProject="MBGTest/generatedsrc" />
<sqlMapGenerator targetPackage="gen.src.mapper" targetProject="MBGTest/generatedsrc" />
<javaClientGenerator targetPackage="gen.src.mapper" targetProject="MBGTest/generatedsrc" type="XMLMAPPER" />
<table schema="mbgtest" tableName="%" />
</context>
</generatorConfiguration>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<baseElement>
<subElement name="fred" />
</baseElement>
Expand Up @@ -94,7 +94,7 @@ public boolean isConfigurationFile() {
return rc;
}

private boolean isConfigFile(InputStream inputStream) {
boolean isConfigFile(InputStream inputStream) {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
Expand Down

0 comments on commit f2ca1ca

Please sign in to comment.