forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssetForwardingTest.java
More file actions
112 lines (100 loc) · 3.03 KB
/
AssetForwardingTest.java
File metadata and controls
112 lines (100 loc) · 3.03 KB
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
package org.jooby;
import static org.easymock.EasyMock.expect;
import org.jooby.test.MockUnit;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
public class AssetForwardingTest {
@Test
public void etag() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.etag()).andReturn("tag");
})
.run(unit -> {
assertEquals("tag", new Asset.Forwarding(unit.get(Asset.class)).etag());
});
}
@Test
public void lastModified() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.lastModified()).andReturn(1L);
})
.run(unit -> {
assertEquals(1L, new Asset.Forwarding(unit.get(Asset.class)).lastModified());
});
}
@Test
public void len() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.length()).andReturn(1L);
})
.run(unit -> {
assertEquals(1L, new Asset.Forwarding(unit.get(Asset.class)).length());
});
}
@Test
public void name() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.name()).andReturn("n");
})
.run(unit -> {
assertEquals("n", new Asset.Forwarding(unit.get(Asset.class)).name());
});
}
@Test
public void path() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.path()).andReturn("p");
})
.run(unit -> {
assertEquals("p", new Asset.Forwarding(unit.get(Asset.class)).path());
});
}
@Test
public void url() throws Exception {
URL url = new File("pom.xml").toURI().toURL();
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.resource()).andReturn(url);
})
.run(unit -> {
assertEquals(url, new Asset.Forwarding(unit.get(Asset.class)).resource());
});
}
@Test
public void stream() throws Exception {
new MockUnit(Asset.class, InputStream.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.stream()).andReturn(unit.get(InputStream.class));
})
.run(unit -> {
assertEquals(unit.get(InputStream.class),
new Asset.Forwarding(unit.get(Asset.class)).stream());
});
}
@Test
public void type() throws Exception {
new MockUnit(Asset.class)
.expect(unit -> {
Asset asset = unit.get(Asset.class);
expect(asset.type()).andReturn(MediaType.css);
})
.run(unit -> {
assertEquals(MediaType.css, new Asset.Forwarding(unit.get(Asset.class)).type());
});
}
}