forked from dirkriehle/wahlzeit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AbstractAdapterTest as super class for new GcsAdapterTest and D…
…atastoreAdapterTest, corrected spelling in persistence package.
- Loading branch information
Showing
7 changed files
with
120 additions
and
50 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
2 changes: 1 addition & 1 deletion
2
...lzeit/model/persistance/ImageStorage.java → ...lzeit/model/persistence/ImageStorage.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
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
49 changes: 49 additions & 0 deletions
49
src/test/java/org/wahlzeit/model/persistence/DatastoreAdapterTest.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,49 @@ | ||
package org.wahlzeit.model.persistence; | ||
|
||
import com.google.appengine.api.images.Image; | ||
import com.google.appengine.api.images.ImagesServiceFactory; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.rules.RuleChain; | ||
import org.junit.rules.TestRule; | ||
import org.wahlzeit.testEnvironmentProvider.LocalDatastoreServiceTestConfigProvider; | ||
import org.wahlzeit.testEnvironmentProvider.RegisteredOfyEnvironmentProvider; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* Test class for {@link DatastoreAdapter} | ||
* <p/> | ||
* Created by Lukas Hahmann on 20.08.15. | ||
*/ | ||
public class DatastoreAdapterTest extends AbstractAdapterTest { | ||
|
||
@ClassRule | ||
public static TestRule chain = RuleChain. | ||
outerRule(new LocalDatastoreServiceTestConfigProvider()). | ||
around(new RegisteredOfyEnvironmentProvider()); | ||
|
||
private Image tooLargeTestImage; | ||
|
||
|
||
@Override | ||
protected void storageDependentSetUp() { | ||
imageStorage = new DatastoreAdapter(); | ||
|
||
ByteBuffer bb = ByteBuffer.allocate(1024 * 1025); | ||
tooLargeTestImage = ImagesServiceFactory.makeImage(bb.array()); | ||
} | ||
|
||
|
||
@Test(expected = ArrayIndexOutOfBoundsException.class) | ||
public void testUpperSizeLimit() { | ||
try { | ||
imageStorage.writeImage(tooLargeTestImage, "blub", 1); | ||
} catch (IOException e) { | ||
fail("IOException should not be thrown!"); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/org/wahlzeit/model/persistence/GcsAdapterTest.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,23 @@ | ||
package org.wahlzeit.model.persistence; | ||
|
||
import com.google.appengine.tools.development.testing.LocalBlobstoreServiceTestConfig; | ||
import com.google.appengine.tools.development.testing.LocalServiceTestHelper; | ||
|
||
/** | ||
* Created by Lukas Hahmann on 24.08.15. | ||
*/ | ||
public class GcsAdapterTest extends AbstractAdapterTest { | ||
|
||
private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalBlobstoreServiceTestConfig()); | ||
|
||
@Override | ||
protected void storageDependentSetUp() { | ||
helper.setUp(); | ||
imageStorage = new GcsAdapter.Builder().build(); | ||
} | ||
|
||
@Override | ||
protected void storageDependentTearDown() { | ||
helper.tearDown(); | ||
} | ||
} |