github.phpd.cn/thought-machine/please@v12.2.0+incompatible/tools/please_maven/maven/maven_test.go (about)

     1  // This is a more or less end-to-end test with a fake web server on the whole package
     2  // as a black box. Expected outputs are taken from the older version of the tool, so
     3  // may not be 100% correct, but empirically they are pretty reasonable and so are
     4  // a good place to start for testing the new version.
     5  
     6  package maven
     7  
     8  import (
     9  	"net/http"
    10  	"net/http/httptest"
    11  	"os"
    12  	"strings"
    13  	"testing"
    14  
    15  	"github.com/stretchr/testify/assert"
    16  
    17  	"cli"
    18  	"sort"
    19  )
    20  
    21  // concurrency is the number of concurrent goroutines we use during the test.
    22  // TODO(peterebden): Make this configurable so we test with different numbers.
    23  const concurrency = 10
    24  
    25  // Packages that we exclude (they should be test-only dependencies but aren't marked as such)
    26  var excludes = []string{"junit", "easymock", "easymockclassextension"}
    27  
    28  var server *httptest.Server
    29  var errorProne, grpc []Artifact
    30  
    31  func TestAllDependenciesGRPC(t *testing.T) {
    32  	f := NewFetch([]string{server.URL}, excludes, nil)
    33  	expected := []string{
    34  		"io.grpc:grpc-auth:1.1.2:src:BSD 3-Clause",
    35  		"io.grpc:grpc-core:1.1.2:src:BSD 3-Clause",
    36  		"com.google.guava:guava:20.0:src:The Apache Software License, Version 2.0",
    37  		"com.google.errorprone:error_prone_annotations:2.0.11:src:Apache 2.0",
    38  		"com.google.code.findbugs:jsr305:3.0.0:src:The Apache Software License, Version 2.0",
    39  		"io.grpc:grpc-context:1.1.2:src:BSD 3-Clause",
    40  		"com.google.instrumentation:instrumentation-api:0.3.0:src:Apache License, Version 2.0",
    41  		"com.google.auth:google-auth-library-credentials:0.4.0:src:BSD New license",
    42  		"io.grpc:grpc-netty:1.1.2:src:BSD 3-Clause",
    43  		"io.netty:netty-codec-http2:4.1.8.Final:src:Apache License, Version 2.0",
    44  		"io.netty:netty-codec-http:4.1.8.Final:src:Apache License, Version 2.0",
    45  		"io.netty:netty-codec:4.1.8.Final:src:Apache License, Version 2.0",
    46  		"io.netty:netty-transport:4.1.8.Final:src:Apache License, Version 2.0",
    47  		"io.netty:netty-buffer:4.1.8.Final:src:Apache License, Version 2.0",
    48  		"io.netty:netty-common:4.1.8.Final:src:Apache License, Version 2.0",
    49  		"io.netty:netty-resolver:4.1.8.Final:src:Apache License, Version 2.0",
    50  		"io.netty:netty-handler:4.1.8.Final:src:Apache License, Version 2.0",
    51  		"com.google.code.gson:gson:2.7:no_src:Apache 2.0",
    52  		"io.netty:netty-handler-proxy:4.1.8.Final:src:Apache License, Version 2.0",
    53  		"io.netty:netty-codec-socks:4.1.8.Final:src:Apache License, Version 2.0",
    54  		"io.grpc:grpc-okhttp:1.1.2:src:BSD 3-Clause",
    55  		"com.squareup.okhttp:okhttp:2.5.0:src:Apache 2.0",
    56  		"com.squareup.okio:okio:1.6.0:no_src:Apache 2.0",
    57  		"io.grpc:grpc-protobuf:1.1.2:src:BSD 3-Clause",
    58  		"com.google.protobuf:protobuf-java:3.1.0:src:New BSD license",
    59  		"com.google.protobuf:protobuf-java-util:3.1.0:src:New BSD license",
    60  		"io.grpc:grpc-protobuf-lite:1.1.2:src:BSD 3-Clause",
    61  		"com.google.protobuf:protobuf-lite:3.0.1:src:New BSD license",
    62  		"io.grpc:grpc-protobuf-nano:1.1.2:src:BSD 3-Clause",
    63  		"com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5:src:New BSD license",
    64  		"io.grpc:grpc-stub:1.1.2:src:BSD 3-Clause",
    65  	}
    66  	actual := AllDependencies(f, grpc, concurrency, false, false)
    67  	assert.Equal(t, expected, actual)
    68  }
    69  
    70  func TestAllDependenciesGRPCWithIndent(t *testing.T) {
    71  	f := NewFetch([]string{server.URL}, excludes, nil)
    72  	expected := []string{
    73  		"io.grpc:grpc-auth:1.1.2:src:BSD 3-Clause",
    74  		"  io.grpc:grpc-core:1.1.2:src:BSD 3-Clause",
    75  		"    com.google.guava:guava:20.0:src:The Apache Software License, Version 2.0",
    76  		"    com.google.errorprone:error_prone_annotations:2.0.11:src:Apache 2.0",
    77  		"    com.google.code.findbugs:jsr305:3.0.0:src:The Apache Software License, Version 2.0",
    78  		"    io.grpc:grpc-context:1.1.2:src:BSD 3-Clause",
    79  		"    com.google.instrumentation:instrumentation-api:0.3.0:src:Apache License, Version 2.0",
    80  		"  com.google.auth:google-auth-library-credentials:0.4.0:src:BSD New license",
    81  		"io.grpc:grpc-netty:1.1.2:src:BSD 3-Clause",
    82  		"  io.netty:netty-codec-http2:4.1.8.Final:src:Apache License, Version 2.0",
    83  		"    io.netty:netty-codec-http:4.1.8.Final:src:Apache License, Version 2.0",
    84  		"      io.netty:netty-codec:4.1.8.Final:src:Apache License, Version 2.0",
    85  		"        io.netty:netty-transport:4.1.8.Final:src:Apache License, Version 2.0",
    86  		"          io.netty:netty-buffer:4.1.8.Final:src:Apache License, Version 2.0",
    87  		"            io.netty:netty-common:4.1.8.Final:src:Apache License, Version 2.0",
    88  		"          io.netty:netty-resolver:4.1.8.Final:src:Apache License, Version 2.0",
    89  		"    io.netty:netty-handler:4.1.8.Final:src:Apache License, Version 2.0",
    90  		"    com.google.code.gson:gson:2.7:no_src:Apache 2.0",
    91  		"  io.netty:netty-handler-proxy:4.1.8.Final:src:Apache License, Version 2.0",
    92  		"    io.netty:netty-codec-socks:4.1.8.Final:src:Apache License, Version 2.0",
    93  		"io.grpc:grpc-okhttp:1.1.2:src:BSD 3-Clause",
    94  		"  com.squareup.okhttp:okhttp:2.5.0:src:Apache 2.0",
    95  		"    com.squareup.okio:okio:1.6.0:no_src:Apache 2.0",
    96  		"io.grpc:grpc-protobuf:1.1.2:src:BSD 3-Clause",
    97  		"  com.google.protobuf:protobuf-java:3.1.0:src:New BSD license",
    98  		"  com.google.protobuf:protobuf-java-util:3.1.0:src:New BSD license",
    99  		"  io.grpc:grpc-protobuf-lite:1.1.2:src:BSD 3-Clause",
   100  		"    com.google.protobuf:protobuf-lite:3.0.1:src:New BSD license",
   101  		"io.grpc:grpc-protobuf-nano:1.1.2:src:BSD 3-Clause",
   102  		"  com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5:src:New BSD license",
   103  		"io.grpc:grpc-stub:1.1.2:src:BSD 3-Clause",
   104  	}
   105  	actual := AllDependencies(f, grpc, concurrency, true, false)
   106  	assert.Equal(t, expected, actual)
   107  }
   108  
   109  func TestAllDependenciesErrorProne(t *testing.T) {
   110  	f := NewFetch([]string{server.URL}, nil, nil)
   111  	expected := []string{
   112  		"com.google.errorprone:error_prone_annotation:2.0.14:src:Apache 2.0",
   113  		"com.google.guava:guava:19.0:no_src:The Apache Software License, Version 2.0",
   114  		"com.google.errorprone:error_prone_check_api:2.0.14:src:Apache 2.0",
   115  		"com.google.code.findbugs:jsr305:3.0.0:src:The Apache Software License, Version 2.0",
   116  		"org.checkerframework:dataflow:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   117  		"org.checkerframework:javacutil:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   118  		"com.google.errorprone:javac:1.9.0-dev-r2973-2:src:GNU General Public License, version 2, with the Classpath Exception",
   119  		"com.googlecode.java-diff-utils:diffutils:1.3.0:src:The Apache Software License, Version 2.0",
   120  		"com.google.auto.value:auto-value:1.1:src:Apache 2.0",
   121  		"com.google.errorprone:error_prone_annotations:2.0.14:no_src:Apache 2.0",
   122  		"com.github.stephenc.jcip:jcip-annotations:1.0-1:src:Apache License, Version 2.0",
   123  		"org.pcollections:pcollections:2.1.2:src:The MIT License",
   124  		"com.google.auto:auto-common:0.7:src:Apache 2.0",
   125  		"com.google.code.findbugs:jFormatString:3.0.0:src:GNU Lesser Public License",
   126  	}
   127  	actual := AllDependencies(f, errorProne, concurrency, false, false)
   128  	assert.Equal(t, expected, actual)
   129  }
   130  
   131  func TestAllDependenciesErrorProneWithIndent(t *testing.T) {
   132  	f := NewFetch([]string{server.URL}, nil, nil)
   133  	expected := []string{
   134  		"com.google.errorprone:error_prone_annotation:2.0.14:src:Apache 2.0",
   135  		"  com.google.guava:guava:19.0:no_src:The Apache Software License, Version 2.0",
   136  		"com.google.errorprone:error_prone_check_api:2.0.14:src:Apache 2.0",
   137  		"  com.google.code.findbugs:jsr305:3.0.0:src:The Apache Software License, Version 2.0",
   138  		"  org.checkerframework:dataflow:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   139  		"    org.checkerframework:javacutil:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   140  		"  com.google.errorprone:javac:1.9.0-dev-r2973-2:src:GNU General Public License, version 2, with the Classpath Exception",
   141  		"  com.googlecode.java-diff-utils:diffutils:1.3.0:src:The Apache Software License, Version 2.0",
   142  		"  com.google.auto.value:auto-value:1.1:src:Apache 2.0",
   143  		"  com.google.errorprone:error_prone_annotations:2.0.14:no_src:Apache 2.0",
   144  		"com.github.stephenc.jcip:jcip-annotations:1.0-1:src:Apache License, Version 2.0",
   145  		"org.pcollections:pcollections:2.1.2:src:The MIT License",
   146  		"com.google.auto:auto-common:0.7:src:Apache 2.0",
   147  		"com.google.code.findbugs:jFormatString:3.0.0:src:GNU Lesser Public License",
   148  	}
   149  	actual := AllDependencies(f, errorProne, concurrency, true, false)
   150  	assert.Equal(t, expected, actual)
   151  }
   152  
   153  func TestAllDependenciesTogether(t *testing.T) {
   154  	f := NewFetch([]string{server.URL}, excludes, nil)
   155  	expected := []string{
   156  		"com.google.errorprone:error_prone_annotation:2.0.14:src:Apache 2.0",
   157  		"com.google.guava:guava:20.0:src:The Apache Software License, Version 2.0",
   158  		"com.google.errorprone:error_prone_check_api:2.0.14:src:Apache 2.0",
   159  		"com.google.code.findbugs:jsr305:3.0.0:src:The Apache Software License, Version 2.0",
   160  		"org.checkerframework:dataflow:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   161  		"org.checkerframework:javacutil:1.8.10:src:GNU General Public License, version 2 (GPL2), with the classpath exception|The MIT License",
   162  		"com.google.errorprone:javac:1.9.0-dev-r2973-2:src:GNU General Public License, version 2, with the Classpath Exception",
   163  		"com.googlecode.java-diff-utils:diffutils:1.3.0:src:The Apache Software License, Version 2.0",
   164  		"com.google.auto.value:auto-value:1.1:src:Apache 2.0",
   165  		"com.google.errorprone:error_prone_annotations:2.0.14:no_src:Apache 2.0",
   166  		"com.github.stephenc.jcip:jcip-annotations:1.0-1:src:Apache License, Version 2.0",
   167  		"org.pcollections:pcollections:2.1.2:src:The MIT License",
   168  		"com.google.auto:auto-common:0.7:src:Apache 2.0",
   169  		"com.google.code.findbugs:jFormatString:3.0.0:src:GNU Lesser Public License",
   170  		"io.grpc:grpc-auth:1.1.2:src:BSD 3-Clause",
   171  		"io.grpc:grpc-core:1.1.2:src:BSD 3-Clause",
   172  		"io.grpc:grpc-context:1.1.2:src:BSD 3-Clause",
   173  		"com.google.instrumentation:instrumentation-api:0.3.0:src:Apache License, Version 2.0",
   174  		"com.google.auth:google-auth-library-credentials:0.4.0:src:BSD New license",
   175  		"io.grpc:grpc-netty:1.1.2:src:BSD 3-Clause",
   176  		"io.netty:netty-codec-http2:4.1.8.Final:src:Apache License, Version 2.0",
   177  		"io.netty:netty-codec-http:4.1.8.Final:src:Apache License, Version 2.0",
   178  		"io.netty:netty-codec:4.1.8.Final:src:Apache License, Version 2.0",
   179  		"io.netty:netty-transport:4.1.8.Final:src:Apache License, Version 2.0",
   180  		"io.netty:netty-buffer:4.1.8.Final:src:Apache License, Version 2.0",
   181  		"io.netty:netty-common:4.1.8.Final:src:Apache License, Version 2.0",
   182  		"io.netty:netty-resolver:4.1.8.Final:src:Apache License, Version 2.0",
   183  		"io.netty:netty-handler:4.1.8.Final:src:Apache License, Version 2.0",
   184  		"com.google.code.gson:gson:2.7:no_src:Apache 2.0",
   185  		"io.netty:netty-handler-proxy:4.1.8.Final:src:Apache License, Version 2.0",
   186  		"io.netty:netty-codec-socks:4.1.8.Final:src:Apache License, Version 2.0",
   187  		"io.grpc:grpc-okhttp:1.1.2:src:BSD 3-Clause",
   188  		"com.squareup.okhttp:okhttp:2.5.0:src:Apache 2.0",
   189  		"com.squareup.okio:okio:1.6.0:no_src:Apache 2.0",
   190  		"io.grpc:grpc-protobuf:1.1.2:src:BSD 3-Clause",
   191  		"com.google.protobuf:protobuf-java:3.1.0:src:New BSD license",
   192  		"com.google.protobuf:protobuf-java-util:3.1.0:src:New BSD license",
   193  		"io.grpc:grpc-protobuf-lite:1.1.2:src:BSD 3-Clause",
   194  		"com.google.protobuf:protobuf-lite:3.0.1:src:New BSD license",
   195  		"io.grpc:grpc-protobuf-nano:1.1.2:src:BSD 3-Clause",
   196  		"com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5:src:New BSD license",
   197  		"io.grpc:grpc-stub:1.1.2:src:BSD 3-Clause",
   198  	}
   199  	both := append(errorProne, grpc...)
   200  	actual := AllDependencies(f, both, concurrency, false, false)
   201  	assert.Equal(t, expected, actual)
   202  }
   203  
   204  func TestBuildRulesErrorProne(t *testing.T) {
   205  	const expected = `maven_jar(
   206      name = 'jsr305',
   207      id = 'com.google.code.findbugs:jsr305:3.0.0',
   208      hash = '',
   209  )
   210  
   211  maven_jar(
   212      name = 'error_prone_annotations',
   213      id = 'com.google.errorprone:error_prone_annotations:2.0.14',
   214      hash = '',
   215  )
   216  
   217  maven_jar(
   218      name = 'guava',
   219      id = 'com.google.guava:guava:19.0',
   220      hash = '',
   221  )
   222  
   223  maven_jar(
   224      name = 'error_prone_annotation',
   225      id = 'com.google.errorprone:error_prone_annotation:2.0.14',
   226      hash = '',
   227      deps = [
   228          ':guava',
   229      ],
   230  )
   231  
   232  maven_jar(
   233      name = 'javacutil',
   234      id = 'org.checkerframework:javacutil:1.8.10',
   235      hash = '',
   236  )
   237  
   238  maven_jar(
   239      name = 'dataflow',
   240      id = 'org.checkerframework:dataflow:1.8.10',
   241      hash = '',
   242      deps = [
   243          ':javacutil',
   244      ],
   245  )
   246  
   247  maven_jar(
   248      name = 'javac',
   249      id = 'com.google.errorprone:javac:1.9.0-dev-r2973-2',
   250      hash = '',
   251  )
   252  
   253  maven_jar(
   254      name = 'diffutils',
   255      id = 'com.googlecode.java-diff-utils:diffutils:1.3.0',
   256      hash = '',
   257  )
   258  
   259  maven_jar(
   260      name = 'auto-value',
   261      id = 'com.google.auto.value:auto-value:1.1',
   262      hash = '',
   263  )
   264  
   265  maven_jar(
   266      name = 'error_prone_check_api',
   267      id = 'com.google.errorprone:error_prone_check_api:2.0.14',
   268      hash = '',
   269      deps = [
   270          ':error_prone_annotation',
   271          ':jsr305',
   272          ':dataflow',
   273          ':javac',
   274          ':diffutils',
   275          ':auto-value',
   276          ':error_prone_annotations',
   277      ],
   278  )
   279  
   280  maven_jar(
   281      name = 'jcip-annotations',
   282      id = 'com.github.stephenc.jcip:jcip-annotations:1.0-1',
   283      hash = '',
   284  )
   285  
   286  maven_jar(
   287      name = 'pcollections',
   288      id = 'org.pcollections:pcollections:2.1.2',
   289      hash = '',
   290  )
   291  
   292  maven_jar(
   293      name = 'auto-common',
   294      id = 'com.google.auto:auto-common:0.7',
   295      hash = '',
   296      deps = [
   297          ':guava',
   298      ],
   299  )
   300  
   301  maven_jar(
   302      name = 'jFormatString',
   303      id = 'com.google.code.findbugs:jFormatString:3.0.0',
   304      hash = '',
   305  )
   306  
   307  maven_jar(
   308      name = 'error_prone_core',
   309      id = 'com.google.errorprone:error_prone_core:2.0.14',
   310      hash = '',
   311      deps = [
   312          ':error_prone_annotation',
   313          ':error_prone_check_api',
   314          ':jcip-annotations',
   315          ':pcollections',
   316          ':guava',
   317          ':auto-common',
   318          ':jFormatString',
   319          ':jsr305',
   320          ':dataflow',
   321          ':javac',
   322          ':auto-value',
   323          ':error_prone_annotations',
   324      ],
   325  )`
   326  	f := NewFetch([]string{server.URL}, nil, nil)
   327  	actual := AllDependencies(f, errorProne, concurrency, false, true)
   328  	// The rules come out in a different order to the original tool; this doesn't
   329  	// really matter since order of rules in a BUILD file is unimportant.
   330  	expectedSlice := strings.Split(expected, "\n\n")
   331  	sort.Strings(actual)
   332  	sort.Strings(expectedSlice)
   333  	assert.Equal(t, expectedSlice, actual)
   334  }
   335  
   336  func TestBuildRulesGRPC(t *testing.T) {
   337  	const expected = `maven_jar(
   338      name = 'guava',
   339      id = 'com.google.guava:guava:20.0',
   340      hash = '',
   341  )
   342  
   343  maven_jar(
   344      name = 'error_prone_annotations',
   345      id = 'com.google.errorprone:error_prone_annotations:2.0.11',
   346      hash = '',
   347  )
   348  
   349  maven_jar(
   350      name = 'jsr305',
   351      id = 'com.google.code.findbugs:jsr305:3.0.0',
   352      hash = '',
   353  )
   354  
   355  maven_jar(
   356      name = 'grpc-context',
   357      id = 'io.grpc:grpc-context:1.1.2',
   358      hash = '',
   359  )
   360  
   361  maven_jar(
   362      name = 'instrumentation-api',
   363      id = 'com.google.instrumentation:instrumentation-api:0.3.0',
   364      hash = '',
   365      deps = [
   366          ':jsr305',
   367      ],
   368  )
   369  
   370  maven_jar(
   371      name = 'grpc-core',
   372      id = 'io.grpc:grpc-core:1.1.2',
   373      hash = '',
   374      deps = [
   375          ':guava',
   376          ':error_prone_annotations',
   377          ':jsr305',
   378          ':grpc-context',
   379          ':instrumentation-api',
   380      ],
   381  )
   382  
   383  maven_jar(
   384      name = 'google-auth-library-credentials',
   385      id = 'com.google.auth:google-auth-library-credentials:0.4.0',
   386      hash = '',
   387  )
   388  
   389  maven_jar(
   390      name = 'grpc-auth',
   391      id = 'io.grpc:grpc-auth:1.1.2',
   392      hash = '',
   393      deps = [
   394          ':grpc-core',
   395          ':google-auth-library-credentials',
   396      ],
   397  )
   398  
   399  maven_jar(
   400      name = 'netty-common',
   401      id = 'io.netty:netty-common:4.1.8.Final',
   402      hash = '',
   403  )
   404  
   405  maven_jar(
   406      name = 'netty-buffer',
   407      id = 'io.netty:netty-buffer:4.1.8.Final',
   408      hash = '',
   409      deps = [
   410          ':netty-common',
   411      ],
   412  )
   413  
   414  maven_jar(
   415      name = 'netty-resolver',
   416      id = 'io.netty:netty-resolver:4.1.8.Final',
   417      hash = '',
   418      deps = [
   419          ':netty-common',
   420      ],
   421  )
   422  
   423  maven_jar(
   424      name = 'netty-transport',
   425      id = 'io.netty:netty-transport:4.1.8.Final',
   426      hash = '',
   427      deps = [
   428          ':netty-buffer',
   429          ':netty-resolver',
   430      ],
   431  )
   432  
   433  maven_jar(
   434      name = 'netty-codec',
   435      id = 'io.netty:netty-codec:4.1.8.Final',
   436      hash = '',
   437      deps = [
   438          ':netty-transport',
   439      ],
   440  )
   441  
   442  maven_jar(
   443      name = 'netty-codec-http',
   444      id = 'io.netty:netty-codec-http:4.1.8.Final',
   445      hash = '',
   446      deps = [
   447          ':netty-codec',
   448      ],
   449  )
   450  
   451  maven_jar(
   452      name = 'netty-handler',
   453      id = 'io.netty:netty-handler:4.1.8.Final',
   454      hash = '',
   455      deps = [
   456          ':netty-buffer',
   457          ':netty-transport',
   458          ':netty-codec',
   459      ],
   460  )
   461  
   462  maven_jar(
   463      name = 'gson',
   464      id = 'com.google.code.gson:gson:2.7',
   465      hash = '',
   466  )
   467  
   468  maven_jar(
   469      name = 'netty-codec-http2',
   470      id = 'io.netty:netty-codec-http2:4.1.8.Final',
   471      hash = '',
   472      deps = [
   473          ':netty-codec-http',
   474          ':netty-handler',
   475          ':gson',
   476      ],
   477  )
   478  
   479  maven_jar(
   480      name = 'netty-codec-socks',
   481      id = 'io.netty:netty-codec-socks:4.1.8.Final',
   482      hash = '',
   483      deps = [
   484          ':netty-codec',
   485      ],
   486  )
   487  
   488  maven_jar(
   489      name = 'netty-handler-proxy',
   490      id = 'io.netty:netty-handler-proxy:4.1.8.Final',
   491      hash = '',
   492      deps = [
   493          ':netty-transport',
   494          ':netty-codec-socks',
   495          ':netty-codec-http',
   496      ],
   497  )
   498  
   499  maven_jar(
   500      name = 'grpc-netty',
   501      id = 'io.grpc:grpc-netty:1.1.2',
   502      hash = '',
   503      deps = [
   504          ':grpc-core',
   505          ':netty-codec-http2',
   506          ':netty-handler-proxy',
   507      ],
   508  )
   509  
   510  maven_jar(
   511      name = 'okio',
   512      id = 'com.squareup.okio:okio:1.6.0',
   513      hash = '',
   514  )
   515  
   516  maven_jar(
   517      name = 'okhttp',
   518      id = 'com.squareup.okhttp:okhttp:2.5.0',
   519      hash = '',
   520      deps = [
   521          ':okio',
   522      ],
   523  )
   524  
   525  maven_jar(
   526      name = 'grpc-okhttp',
   527      id = 'io.grpc:grpc-okhttp:1.1.2',
   528      hash = '',
   529      deps = [
   530          ':grpc-core',
   531          ':okhttp',
   532          ':okio',
   533      ],
   534  )
   535  
   536  maven_jar(
   537      name = 'protobuf-java',
   538      id = 'com.google.protobuf:protobuf-java:3.1.0',
   539      hash = '',
   540      deps = [
   541          ':junit',
   542          ':easymock',
   543          ':easymockclassextension',
   544      ],
   545  )
   546  
   547  maven_jar(
   548      name = 'protobuf-java-util',
   549      id = 'com.google.protobuf:protobuf-java-util:3.1.0',
   550      hash = '',
   551      deps = [
   552          ':protobuf-java',
   553          ':guava',
   554          ':gson',
   555          ':junit',
   556          ':easymock',
   557          ':easymockclassextension',
   558      ],
   559  )
   560  
   561  maven_jar(
   562      name = 'protobuf-lite',
   563      id = 'com.google.protobuf:protobuf-lite:3.0.1',
   564      hash = '',
   565      deps = [
   566          ':junit',
   567          ':easymock',
   568          ':easymockclassextension',
   569      ],
   570  )
   571  
   572  maven_jar(
   573      name = 'grpc-protobuf-lite',
   574      id = 'io.grpc:grpc-protobuf-lite:1.1.2',
   575      hash = '',
   576      deps = [
   577          ':grpc-core',
   578          ':protobuf-lite',
   579          ':guava',
   580      ],
   581  )
   582  
   583  maven_jar(
   584      name = 'grpc-protobuf',
   585      id = 'io.grpc:grpc-protobuf:1.1.2',
   586      hash = '',
   587      deps = [
   588          ':grpc-core',
   589          ':protobuf-java',
   590          ':guava',
   591          ':protobuf-java-util',
   592          ':grpc-protobuf-lite',
   593      ],
   594  )
   595  
   596  maven_jar(
   597      name = 'protobuf-javanano',
   598      id = 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5',
   599      hash = '',
   600  )
   601  
   602  maven_jar(
   603      name = 'grpc-protobuf-nano',
   604      id = 'io.grpc:grpc-protobuf-nano:1.1.2',
   605      hash = '',
   606      deps = [
   607          ':grpc-core',
   608          ':protobuf-javanano',
   609          ':guava',
   610      ],
   611  )
   612  
   613  maven_jar(
   614      name = 'grpc-stub',
   615      id = 'io.grpc:grpc-stub:1.1.2',
   616      hash = '',
   617      deps = [
   618          ':grpc-core',
   619      ],
   620  )
   621  
   622  maven_jar(
   623      name = 'grpc-all',
   624      id = 'io.grpc:grpc-all:1.1.2',
   625      hash = '',
   626      deps = [
   627          ':grpc-auth',
   628          ':grpc-core',
   629          ':grpc-context',
   630          ':grpc-netty',
   631          ':grpc-okhttp',
   632          ':grpc-protobuf',
   633          ':grpc-protobuf-lite',
   634          ':grpc-protobuf-nano',
   635          ':grpc-stub',
   636      ],
   637  )`
   638  	f := NewFetch([]string{server.URL}, excludes, nil)
   639  	actual := AllDependencies(f, grpc, concurrency, false, true)
   640  	// The rules come out in a different order to the original tool; this doesn't
   641  	// really matter since order of rules in a BUILD file is unimportant.
   642  	expectedSlice := strings.Split(expected, "\n\n")
   643  	sort.Strings(actual)
   644  	sort.Strings(expectedSlice)
   645  	assert.Equal(t, expectedSlice, actual)
   646  }
   647  
   648  func TestMain(m *testing.M) {
   649  	cli.InitLogging(1) // Suppress informational messages which there can be an awful lot of
   650  	errorProne = []Artifact{{}}
   651  	grpc = []Artifact{{}}
   652  	errorProne[0].FromID("com.google.errorprone:error_prone_core:2.0.14")
   653  	grpc[0].FromID("io.grpc:grpc-all:1.1.2")
   654  	server = httptest.NewServer(http.FileServer(http.Dir("tools/please_maven/maven/test_data")))
   655  	ret := m.Run()
   656  	server.Close()
   657  	os.Exit(ret)
   658  }