CPD Results

The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
org/codehaus/plexus/PlexusJUnit4TestCase.java 195
org/codehaus/plexus/PlexusTestCase.java 175
}

    protected void release(Object component) throws Exception {
        getContainer().release(component);
    }

    // ----------------------------------------------------------------------
    // Helper methods for sub classes
    // ----------------------------------------------------------------------

    public static File getTestFile(String path) {
        return new File(getBasedir(), path);
    }

    public static File getTestFile(String basedir, String path) {
        File basedirFile = new File(basedir);

        if (!basedirFile.isAbsolute()) {
            basedirFile = getTestFile(basedir);
        }

        return new File(basedirFile, path);
    }

    public static String getTestPath(String path) {
        return getTestFile(path).getAbsolutePath();
    }

    public static String getTestPath(String basedir, String path) {
        return getTestFile(basedir, path).getAbsolutePath();
    }

    public static String getBasedir() {
        if (basedir != null) {
            return basedir;
        }

        basedir = System.getProperty("basedir");

        if (basedir == null) {
            basedir = new File("").getAbsolutePath();
        }

        return basedir;
    }

    public String getTestConfiguration() {
        return getTestConfiguration(getClass());
    }

    public static String getTestConfiguration(Class<?> clazz) {
        String s = clazz.getName().replace('.', '/');

        return s.substring(0, s.indexOf("$")) + ".xml";
    }
}
File Line
org/codehaus/plexus/PlexusJUnit4TestCase.java 47
org/codehaus/plexus/PlexusTestCase.java 42
protected void setupContainer() {
        // ----------------------------------------------------------------------------
        // Context Setup
        // ----------------------------------------------------------------------------

        DefaultContext context = new DefaultContext();

        context.put("basedir", getBasedir());

        customizeContext(context);

        boolean hasPlexusHome = context.contains("plexus.home");

        if (!hasPlexusHome) {
            File f = getTestFile("target/plexus-home");

            if (!f.isDirectory()) {
                f.mkdir();
            }

            context.put("plexus.home", f.getAbsolutePath());
        }

        // ----------------------------------------------------------------------------
        // Configuration
        // ----------------------------------------------------------------------------

        String config = getCustomConfigurationName();

        ContainerConfiguration containerConfiguration =
                new DefaultContainerConfiguration().setName("test").setContext(context.getContextData());

        if (config != null) {
            containerConfiguration.setContainerConfiguration(config);
        } else {
            String resource = getConfigurationName(null);

            containerConfiguration.setContainerConfiguration(resource);
        }

        customizeContainerConfiguration(containerConfiguration);

        try {
            container = new DefaultPlexusContainer(containerConfiguration);
        } catch (PlexusContainerException e) {
            e.printStackTrace();
            fail("Failed to create plexus container.");
        }
    }

    /**
     * Allow custom test case implementations do augment the default container configuration before
     * executing tests.
     *
     * @param containerConfiguration The configuration
     */
    protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {}

    protected void customizeContext(Context context) {}

    protected PlexusConfiguration customizeComponentConfiguration() {
        return null;
    }
File Line
org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java 71
org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java 107
Class childType = getClassForImplementationHint(null, childConfiguration, classLoader);

            // check if the name is a fully qualified classname

            if (childType == null && name.indexOf('.') > 0) {
                try {
                    childType = classLoader.loadClass(name);
                } catch (ClassNotFoundException e) {
                    // doesn't exist - continue processing
                }
            }

            if (childType == null) {
                // try to find the class in the package of the baseType
                // (which is the component being configured)

                String baseTypeName = baseType.getName();

                int lastDot = baseTypeName.lastIndexOf('.');

                String className;

                if (lastDot == -1) {
                    className = name;
                } else {
                    String basePackage = baseTypeName.substring(0, lastDot);
                    className = basePackage + "." + StringUtils.capitalizeFirstLetter(name);
                }

                try {
                    childType = classLoader.loadClass(className);
                } catch (ClassNotFoundException e) {