Skip to content

Commit

Permalink
Merge pull request #137 from adrienlauer/fix-rule-binding
Browse files Browse the repository at this point in the history
Bind all testing rules in IT plugin
  • Loading branch information
adrienlauer committed Oct 15, 2015
2 parents 8d53a28 + 129c32f commit e67ab35
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.seedstack.seed.cli.api.CliErrorCode;
import org.seedstack.seed.cli.api.WithCommandLine;
import org.seedstack.seed.core.api.SeedException;
import org.seedstack.seed.it.api.ITBind;
import org.seedstack.seed.it.spi.KernelRule;
import org.seedstack.seed.it.spi.PausableStatement;

Expand All @@ -28,6 +29,7 @@
* @author epo.jemba@ext.mpsa.com
* @author adrien.lauer@mpsa.com
*/
@ITBind
public class CommandLineITRule implements MethodRule, KernelRule {
private KernelConfiguration kernelConfiguration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class CommandLineModule extends AbstractModule {

@Override
protected void configure() {
bind(CommandLineITRule.class);

for (Map.Entry<String, Class<? extends CommandLineHandler>> cliHandlerEntry : cliHandlers.entrySet()) {
bind(CommandLineHandler.class).annotatedWith(Names.named(cliHandlerEntry.getKey())).to(cliHandlerEntry.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
*/
package org.seedstack.seed.security.internal;

import javax.inject.Inject;
import javax.inject.Named;

import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import org.seedstack.seed.it.api.ITBind;
import org.seedstack.seed.security.api.WithUser;

import javax.inject.Inject;

/**
* MethodRule used to connect a user to seed security if annotation @ {@link org.seedstack.seed.security.api.WithUser} is present on method or on target class.
* MethodRule used to connect a user to seed security if annotation @ {@link org.seedstack.seed.security.api.WithUser}
* is present on method or on target class.
*
* @author yves.dautremay@mpsa.com
*/
@ITBind
public class SecurityITRule implements TestRule {
/**
* The securityManager to be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class SecurityInternalModule extends PrivateModule {
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void configure() {
bind(SecurityITRule.class);
bind(Configuration.class).annotatedWith(Names.named("seed-security-config")).toInstance(securityConfigurer.getSecurityConfiguration());
bind(CacheManager.class).to(MemoryConstrainedCacheManager.class);
try {
Expand All @@ -63,7 +62,6 @@ public void configure() {
principalCustomizers.addBinding().to(customizerClass);
}

expose(SecurityITRule.class);
expose(new TypeLiteral<Set<Realm>>() {});
expose(new TypeLiteral<Set<PrincipalCustomizer>>() {});
expose(SecuritySupport.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import io.nuun.kernel.api.plugin.request.ClasspathScanRequest;
import io.nuun.kernel.core.AbstractPlugin;
import io.nuun.kernel.core.internal.context.InitContextInternal;
import org.junit.rules.MethodRule;
import org.junit.rules.TestRule;
import org.kametic.specifications.Specification;
import org.seedstack.seed.core.internal.application.ApplicationPlugin;
import org.seedstack.seed.it.api.ITBind;
Expand Down Expand Up @@ -56,8 +54,6 @@ public class ITPlugin extends AbstractPlugin {

@SuppressWarnings("unchecked")
private final Specification<Class<?>> itBindingSpec = or(classAnnotatedWith(ITBind.class));
@SuppressWarnings("unchecked")
private final Specification<Class<?>> ruleSpec = or(classImplements(TestRule.class), classImplements(MethodRule.class));

@Override
public String name() {
Expand Down Expand Up @@ -129,7 +125,7 @@ public void stop() {

@Override
public Collection<ClasspathScanRequest> classpathScanRequests() {
return classpathScanRequestBuilder().specification(itBindingSpec).specification(ruleSpec).build();
return classpathScanRequestBuilder().specification(itBindingSpec).build();
}

@Override
Expand Down

0 comments on commit e67ab35

Please sign in to comment.