// Path: chili/src/test/java/me/defying/chili/memoize/MemoizeTestService.java
// public class MemoizeTestService {
// 
//     @Memoize
//     public Wrap simple(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(size = 3)
//     public Wrap keep3(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(time = 1, unit = TimeUnit.SECONDS)
//     public Wrap keep1Sec(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(size = 3, time = 1, unit = TimeUnit.SECONDS)
//     public Wrap keep3for1Sec(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(statistics = true)
//     public Wrap statistics(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap exception(final String x) throws Exception {
//         throw new IOException();
//     }
// 
//     @Memoize
//     public Wrap noArgs() {
//         return new Wrap(null);
//     }
// 
//     @Memoize
//     public Wrap twoArgs(final String x, final String y) {
//         return new Wrap(x + y);
//     }
// 
//     @Memoize
//     public Wrap varArgs(final String... x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap mixedVarArgs(final String x, final String... y) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap primitiveVarArgs(final int... x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(statistics = true)
//     public Wrap nullResult(final String x) {
//         return null;
//     }
// 
//     @Memoize
//     public Wrap array(final String[] x) {
//         return new Wrap(x);
//     }
// }
// 
// Path: chili/src/test/java/me/defying/chili/memoize/Wrap.java
// public class Wrap {
//     private final Object value;
// 
//     public Wrap(final Object value) {
//         this.value = value;
//     }
// 
//     public Object getValue() {
//         return value;
//     }
// }
// 
// Path: chili/src/test/java/me/defying/chili/util/ChiliTest.java
// public abstract class ChiliTest {
// 
//     // output stream that will hold log entries
//     protected static final ByteArrayOutputStream LOG = new ByteArrayOutputStream();
// 
//     // pattern format to be compared with log entries
//     protected final String format = "^DEBUG Invoked %s\\(%s\\) => %s in [0-9]+ ms\\.$";
// 
//     @BeforeClass
//     public static void setUpBeforeClass() {
//         // logs produced will be in the format "LEVEL Message."
//         System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "trace");
//         System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
//         System.setProperty("org.slf4j.simpleLogger.showLogName", "false");
// 
//         // redefine error output stream to something we may read
//         // slf4j-simple logger writes log to System.err by default
//         System.setErr(new PrintStream(LOG));
//     }
// 
//     @Before
//     public void setUp() {
//         final Injector injector = Guice.createInjector(new ChiliModule());
//         injector.injectMembers(this);
// 
//         // reset log before test
//         LOG.reset();
//     }
// 
//     //
//     // helpers
//     //
// 
//     /**
//      * Asserts that a string matches a regular expression.
//      * If it doesn't it throws an AssertionError without a message.
//      *
//      * @param pattern the regular expression
//      * @param string the string to be checked against the pattern
//      */
//     protected void assertMatches(final String pattern, final String string) {
//         assertTrue(pattern.matches(string));
//     }
// }


import me.defying.chili.memoize.MemoizeTestService;
import me.defying.chili.memoize.Wrap;
import me.defying.chili.util.ChiliTest;
import java.io.IOException;
import com.google.inject.Inject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
/*
 * The MIT License (MIT)
 * Copyright (c) 2015 Rafael Marmelo
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package me.defying.chili;




/**
 * Test class for {@code Memoize} annotation.
 *
 * @author Rafael Marmelo
 * @since 1.0
 */
public class MemoizeTest extends ChiliTest {
    @Inject
    private MemoizeTestService service;

    /**
     * Test simple memoization, without any arguments.
     */
    @Test
    public void simpleTest() {
        // different arguments yield different results
// Path: chili/src/test/java/me/defying/chili/memoize/MemoizeTestService.java
// public class MemoizeTestService {
// 
//     @Memoize
//     public Wrap simple(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(size = 3)
//     public Wrap keep3(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(time = 1, unit = TimeUnit.SECONDS)
//     public Wrap keep1Sec(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(size = 3, time = 1, unit = TimeUnit.SECONDS)
//     public Wrap keep3for1Sec(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(statistics = true)
//     public Wrap statistics(final String x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap exception(final String x) throws Exception {
//         throw new IOException();
//     }
// 
//     @Memoize
//     public Wrap noArgs() {
//         return new Wrap(null);
//     }
// 
//     @Memoize
//     public Wrap twoArgs(final String x, final String y) {
//         return new Wrap(x + y);
//     }
// 
//     @Memoize
//     public Wrap varArgs(final String... x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap mixedVarArgs(final String x, final String... y) {
//         return new Wrap(x);
//     }
// 
//     @Memoize
//     public Wrap primitiveVarArgs(final int... x) {
//         return new Wrap(x);
//     }
// 
//     @Memoize(statistics = true)
//     public Wrap nullResult(final String x) {
//         return null;
//     }
// 
//     @Memoize
//     public Wrap array(final String[] x) {
//         return new Wrap(x);
//     }
// }
// 
// Path: chili/src/test/java/me/defying/chili/memoize/Wrap.java
// public class Wrap {
//     private final Object value;
// 
//     public Wrap(final Object value) {
//         this.value = value;
//     }
// 
//     public Object getValue() {
//         return value;
//     }
// }
// 
// Path: chili/src/test/java/me/defying/chili/util/ChiliTest.java
// public abstract class ChiliTest {
// 
//     // output stream that will hold log entries
//     protected static final ByteArrayOutputStream LOG = new ByteArrayOutputStream();
// 
//     // pattern format to be compared with log entries
//     protected final String format = "^DEBUG Invoked %s\\(%s\\) => %s in [0-9]+ ms\\.$";
// 
//     @BeforeClass
//     public static void setUpBeforeClass() {
//         // logs produced will be in the format "LEVEL Message."
//         System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "trace");
//         System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
//         System.setProperty("org.slf4j.simpleLogger.showLogName", "false");
// 
//         // redefine error output stream to something we may read
//         // slf4j-simple logger writes log to System.err by default
//         System.setErr(new PrintStream(LOG));
//     }
// 
//     @Before
//     public void setUp() {
//         final Injector injector = Guice.createInjector(new ChiliModule());
//         injector.injectMembers(this);
// 
//         // reset log before test
//         LOG.reset();
//     }
// 
//     //
//     // helpers
//     //
// 
//     /**
//      * Asserts that a string matches a regular expression.
//      * If it doesn't it throws an AssertionError without a message.
//      *
//      * @param pattern the regular expression
//      * @param string the string to be checked against the pattern
//      */
//     protected void assertMatches(final String pattern, final String string) {
//         assertTrue(pattern.matches(string));
//     }
// }


// Path: chili/src/test/java/me/defying/chili/MemoizeTest.java
import me.defying.chili.memoize.MemoizeTestService;
import me.defying.chili.memoize.Wrap;
import me.defying.chili.util.ChiliTest;
import java.io.IOException;
import com.google.inject.Inject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;

/*
 * The MIT License (MIT)
 * Copyright (c) 2015 Rafael Marmelo
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package me.defying.chili;




/**
 * Test class for {@code Memoize} annotation.
 *
 * @author Rafael Marmelo
 * @since 1.0
 */
public class MemoizeTest extends ChiliTest {
    @Inject
    private MemoizeTestService service;

    /**
     * Test simple memoization, without any arguments.
     */
    @Test
    public void simpleTest() {
        // different arguments yield different results
        final Wrap a = service.simple("a");