mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Merge pull request #1256 from querydsl/resourcecheck
Remove ResourceCheck based test filtering
This commit is contained in:
commit
745f7fda2e
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011, Mysema Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.querydsl.core.testutil;
|
||||
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
|
||||
public class FilteringTestRunner extends BlockJUnit4ClassRunner {
|
||||
|
||||
private boolean run = true;
|
||||
|
||||
public FilteringTestRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass);
|
||||
ResourceCheck rc = klass.getAnnotation(ResourceCheck.class);
|
||||
if (rc != null) {
|
||||
run = klass.getResourceAsStream(rc.value()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(RunNotifier notifier) {
|
||||
if (run) {
|
||||
super.run(notifier);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011, Mysema Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.querydsl.core.testutil;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
public @interface ResourceCheck {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String value();
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011, Mysema Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.querydsl.core.testutil;
|
||||
|
||||
import org.junit.rules.MethodRule;
|
||||
import org.junit.runners.model.FrameworkMethod;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
public class ResourceCheckRule implements MethodRule{
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, FrameworkMethod method, Object target) {
|
||||
Class<?> testClass = target.getClass();
|
||||
ResourceCheck rc = testClass.getAnnotation(ResourceCheck.class);
|
||||
boolean run = true;
|
||||
if (rc != null) {
|
||||
run = testClass.getResourceAsStream(rc.value()) != null;
|
||||
}
|
||||
return run ? base : EmptyStatement.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
@ -568,6 +568,7 @@
|
||||
<excludes>
|
||||
<exclude>**/*$*</exclude>
|
||||
<exclude>**/DB2*SuiteTest.java</exclude>
|
||||
<exclude>**/ExportMSSQLTest.java</exclude>
|
||||
<exclude>**/ExportOracleTest.java</exclude>
|
||||
<exclude>**/ExportTeradataTest.java</exclude>
|
||||
<exclude>**/Oracle*SuiteTest.java</exclude>
|
||||
|
||||
@ -18,12 +18,9 @@ import java.sql.SQLException;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.querydsl.sql.Connections;
|
||||
import com.querydsl.core.testutil.FilteringTestRunner;
|
||||
|
||||
@RunWith(FilteringTestRunner.class)
|
||||
public abstract class ExportBaseTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -14,11 +14,12 @@
|
||||
package com.querydsl.sql.codegen;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import com.querydsl.core.testutil.ResourceCheck;
|
||||
import com.querydsl.core.testutil.ExternalDB;
|
||||
import com.querydsl.sql.Connections;
|
||||
|
||||
@ResourceCheck("/sqlserver.run")
|
||||
@Category(ExternalDB.class)
|
||||
public class ExportMSSQLTest extends ExportBaseTest{
|
||||
|
||||
@BeforeClass
|
||||
|
||||
@ -6,7 +6,6 @@ import org.junit.experimental.categories.Category;
|
||||
import com.querydsl.core.testutil.ExternalDB;
|
||||
import com.querydsl.sql.Connections;
|
||||
|
||||
//@Ignore
|
||||
@Category(ExternalDB.class)
|
||||
public class ExportTeradataTest extends ExportBaseTest {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user