Skip to content

Commit

Permalink
Added the core testing API.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstok committed Feb 12, 2013
1 parent 4851ebf commit adbbb43
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/java/main/com/johnstok/avalanche/Callback.java
@@ -0,0 +1,31 @@
/*-----------------------------------------------------------------------------
* Copyright © 2013 Keith Webster Johnston.
* All rights reserved.
*
* This file is part of avalanche.
*
* avalanche is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* avalanche is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with avalanche. If not, see <http://www.gnu.org/licenses/>.
*---------------------------------------------------------------------------*/
package com.johnstok.avalanche;


/**
* A callback for notifying events related to an item of work.
*
* @author Keith Webster Johnston.
*/
public interface Callback {

void onComplete();
}
35 changes: 35 additions & 0 deletions src/java/main/com/johnstok/avalanche/Generator.java
@@ -0,0 +1,35 @@
/*-----------------------------------------------------------------------------
* Copyright © 2013 Keith Webster Johnston.
* All rights reserved.
*
* This file is part of avalanche.
*
* avalanche is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* avalanche is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with avalanche. If not, see <http://www.gnu.org/licenses/>.
*---------------------------------------------------------------------------*/
package com.johnstok.avalanche;

import java.util.concurrent.Future;


/**
* A generator generates work.
*
* @param <T>
*
* @author Keith Webster Johnston.
*/
public interface Generator<T> {

Future<T> generate(Callback callback);
}
49 changes: 49 additions & 0 deletions src/java/main/com/johnstok/avalanche/GeneratorRunnable.java
@@ -0,0 +1,49 @@
/*-----------------------------------------------------------------------------
* Copyright © 2013 Keith Webster Johnston.
* All rights reserved.
*
* This file is part of avalanche.
*
* avalanche is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* avalanche is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with avalanche. If not, see <http://www.gnu.org/licenses/>.
*---------------------------------------------------------------------------*/
package com.johnstok.avalanche;


public class GeneratorRunnable<T> implements Runnable {

private final Generator<T> _generator;
private final Callback _callback;


/**
* Constructor.
*
* @param generator
* @param callback
*/
public GeneratorRunnable(final Generator<T> generator,
final Callback callback) {
_generator = generator;
_callback = callback;
}



/** {@inheritDoc} */
@Override
public void run() {
_generator.generate(_callback);
}

}
35 changes: 35 additions & 0 deletions src/java/main/com/johnstok/avalanche/NoOpCallback.java
@@ -0,0 +1,35 @@
/*-----------------------------------------------------------------------------
* Copyright © 2013 Keith Webster Johnston.
* All rights reserved.
*
* This file is part of avalanche.
*
* avalanche is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* avalanche is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with avalanche. If not, see <http://www.gnu.org/licenses/>.
*---------------------------------------------------------------------------*/
package com.johnstok.avalanche;


/**
* A callback with no action.
*
* @author Keith Webster Johnston.
*/
public class NoOpCallback
implements
Callback {

/** {@inheritDoc} */
@Override
public void onComplete() { /* No Op. */ }
}
35 changes: 35 additions & 0 deletions src/java/main/com/johnstok/avalanche/Workload.java
@@ -0,0 +1,35 @@
/*-----------------------------------------------------------------------------
* Copyright © 2013 Keith Webster Johnston.
* All rights reserved.
*
* This file is part of avalanche.
*
* avalanche is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* avalanche is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with avalanche. If not, see <http://www.gnu.org/licenses/>.
*---------------------------------------------------------------------------*/
package com.johnstok.avalanche;


import java.util.concurrent.Future;


/**
* A pattern of requests emitted via a generator.
*
* @author Keith Webster Johnston.
*/
public interface Workload {

Future<Void> execute(Generator<Void> command);

}

0 comments on commit adbbb43

Please sign in to comment.