Skip to content

Commit ab8a744

Browse files
Merge pull request #475 from TakayukiHoshi1984/bugfix_unit_test
JUnit 修正
2 parents 6661c05 + 9facc51 commit ab8a744

File tree

10 files changed

+444
-10
lines changed

10 files changed

+444
-10
lines changed

dConnectDevicePlugin/dConnectDeviceTest/app/src/main/java/org/deviceconnect/android/deviceplugin/test/UnitTestDeviceService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class UnitTestDeviceService extends DConnectMessageService {
4141
@Override
4242
public void onCreate() {
4343
super.onCreate();
44+
setUseLocalOAuth(false);
4445

4546
mFileManager = new FileManager(this);
4647

dConnectManager/dConnectServer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ compileJava {
1111

1212
sourceSets {
1313
main.java.srcDirs = ['src']
14-
main.resources.srcDirs = ['src']
14+
main.resources.srcDirs = ['src/resources']
1515
test.java.srcDirs = ['tests/java']
1616
test.resources.srcDirs = ['tests/resources']
1717
}

dConnectManager/dConnectServerNanoHttpd/nanohttpd/build.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ apply plugin: 'com.android.library'
22

33
dependencies {
44
implementation fileTree(include: '*.jar', dir: 'libs')
5+
implementation 'org.nanohttpd:nanohttpd-websocket:2.3.0'
6+
androidTestImplementation 'com.android.support.test:testing-support-lib:0.1'
7+
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
8+
androidTestImplementation "org.java-websocket:java-websocket:1.3.3"
9+
510
api project(':dconnect-server')
611
androidTestImplementation fileTree(include: '*.jar', dir: 'testLibs')
712
}
@@ -45,12 +50,4 @@ android {
4550
maven { url 'http://clojars.org/repo' }
4651
mavenCentral()
4752
}
48-
49-
dependencies {
50-
implementation fileTree(dir: 'libs', include: ['*.jar'])
51-
implementation 'org.nanohttpd:nanohttpd-websocket:2.3.0'
52-
androidTestImplementation 'com.android.support.test:testing-support-lib:0.1'
53-
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
54-
androidTestImplementation "org.java-websocket:java-websocket:1.3.3"
55-
}
5653
}
-173 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2009 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.deviceconnect.server.nanohttpd.util;
17+
import java.security.cert.X509Certificate;
18+
import javax.net.ssl.X509TrustManager;
19+
/**
20+
* A trust manager that accepts all X509 client and server certificates.
21+
*
22+
* @see "http://java.sun.com/products/javamail/SSLNOTES.txt"
23+
*/
24+
public class DummyTrustManager implements X509TrustManager {
25+
public void checkClientTrusted(X509Certificate[] chain, String authType) {
26+
// Does not throw CertificateException: all chains trusted
27+
return;
28+
}
29+
public void checkServerTrusted(X509Certificate[] chain, String authType) {
30+
// Does not throw CertificateException: all chains trusted
31+
return;
32+
}
33+
public X509Certificate[] getAcceptedIssuers() {
34+
return new X509Certificate[0];
35+
}
36+
}

dConnectManager/dConnectServerNanoHttpd/nanohttpd/src/androidTest/java/org/deviceconnect/server/nanohttpd/util/KeyStoreManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import android.provider.Settings;
5353
import android.util.Log;
5454

55-
import com.google.polo.ssl.SslUtil;
5655

5756
/**
5857
* キーストア・マネージャー. クライアントとサーバの証明書を管理する.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
SecurityUtil.java
3+
Copyright (c) 2019 NTT DOCOMO,INC.
4+
Released under the MIT license
5+
http://opensource.org/licenses/mit-license.php
6+
*/
7+
package org.deviceconnect.server.nanohttpd.util;
8+
9+
import android.os.Build;
10+
11+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
12+
13+
import java.security.Security;
14+
15+
/**
16+
* セキュリティ関連のユーティリティ.
17+
*
18+
* @author NTT DOCOMO, INC.
19+
*/
20+
final class SecurityUtil {
21+
22+
static {
23+
if (canUseBouncyCastleProvider()) {
24+
Security.addProvider(new BouncyCastleProvider());
25+
SECURITY_PROVIDER = "BC";
26+
} else {
27+
SECURITY_PROVIDER = null; // デフォルトのプロバイダーを使用.
28+
}
29+
}
30+
31+
private static final String SECURITY_PROVIDER;
32+
33+
/**
34+
* 本 SDK の内部で使用するセキュリティプロバイダの名前を取得する.
35+
*
36+
* @return セキュリティプロバイダの名前. デフォルトのプロバイダを使用する場合は <code>null</code>
37+
*/
38+
public static String getSecurityProvider() {
39+
return SECURITY_PROVIDER;
40+
}
41+
42+
/**
43+
* セキュリティプロバイダとして BouncyCastleProvider を使用可能かどうかを確認する.
44+
*
45+
* @return BouncyCastleProvider を使用できる場合は <code>true</code>, そうでない場合は <code>false</code>
46+
*/
47+
private static boolean canUseBouncyCastleProvider() {
48+
return Build.VERSION.SDK_INT < Build.VERSION_CODES.P;
49+
}
50+
51+
/**
52+
* プライベートコンストラクタ.
53+
*/
54+
private SecurityUtil() {
55+
}
56+
57+
}

0 commit comments

Comments
 (0)