Skip to content

Instantly share code, notes, and snippets.

@cescoffier
Created February 21, 2013 08:50
Show Gist options
  • Save cescoffier/5003313 to your computer and use it in GitHub Desktop.
Save cescoffier/5003313 to your computer and use it in GitHub Desktop.
Mockito can't be resolved with the Pax Exam Junit bundles.
package org.apache.felix.ipojo.runtime.core;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.useradmin.User;
import javax.inject.Inject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class MockitoTest {
@Inject
private BundleContext bc;
@Configuration
public Option[] config() {
return CoreOptions.options(
junitBundles(),
mavenBundle("org.mockito", "mockito-all", "1.9.5"),
mavenBundle().groupId("org.apache.felix").artifactId("org.osgi.compendium").version("1.4.0"));
}
@Test
public void test() {
for (Bundle bundle : bc.getBundles()) {
System.out.println("Bundle " + bundle.getSymbolicName() + " - " + bundle.getState());
}
User user = mock(User.class);
System.out.println(user);
user.getName();
verify(user).getName();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment