-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from shimono/feature-483
- Loading branch information
Showing
11 changed files
with
220 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/java/io/personium/core/rs/box/DavFileResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Personium | ||
* Copyright 2019 Personium Project | ||
* - FUJITSU LIMITED | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.personium.core.rs.box; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
|
||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import com.google.common.base.Charsets; | ||
|
||
import io.personium.core.PersoniumCoreException; | ||
import io.personium.test.categories.Unit; | ||
|
||
/** | ||
* DavFileResource unit test class. | ||
*/ | ||
@Category({ Unit.class }) | ||
public class DavFileResourceTest { | ||
|
||
/** Target class of unit test. */ | ||
private DavFileResource davFileResource; | ||
|
||
/** | ||
* put with If-None-Match header value * should fail with 412. | ||
*/ | ||
@Test | ||
public void put_IfNoneMatchWildcard_ShouldFail() { | ||
// Prepare test target object | ||
davFileResource = new DavFileResource(null, null); | ||
|
||
// Run method | ||
try { | ||
InputStream is = new ByteArrayInputStream("{test:1}".getBytes(Charsets.UTF_8)); | ||
davFileResource.put(org.apache.http.entity.ContentType.APPLICATION_JSON.toString(), null, "*", is); | ||
fail("Not throws exception."); | ||
} catch (PersoniumCoreException e) { | ||
// Confirm result | ||
PersoniumCoreException expected = PersoniumCoreException.Dav.ETAG_MATCH; | ||
assertEquals(expected.getCode(), e.getCode()); | ||
} | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
src/test/java/io/personium/core/rs/box/NullResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Personium | ||
* Copyright 2017-2019 Personium Project | ||
* - FUJITSU LIMITED | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.personium.core.rs.box; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import io.personium.core.PersoniumCoreException; | ||
import io.personium.core.model.Cell; | ||
import io.personium.core.model.DavCmp; | ||
import io.personium.core.model.DavRsCmp; | ||
import io.personium.test.categories.Unit; | ||
|
||
/** | ||
* ODataSvcCollectionResource unit test classs. | ||
*/ | ||
@Category({ Unit.class }) | ||
public class NullResourceTest { | ||
|
||
/** Target class of unit test. */ | ||
private NullResource nullResource; | ||
|
||
@Before | ||
public void before() { | ||
// -------------------- | ||
// Test method args | ||
// -------------------- | ||
String url = "https://personium/cell/box"; | ||
String name = "col"; | ||
String cellUrl = "https://personium/cell/"; | ||
|
||
// -------------------- | ||
// Mock settings | ||
// -------------------- | ||
DavRsCmp davRsCmp = mock(DavRsCmp.class); | ||
DavCmp davCmp = mock(DavCmp.class); | ||
Cell cell = mock(Cell.class); | ||
doReturn(null).when(davRsCmp).getAccessContext(); | ||
doReturn(url).when(davRsCmp).getUrl(); | ||
doReturn(cell).when(davRsCmp).getCell(); | ||
doReturn(cellUrl).when(cell).getUrl(); | ||
doReturn(name).when(davCmp).getName(); | ||
nullResource = new NullResource(davRsCmp, davCmp, false); | ||
|
||
} | ||
|
||
/** | ||
* | ||
*/ | ||
@Test | ||
public void put_With_IfMatchWildCard_ShouldReturn_412() { | ||
try { | ||
nullResource.put("text/html", "*", null); | ||
fail(); | ||
}catch (PersoniumCoreException e) { | ||
assertEquals(PersoniumCoreException.Dav.NO_ENTITY_MATCH.getCode(), e.getCode()); | ||
} | ||
} | ||
|
||
/** | ||
* delete_ShouldReturn_404 | ||
*/ | ||
@Test | ||
public void delete_ShouldReturn_404() { | ||
try { | ||
nullResource.delete(null); | ||
fail(); | ||
}catch (PersoniumCoreException e) { | ||
assertEquals(PersoniumCoreException.Dav.RESOURCE_NOT_FOUND.getCode(), e.getCode()); | ||
} | ||
} | ||
/** | ||
* delete_With_IfMatchWildCard_ShouldReturn_412 | ||
*/ | ||
@Test | ||
public void delete_With_IfMatchWildCard_ShouldReturn_412() { | ||
try { | ||
nullResource.delete("*"); | ||
fail(); | ||
}catch (PersoniumCoreException e) { | ||
assertEquals(PersoniumCoreException.Dav.NO_ENTITY_MATCH.getCode(), e.getCode()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters