-
Notifications
You must be signed in to change notification settings - Fork 205
/
ClientConfigTest.java
123 lines (103 loc) · 3.8 KB
/
ClientConfigTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.bugsnag.android;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class ClientConfigTest {
private Configuration config;
private Client client;
/**
* Generates a configuration and clears sharedPrefs values to begin the test with a clean slate
* @throws Exception if initialisation failed
*/
@Before
public void setUp() throws Exception {
Context context = InstrumentationRegistry.getContext();
config = new Configuration("api-key");
client = new Client(context, config);
}
@After
public void tearDown() throws Exception {
client.getOrientationListener().disable();
}
@Test
public void testSetReleaseStage() throws Exception {
client.setReleaseStage("beta");
assertEquals("beta", config.getReleaseStage());
}
@Test
public void testSetAutoCaptureSessions() throws Exception {
client.setAutoCaptureSessions(true);
assertEquals(true, config.getAutoCaptureSessions());
}
@Test
public void testSetAppVersion() throws Exception {
client.setAppVersion("5.6.7");
assertEquals("5.6.7", config.getAppVersion());
}
@Test
public void testSetContext() throws Exception {
client.setContext("JunitTest");
assertEquals("JunitTest", client.getContext());
assertEquals("JunitTest", config.getContext());
}
@SuppressWarnings("deprecation")
@Test
public void testSetEndpoint() throws Exception {
client.setEndpoint("http://example.com/bugsnag");
assertEquals("http://example.com/bugsnag", config.getEndpoint());
}
@Test
public void testSetBuildUuid() throws Exception {
client.setBuildUUID("gh905");
assertEquals("gh905", config.getBuildUUID());
}
@Test
public void testSetIgnoreClasses() throws Exception {
client.setIgnoreClasses("RuntimeException", "Foo");
assertArrayEquals(new String[]{"RuntimeException", "Foo"}, config.getIgnoreClasses());
}
@Test
public void testSetNotifyReleaseStages() throws Exception {
client.setNotifyReleaseStages("beta", "prod");
assertArrayEquals(new String[]{"beta", "prod"}, config.getNotifyReleaseStages());
}
@Test
public void testSetSendThreads() throws Exception {
client.setSendThreads(false);
assertFalse(config.getSendThreads());
}
@Test
public void testDefaultClientDelivery() {
assertFalse(client.config.getDelivery() instanceof DeliveryCompat);
}
@Test
public void testCustomDeliveryOverride() {
Context context = InstrumentationRegistry.getContext();
config = BugsnagTestUtils.generateConfiguration();
Delivery customDelivery = new Delivery() {
@Override
public void deliver(@NonNull SessionTrackingPayload payload,
@NonNull Configuration config)
throws DeliveryFailureException {}
@Override
public void deliver(@NonNull Report report,
@NonNull Configuration config)
throws DeliveryFailureException {}
};
config.setDelivery(customDelivery);
client = new Client(context, config);
assertEquals(customDelivery, client.config.getDelivery());
}
}