Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2010 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.callbackparams.junit3;

Author(s):
Henrik Kaipe
See also:
CallbackTestrunWrapper
    private final Class rebytedTestClass;

    
Wrapper for a byte-code modified version of class CallbackTestrunWrapper, which have had its name changed to that of rebytedTestClass.
    private final ClassWrapper classWrapper;
    TestInstanceFactory(Class rebytedTestClass) {
        this. = rebytedTestClass;
        this. = TemplateBasedClassBuilder
                .newBuilder(getClass().getClassLoader(),
                            CallbackTestrunWrapper.class)
                .setNewClassName(rebytedTestClass.getName())
                .wrapClass();
    }
    TestCase newTestrun(String testNameObject testRunCallbackRecord) {
        return newTestrun(extractNoargTestMethodName(testName),
                extractActualTestMethodName(testName), testRunCallbackRecord);
    }
    TestCase newTestrun(String noargTestMethodNameString actualTestMethodName,
            Object testRunCallbackRecord) {
        return (TestCase.newInstance(new Object[] {
            noargTestMethodNameactualTestMethodName,
            toCollection(testRunCallbackRecord)
        });
    }
    private static Collection toCollection(Object testRunCallbackRecord) {
        if (testRunCallbackRecord instanceof Collection) {
            return (Collection)testRunCallbackRecord;
        } else if (testRunCallbackRecord instanceof Object[]) {
            return Arrays.asList((Object[])testRunCallbackRecord);
        } else {
            throw new AssertionError(
                    "Not a callback record: " + testRunCallbackRecord);
        }
    }
    private static String extractNoargTestMethodName(String testName) {
        int dashIndex = testName.indexOf('-');
        return -1 == dashIndex ? testName : testName.substring(0, dashIndex);
    }
    private static String extractActualTestMethodName(String testName) {
        return testName.substring(testName.indexOf('-') + 1);
    }
    static String asTestName(Map.Entry/*String,String*/ proxyMethodEntr) {
        return proxyMethodEntr.getKey() + "-" + proxyMethodEntr.getValue();
    }
New to GrepCode? Check out our FAQ X