Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Fryc committed Aug 31, 2012
1 parent fe55493 commit c8f9309
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
Expand Up @@ -79,6 +79,6 @@ protected void configure() {
bind(LibraryCompiler.class).to(IncrementalLibraryCompiler.class);
bind(JavaSourceProcessor.class).in(Singleton.class);
bind(LibraryGenerator.class).to(DefaultLibraryGenerator.class);
bind(JavaSourceCache.class).in(Singleton.class);
bind(JavaSourceTracker.class).to(JavaSourceTrackerImpl.class);
}
}
Expand Up @@ -72,12 +72,16 @@ public synchronized void init(ProcessingEnvironment processingEnv) {

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (time == null) {
time = new TimeMeasure("java source processing", log).info(true);
}

if (!roundEnv.processingOver()) {
if (firstRound) {
firstRound = false;
compiler.beforeJavaSourceProcessing();

time = new TimeMeasure("java source processing", log).info(true).start();
time.start();
}
compiler.processJavaSource(processingEnv, roundEnv);
} else {
Expand Down
Expand Up @@ -10,7 +10,6 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;

import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
Expand All @@ -29,7 +28,7 @@ public class JavaSourceProcessor {
private ComponentLibrary library;

@Inject
private JavaSourceCache sourceCache;
private JavaSourceTracker sourceCache;

private ProcessingEnvironment processingEnv;

Expand Down Expand Up @@ -115,8 +114,4 @@ private void sendError(Element componentElement, Exception e) {
// rise error and continue.
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR, e.getMessage(), componentElement);
}

private void sendError(CdkException e) {
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR, e.getMessage());
}
}
@@ -0,0 +1,11 @@
package org.richfaces.cdk.apt;

import javax.lang.model.element.Element;
import javax.tools.JavaFileObject;

public interface JavaSourceTracker {

void putChanged(JavaFileObject sourceObject);

boolean isChanged(Element element);
}
Expand Up @@ -14,8 +14,10 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.inject.Singleton;

public class JavaSourceCache {
@Singleton
public class JavaSourceTrackerImpl implements JavaSourceTracker {

private List<JavaFileObject> changed = Lists.newLinkedList();
private Map<Element, Boolean> elements = Maps.newHashMap();
Expand Down
Expand Up @@ -86,7 +86,7 @@ public class TaskFactoryImpl implements CompilationTaskFactory {
private LibraryCache javaCache;

@Inject
private JavaSourceCache sourceCache;
private JavaSourceTracker sourceCache;

private JavaCompiler javaCompiler;
private StandardJavaFileManager fileManager;
Expand Down
18 changes: 18 additions & 0 deletions generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
Expand Up @@ -33,10 +33,14 @@
import java.util.Locale;
import java.util.logging.LogManager;

import javax.lang.model.element.Element;
import javax.tools.JavaFileObject;

import org.junit.After;
import org.junit.Before;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.apt.CacheType;
import org.richfaces.cdk.apt.JavaSourceTracker;
import org.richfaces.cdk.apt.LibraryCache;
import org.richfaces.cdk.model.ComponentLibrary;

Expand All @@ -60,6 +64,7 @@ public void configure(Binder binder) {
binder.bind(Locale.class).toInstance(Locale.getDefault());
binder.bind(Charset.class).toInstance(Charset.defaultCharset());

binder.bind(JavaSourceTracker.class).to(TestingJavaSourceTracker.class);
for (CacheType cacheType : CacheType.values()) {
binder.bind(LibraryCache.class).annotatedWith(new CacheImpl(cacheType)).toInstance(new EmptyLibraryCache());
}
Expand Down Expand Up @@ -139,6 +144,19 @@ protected File getLibraryFile(String resource) throws Exception {
}
}

private static class TestingJavaSourceTracker implements JavaSourceTracker {

@Override
public void putChanged(JavaFileObject sourceObject) {
// do nothing
}

@Override
public boolean isChanged(Element element) {
return true;
}
}

private static class EmptyLibraryCache implements LibraryCache {

@Override
Expand Down

0 comments on commit c8f9309

Please sign in to comment.