Java Code Examples for org.junit.Before

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Aardvark, under directory /aardvark-core/src/test/java/gw/vark/.

Source file: TestprojectTest.java

  15 
vote

@Before public void setupProject() throws Exception {
  clean();
  Project antProject=new Project();
  _logger=new InMemoryLogger();
  Aardvark.setProject(antProject,_logger);
  _aardvarkProject=AardvarkProgram.parse(antProject,_varkFile);
}
 

Example 2

From project activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/.

Source file: SetParentTest.java

  15 
vote

@Before public void before() throws Exception {
  super.before();
  deleteFromTable("computers");
  deleteFromTable("motherboards");
  deleteFromTable("keyboards");
  populateTable("motherboards");
  populateTable("keyboards");
  populateTable("computers");
}
 

Example 3

From project addis, under directory /application/src/integration-test/java/org/drugis/addis/mtc/.

Source file: ConsistencyModelIT.java

  15 
vote

@Before public void setUp(){
  d_builder=new DichotomousNetworkBuilder<String>();
  d_builder.add("1","A",5,100);
  d_builder.add("1","B",23,100);
  d_builder.add("2","B",12,43);
  d_builder.add("2","C",15,40);
  d_builder.add("3","A",12,150);
  d_builder.add("3","C",100,150);
  d_network=d_builder.buildNetwork();
  ModelFactory factory=DefaultModelFactory.instance();
  d_model=factory.getConsistencyModel(d_network);
}
 

Example 4

From project addressbook-sample-mongodb, under directory /contacts/src/test/java/nl/enovation/addressbook/cqrs/commandhandler/.

Source file: ContactCommandHandlerIntegrationTest.java

  15 
vote

@Before public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  fixture=Fixtures.newGivenWhenThenFixture();
  ContactCommandHandler commandHandler=new ContactCommandHandler();
  commandHandler.setContactRepository(fixture.createGenericRepository(Contact.class));
  fixture.registerAnnotatedCommandHandler(commandHandler);
}
 

Example 5

From project AdminCmd, under directory /src/test/java/be/Balor/JUnit/.

Source file: ExtendedConfigurationTest.java

  15 
vote

/** 
 * @throws java.lang.Exception
 */
@Before public void setUp() throws Exception {
  ExtendedConfiguration.setClassLoader(this.getClass().getClassLoader());
  file=new File("test.yml");
  final ExtendedConfiguration conf=ExtendedConfiguration.loadConfiguration(file);
  conf.add("test","blah");
  conf.createSection("yatta").set("test","blah");
  conf.save();
}
 

Example 6

From project aerogear-controller, under directory /src/test/java/org/jboss/aerogear/controller/router/.

Source file: DefaultRouterTest.java

  15 
vote

@Before public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  final RoutingModule routingModule=new AbstractRoutingModule(){
    @Override public void configuration(){
      route().from("/car/{id}").roles("admin").on(RequestMethod.GET).to(SampleController.class).find(pathParam("id"));
    }
  }
;
  router=new DefaultRouter(routingModule,beanManager,viewResolver,controllerFactory,securityProvider);
}
 

Example 7

From project aether-core, under directory /aether-connector-asynchttpclient/src/test/java/org/eclipse/aether/connector/async/.

Source file: AsyncConnectorSuiteConfiguration.java

  15 
vote

@Override @Before public void before() throws Exception {
  super.before();
  this.factory=new AsyncRepositoryConnectorFactory();
  this.factory.setFileProcessor(new TestFileProcessor());
  this.session=new TestRepositorySystemSession();
  this.repository=new RemoteRepository.Builder("async-test-repo","default",url("repo")).build();
  this.artifact=new DefaultArtifact("gid","aid","classifier","extension","version",null);
  this.metadata=new DefaultMetadata("gid","aid","version","maven-metadata.xml",Metadata.Nature.RELEASE_OR_SNAPSHOT,null);
  connector=null;
}
 

Example 8

From project agileBase, under directory /gtpb_server/tests/com/gtwm/pb/auth/.

Source file: AuthenticatorTest.java

  15 
vote

