Skip to content

Instantly share code, notes, and snippets.

@shelajev
Created November 21, 2017 13:29
Show Gist options
  • Select an option

  • Save shelajev/d128bb1ed7c09ce1ad610d4f9d082b85 to your computer and use it in GitHub Desktop.

Select an option

Save shelajev/d128bb1ed7c09ce1ad610d4f9d082b85 to your computer and use it in GitHub Desktop.
Rubah test classes
package com.shelajev.updates;
import rubah.Rubah;
public class Component {
private static DataHolder data = new DataHolder(0);
public String wrangle(int i, String s) {
Rubah.update("wrangle");
// return "v0: " + i + ", " + data + ", " + data.counter++;
return "v1: " + i + ", " + data + ", " + data.counter++ + ", " + data.name.toString();
};
}
package com.shelajev.updates;
import rubah.RubahThread;
public class Main {
public static void main(String[] args) {
RubahThread rubahThread = new RubahThread() {
@Override protected void rubahRun() {
Component c = new Component();
for(int i = 0; i < Long.MAX_VALUE; i++) {
System.out.println(c.wrangle(i, Integer.toHexString(i)));
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
}
}
};
rubahThread.start();
}
}
package com.shelajev.updates;
public class DataHolder {
public int counter;
public DataHolder(int counterValue) {
this.counter = counterValue;
}
@Override public String toString() {
return "DataHolder {" +
"counter=" + counter +
'}';
}
}
package com.shelajev.updates;
public class DataHolder {
public static String DEFAULT_NAME = "DEFAULT_NAME";
public int counter;
public String name;
public DataHolder(int counterValue) {
this.counter = counterValue;
this.name = DEFAULT_NAME;
}
@Override public String toString() {
return "DataHolder {" +
"counter=" + counter +
", name=" + name +
'}';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment