How do I easily mock out a static method in Java?
I'm using Spring 2.5 and JUnit 4.4
@Service
public class SomeServiceImpl implements SomeService {
public Object doSomething() {
Logger.getLogger(this.class); //a static method invoked.
// ...
}
}
I don't control the static method that my service needs to invoke so I...
I use a single static class in my code that defines a static field which I'm reusing between Activity onStop/onStart invocations. Here's a scenario:
User clicks on "Authorize" button (static data is initialized)
Activity is stopped and web browser is called
Browser executes callback and Activity is restored (static data is reused)
At...
I'm new to Visual Studio and Windows as a development platform, and I'm having troubles linking a static library from one 'Project' into an executable in another. The library builds without error, but linking bails after finding several STL template instantiations defined in the library.
For the purpose of this question, Project A build...
Is there any way to get the equivalent of GetType within a static constructor?
I want to iterate through the available properties of the type within the static constructor but GetType is an instance method? Why is this? The typeinfo should exist in the static context. Is there a way around this??
~ Cameron
...
Hello everyone. Here's my question for today. I'm building (for fun) a simple templating engine. The basic idea is that I have a tag like this {blog:content} and I break it in a method and a action. The problem is when I want to call a static variable dynamically, I get the following error .
Parse error: parse error, expecting `','' or ...
I've got an instance of a DB object that's passed to a Session object, because the Session object has several methods that make use of DB object to execute SQL statements I had plan to store this DB object in Session object property.
Through testing I found that print_r exposed the DB object stored in the Session object property; includ...
Hi,
When we want deploy Web Application should we use singleton Object or use Static instead of?
what is the bottleneck for use each of them?
I should know about Memory Problem , Concurrency problem and ... .
P.S: what happen for the class that was just readable (should use static or Singleton)
P.S 2: what happen for the class that wa...
Hello,
I'm getting the following strange looking error.
Unexpected PHP error [Use of undefined constant s - assumed 's'] severity [E_NOTICE] in [C:\Documents and Settings\yepthatsme\My Documents\Dev\nicnames\main\resources\includes\name.inc.php line 180]
The line it is referring to has:
$types = nicnames_config::$resourcetypes...
Hi,
I'm just starting my journey into OOP - and I'm currently trying to roll my own MVC - purely for learning purposes. I'm working through a tutorial in the Apress PHP-Objects Patterns Practice book. I've created a registry singleton object using the private __construct/__clone technique:
class Registry
{
private static $instance;
...
Hello, I need help with this error. This error ocours only in some computers.
By reading the stack information, there is some problem when I call to this static method("FormatQuery") in static class:
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Text;
using Sys...
I want to make a menu that will dynamically show the active static pages from CMS; for example if in my CMS i have:
About Us (enabled)
Shipping & Refund (disabled)
Terms and Conditions (enabled)
Contacts (enabled)
then the menu would look like:
About US | Terms and Conditions | Contacts
i need just a few tips on how to get started;...
I would like to create/update text columns in sqlite3.
When i retrieve rows after the create/update, the text is '?'.
Integer values are properly persisted however.
My text statements look like this:
sqlite3_bind_text(update_statment, 5, [[dt stringFromDate:self.updated]
UTF8String], -1, SQLITE_TRANSIENT);
I've tried SQLITE_TRAN...
I'm used to thinking of all initialization of globals/static-class-members as happening before the first line of main(). But I recently read somewhere that the standard allows initialization to happen later to "assist with dynamic loading of modules." I could see this being true when dynamic linking: I wouldn't expect a global initialize...
In C++, is there any reason to not access static member variables through a class instance? I know Java frowns on this and was wondering if it matters in C++. Example:
class Foo {
static const int ZERO = 0;
static const int ONE = 1;
...
};
void bar(const Foo& inst) {
// is this ok?
int val1 = inst.ZERO;
// or should I p...
Hi,
Why is static virtual impossible? Is C# dependent or just don't have any sense in the OO world?
I know the concept has already been underlined but I did not find a simple answer to the previous question.
Thx
...
Is there a simple way to implement this, and if possible without instanciating an object :
interface I
{
static string GetClassName();
}
public class Helper
{
static void PrintClassName<T>() where T : I
{
Console.WriteLine(T.GetClassName());
}
}
...
Hi,
I have designed a website with the GWT, This is purely a static site and it doesnt have any servlet or any rpc part involved in it. Its just a plain static pages in GWT .I have compiled with the GWT and there are all related html ,.js files are present in the public folder. Now i want to host the same in any of the web host.
Good ...
ok, its a little more complicated than the question.
class A
{
static int needsToBeThreadSafe = 0;
public static void M1()
{
needsToBeThreadSafe = RandomNumber();
}
public static void M2()
{
print(needsToBeThreadSafe);
}
}
now i require that between M1() and M2() calls 'needsToBeThreadSafe' stays Threa...
Hi to all!
Assuming I have this class in C++:
class A
{
public:
static const TDouble pi_d;
static const TDouble pi;
static const TDouble div;
};
They are initialized at the .h file in the following way:
const TDouble A::pi_d = 3.14;
const TDouble A::pi = A::pi_d;
const TDouble A::div = A::pi / 180.0;
When I print the...
I have a generic class definition similar to this:
public sealed class MyClass<TProperty,TOwner>
{
...
}
Now I'd like any instances of MyClass<TProperty,TOwner> regardless of the types of TProperty or TOwner to share a Hashtable. I thought of creating an internal MyClassBase with a protected internal static field of type Hashtable...