• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #3930

15 Jul 2024 09:25AM CUT coverage: 72.44%. Remained the same
#3930

push

github

web-flow
test: Add test for uploading file using stream (#1258)

Closes: SDK-3898

7683 of 10606 relevant lines covered (72.44%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdk/InMemoryLRUAccessTokenCache.java
1
package com.box.sdk;
2

3
import java.util.LinkedHashMap;
4
import java.util.Map;
5

6
/**
7
 * Use this class to create an in-memory LRU (least recently used) access token cache to be
8
 * passed to BoxDeveloperEditionAPIConnection.
9
 */
10
public class InMemoryLRUAccessTokenCache implements IAccessTokenCache {
11

12
    private final Map<String, String> cache;
13

14
    /**
15
     * Creates an in-memory LRU access token cache.
16
     *
17
     * @param maxEntries maximum number of entries to store.
18
     */
19
    public InMemoryLRUAccessTokenCache(final int maxEntries) {
×
20
        this.cache = new LinkedHashMap<String, String>(maxEntries, 0.75F, true) {
×
21
            private static final long serialVersionUID = -187234623489L;
22

23
            @Override
24
            protected boolean removeEldestEntry(java.util.Map.Entry<String, String> eldest) {
25
                return size() > maxEntries;
×
26
            }
27
        };
28
    }
×
29

30
    /**
31
     * Add an entry to the cache.
32
     *
33
     * @param key   key to use.
34
     * @param value access token information to store.
35
     */
36
    public void put(String key, String value) {
37
        synchronized (this.cache) {
×
38
            this.cache.put(key, value);
×
39
        }
×
40
    }
×
41

42
    /**
43
     * Get an entry from the cache.
44
     *
45
     * @param key key to look for.
46
     * @return access token information.
47
     */
48
    public String get(String key) {
49
        synchronized (this.cache) {
×
50
            return this.cache.get(key);
×
51
        }
52
    }
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc