Skip to content
This repository has been archived by the owner on Sep 28, 2019. It is now read-only.

Commit

Permalink
jgravatar
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfebert committed Feb 21, 2010
1 parent 88e790a commit b6f4019
Show file tree
Hide file tree
Showing 20 changed files with 692 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
log
tmp
db/*.sqlite3
nbproject/private
bin
.DS_Store
7 changes: 7 additions & 0 deletions jgravatar.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions jgravatar.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jgravatar.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions jgravatar.tests/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Sun Feb 21 03:22:59 CET 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
4 changes: 4 additions & 0 deletions jgravatar.tests/.settings/org.eclipse.pde.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Sun Feb 21 03:22:59 CET 2010
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
15 changes: 15 additions & 0 deletions jgravatar.tests/JGravatarTest.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/jgravatar.tests/src/jgravatar/JGravatarTest.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="jgravatar.JGravatarTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="jgravatar.tests"/>
</launchConfiguration>
10 changes: 10 additions & 0 deletions jgravatar.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: jgravatar Unit Tests
Bundle-SymbolicName: jgravatar.tests
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: jgravatar,
org.hamcrest.core;version="1.1.0",
org.junit;version="4.5.0"
Bundle-Vendor: Ralf Ebert
4 changes: 4 additions & 0 deletions jgravatar.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
62 changes: 62 additions & 0 deletions jgravatar.tests/src/jgravatar/JGravatarTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package jgravatar;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class JGravatarTest {

private Gravatar gravatar;

@Before
public void setup() {
gravatar = new Gravatar();
}

@Test
public void testGetImageUrlDefaults() {
assertEquals("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802.jpg?d=404", gravatar.getUrl("iHaveAn@email.com"));
assertEquals("http://www.gravatar.com/avatar/fa8771dec9da9299afed9ffce70c2c18.jpg?d=404", gravatar.getUrl("info@ralfebert.de"));
}

@Test
public void testGetImageUrlSize() {
gravatar.setSize(100);
assertEquals("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802.jpg?s=100&d=404", gravatar.getUrl("iHaveAn@email.com"));
}

@Test
public void testGetImageUrlRating() {
gravatar.setRating(GravatarRating.PARENTAL_GUIDANCE_SUGGESTED);
assertEquals("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802.jpg?r=pg&d=404", gravatar.getUrl("iHaveAn@email.com"));
}

@Test
public void testGetImageUrlDefaultImage() {
gravatar.setDefaultImage(GravatarDefaultImage.IDENTICON);
assertEquals("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802.jpg?d=identicon", gravatar.getUrl("iHaveAn@email.com"));
}

@Test
public void testGetImageUrlCombined() {
gravatar = new Gravatar();
gravatar.setSize(123);
gravatar.setDefaultImage(GravatarDefaultImage.IDENTICON);
assertEquals("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802.jpg?s=123&d=identicon", gravatar.getUrl("iHaveAn@email.com"));
}

@Test
public void testDownload() {
Gravatar g = new Gravatar();
byte[] bytes = g.download("info@ralfebert.de");
assertTrue("content present", bytes.length>100);

assertNull("null for no gravatar by default", g.download("doesntexist@example.com"));

g.setDefaultImage(GravatarDefaultImage.IDENTICON);
bytes = g.download("info@ralfebert.de");
assertTrue("content present", bytes.length>100);
}

}
7 changes: 7 additions & 0 deletions jgravatar/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions jgravatar/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jgravatar</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Loading

0 comments on commit b6f4019

Please sign in to comment.