@Before public void setUp() throws MissingParametersException, CodingErrorException {
  this.company=new Company("Test Company");
  this.appUser=new AppUser(this.company,new RandomString().toString(),"testuser","User","Test","password");
  this.appRole=new AppRole(this.company,new RandomString().toString(),"testrole");
  this.authenticator.addCompany(company);
  this.authenticator.addUser(appUser);
  this.authenticator.addRole(appRole);
}
 

Example 9

From project agit, under directory /agit/src/test/java/com/madgag/agit/.

Source file: CloneLauncherActivityRobolectricTest.java

  15 
vote

@Before public void setUp(){
  activity.onCreate(null);
  RoboGuice.injectMembers(activity,this);
  clone=new GitIntentBuilder("");
  bareRepoCheckbox=checkable(R.id.BareRepo);
  defaultLocationCheckBox=checkable(UseDefaultGitDirLocation);
  directoryEditText=textView(GitDirEditText);
}
 

Example 10

From project agraph-java-client, under directory /src/test/.

Source file: AGAbstractTest.java

  15 
vote

@Before public void setUp() throws Exception {
  repo=cat.createRepository(repoId);
  closeLater(repo);
  repo.initialize();
  vf=repo.getValueFactory();
  conn=getConnection();
  conn.clear();
  conn.clearMappings();
  conn.clearNamespaces();
  conn.setNamespace("fti","http://franz.com/ns/allegrograph/2.2/textindex/");
  conn.setNamespace("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
}
 

Example 11

From project aim3-tu-berlin, under directory /seminar/exercises/datamining/core/src/test/java/de/tuberlin/dima/aim/exercises/.

Source file: HadoopAndPactTestcase.java

  15 
vote

@Before public void setUp() throws Exception {
  RandomUtils.useTestSeed();
  testTempDir=null;
  testTempDirPath=null;
  fs=null;
}
 

Example 12

From project Aion-Extreme, under directory /AE-go_GameServer/test/com/aionemu/gameserver/services/.

Source file: PlayerServiceTest.java

  15 
vote

@Before public void init(){
  System.out.println("Loading config and database");
  LoggingService.init();
  Config.load();
  DatabaseFactory.init();
}
 

Example 13

From project AirCastingAndroidClient, under directory /src/test/java/pl/llp/aircasting/activity/adapter/.

Source file: StreamAdapterTest.java

  15 
vote

@Before public void setup(){
  adapter=new StreamAdapter(mock(ButtonsActivity.class),new ArrayList<Map<String,Object>>(),mock(EventBus.class),mock(GaugeHelper.class),mock(TopBarHelper.class),mock(SensorManager.class),mock(SessionManager.class));
  sensor=mock(Sensor.class);
  view=mock(View.class);
  when(view.getTag()).thenReturn(sensor);
}
 

Example 14

From project ajah, under directory /ajah-util/src/test/java/test/ajah/util/io/file/.

Source file: FileScanTest.java

  15 
vote

/** 
 * Create a random file to use for testing.
 * @throws IOException
 */
@Before public void setup() throws IOException {
  this.file=new File("/tmp/.ajah/" + UUID.randomUUID().toString());
  this.file.mkdirs();
  new File(this.file,UUID.randomUUID().toString()).createNewFile();
  new File(this.file,UUID.randomUUID().toString()).mkdirs();
}
 

Example 15

From project alphaportal_dev, under directory /sys-src/alphaportal/core/src/test/java/alpha/portal/dao/.

Source file: UserSessionTest.java

  15 
vote

/** 
 * Sets the up.
 */
@Before public void setUp(){
  this.userSessionDao=new GenericDaoHibernate<UserSession,Long>(UserSession.class);
  this.userSessionDao.setSessionFactory(this.sessionFactory);
  this.testUser=new User("testUser");
  this.testUser.setId(42L);
  return;
}
 

Example 16

From project android-client, under directory /xwiki-android-test-fixture-setup/test/org/xwiki/android/test/fixture/setup/.

Source file: ServerStartTest.java

  15 
vote

@Before public void setup(){
  exec=new XWikiExecutor(TestEnv.SERVER_INDEX);
  try {
    exec.start();
  }
 catch (  Exception e) {
    throw new AssertionFailedError(e.getMessage());
  }
}
 

Example 17

From project android-client_1, under directory /test/com/buddycloud/view/.

Source file: TestFollowActivity.java

  15 
vote

@Before public void setUp() throws Exception {
  activity=new FollowActivity();
  activity.onCreate(null);
  abortButton=(Button)activity.findViewById(R.id.abort);
  followActivityButton=(Button)activity.findViewById(R.id.follow);
}
 

Example 18

From project android-rindirect, under directory /maven-rindirect-plugin-it/src/test/java/de/akquinet/android/rindirect/.

Source file: ClassnameTest.java

  15 
vote

@Before public void setUp() throws VerificationException, IOException {
  Verifier verifier;
  verifier=new Verifier(ROOT.getAbsolutePath());
  verifier.deleteArtifact(Constants.TEST_GROUP_ID,Constants.TEST_ARTIFACT_ID,Constants.TEST_VERSION,"apk");
  verifier.setSystemProperties(Constants.getSystemProperties());
  verifier.executeGoal("clean");
}
 

Example 19

From project android-sdk, under directory /src/test/java/com/mobeelizer/mobile/android/.

Source file: MobeelizerDatabaseImplTest.java

  15 
vote

@Before @SuppressWarnings({"unchecked"}) public void init() throws Exception {
  MobeelizerApplication application=mock(MobeelizerApplication.class);
  when(application.getUser()).thenReturn("owner");
  when(application.getGroup()).thenReturn("group");
  contentValues=PowerMockito.mock(ContentValues.class);
  PowerMockito.whenNew(ContentValues.class).withNoArguments().thenReturn(contentValues);
  exceptionBuilder=mock(MobeelizerErrorsBuilder.class);
  PowerMockito.whenNew(MobeelizerErrorsBuilder.class).withNoArguments().thenReturn(exceptionBuilder);
  model=mock(MobeelizerAndroidModel.class);
  clazzNotExists=String.class;
  clazz=TestEntity.class;
  when(model.getMappingClass()).thenReturn(clazz);
  when(model.getName()).thenReturn("modelName");
  models=new HashSet<MobeelizerAndroidModel>();
  models.add(model);
  database=mock(SQLiteDatabase.class);
  databaseHelper=mock(MobeelizerDatabaseHelper.class);
  when(databaseHelper.getWritableDatabase()).thenReturn(database);
  whenNew(MobeelizerDatabaseHelper.class).withArguments(application,models).thenReturn(databaseHelper);
  databaseAdapter=new MobeelizerDatabaseImpl(application,models);
  databaseAdapter.open();
}
 

Example 20

From project Android-SQL-Helper, under directory /tests/AndroidSQLHelperTest/src/com/sgxmobileapps/androidsqlhelper/test/.

Source file: BaseTestCase.java

  15 
vote

@Before public void beforeTest() throws IOException {
  printStartTest(name.getMethodName());
  getInDir();
  getOutSrcDir();
  getOutBuildDir();
}
 

Example 21

From project androidannotations, under directory /AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/prefs/.

Source file: PrefsActivityTest.java

  15 
vote

@Before public void setup(){
  activity=new PrefsActivity_();
  activity.onCreate(null);
  somePrefs=activity.somePrefs;
  sharedPref=somePrefs.getSharedPreferences();
}
 

Example 22

From project ANNIS, under directory /annis-service/src/test/java/annis/administration/.

Source file: TestAnnisAdminRunner.java

  15 
vote

@Before public void setup(){
  initMocks(this);
  main=new AnnisAdminRunner();
  main.setCorpusAdministration(null);
  main.setCorpusAdministration(administration);
}
 

Example 23

From project ant4eclipse, under directory /org.ant4eclipse.lib.core.test/src/org/ant4eclipse/lib/core/logging/.

Source file: Failuretest.java

  15 
vote

@Before public void configureServiceRegistry(){
  ServiceRegistryConfiguration configuration=new ServiceRegistryConfiguration(){
    public void configure(    ConfigurationContext context){
    }
  }
;
  ServiceRegistryAccess.configure(configuration);
}
 

Example 24

From project any23, under directory /core/src/test/java/org/apache/any23/extractor/html/.

Source file: AbstractExtractorTestCase.java

  15 
vote

/** 
 * Test case initialization.
 * @throws Exception
 */
@Before public void setUp() throws Exception {
  super.setUp();
  Sail store=new MemoryStore();
  store.initialize();
  conn=new SailRepository(store).getConnection();
}
 

Example 25

From project api-sdk-java, under directory /api-sdk/src/test/java/com/smartling/api/sdk/file/.

Source file: FileApiClientAdapterTest.java

  15 
vote

@Before public void setup(){
  boolean testMode=FileApiTestHelper.getTestMode();
  String apiKey=FileApiTestHelper.getApiKey();
  String projectId=FileApiTestHelper.getProjectId();
  locale=FileApiTestHelper.getLocale();
  fileApiClientAdapter=new FileApiClientAdapterImpl(testMode,apiKey,projectId);
}
 

Example 26

From project apollo, under directory /injector/src/test/java/com/bskyb/cg/environments/cassandra/.

Source file: TestCassandraDao.java

  15 
vote

@Before public void setUp() throws Exception {
  CassandraConfigurationBuilder cassandraConfigurationBuilder=new CassandraConfigurationBuilder();
  cassandraConfigurationBuilder.setClusterName(clusterName);
  cassandraConfigurationBuilder.setExhaustPolicy(exhaustPolicy);
  cassandraConfigurationBuilder.setHosts(hosts);
  cassandraConfigurationBuilder.setKeySpaceName(keySpaceName);
  cassandraConfigurationBuilder.setLifo(true);
  cassandraConfigurationBuilder.setMaxActive(10);
  cassandraConfigurationBuilder.setMaxIdle(10);
  cassandraConfigurationBuilder.setMaxWaitTimeWhenExhausted(10);
  cassandraConfigurationBuilder.setReadConsistencyLevel(readConsistencyLevel);
  cassandraConfigurationBuilder.setRowCount(10);
  cassandraConfigurationBuilder.setThriftSocketTimeout(10);
  cassandraConfigurationBuilder.setTimeToGoStaleInMinutes(2);
  cassandraConfigurationBuilder.setTimeToLiveInMinutes(2);
  cassandraConfigurationBuilder.setWriteConsistencyLevel(writeConsistencyLevel);
  cassandraConfigurationBuilder.setMsgType(msgType);
  cassandraConfigurationBuilder.buildSchema();
  cassandraConfiguration=cassandraConfigurationBuilder.build();
  cassandraDao=new CassandraDao(cassandraConfiguration);
}
 

Example 27

From project aranea, under directory /core/src/test/java/no/dusken/aranea/service/.

Source file: BannerLocationServiceImplTest.java

  15 
vote

@Before public void setUp() throws Exception {
  BannerLocation bl1=new BannerLocation();
  bl1.setName("bl1");
  bl1.setUrl("bl1");
  bl1=bannerLocationService.saveOrUpdate(bl1);
  BannerLocation bl2=new BannerLocation();
  bl2.setName("bl2");
  bl2.setUrl("bl2");
  bl2=bannerLocationService.saveOrUpdate(bl2);
}
 

Example 28

From project Archimedes, under directory /br.org.archimedes.arc.tests/test/br/org/archimedes/arc/.

Source file: ArcTest.java

  15 
vote

@Before public void setUp() throws Exception {
  initial=new Point(1,0);
  middle=new Point(0,1);
  ending=new Point(-1,0);
  center=new Point(0,0);
  points=new LinkedList<Point>();
  points.add(initial);
  points.add(ending);
  points.add(middle);
  points.add(center);
  arc1=new Arc(ending,middle,initial);
  arc1Clone=new Arc(initial,middle,ending);
  arc2=new Arc(ending,initial,center,false);
  arc3=new Arc(ending,initial,center,middle);
  arc=new Arc(ending,initial,center,true);
}