@Test public void convertSpecRejectsPlaintext() { com.squareup.okhttp.ConnectionSpec plaintext = com.squareup.okhttp.ConnectionSpec.CLEARTEXT; thrown.expect(IllegalArgumentException.class); thrown.expectMessage("plaintext ConnectionSpec is not accepted"); Utils.convertSpec(plaintext); }
static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); static Metadata convertHeaders(List<Header> http2Headers); static Metadata convertTrailers(List<Header> http2Headers); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); static Metadata convertHeaders(List<Header> http2Headers); static Metadata convertTrailers(List<Header> http2Headers);  }