[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] storm ./Makefile org/nongnu/storm/BlockId.java ...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] storm ./Makefile org/nongnu/storm/BlockId.java ... |
Date: |
Mon, 07 Apr 2003 15:05:23 -0400 |
CVSROOT: /cvsroot/storm
Module name: storm
Changes by: Benja Fallenstein <address@hidden> 03/04/07 15:05:23
Modified files:
. : Makefile
org/nongnu/storm: BlockId.java BlockId.test
Added files:
. : dbg.py test.py
org/nongnu/storm/util: Dbg.java
Log message:
more
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/dbg.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/test.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/Makefile.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/BlockId.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/BlockId.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/util/Dbg.java?rev=1.1
Patches:
Index: storm/Makefile
diff -u storm/Makefile:1.4 storm/Makefile:1.5
--- storm/Makefile:1.4 Mon Apr 7 12:00:04 2003
+++ storm/Makefile Mon Apr 7 15:05:23 2003
@@ -1,11 +1,12 @@
-all: java
+all: java test
RAWSRC = `find org/ -name "*.java"` `find com/ -name "*.java"`
CLASSDIR=CLASSES/
STORM_DEPENDS=../storm-depends
-CLASSPATH=$(CLASSDIR):$(STORM_DEPENDS)/cryptix-jce-provider.jar:$(shell echo
$$CLASSPATH)
+CLASSPATH=$(CLASSDIR):$(STORM_DEPENDS)/cryptix-jce-provider.jar:$(STORM_DEPENDS)/jython.jar:$(shell
echo $$CLASSPATH)
export CLASSPATH
JAVAC=javac
+JAVA=java
clean:
@echo "Removing everything found in .cvsignores"
@@ -16,6 +17,9 @@
java:
mkdir -p CLASSES
$(JAVAC) $(DEBUG) -d $(CLASSDIR) $(RAWSRC)
+
+test:
+ $(JAVA) $(DEBUG)
-Dpython.path=$(STORM_DEPENDS)/jythonlib.jar:$(STORM_DEPENDS)/pythonlib.jar
org.python.util.jython test.py org/
########################
# Navidoc targets begin
Index: storm/org/nongnu/storm/BlockId.java
diff -u storm/org/nongnu/storm/BlockId.java:1.5
storm/org/nongnu/storm/BlockId.java:1.6
--- storm/org/nongnu/storm/BlockId.java:1.5 Mon Apr 7 14:35:58 2003
+++ storm/org/nongnu/storm/BlockId.java Mon Apr 7 15:05:23 2003
@@ -62,8 +62,8 @@
tigertree = Base32.decode(uri.substring(dot+1));
}
- public BlockId(byte[] sha1, byte[] tigertree,
- String contentType) {
+ public BlockId(String contentType,
+ byte[] sha1, byte[] tigertree) {
this.sha1 = sha1;
this.tigertree = tigertree;
this.contentType = contentType;
@@ -83,7 +83,9 @@
/** Check that the given data bytes match this id.
*/
- public void check(byte[] data) throws WrongIdException {
+ public void check(byte[] data) throws WrongIdException, Exception {
+ if(!equals(getIdForData(contentType, data)))
+ throw new WrongIdException("ID doesn't match");
}
/** Get an InputStream that checks whether the data read from
@@ -112,7 +114,15 @@
/** Get the id for a given array of bytes.
* The byte array must contain the bytes in a block.
*/
- public static BlockId getIdForData(byte[] bytes) {
- return null;
+ public static BlockId getIdForData(String contentType,
+ byte[] bytes) throws Exception {
+ MessageDigest dig_tt = new TreeTiger();
+ MessageDigest dig_sha1 = MessageDigest.getInstance("SHA");
+
+ dig_tt.update(bytes);
+ dig_sha1.update(bytes);
+
+ return new BlockId(contentType, dig_sha1.digest(),
+ dig_tt.digest());
}
}
Index: storm/org/nongnu/storm/BlockId.test
diff -u storm/org/nongnu/storm/BlockId.test:1.2
storm/org/nongnu/storm/BlockId.test:1.3
--- storm/org/nongnu/storm/BlockId.test:1.2 Mon Apr 7 14:47:39 2003
+++ storm/org/nongnu/storm/BlockId.test Mon Apr 7 15:05:23 2003
@@ -45,8 +45,8 @@
assert id.getURI() == lower_1
assert id.getContentType() == "application/rdf+xml"
- id2 = BlockId(id.getSha1(), id.getTigerTree(),
- id.getContentType())
+ id2 = BlockId(id.getContentType(),
+ id.getSha1(), id.getTigerTree())
assert id2.getURI() == lower_1
assert id == id2
@@ -58,5 +58,27 @@
assert id != id3
assert id.hashCode() != id3.hashCode()
+def testGetIdForData():
+ id_1 = BlockId(uri_1)
+ id_2 = BlockId(uri_2)
+ id_3 = BlockId(uri_3)
+ get = BlockId.getIdForData
+
+ assert id_2 == get('application/Octet-Stream', data_2) != id_3
+ assert id_3 == get('text/plain', data_3) != id_2
+
+def check(id, data):
+ try: id.check(data)
+ except BlockId.WrongIdException: return 0
+ else: return 1
+
+def testCheck():
+ id_1 = BlockId(uri_1)
+ id_2 = BlockId(uri_2)
+ id_3 = BlockId(uri_3)
+
+ assert check(id_2, data_2)
+ assert (not check(id_1, data_2)) and (not check(id_3, data_2))
-
+ assert check(id_3, data_3)
+ assert (not check(id_1, data_3)) and (not check(id_2, data_3))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] storm ./Makefile org/nongnu/storm/BlockId.java ...,
Benja Fallenstein <=