Package net.sf.urlchecker.commands

Examples of net.sf.urlchecker.commands.StandardContext


    @Test
    public void testChainListeners() {
        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        // We need to add the listener to the context before we start. this test
        // class has been amended to implement the chain listener because the
        // invocation of the fireEvent method uses ClosureUtils from Apache
        // Commons and an in-line listener method is not accessible at run time.
        context.addListener(this);

        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));

            final long t = System.currentTimeMillis();
            resolver.process(context);
            final long tt = System.currentTimeMillis();
            LOGGER.info("Total Time:" + (tt - t) + "ms");
View Full Code Here


    @Test
    public void testGeneralMultiThreaded() {

        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        Set<Result> results;
        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));

            final long t = System.currentTimeMillis();
            results = resolver.process(context);
            final long tt = System.currentTimeMillis();
            LOGGER.info("Total Time:" + (tt - t) + "ms");
View Full Code Here

    public void testGeneralMultiThreaded1000() {
        for (int i = 0; i < 1000; i++) {
            final InputStream inStream = this.getClass().getClassLoader()
                    .getResourceAsStream("dummyData.xml");
            final Context context = new StandardContext();

            Set<Result> results;
            try {
                context.setSource(new InputStreamReader(inStream, "UTF-8"));

                final long t = System.currentTimeMillis();
                results = resolver.process(context);
                final long tt = System.currentTimeMillis();
                LOGGER.info("Total Time:" + (tt - t) + "ms");
View Full Code Here

    @Test
    public void testGeneralNewClientMultiThreaded() {

        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        Set<Result> results;
        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));

            final long t = System.currentTimeMillis();
            results = resolver2.process(context);
            final long tt = System.currentTimeMillis();
            LOGGER.info("Total Time:" + (tt - t) + "ms");
View Full Code Here

        resolver = new URLMatchCommand(new AddedCommand(new CheckUrlsCommand(
                null, builder.getMultithreadedClient())));

        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        Set<Result> results;
        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));

            System.currentTimeMillis();
            results = resolver.process(context);
            System.currentTimeMillis();
View Full Code Here

        }

        @Override
        public Set<Result> process(Context input) throws ConfigurationException {
            final Iterator<Result> iter = input.getResults().iterator();
            final Context tempCtx = new StandardContext(input);

            while (iter.hasNext()) {
                final Result res = iter.next();
                if (!AVOID.equals(res.getTarget())) {
                    tempCtx.getResults().add(res);
                }
            }
            return super.process(tempCtx);
        }
View Full Code Here

     */
    @Test
    public void testProcessHttpException() {
        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        final Command com = new URLMatchCommand(null);

        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));
            com.process(context);
        } catch (final ConfigurationException e1) {
            fail("ConfigurationException thrown while waiting for HttpException");
            LOGGER.error("Error occured in testProcess:", e1);
        } catch (final UnsupportedEncodingException e) {
            fail("Wrong Encoding thrown while waiting for HttpException");
            LOGGER.error("Error occured in testProcess:", e);
        }
        CheckUrlsCommand command;
        final HttpClient client = createNiceMock(HttpClient.class);
        try {
            expect(client.executeMethod(isA(HttpMethod.class))).andThrow(
                    new HttpException()).anyTimes();
            expect(client.getHttpConnectionManager()).andReturn(
                    new MultiThreadedHttpConnectionManager()).anyTimes();
            replay(client);

            command = new CheckUrlsCommand(null, client);
            command.process(context);
            assertEquals(14, context.getResults().size());
            assertNull(CollectionUtils.find(context.getResults(),
                    new Predicate() {

                        public boolean evaluate(final Object object) {
                            final Result r = (Result) object;
                            return r.isValid();
View Full Code Here

    @Test
    public void testProcessIOException() {
        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        final Command com = new URLMatchCommand(null);

        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));
            com.process(context);
        } catch (final ConfigurationException e1) {
            fail("ConfigurationException thrown ");
            LOGGER.error("Error occured in testProcess:", e1);
        } catch (final UnsupportedEncodingException e) {
            fail("Encoding exception thrown ");
            LOGGER.error("Error occured in testProcess:", e);
        }
        CheckUrlsCommand command;
        final HttpClient client = createNiceMock(HttpClient.class);
        try {
            expect(client.executeMethod(isA(HttpMethod.class))).andThrow(
                    new IOException()).anyTimes();
            expect(client.getHttpConnectionManager()).andReturn(
                    new MultiThreadedHttpConnectionManager()).anyTimes();
            replay(client);

            command = new CheckUrlsCommand(null, client);
            command.process(context);
            assertEquals(14, context.getResults().size());
            assertNull(CollectionUtils.find(context.getResults(),
                    new Predicate() {
                        public boolean evaluate(final Object object) {
                            final Result r = (Result) object;
                            return r.isValid();
                        }
View Full Code Here

    @Test
    public void testGeneralNewClientSingleThreaded() {
        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        Set<Result> results;
        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));
            // SingleThreaded try

            final long t = System.currentTimeMillis();
            results = resolver2.process(context);
            final long tt = System.currentTimeMillis();
View Full Code Here

    @Test
    public void testGeneralSinglethreaded() {
        final InputStream inStream = this.getClass().getClassLoader()
                .getResourceAsStream("dummyData.xml");
        final Context context = new StandardContext();

        Set<Result> results;
        try {
            context.setSource(new InputStreamReader(inStream, "UTF-8"));
            // SingleThreaded try

            final long t = System.currentTimeMillis();
            results = resolver1.process(context);
            final long tt = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of net.sf.urlchecker.commands.StandardContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.