Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
590c6e6a
Commit
590c6e6a
authored
Jul 19, 2018
by
Junling Bu
Browse files
feat[litemall-os-api]: 实现阿里云存储的测试类
parent
3034cd04
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-os-api/src/test/java/org/linlinjava/litemall/os/AosTest.java
0 → 100644
View file @
590c6e6a
package
org.linlinjava.litemall.os
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.linlinjava.litemall.os.service.AliyunOsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.core.io.Resource
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.util.FileCopyUtils
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
@WebAppConfiguration
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
AosTest
{
@Autowired
private
AliyunOsService
aliyunOsService
;
@Test
public
void
test
()
throws
IOException
{
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
byte
[]
content
=
(
byte
[])
FileCopyUtils
.
copyToByteArray
(
new
FileInputStream
(
test
));
MockMultipartFile
mockMultipartFile
=
new
MockMultipartFile
(
"litemall.png"
,
"litemall.png"
,
"image/png"
,
content
);
aliyunOsService
.
store
(
mockMultipartFile
,
"aos.png"
);
Resource
resource
=
aliyunOsService
.
loadAsResource
(
"aos.png"
);
String
url
=
aliyunOsService
.
generateUrl
(
"aos.png"
);
System
.
out
.
println
(
"test file "
+
test
);
System
.
out
.
println
(
"store file "
+
resource
.
getURI
());
System
.
out
.
println
(
"generate url "
+
url
);
// tencentOsService.delete("aos.png");
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment