INT-2026 added new packages

This commit is contained in:
Oleg Zhurakousky
2011-08-01 10:03:56 -04:00
parent 24236fa981
commit c6403f3feb
3 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2002-2011 the original author or authors.
*
* 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 org.springframework.integration.mongodb.rules;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author Oleg Zhurakousky
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface MongodbAvailable {
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2002-2011 the original author or authors.
*
* 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 org.springframework.integration.mongodb.rules;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import com.mongodb.Mongo;
/**
* @author Oleg Zhurakousky
*
*/
public final class MongodbAvailableRule implements MethodRule{
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
return new Statement(){
@Override
public void evaluate() throws Throwable {
MongodbAvailable redisAvailable = method.getAnnotation(MongodbAvailable.class);
if (redisAvailable != null){
try {
Mongo mongo = new Mongo();
mongo.getDatabaseNames();
} catch (Exception e) {
System.out.println("Mongodb is not available. Skipping the test.");
return;
}
}
base.evaluate();
}
};
}
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2002-2011 the original author or authors.
*
* 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 org.springframework.integration.mongodb.rules;
import org.junit.Rule;
/**
* @author Oleg Zhurakousky
*
*/
public class MongodbAvailableTests {
@Rule
public MongodbAvailableRule redisAvailableRule = new MongodbAvailableRule();
}