Package org.drools.guvnor.client.rpc

Examples of org.drools.guvnor.client.rpc.MavenArtifact


public class FileDownloadUtilTest {

    @Test
    public void testDownloadRemoteRepository() throws IOException {
        final String jbossReleaseRepo = "http://repository.jboss.org/nexus/content/repositories/releases/";
        final MavenArtifact artifact = new MavenArtifact( "org.drools:knowledge-api:jar:5.3.1.Final:compile" );

        final HttpURLConnection connection = (HttpURLConnection) new URL( artifact.toURL( jbossReleaseRepo ) ).openConnection();
        connection.setRequestMethod( "HEAD" );
        try {
            final int responseCode = connection.getResponseCode();
            if ( responseCode != 200 ) {
                //won't fail if you can't get access to external resource
                return;
            }
        } catch ( UnknownHostException ex ) {
            //won't fail if you can't reach jboss repo
            return;
        }

        final String finalFileName = System.getProperty( "java.io.tmpdir" ) + "/" + artifact.toFileName();
        final File result = downloadFile( artifact.toURL( jbossReleaseRepo ),
                                          finalFileName );

        assertNotNull( result );
        assertEquals( "47c645f0f605790b5d505c7d2f27b745",
                      md5Hex( getBytes( result ) ) );
View Full Code Here


    }

    @Test
    public void testLocalFile() throws IOException {
        final String localMavenRepo = getURLtoLocalUserMavenRepo();
        final MavenArtifact artifact = new MavenArtifact( "org.antlr:antlr-runtime:jar:3.3:compile" );

        final String finalFileName = System.getProperty( "java.io.tmpdir" ) + "/" + artifact.toFileName();

        final File result = downloadFile( artifact.toURL( localMavenRepo ),
                                          finalFileName );

        assertNotNull( result );
        assertEquals( "ccd65b08cbc9b7e90b9facd4d125a133c6f87228",
                      shaHex( getBytes( result ) ) );
View Full Code Here

    }

    @Test
    public void testNonExistentFile() throws IOException {
        final String localMavenRepo = getURLtoLocalUserMavenRepo();
        final MavenArtifact artifact = new MavenArtifact( "org.antlr:antlr-some:jar:3.3:compile" );

        final String finalFileName = System.getProperty( "java.io.tmpdir" ) + "/" + artifact.toFileName();

        final File result = downloadFile( artifact.toURL( localMavenRepo ),
                                          finalFileName );

        assertNull( result );
    }
View Full Code Here

        assertNotNull(result.getV1());
        assertNotNull(result.getV2());
        assertEquals(1, result.getV1().size());
        assertEquals(1, result.getV2().size());

        result.getV1().iterator().next().equals(new MavenArtifact("org.drools:knowledge-api:jar:5.5.0-SNAPSHOT:compile"));
        result.getV2().iterator().next().equals(new MavenArtifact("org.drools:knowledge-api:jar:5.5.0-SNAPSHOT:compile"));
    }
View Full Code Here

        assertNotNull(result.getV1());
        assertNotNull(result.getV2());
        assertEquals(2, result.getV1().size());
        assertEquals(2, result.getV2().size());

        result.getV1().iterator().next().equals(new MavenArtifact("org.drools:knowledge-api:jar:5.5.0-SNAPSHOT:compile"));
    }
View Full Code Here

        assertNotNull(result.getV2());
        assertEquals(8, result.getV2().size());
        assertEquals(2, result.getV1().size());

        for (final MavenArtifact artifact : result.getV1()) {
            if (artifact.equals(new MavenArtifact("org.drools:drools-camel:jar:5.5.0-SNAPSHOT:compile"))) {
                validateDroolsCamel(artifact);
            } else if (artifact.equals(new MavenArtifact("org.apache.camel:camel-core:jar:2.4.0:compile"))) {
                assertFalse(artifact.hasChild());
            } else {
                fail();
            }
        }
View Full Code Here

    private void validateDroolsCamel(final MavenArtifact artifact) {
        assertEquals(2, artifact.getChild().size());

        final Iterator<MavenArtifact> droolsCamelChildIterator =  artifact.getChild().iterator();
        final MavenArtifact shouldBeSpringAOP = droolsCamelChildIterator.next();

        assertEquals(new MavenArtifact("org.springframework:spring-aop:jar:2.5.6:compile"), shouldBeSpringAOP);
        assertEquals(0, shouldBeSpringAOP.getChild().size());

        final MavenArtifact shouldBeCxfRtFrontendJaxws = droolsCamelChildIterator.next();

        assertEquals(new MavenArtifact("org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.4.4:compile"), shouldBeCxfRtFrontendJaxws);
        assertEquals(2, shouldBeCxfRtFrontendJaxws.getChild().size());

        final Iterator<MavenArtifact> cxfRtFrontendJaxwsChildIterator =  shouldBeCxfRtFrontendJaxws.getChild().iterator();
        final MavenArtifact shouldXmlResolver = cxfRtFrontendJaxwsChildIterator.next();
        assertEquals(new MavenArtifact("xml-resolver:xml-resolver:jar:1.2:compile"), shouldXmlResolver);
        assertEquals(2, shouldXmlResolver.getChild().size());

        final Iterator<MavenArtifact> xmlResolverChildIterator =  shouldXmlResolver.getChild().iterator();

        final MavenArtifact shouldCxfToolsCommon = xmlResolverChildIterator.next();
        assertEquals(new MavenArtifact("org.apache.cxf:cxf-tools-common:jar:2.4.4:compile"), shouldCxfToolsCommon);
        assertEquals(0, shouldCxfToolsCommon.getChild().size());

        final MavenArtifact shouldcxfRtDatabindingJaxb = xmlResolverChildIterator.next();
        assertEquals(new MavenArtifact("org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.4.4:compile"), shouldcxfRtDatabindingJaxb);
        assertEquals(0, shouldcxfRtDatabindingJaxb.getChild().size());


        final MavenArtifact shouldJbossSomething = cxfRtFrontendJaxwsChildIterator.next();
        assertEquals(new MavenArtifact("org.jboss:something:jar:2.4.4:compile"), shouldJbossSomething);
        assertEquals(0, shouldJbossSomething.getChild().size());
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.rpc.MavenArtifact

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.